ommx-python-mip-adapter 1.5.1__tar.gz → 1.6.0__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.
Files changed (17) hide show
  1. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/PKG-INFO +4 -5
  2. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/ommx_python_mip_adapter/ommx_to_python_mip.py +1 -4
  3. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/ommx_python_mip_adapter/python_mip_to_ommx.py +4 -1
  4. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/ommx_python_mip_adapter.egg-info/PKG-INFO +4 -5
  5. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/pyproject.toml +5 -8
  6. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/tests/test_model_to_instance.py +17 -0
  7. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/README.md +0 -0
  8. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/ommx_python_mip_adapter/__init__.py +0 -0
  9. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/ommx_python_mip_adapter/exception.py +0 -0
  10. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/ommx_python_mip_adapter.egg-info/SOURCES.txt +0 -0
  11. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/ommx_python_mip_adapter.egg-info/dependency_links.txt +0 -0
  12. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/ommx_python_mip_adapter.egg-info/requires.txt +0 -0
  13. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/ommx_python_mip_adapter.egg-info/top_level.txt +0 -0
  14. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/setup.cfg +0 -0
  15. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/tests/test_constant_constraint.py +0 -0
  16. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/tests/test_instance_to_model.py +0 -0
  17. {ommx_python_mip_adapter-1.5.1 → ommx_python_mip_adapter-1.6.0}/tests/test_integration.py +0 -0
@@ -1,18 +1,17 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ommx_python_mip_adapter
3
- Version: 1.5.1
3
+ Version: 1.6.0
4
4
  Summary: An adapter for the Python-MIP from/to OMMX.
5
5
  Author-email: "Jij Inc." <info@j-ij.com>
6
- Project-URL: Repository, https://github.com/Jij-Inc/ommx-python-mip-adapter
7
- Project-URL: Issues, https://github.com/Jij-Inc/ommx-python-mip-adapter/issues
6
+ Project-URL: Repository, https://github.com/Jij-Inc/ommx
7
+ Project-URL: Issues, https://github.com/Jij-Inc/ommx/issues
8
8
  Classifier: Programming Language :: Python :: 3 :: Only
9
- Classifier: Programming Language :: Python :: 3.8
10
9
  Classifier: Programming Language :: Python :: 3.9
11
10
  Classifier: Programming Language :: Python :: 3.10
12
11
  Classifier: Programming Language :: Python :: 3.11
13
12
  Classifier: License :: OSI Approved :: Apache Software License
14
13
  Classifier: License :: OSI Approved :: MIT License
15
- Requires-Python: >=3.8
14
+ Requires-Python: >=3.9
16
15
  Description-Content-Type: text/markdown
17
16
  Requires-Dist: ommx<2.0.0,>=1.4.0
18
17
  Requires-Dist: mip<2.0.0,>=1.15.0
@@ -6,7 +6,7 @@ from dataclasses import dataclass
6
6
  import mip
7
7
 
8
8
  from ommx.v1.function_pb2 import Function
9
- from ommx.v1.solution_pb2 import Optimality, Result, Infeasible, Unbounded, Relaxation
9
+ from ommx.v1.solution_pb2 import Result, Infeasible, Unbounded, Relaxation
10
10
  from ommx.v1 import Instance, DecisionVariable, Constraint
11
11
 
12
12
  from .exception import OMMXPythonMIPAdapterError
