MPS File Reader

titanq.tools.from_mps(path: str | PathLike, model: Model, *, skip_empty_lines: bool = False) None

Configure a model from an .mps file. It currently supports these following sections.

  • NAME: The name of the problem.

  • ROWS: The definition of constraints.

  • COLUMNS: The coefficients for the variables.

  • RHS: The right-hand side values for the constraints.

  • BOUNDS: The bounds on the variables.

  • QUADOBJ or QMATRIX: The quadratic objective matrix

  • ENDATA: Marks the end of the data.

Integer variables in .mps files are supported both by the markers in the COLUMNS section and from the types in the BOUNDS section.

Parameters

path

The path to the .mps file

model

The instance of the model to configure. Must not be already configured.

options

Additional options applied when parsing the .mps file

Raises

OSError, FileNotFoundError

If the specified MPS file path cannot be open.

titanq.errors.MpsConfiguredModelError

If the provided model already contains data (e.g. variables).

titanq.errors.MpsParsingError

If the provided MPS file cannot be parsed.

Example

>>> from titanq.tools import from_mps
>>> from titanq import Model
>>> model = Model()
>>> from_mps("path/to/file.mps", model)
>>> model.optimize()
titanq.tools.configure_model_from_mps_file(model: Model, file_path: Path) None

Deprecated. Alternative form of from_mps().

Parameters

model

The instance of the model to configure.

file_path

The path to the MPS file.

Deprecated since version 0.26.0: Use from_mps() instead.