ommx-python-mip-adapter 3.0.0b4__tar.gz → 3.0.0b5__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.0b4 → ommx_python_mip_adapter-3.0.0b5}/PKG-INFO +2 -2
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/ommx_python_mip_adapter/adapter.py +13 -6
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/ommx_python_mip_adapter.egg-info/PKG-INFO +2 -2
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/ommx_python_mip_adapter.egg-info/requires.txt +1 -1
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/pyproject.toml +2 -2
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/tests/test_adapter.py +23 -6
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/README.md +0 -0
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/ommx_python_mip_adapter/__init__.py +0 -0
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/ommx_python_mip_adapter/exception.py +0 -0
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/ommx_python_mip_adapter/python_mip_to_ommx.py +0 -0
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/ommx_python_mip_adapter.egg-info/SOURCES.txt +0 -0
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/ommx_python_mip_adapter.egg-info/dependency_links.txt +0 -0
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/ommx_python_mip_adapter.egg-info/top_level.txt +0 -0
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/setup.cfg +0 -0
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/tests/test_constant_constraint.py +0 -0
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/tests/test_integration.py +0 -0
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/tests/test_model_to_instance.py +0 -0
- {ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/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.0b5
|
|
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.0b5
|
|
19
19
|
Requires-Dist: mip<2.0.0,>=1.17.0
|
|
20
20
|
Requires-Dist: cffi<2.0.0,>=1.15.0
|
|
21
21
|
|
|
@@ -16,13 +16,13 @@ from ommx.adapter import (
|
|
|
16
16
|
from ommx import (
|
|
17
17
|
Constraint,
|
|
18
18
|
DecisionVariable,
|
|
19
|
-
DegreeBound,
|
|
20
19
|
Equality,
|
|
21
20
|
Function,
|
|
22
21
|
Instance,
|
|
23
22
|
InstanceClass,
|
|
24
23
|
InstanceClassClause,
|
|
25
24
|
Kind,
|
|
25
|
+
PolynomialRequirement,
|
|
26
26
|
PreparationPolicy,
|
|
27
27
|
Sense,
|
|
28
28
|
Solution,
|
|
@@ -35,9 +35,9 @@ from .exception import OMMXPythonMIPAdapterError
|
|
|
35
35
|
|
|
36
36
|
_tracer = trace.get_tracer("ommx.adapter.python_mip")
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
Equality.EqualToZero:
|
|
40
|
-
Equality.LessThanOrEqualToZero:
|
|
38
|
+
_LINEAR_CONSTRAINT_POLYNOMIAL_REQUIREMENTS = {
|
|
39
|
+
Equality.EqualToZero: PolynomialRequirement.at_most(1),
|
|
40
|
+
Equality.LessThanOrEqualToZero: PolynomialRequirement.at_most(1),
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
|
|
@@ -47,8 +47,10 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
47
47
|
InstanceClassClause(
|
|
48
48
|
label="python-mip-linear-mip",
|
|
49
49
|
allowed_variable_kinds={Kind.Binary, Kind.Integer, Kind.Continuous},
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
objective_polynomial_requirement=PolynomialRequirement.at_most(1),
|
|
51
|
+
regular_constraint_polynomial_requirements=(
|
|
52
|
+
_LINEAR_CONSTRAINT_POLYNOMIAL_REQUIREMENTS
|
|
53
|
+
),
|
|
52
54
|
allowed_senses={Sense.Minimize, Sense.Maximize},
|
|
53
55
|
)
|
|
54
56
|
]
|
|
@@ -447,6 +449,11 @@ class OMMXPythonMIPAdapter(SolverAdapter):
|
|
|
447
449
|
Translate ommx.Function to `mip.LinExpr` or `float`.
|
|
448
450
|
"""
|
|
449
451
|
degree = f.degree()
|
|
452
|
+
if degree is None:
|
|
453
|
+
raise OMMXPythonMIPAdapterError(
|
|
454
|
+
"Non-polynomial functions are not supported. "
|
|
455
|
+
"Only linear (degree 1) and constant (degree 0) functions are supported."
|
|
456
|
+
)
|
|
450
457
|
constant = f.constant_term
|
|
451
458
|
if degree > 1:
|
|
452
459
|
raise OMMXPythonMIPAdapterError(
|
|
@@ -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.0b5
|
|
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.0b5
|
|
19
19
|
Requires-Dist: mip<2.0.0,>=1.17.0
|
|
20
20
|
Requires-Dist: cffi<2.0.0,>=1.15.0
|
|
21
21
|
|
|
@@ -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.0b5"
|
|
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.0b5, < 4.0.0",
|
|
27
27
|
"mip >= 1.17.0, < 2.0.0",
|
|
28
28
|
"cffi >= 1.15.0, < 2.0.0",
|
|
29
29
|
]
|
|
@@ -2,13 +2,14 @@ import pytest
|
|
|
2
2
|
|
|
3
3
|
from ommx import (
|
|
4
4
|
DecisionVariable,
|
|
5
|
-
DegreeBound,
|
|
6
5
|
Equality,
|
|
6
|
+
Function,
|
|
7
7
|
IndicatorConstraint,
|
|
8
8
|
Instance,
|
|
9
9
|
InstanceClassMismatch,
|
|
10
10
|
Kind,
|
|
11
11
|
OneHotConstraint,
|
|
12
|
+
PolynomialRequirement,
|
|
12
13
|
Sense,
|
|
13
14
|
Sos1Constraint,
|
|
14
15
|
)
|
|
@@ -26,12 +27,12 @@ def test_declares_linear_mip_input_class() -> None:
|
|
|
26
27
|
Kind.Integer,
|
|
27
28
|
Kind.Continuous,
|
|
28
29
|
}
|
|
29
|
-
assert clause.
|
|
30
|
-
assert clause.
|
|
31
|
-
Equality.EqualToZero:
|
|
32
|
-
Equality.LessThanOrEqualToZero:
|
|
30
|
+
assert clause.objective_polynomial_requirement == PolynomialRequirement.at_most(1)
|
|
31
|
+
assert clause.regular_constraint_polynomial_requirements == {
|
|
32
|
+
Equality.EqualToZero: PolynomialRequirement.at_most(1),
|
|
33
|
+
Equality.LessThanOrEqualToZero: PolynomialRequirement.at_most(1),
|
|
33
34
|
}
|
|
34
|
-
assert clause.
|
|
35
|
+
assert clause.indicator_body_polynomial_requirements == {}
|
|
35
36
|
assert not clause.allows_one_hot
|
|
36
37
|
assert not clause.allows_sos1
|
|
37
38
|
assert clause.allowed_senses == {Sense.Minimize, Sense.Maximize}
|
|
@@ -73,6 +74,22 @@ def test_error_nonlinear_objective():
|
|
|
73
74
|
)
|
|
74
75
|
|
|
75
76
|
|
|
77
|
+
def test_error_non_polynomial_objective() -> None:
|
|
78
|
+
x = DecisionVariable.continuous(0)
|
|
79
|
+
instance = Instance.from_components(
|
|
80
|
+
decision_variables=[x],
|
|
81
|
+
objective=abs(Function(x)),
|
|
82
|
+
constraints={},
|
|
83
|
+
sense=Sense.Minimize,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
with pytest.raises(AdapterNotApplicableError) as error:
|
|
87
|
+
OMMXPythonMIPAdapter(instance)
|
|
88
|
+
|
|
89
|
+
[mismatch] = error.value.report.clause_reports[0].mismatches
|
|
90
|
+
assert isinstance(mismatch, InstanceClassMismatch.ObjectiveFunctionNotPolynomial)
|
|
91
|
+
|
|
92
|
+
|
|
76
93
|
def test_error_nonlinear_constraint():
|
|
77
94
|
# Objective function: 0
|
|
78
95
|
# Constraint: 2.3 * x * x = 0
|
|
File without changes
|
|
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.0b4 → ommx_python_mip_adapter-3.0.0b5}/tests/test_integration.py
RENAMED
|
File without changes
|
{ommx_python_mip_adapter-3.0.0b4 → ommx_python_mip_adapter-3.0.0b5}/tests/test_model_to_instance.py
RENAMED
|
File without changes
|
|
File without changes
|