ommx_python_mip_adapter.adapter

Classes

OMMXPythonMIPAdapter

An abstract interface for OMMX Solver Adapters, defining how solvers should be used with OMMX.

Module Contents

class OMMXPythonMIPAdapter(ommx_instance: Instance, *, relax: bool = False, solver_name: str = mip.CBC, solver: mip.Solver | None = None, verbose: bool = False)

An abstract interface for OMMX Solver Adapters, defining how solvers should be used with OMMX.

See the implementation guide for more details.

decode(data: mip.Model) Solution

Convert optimized Python-MIP model and ommx.v1.Instance to ommx.v1.Solution.

This method is intended to be used if the model has been acquired with solver_input for futher adjustment of the solver parameters, and separately optimizing the model.

Note that alterations to the model may make the decoding process incompatible – decoding will only work if the model still describes effectively the same problem as the OMMX instance used to create the adapter.

When creating the solution, this method reflects the relax flag used in this adapter’s constructor. The solution’s relaxation metadata will be set _only_ if relax=True was passed to the constructor. There is no way for this adapter to get relaxation information from Python-MIP directly. If relaxing the model separately after obtaining it with solver_input, you must set solution.relaxation yourself if you care about this value.

Examples

decode_to_state(data: mip.Model) State

Create an ommx.v1.State from an optimized Python-MIP Model.

Examples

classmethod solve(ommx_instance: Instance, relax: bool = False, verbose: bool = False) Solution

Solve the given ommx.v1.Instance using Python-MIP, returning an ommx.v1.Solution.

Parameters:
  • ommx_instance – The ommx.v1.Instance to solve.

  • relax – If True, relax all integer variables to continuous variables by using the relax parameter in Python-MIP’s Model.optimize() <https://docs.python-mip.com/en/latest/classes.html#mip.Model.optimize>.

  • verbose – If True, enable Python-MIP’s verbose mode

Examples

KnapSack Problem

Infeasible Problem

Unbounded Problem

Dual variable

instance
model
property solver_input: mip.Model

The Python-MIP model generated from this OMMX instance