Pre-release
This release is a pre-release and may not be stable for production use.
OMMX adapter for Python-MIP
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.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.Instance
A->>U: ommx.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.Instance
U->>O: ommx.Instance and Parameters for other solver
O->>O: Solve the instance with other solver using other adapter
O->>U: ommx.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 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.Solution` from the `mip.Model`
ommx_solution = OMMXPythonMIPAdapter.solve(ommx_instance)
print(ommx_solution)
You can get ommx.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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ommx_python_mip_adapter-3.0.0b3.tar.gz.
File metadata
- Download URL: ommx_python_mip_adapter-3.0.0b3.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b30b0cbad372de527a7c3fff182a3039b706946fc9e1bec9fa36dbf0622ced20
|
|
| MD5 |
515af70b0451f5bdac9214c9852d2953
|
|
| BLAKE2b-256 |
6712cd6987956994e9effed2f0a8ff0c086e9c6f770b2f3bba3886d7c4ecff47
|
Provenance
The following attestation bundles were made for ommx_python_mip_adapter-3.0.0b3.tar.gz:
Publisher:
release_python.yml on Jij-Inc/ommx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ommx_python_mip_adapter-3.0.0b3.tar.gz -
Subject digest:
b30b0cbad372de527a7c3fff182a3039b706946fc9e1bec9fa36dbf0622ced20 - Sigstore transparency entry: 2435188063
- Sigstore integration time:
-
Permalink:
Jij-Inc/ommx@ffa59924d991bb25c73f0f0afc86baef4c4b18e4 -
Branch / Tag:
refs/tags/python-3.0.0b3 - Owner: https://github.com/Jij-Inc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release_python.yml@ffa59924d991bb25c73f0f0afc86baef4c4b18e4 -
Trigger Event:
push
-
Statement type: