ommx-python-mip-adapter 3.0.0b2__tar.gz → 3.0.0b3__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.0b2 → ommx_python_mip_adapter-3.0.0b3}/PKG-INFO +5 -5
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/README.md +3 -3
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/ommx_python_mip_adapter/adapter.py +22 -0
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/ommx_python_mip_adapter.egg-info/PKG-INFO +5 -5
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/ommx_python_mip_adapter.egg-info/requires.txt +1 -1
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/pyproject.toml +2 -2
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/tests/test_adapter.py +34 -0
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/ommx_python_mip_adapter/__init__.py +0 -0
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/ommx_python_mip_adapter/exception.py +0 -0
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/ommx_python_mip_adapter/python_mip_to_ommx.py +0 -0
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/ommx_python_mip_adapter.egg-info/SOURCES.txt +0 -0
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/ommx_python_mip_adapter.egg-info/dependency_links.txt +0 -0
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/ommx_python_mip_adapter.egg-info/top_level.txt +0 -0
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/setup.cfg +0 -0
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/tests/test_constant_constraint.py +0 -0
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/tests/test_integration.py +0 -0
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/tests/test_model_to_instance.py +0 -0
- {ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/tests/test_tracing.py +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.0b3
|
|
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.0b3
|
|
19
19
|
Requires-Dist: mip<2.0.0,>=1.17.0
|
|
20
20
|
Requires-Dist: cffi<2.0.0,>=1.15.0
|
|
21
21
|
|
|
@@ -90,9 +90,9 @@ import mip
|
|
|
90
90
|
import ommx_python_mip_adapter as adapter
|
|
91
91
|
|
|
92
92
|
model = mip.Model()
|
|
93
|
-
x1=model.add_var(name="1", var_type=mip.INTEGER, lb=0, ub=5)
|
|
94
|
-
x2=model.add_var(name="2", var_type=mip.CONTINUOUS, lb=0, ub=5)
|
|
95
|
-
model.objective = -
|
|
93
|
+
x1 = model.add_var(name="1", var_type=mip.INTEGER, lb=0, ub=5)
|
|
94
|
+
x2 = model.add_var(name="2", var_type=mip.CONTINUOUS, lb=0, ub=5)
|
|
95
|
+
model.objective = -x1 - 2 * x2
|
|
96
96
|
model.add_constr(x1 + x2 - 6 <= 0)
|
|
97
97
|
|
|
98
98
|
ommx_instance = adapter.model_to_instance(model)
|
|
@@ -69,9 +69,9 @@ import mip
|
|
|
69
69
|
import ommx_python_mip_adapter as adapter
|
|
70
70
|
|
|
71
71
|
model = mip.Model()
|
|
72
|
-
x1=model.add_var(name="1", var_type=mip.INTEGER, lb=0, ub=5)
|
|
73
|
-
x2=model.add_var(name="2", var_type=mip.CONTINUOUS, lb=0, ub=5)
|
|
74
|
-
model.objective = -
|
|
72
|
+
x1 = model.add_var(name="1", var_type=mip.INTEGER, lb=0, ub=5)
|
|
73
|
+
x2 = model.add_var(name="2", var_type=mip.CONTINUOUS, lb=0, ub=5)
|
|
74
|
+
model.objective = -x1 - 2 * x2
|
|
75
75
|
model.add_constr(x1 + x2 - 6 <= 0)
|
|
76
76
|
|
|
77
77
|
ommx_instance = adapter.model_to_instance(model)
|
|
@@ -22,8 +22,11 @@ from ommx import (
|
|
|
22
22
|
InstanceClass,
|
|
23
23
|
InstanceClassClause,
|
|
24
24
|
Kind,
|
|
25
|
+
PreparationPolicy,
|
|
25
26
|
Sense,
|
|
26
27
|
Solution,
|
|
28
|
+
SpecialConstraintKind,
|
|
29
|
+
SpecialConstraintPreparation,
|
|
27
30
|
State,
|
|
28
31
|
)
|
|
29
32
|
|
|
@@ -50,6 +53,25 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
50
53
|
]
|
|
51
54
|
)
|
|
52
55
|
|
|
56
|
+
@classmethod
|
|
57
|
+
def recommended_preparation_policy(cls) -> PreparationPolicy:
|
|
58
|
+
"""Recommend lowering special constraints before using Python-MIP.
|
|
59
|
+
|
|
60
|
+
Python-MIP currently accepts only regular constraints through this
|
|
61
|
+
adapter. The recommendation therefore lowers the special-constraint
|
|
62
|
+
families currently understood by OMMX. The returned policy is fresh and
|
|
63
|
+
may be edited by the caller before :meth:`Instance.prepare` is invoked.
|
|
64
|
+
"""
|
|
65
|
+
return PreparationPolicy(
|
|
66
|
+
special_constraints=SpecialConstraintPreparation.lower_special_constraints(
|
|
67
|
+
kinds={
|
|
68
|
+
SpecialConstraintKind.Indicator,
|
|
69
|
+
SpecialConstraintKind.OneHot,
|
|
70
|
+
SpecialConstraintKind.Sos1,
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
|
|
53
75
|
def __init__(
|
|
54
76
|
self,
|
|
55
77
|
ommx_instance: Instance,
|
|
@@ -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.0b3
|
|
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.0b3
|
|
19
19
|
Requires-Dist: mip<2.0.0,>=1.17.0
|
|
20
20
|
Requires-Dist: cffi<2.0.0,>=1.15.0
|
|
21
21
|
|
|
@@ -90,9 +90,9 @@ import mip
|
|
|
90
90
|
import ommx_python_mip_adapter as adapter
|
|
91
91
|
|
|
92
92
|
model = mip.Model()
|
|
93
|
-
x1=model.add_var(name="1", var_type=mip.INTEGER, lb=0, ub=5)
|
|
94
|
-
x2=model.add_var(name="2", var_type=mip.CONTINUOUS, lb=0, ub=5)
|
|
95
|
-
model.objective = -
|
|
93
|
+
x1 = model.add_var(name="1", var_type=mip.INTEGER, lb=0, ub=5)
|
|
94
|
+
x2 = model.add_var(name="2", var_type=mip.CONTINUOUS, lb=0, ub=5)
|
|
95
|
+
model.objective = -x1 - 2 * x2
|
|
96
96
|
model.add_constr(x1 + x2 - 6 <= 0)
|
|
97
97
|
|
|
98
98
|
ommx_instance = adapter.model_to_instance(model)
|
|
@@ -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.0b3"
|
|
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.0b3, < 4.0.0",
|
|
27
27
|
"mip >= 1.17.0, < 2.0.0",
|
|
28
28
|
"cffi >= 1.15.0, < 2.0.0",
|
|
29
29
|
]
|
|
@@ -171,3 +171,37 @@ def test_rejects_special_constraints_without_mutating_input() -> None:
|
|
|
171
171
|
assert InstanceClassMismatch.OneHotConstraintsNotAllowed in mismatch_types
|
|
172
172
|
assert InstanceClassMismatch.Sos1ConstraintsNotAllowed in mismatch_types
|
|
173
173
|
assert instance.to_v2_bytes() == before
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def test_recommended_preparation_reaches_the_python_mip_input_class() -> None:
|
|
177
|
+
x = DecisionVariable.binary(0)
|
|
178
|
+
y = DecisionVariable.continuous(1, lower=0, upper=2)
|
|
179
|
+
instance = Instance.from_components(
|
|
180
|
+
decision_variables=[x, y],
|
|
181
|
+
objective=x + y,
|
|
182
|
+
constraints={},
|
|
183
|
+
sense=Sense.Minimize,
|
|
184
|
+
indicator_constraints={
|
|
185
|
+
10: IndicatorConstraint(
|
|
186
|
+
indicator_variable=x,
|
|
187
|
+
function=y - 1,
|
|
188
|
+
equality=Equality.LessThanOrEqualToZero,
|
|
189
|
+
)
|
|
190
|
+
},
|
|
191
|
+
one_hot_constraints={20: OneHotConstraint(variables=[x])},
|
|
192
|
+
sos1_constraints={30: Sos1Constraint(variables=[y])},
|
|
193
|
+
)
|
|
194
|
+
input_class = OMMXPythonMIPAdapter.INPUT_CLASS
|
|
195
|
+
assert input_class is not None
|
|
196
|
+
assert not input_class.contains(instance)
|
|
197
|
+
|
|
198
|
+
policy = OMMXPythonMIPAdapter.recommended_preparation_policy()
|
|
199
|
+
assert policy.special_constraints is not None
|
|
200
|
+
assert policy.sense is None
|
|
201
|
+
assert policy.integer_slack is None
|
|
202
|
+
assert policy.integer_encoding is None
|
|
203
|
+
assert policy.fixed_penalty is None
|
|
204
|
+
|
|
205
|
+
assert instance.prepare(input_class, policy) is None
|
|
206
|
+
assert input_class.contains(instance)
|
|
207
|
+
assert OMMXPythonMIPAdapter.check_applicability(instance).is_applicable
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/tests/test_integration.py
RENAMED
|
File without changes
|
{ommx_python_mip_adapter-3.0.0b2 → ommx_python_mip_adapter-3.0.0b3}/tests/test_model_to_instance.py
RENAMED
|
File without changes
|
|
File without changes
|