Skip to main content

An adapter for the Python-MIP from/to OMMX.

Project description

OMMX adapter for Python-MIP

PyPI - Version

This package provides an adapter for the Python-MIP from/to OMMX

Python-MIP as a solver in OMMX toolchain

sequenceDiagram
    participant U as User
    participant A as Adapter
    participant P as Python-MIP
    U->>A: ommx.v1.Instance
    A->>U: Python-MIP model
    U->>P: Python-MIP model and Parameters for Python-MIP;
    P->>P: Solve with CBC, Gurobi, or other solvers
    P->>U: Optimized model
    U->>A: Optimized model and ommx.v1.Instance
    A->>U: ommx.v1.Solution

Python-MIP as a user interface to create OMMX instance

sequenceDiagram
    participant U as User
    participant A as Adapter
    participant O as Other OMMX toolchain
    U->>A: Python-MIP model
    A->>U: ommx.v1.Instance
    U->>O: ommx.v1.Instance and Parameters for other solver
    O->>O: Solve the instance with other solver using other adapter
    O->>U: ommx.v1.Solution

Usage

ommx-python-mip-adapter can be installed from PyPI as follows:

pip install ommx-python-mip-adapter

Python-MIP can be used through ommx-python-mip-adapter by using the following:

from ommx_python_mip_adapter import OMMXPythonMIPAdapter
from ommx.v1 import Instance, DecisionVariable

x1 = DecisionVariable.integer(1, lower=0, upper=5)
ommx_instance = Instance.from_components(
    decision_variables=[x1],
    objective=x1,
    constraints=[],
    sense=Instance.MINIMIZE,
)

# Create `ommx.v1.Solution` from the `mip.Model`
ommx_solution = OMMXPythonMIPAdapter.solve(ommx_instance)

print(ommx_solution)

You can get ommx.v1.Instance from a Python-MIP model as the following:

import mip
import ommx_python_mip_adapter as adapter

model = mip.Model()
x1=model.add_var(name="1", var_type=mip.INTEGER, lb=0, ub=5)
x2=model.add_var(name="2", var_type=mip.CONTINUOUS, lb=0, ub=5)
model.objective = - x1 - 2 * x2
model.add_constr(x1 + x2 - 6 <= 0)

ommx_instance = adapter.model_to_instance(model)

print(ommx_instance)

Reference

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ommx_python_mip_adapter-2.3.5.tar.gz (11.0 kB view details)

Uploaded Source

File details

Details for the file ommx_python_mip_adapter-2.3.5.tar.gz.

File metadata

  • Download URL: ommx_python_mip_adapter-2.3.5.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ommx_python_mip_adapter-2.3.5.tar.gz
Algorithm Hash digest
SHA256 8c6a794bb6db7933a2e692930fb095bbd93122b1fa1e5ea5e072042daa3a98dd
MD5 27b661c3de6c97706db88e46591604d8
BLAKE2b-256 e27e57ad6e05029c35e1a52c59e7be820471bccc2739a4a5a32c49b3d82b16b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for ommx_python_mip_adapter-2.3.5.tar.gz:

Publisher: release_python.yml on Jij-Inc/ommx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page