ommx-python-mip-adapter 3.0.0a5__tar.gz → 3.0.0a8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/PKG-INFO +11 -11
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/README.md +9 -9
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter/adapter.py +17 -13
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter/python_mip_to_ommx.py +5 -5
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter.egg-info/PKG-INFO +11 -11
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter.egg-info/requires.txt +1 -1
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/pyproject.toml +2 -2
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/tests/test_adapter.py +1 -1
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/tests/test_constant_constraint.py +1 -1
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/tests/test_integration.py +2 -2
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/tests/test_model_to_instance.py +1 -1
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/tests/test_tracing.py +1 -1
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter/__init__.py +0 -0
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter/exception.py +0 -0
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter.egg-info/SOURCES.txt +0 -0
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter.egg-info/dependency_links.txt +0 -0
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter.egg-info/top_level.txt +0 -0
- {ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ommx_python_mip_adapter
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.0a8
|
|
4
4
|
Summary: An adapter for the Python-MIP from/to OMMX.
|
|
5
5
|
Author-email: "Jij Inc." <info@j-ij.com>
|
|
6
6
|
Project-URL: Repository, https://github.com/Jij-Inc/ommx
|
|
@@ -15,7 +15,7 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
15
15
|
Classifier: License :: OSI Approved :: MIT License
|
|
16
16
|
Requires-Python: >=3.10
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
|
-
Requires-Dist: ommx<4.0.0,>=3.0.
|
|
18
|
+
Requires-Dist: ommx<4.0.0,>=3.0.0a8
|
|
19
19
|
Requires-Dist: mip<2.0.0,>=1.17.0
|
|
20
20
|
Requires-Dist: cffi<2.0.0,>=1.15.0
|
|
21
21
|
|
|
@@ -32,13 +32,13 @@ sequenceDiagram
|
|
|
32
32
|
participant U as User
|
|
33
33
|
participant A as Adapter
|
|
34
34
|
participant P as Python-MIP
|
|
35
|
-
U->>A: ommx.
|
|
35
|
+
U->>A: ommx.Instance
|
|
36
36
|
A->>U: Python-MIP model
|
|
37
37
|
U->>P: Python-MIP model and Parameters for Python-MIP;
|
|
38
38
|
P->>P: Solve with CBC, Gurobi, or other solvers
|
|
39
39
|
P->>U: Optimized model
|
|
40
|
-
U->>A: Optimized model and ommx.
|
|
41
|
-
A->>U: ommx.
|
|
40
|
+
U->>A: Optimized model and ommx.Instance
|
|
41
|
+
A->>U: ommx.Solution
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
Python-MIP as a user interface to create OMMX instance
|
|
@@ -49,10 +49,10 @@ sequenceDiagram
|
|
|
49
49
|
participant A as Adapter
|
|
50
50
|
participant O as Other OMMX toolchain
|
|
51
51
|
U->>A: Python-MIP model
|
|
52
|
-
A->>U: ommx.
|
|
53
|
-
U->>O: ommx.
|
|
52
|
+
A->>U: ommx.Instance
|
|
53
|
+
U->>O: ommx.Instance and Parameters for other solver
|
|
54
54
|
O->>O: Solve the instance with other solver using other adapter
|
|
55
|
-
O->>U: ommx.
|
|
55
|
+
O->>U: ommx.Solution
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
Usage
|
|
@@ -67,7 +67,7 @@ Python-MIP can be used through `ommx-python-mip-adapter` by using the following:
|
|
|
67
67
|
|
|
68
68
|
```python markdown-code-runner
|
|
69
69
|
from ommx_python_mip_adapter import OMMXPythonMIPAdapter
|
|
70
|
-
from ommx
|
|
70
|
+
from ommx import Instance, DecisionVariable
|
|
71
71
|
|
|
72
72
|
x1 = DecisionVariable.integer(1, lower=0, upper=5)
|
|
73
73
|
ommx_instance = Instance.from_components(
|
|
@@ -77,13 +77,13 @@ ommx_instance = Instance.from_components(
|
|
|
77
77
|
sense=Instance.MINIMIZE,
|
|
78
78
|
)
|
|
79
79
|
|
|
80
|
-
# Create `ommx.
|
|
80
|
+
# Create `ommx.Solution` from the `mip.Model`
|
|
81
81
|
ommx_solution = OMMXPythonMIPAdapter.solve(ommx_instance)
|
|
82
82
|
|
|
83
83
|
print(ommx_solution)
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
You can get `ommx.
|
|
86
|
+
You can get `ommx.Instance` from a Python-MIP model as the following:
|
|
87
87
|
|
|
88
88
|
```python markdown-code-runner
|
|
89
89
|
import mip
|
|
@@ -11,13 +11,13 @@ sequenceDiagram
|
|
|
11
11
|
participant U as User
|
|
12
12
|
participant A as Adapter
|
|
13
13
|
participant P as Python-MIP
|
|
14
|
-
U->>A: ommx.
|
|
14
|
+
U->>A: ommx.Instance
|
|
15
15
|
A->>U: Python-MIP model
|
|
16
16
|
U->>P: Python-MIP model and Parameters for Python-MIP;
|
|
17
17
|
P->>P: Solve with CBC, Gurobi, or other solvers
|
|
18
18
|
P->>U: Optimized model
|
|
19
|
-
U->>A: Optimized model and ommx.
|
|
20
|
-
A->>U: ommx.
|
|
19
|
+
U->>A: Optimized model and ommx.Instance
|
|
20
|
+
A->>U: ommx.Solution
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
Python-MIP as a user interface to create OMMX instance
|
|
@@ -28,10 +28,10 @@ sequenceDiagram
|
|
|
28
28
|
participant A as Adapter
|
|
29
29
|
participant O as Other OMMX toolchain
|
|
30
30
|
U->>A: Python-MIP model
|
|
31
|
-
A->>U: ommx.
|
|
32
|
-
U->>O: ommx.
|
|
31
|
+
A->>U: ommx.Instance
|
|
32
|
+
U->>O: ommx.Instance and Parameters for other solver
|
|
33
33
|
O->>O: Solve the instance with other solver using other adapter
|
|
34
|
-
O->>U: ommx.
|
|
34
|
+
O->>U: ommx.Solution
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
Usage
|
|
@@ -46,7 +46,7 @@ Python-MIP can be used through `ommx-python-mip-adapter` by using the following:
|
|
|
46
46
|
|
|
47
47
|
```python markdown-code-runner
|
|
48
48
|
from ommx_python_mip_adapter import OMMXPythonMIPAdapter
|
|
49
|
-
from ommx
|
|
49
|
+
from ommx import Instance, DecisionVariable
|
|
50
50
|
|
|
51
51
|
x1 = DecisionVariable.integer(1, lower=0, upper=5)
|
|
52
52
|
ommx_instance = Instance.from_components(
|
|
@@ -56,13 +56,13 @@ ommx_instance = Instance.from_components(
|
|
|
56
56
|
sense=Instance.MINIMIZE,
|
|
57
57
|
)
|
|
58
58
|
|
|
59
|
-
# Create `ommx.
|
|
59
|
+
# Create `ommx.Solution` from the `mip.Model`
|
|
60
60
|
ommx_solution = OMMXPythonMIPAdapter.solve(ommx_instance)
|
|
61
61
|
|
|
62
62
|
print(ommx_solution)
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
You can get `ommx.
|
|
65
|
+
You can get `ommx.Instance` from a Python-MIP model as the following:
|
|
66
66
|
|
|
67
67
|
```python markdown-code-runner
|
|
68
68
|
import mip
|
|
@@ -6,12 +6,13 @@ import mip
|
|
|
6
6
|
from opentelemetry import trace
|
|
7
7
|
|
|
8
8
|
from ommx.adapter import (
|
|
9
|
+
DiagnosticsSink,
|
|
9
10
|
SolverAdapter,
|
|
10
11
|
InfeasibleDetected,
|
|
11
12
|
UnboundedDetected,
|
|
12
13
|
NoSolutionReturned,
|
|
13
14
|
)
|
|
14
|
-
from ommx
|
|
15
|
+
from ommx import Instance, Constraint, DecisionVariable, Solution, State, Function
|
|
15
16
|
|
|
16
17
|
from .exception import OMMXPythonMIPAdapterError
|
|
17
18
|
|
|
@@ -29,7 +30,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
29
30
|
verbose: bool = False,
|
|
30
31
|
):
|
|
31
32
|
"""
|
|
32
|
-
:param ommx_instance: The ommx.
|
|
33
|
+
:param ommx_instance: The ommx.Instance to solve.
|
|
33
34
|
:param relax: Applies integer relaxation globally to this model using Python-MIP's `Model.relax() <https://docs.python-mip.com/en/latest/classes.html#mip.Model.relax>`.
|
|
34
35
|
:param solver_name: Passes a specific solver name to the Python-MIP model. Defaults to `CBC`.
|
|
35
36
|
:param solver: Passes a specific solver to the Python-MIP model.
|
|
@@ -72,11 +73,13 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
72
73
|
ommx_instance: Instance,
|
|
73
74
|
relax: bool = False,
|
|
74
75
|
verbose: bool = False,
|
|
76
|
+
*,
|
|
77
|
+
diagnostics: DiagnosticsSink | None = None,
|
|
75
78
|
) -> Solution:
|
|
76
79
|
"""
|
|
77
|
-
Solve the given ommx.
|
|
80
|
+
Solve the given ommx.Instance using Python-MIP, returning an ommx.Solution.
|
|
78
81
|
|
|
79
|
-
:param ommx_instance: The ommx.
|
|
82
|
+
:param ommx_instance: The ommx.Instance to solve.
|
|
80
83
|
:param 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>`.
|
|
81
84
|
:param verbose: If True, enable Python-MIP's verbose mode
|
|
82
85
|
|
|
@@ -87,7 +90,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
87
90
|
|
|
88
91
|
.. doctest::
|
|
89
92
|
|
|
90
|
-
>>> from ommx
|
|
93
|
+
>>> from ommx import Instance, DecisionVariable
|
|
91
94
|
>>> from ommx_python_mip_adapter import OMMXPythonMIPAdapter
|
|
92
95
|
|
|
93
96
|
>>> p = [10, 13, 18, 32, 7, 15]
|
|
@@ -124,7 +127,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
124
127
|
|
|
125
128
|
.. doctest::
|
|
126
129
|
|
|
127
|
-
>>> from ommx
|
|
130
|
+
>>> from ommx import Instance, DecisionVariable
|
|
128
131
|
>>> from ommx_python_mip_adapter import OMMXPythonMIPAdapter
|
|
129
132
|
|
|
130
133
|
>>> x = DecisionVariable.integer(0, upper=3, lower=0)
|
|
@@ -144,7 +147,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
144
147
|
|
|
145
148
|
.. doctest::
|
|
146
149
|
|
|
147
|
-
>>> from ommx
|
|
150
|
+
>>> from ommx import Instance, DecisionVariable
|
|
148
151
|
>>> from ommx_python_mip_adapter import OMMXPythonMIPAdapter
|
|
149
152
|
|
|
150
153
|
>>> x = DecisionVariable.integer(0, lower=0)
|
|
@@ -164,7 +167,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
164
167
|
|
|
165
168
|
.. doctest::
|
|
166
169
|
|
|
167
|
-
>>> from ommx
|
|
170
|
+
>>> from ommx import Instance, DecisionVariable
|
|
168
171
|
>>> from ommx_python_mip_adapter import OMMXPythonMIPAdapter
|
|
169
172
|
|
|
170
173
|
>>> x = DecisionVariable.continuous(0, lower=0, upper=1)
|
|
@@ -181,6 +184,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
181
184
|
1.0
|
|
182
185
|
|
|
183
186
|
"""
|
|
187
|
+
_ = diagnostics
|
|
184
188
|
with _tracer.start_as_current_span("solve") as span:
|
|
185
189
|
span.set_attribute("adapter", f"{cls.__module__}.{cls.__qualname__}")
|
|
186
190
|
adapter = cls(ommx_instance, relax=relax, verbose=verbose)
|
|
@@ -195,7 +199,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
195
199
|
return self.model
|
|
196
200
|
|
|
197
201
|
def decode(self, data: mip.Model) -> Solution:
|
|
198
|
-
"""Convert optimized Python-MIP model and ommx.
|
|
202
|
+
"""Convert optimized Python-MIP model and ommx.Instance to ommx.Solution.
|
|
199
203
|
|
|
200
204
|
This method is intended to be used if the model has been acquired with
|
|
201
205
|
`solver_input` for futher adjustment of the solver parameters, and
|
|
@@ -219,7 +223,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
219
223
|
|
|
220
224
|
.. doctest::
|
|
221
225
|
|
|
222
|
-
>>> from ommx
|
|
226
|
+
>>> from ommx import Instance, DecisionVariable
|
|
223
227
|
>>> from ommx_python_mip_adapter import OMMXPythonMIPAdapter
|
|
224
228
|
|
|
225
229
|
>>> p = [10, 13, 18, 32, 7, 15]
|
|
@@ -265,7 +269,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
265
269
|
|
|
266
270
|
def decode_to_state(self, data: mip.Model) -> State:
|
|
267
271
|
"""
|
|
268
|
-
Create an ommx.
|
|
272
|
+
Create an ommx.State from an optimized Python-MIP Model.
|
|
269
273
|
|
|
270
274
|
Examples
|
|
271
275
|
=========
|
|
@@ -275,7 +279,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
275
279
|
The following example of solving an unconstrained linear optimization problem with x1 as the objective function.
|
|
276
280
|
|
|
277
281
|
>>> from ommx_python_mip_adapter import OMMXPythonMIPAdapter
|
|
278
|
-
>>> from ommx
|
|
282
|
+
>>> from ommx import Instance, DecisionVariable
|
|
279
283
|
|
|
280
284
|
>>> x1 = DecisionVariable.integer(1, lower=0, upper=5)
|
|
281
285
|
>>> ommx_instance = Instance.from_components(
|
|
@@ -355,7 +359,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
355
359
|
f: Function,
|
|
356
360
|
) -> mip.LinExpr:
|
|
357
361
|
"""
|
|
358
|
-
Translate ommx.
|
|
362
|
+
Translate ommx.Function to `mip.LinExpr` or `float`.
|
|
359
363
|
"""
|
|
360
364
|
degree = f.degree()
|
|
361
365
|
constant = f.constant_term
|
|
@@ -4,7 +4,7 @@ from typing import final
|
|
|
4
4
|
import mip
|
|
5
5
|
|
|
6
6
|
from mip.exceptions import ParameterNotAvailable
|
|
7
|
-
from ommx
|
|
7
|
+
from ommx import Instance, DecisionVariable, Constraint, Function, Linear
|
|
8
8
|
|
|
9
9
|
from .exception import OMMXPythonMIPAdapterError
|
|
10
10
|
|
|
@@ -12,14 +12,14 @@ from .exception import OMMXPythonMIPAdapterError
|
|
|
12
12
|
@dataclass
|
|
13
13
|
class OMMXInstanceBuilder:
|
|
14
14
|
"""
|
|
15
|
-
Build ommx.
|
|
15
|
+
Build ommx.Instance from Python-MIP Model.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
model: mip.Model
|
|
19
19
|
|
|
20
20
|
def decision_variables(self) -> list[DecisionVariable]:
|
|
21
21
|
"""
|
|
22
|
-
Gather decision variables from Python-MIP Model as ommx.
|
|
22
|
+
Gather decision variables from Python-MIP Model as ommx.DecisionVariable.
|
|
23
23
|
"""
|
|
24
24
|
decision_variables = []
|
|
25
25
|
for var in self.model.vars:
|
|
@@ -93,7 +93,7 @@ class OMMXInstanceBuilder:
|
|
|
93
93
|
name=name,
|
|
94
94
|
)
|
|
95
95
|
elif lin_expr.sense == ">":
|
|
96
|
-
# `ommx.
|
|
96
|
+
# `ommx.Constraint` does not support `GREATER_THAN_OR_EQUAL_TO_ZERO`.
|
|
97
97
|
# So multiply the linear expression by -1.
|
|
98
98
|
constraint = Constraint(
|
|
99
99
|
function=self.as_ommx_function(-lin_expr),
|
|
@@ -129,7 +129,7 @@ class OMMXInstanceBuilder:
|
|
|
129
129
|
|
|
130
130
|
def model_to_instance(model: mip.Model) -> Instance:
|
|
131
131
|
"""
|
|
132
|
-
The function to convert Python-MIP Model to ommx.
|
|
132
|
+
The function to convert Python-MIP Model to ommx.Instance.
|
|
133
133
|
|
|
134
134
|
Examples
|
|
135
135
|
=========
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ommx_python_mip_adapter
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.0a8
|
|
4
4
|
Summary: An adapter for the Python-MIP from/to OMMX.
|
|
5
5
|
Author-email: "Jij Inc." <info@j-ij.com>
|
|
6
6
|
Project-URL: Repository, https://github.com/Jij-Inc/ommx
|
|
@@ -15,7 +15,7 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
15
15
|
Classifier: License :: OSI Approved :: MIT License
|
|
16
16
|
Requires-Python: >=3.10
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
|
-
Requires-Dist: ommx<4.0.0,>=3.0.
|
|
18
|
+
Requires-Dist: ommx<4.0.0,>=3.0.0a8
|
|
19
19
|
Requires-Dist: mip<2.0.0,>=1.17.0
|
|
20
20
|
Requires-Dist: cffi<2.0.0,>=1.15.0
|
|
21
21
|
|
|
@@ -32,13 +32,13 @@ sequenceDiagram
|
|
|
32
32
|
participant U as User
|
|
33
33
|
participant A as Adapter
|
|
34
34
|
participant P as Python-MIP
|
|
35
|
-
U->>A: ommx.
|
|
35
|
+
U->>A: ommx.Instance
|
|
36
36
|
A->>U: Python-MIP model
|
|
37
37
|
U->>P: Python-MIP model and Parameters for Python-MIP;
|
|
38
38
|
P->>P: Solve with CBC, Gurobi, or other solvers
|
|
39
39
|
P->>U: Optimized model
|
|
40
|
-
U->>A: Optimized model and ommx.
|
|
41
|
-
A->>U: ommx.
|
|
40
|
+
U->>A: Optimized model and ommx.Instance
|
|
41
|
+
A->>U: ommx.Solution
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
Python-MIP as a user interface to create OMMX instance
|
|
@@ -49,10 +49,10 @@ sequenceDiagram
|
|
|
49
49
|
participant A as Adapter
|
|
50
50
|
participant O as Other OMMX toolchain
|
|
51
51
|
U->>A: Python-MIP model
|
|
52
|
-
A->>U: ommx.
|
|
53
|
-
U->>O: ommx.
|
|
52
|
+
A->>U: ommx.Instance
|
|
53
|
+
U->>O: ommx.Instance and Parameters for other solver
|
|
54
54
|
O->>O: Solve the instance with other solver using other adapter
|
|
55
|
-
O->>U: ommx.
|
|
55
|
+
O->>U: ommx.Solution
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
Usage
|
|
@@ -67,7 +67,7 @@ Python-MIP can be used through `ommx-python-mip-adapter` by using the following:
|
|
|
67
67
|
|
|
68
68
|
```python markdown-code-runner
|
|
69
69
|
from ommx_python_mip_adapter import OMMXPythonMIPAdapter
|
|
70
|
-
from ommx
|
|
70
|
+
from ommx import Instance, DecisionVariable
|
|
71
71
|
|
|
72
72
|
x1 = DecisionVariable.integer(1, lower=0, upper=5)
|
|
73
73
|
ommx_instance = Instance.from_components(
|
|
@@ -77,13 +77,13 @@ ommx_instance = Instance.from_components(
|
|
|
77
77
|
sense=Instance.MINIMIZE,
|
|
78
78
|
)
|
|
79
79
|
|
|
80
|
-
# Create `ommx.
|
|
80
|
+
# Create `ommx.Solution` from the `mip.Model`
|
|
81
81
|
ommx_solution = OMMXPythonMIPAdapter.solve(ommx_instance)
|
|
82
82
|
|
|
83
83
|
print(ommx_solution)
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
You can get `ommx.
|
|
86
|
+
You can get `ommx.Instance` from a Python-MIP model as the following:
|
|
87
87
|
|
|
88
88
|
```python markdown-code-runner
|
|
89
89
|
import mip
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ommx_python_mip_adapter"
|
|
7
|
-
version = "3.0.
|
|
7
|
+
version = "3.0.0a8"
|
|
8
8
|
|
|
9
9
|
description = "An adapter for the Python-MIP from/to OMMX."
|
|
10
10
|
authors = [{ name = "Jij Inc.", email = "info@j-ij.com" }]
|
|
@@ -23,7 +23,7 @@ classifiers = [
|
|
|
23
23
|
]
|
|
24
24
|
|
|
25
25
|
dependencies = [
|
|
26
|
-
"ommx >= 3.0.
|
|
26
|
+
"ommx >= 3.0.0a8, < 4.0.0",
|
|
27
27
|
"mip >= 1.17.0, < 2.0.0",
|
|
28
28
|
"cffi >= 1.15.0, < 2.0.0",
|
|
29
29
|
]
|
{ommx_python_mip_adapter-3.0.0a5 → ommx_python_mip_adapter-3.0.0a8}/tests/test_integration.py
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
|
|
3
|
-
from ommx
|
|
3
|
+
from ommx import Instance, DecisionVariable, Solution
|
|
4
4
|
from ommx.adapter import InfeasibleDetected, UnboundedDetected, NoSolutionReturned
|
|
5
5
|
from ommx.testing import SingleFeasibleLPGenerator, DataType
|
|
6
6
|
|
|
@@ -113,7 +113,7 @@ def test_relax_constraint():
|
|
|
113
113
|
assert instance.used_decision_variables == x
|
|
114
114
|
instance.relax_constraint(1, "relax")
|
|
115
115
|
# id for x[2] is listed as irrelevant
|
|
116
|
-
assert instance.
|
|
116
|
+
assert instance.irrelevant_decision_variable_ids() == {x[2].id}
|
|
117
117
|
|
|
118
118
|
solution = OMMXPythonMIPAdapter.solve(instance)
|
|
119
119
|
# x[2] is still present as part of the evaluate/decoding process but has a value of 0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|