@@ -305,9 +305,6 @@ def solve(
305
305
 
306
306
  solution = model_to_solution(model, instance)
307
307
 
308
- if model.status == mip.OptimizationStatus.OPTIMAL:
309
- solution.raw.optimality = Optimality.OPTIMALITY_OPTIMAL
310
-
311
308
  if relax:
312
309
  solution.raw.relaxation = Relaxation.RELAXATION_LP_RELAXED
313
310
 
@@ -7,7 +7,7 @@ from mip.exceptions import ParameterNotAvailable
7
7
  from ommx.v1.constraint_pb2 import Constraint, Equality
8
8
  from ommx.v1.function_pb2 import Function
9
9
  from ommx.v1.linear_pb2 import Linear
10
- from ommx.v1.solution_pb2 import State
10
+ from ommx.v1.solution_pb2 import State, Optimality
11
11
  from ommx.v1 import Instance, DecisionVariable, Solution
12
12
 
13
13
  from .exception import OMMXPythonMIPAdapterError
@@ -248,4 +248,7 @@ def model_to_solution(
248
248
  if id in dual_variables:
249
249
  constraint.dual_variable = dual_variables[id]
250
250
 
251
+ if model.status == mip.OptimizationStatus.OPTIMAL:
252
+ solution.raw.optimality = Optimality.OPTIMALITY_OPTIMAL
253
+
251
254
  return solution
@@ -1,18 +1,17 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ommx_python_mip_adapter
3
- Version: 1.5.1
3
+ Version: 1.6.0
4
4
  Summary: An adapter for the Python-MIP from/to OMMX.
5
5
  Author-email: "Jij Inc." <info@j-ij.com>
6
- Project-URL: Repository, https://github.com/Jij-Inc/ommx-python-mip-adapter
7
- Project-URL: Issues, https://github.com/Jij-Inc/ommx-python-mip-adapter/issues
6
+ Project-URL: Repository, https://github.com/Jij-Inc/ommx
7
+ Project-URL: Issues, https://github.com/Jij-Inc/ommx/issues
8
8
  Classifier: Programming Language :: Python :: 3 :: Only
9
- Classifier: Programming Language :: Python :: 3.8
10
9
  Classifier: Programming Language :: Python :: 3.9
11
10
  Classifier: Programming Language :: Python :: 3.10
12
11
  Classifier: Programming Language :: Python :: 3.11
13
12
  Classifier: License :: OSI Approved :: Apache Software License
14
13
  Classifier: License :: OSI Approved :: MIT License
15
- Requires-Python: >=3.8
14
+ Requires-Python: >=3.9
16
15
  Description-Content-Type: text/markdown
17
16
  Requires-Dist: ommx<2.0.0,>=1.4.0
18
17
  Requires-Dist: mip<2.0.0,>=1.15.0
@@ -4,18 +4,15 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ommx_python_mip_adapter"
7
- version = "1.5.1"
7
+ version = "1.6.0"
8
8
 
9
9
  description = "An adapter for the Python-MIP from/to OMMX."
10
- authors = [
11
- { name="Jij Inc.", email="info@j-ij.com" },
12
- ]
10
+ authors = [{ name = "Jij Inc.", email = "info@j-ij.com" }]
13
11
  readme = "README.md"
14
12
 
15
- requires-python = ">=3.8"
13
+ requires-python = ">=3.9"
16
14
  classifiers = [
17
15
  "Programming Language :: Python :: 3 :: Only",
18
- "Programming Language :: Python :: 3.8",
19
16
  "Programming Language :: Python :: 3.9",
20
17
  "Programming Language :: Python :: 3.10",
21
18
  "Programming Language :: Python :: 3.11",
@@ -31,8 +28,8 @@ dependencies = [
31
28
  ]
32
29
 
33
30
  [project.urls]
34
- Repository = "https://github.com/Jij-Inc/ommx-python-mip-adapter"
35
- Issues = "https://github.com/Jij-Inc/ommx-python-mip-adapter/issues"
31
+ Repository = "https://github.com/Jij-Inc/ommx"
32
+ Issues = "https://github.com/Jij-Inc/ommx/issues"
36
33
 
37
34
  [project.optional-dependencies]
38
35
  dev = [
@@ -1,6 +1,7 @@
1
1
  import mip
2
2
 
3
3
  from ommx.v1 import Instance, DecisionVariable, Constraint
4
+ from ommx.v1.solution_pb2 import Optimality
4
5
 
5
6
  import ommx_python_mip_adapter as adapter
6
7
 
@@ -200,3 +201,19 @@ def test_no_objective_model():
200
201
  constraint2_term_x3 = constraint2.function.linear.terms[1]
201
202
  assert constraint2_term_x3.id == 1
202
203
  assert constraint2_term_x3.coefficient == 3
204
+
205
+
206
+ def test_solution_optimality():
207
+ x = DecisionVariable.integer(1, lower=0, upper=5)
208
+ y = DecisionVariable.integer(1, lower=0, upper=5)
209
+ ommx_instance = Instance.from_components(
210
+ decision_variables=[x, y],
211
+ objective=x + y,
212
+ constraints=[],
213
+ sense=Instance.MAXIMIZE,
214
+ )
215
+
216
+ model = adapter.instance_to_model(ommx_instance)
217
+ model.optimize()
218
+ solution = adapter.model_to_solution(model, ommx_instance)
219
+ assert solution.optimality == Optimality.OPTIMALITY_OPTIMAL