ommx-python-mip-adapter 3.0.0a7__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.
Files changed (18) hide show
  1. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/PKG-INFO +11 -11
  2. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/README.md +9 -9
  3. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter/adapter.py +13 -13
  4. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter/python_mip_to_ommx.py +5 -5
  5. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter.egg-info/PKG-INFO +11 -11
  6. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter.egg-info/requires.txt +1 -1
  7. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/pyproject.toml +2 -2
  8. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/tests/test_adapter.py +1 -1
  9. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/tests/test_constant_constraint.py +1 -1
  10. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/tests/test_integration.py +2 -2
  11. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/tests/test_model_to_instance.py +1 -1
  12. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/tests/test_tracing.py +1 -1
  13. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter/__init__.py +0 -0
  14. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter/exception.py +0 -0
  15. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter.egg-info/SOURCES.txt +0 -0
  16. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter.egg-info/dependency_links.txt +0 -0
  17. {ommx_python_mip_adapter-3.0.0a7 → ommx_python_mip_adapter-3.0.0a8}/ommx_python_mip_adapter.egg-info/top_level.txt +0 -0
  18. {ommx_python_mip_adapter-3.0.0a7 → 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.0a7
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.0a7
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.v1.Instance
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.v1.Instance
41
- A->>U: ommx.v1.Solution
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.v1.Instance
53
- U->>O: ommx.v1.Instance and Parameters for other solver
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.v1.Solution
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.v1 import Instance, DecisionVariable
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.v1.Solution` from the `mip.Model`
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.v1.Instance` from a Python-MIP model as the following:
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.v1.Instance
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.v1.Instance
20
- A->>U: ommx.v1.Solution
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.v1.Instance
32
- U->>O: ommx.v1.Instance and Parameters for other solver
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.v1.Solution
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.v1 import Instance, DecisionVariable
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.v1.Solution` from the `mip.Model`
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.v1.Instance` from a Python-MIP model as the following:
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
@@ -12,7 +12,7 @@ from ommx.adapter import (
12
12
  UnboundedDetected,
13
13
  NoSolutionReturned,
14
14
  )
15
- from ommx.v1 import Instance, Constraint, DecisionVariable, Solution, State, Function
15
+ from ommx import Instance, Constraint, DecisionVariable, Solution, State, Function
16
16
 
17
17
  from .exception import OMMXPythonMIPAdapterError
18
18
 
@@ -30,7 +30,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
30
30
  verbose: bool = False,
31
31
  ):
32
32
  """
33
- :param ommx_instance: The ommx.v1.Instance to solve.
33
+ :param ommx_instance: The ommx.Instance to solve.
34
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>`.
35
35
  :param solver_name: Passes a specific solver name to the Python-MIP model. Defaults to `CBC`.
36
36
  :param solver: Passes a specific solver to the Python-MIP model.
@@ -77,9 +77,9 @@ class OMMXPythonMIPAdapter(SolverAdapter):
77
77
  diagnostics: DiagnosticsSink | None = None,
78
78
  ) -> Solution:
79
79
  """
80
- Solve the given ommx.v1.Instance using Python-MIP, returning an ommx.v1.Solution.
80
+ Solve the given ommx.Instance using Python-MIP, returning an ommx.Solution.
81
81
 
82
- :param ommx_instance: The ommx.v1.Instance to solve.
82
+ :param ommx_instance: The ommx.Instance to solve.
83
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>`.
84
84
  :param verbose: If True, enable Python-MIP's verbose mode
85
85
 
@@ -90,7 +90,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
90
90
 
91
91
  .. doctest::
92
92
 
93
- >>> from ommx.v1 import Instance, DecisionVariable
93
+ >>> from ommx import Instance, DecisionVariable
94
94
  >>> from ommx_python_mip_adapter import OMMXPythonMIPAdapter
95
95
 
96
96
  >>> p = [10, 13, 18, 32, 7, 15]
@@ -127,7 +127,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
127
127
 
128
128
  .. doctest::
129
129
 
130
- >>> from ommx.v1 import Instance, DecisionVariable
130
+ >>> from ommx import Instance, DecisionVariable
131
131
  >>> from ommx_python_mip_adapter import OMMXPythonMIPAdapter
132
132
 
133
133
  >>> x = DecisionVariable.integer(0, upper=3, lower=0)
@@ -147,7 +147,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
147
147
 
148
148
  .. doctest::
149
149
 
150
- >>> from ommx.v1 import Instance, DecisionVariable
150
+ >>> from ommx import Instance, DecisionVariable
151
151
  >>> from ommx_python_mip_adapter import OMMXPythonMIPAdapter
152
152
 
153
153
  >>> x = DecisionVariable.integer(0, lower=0)
@@ -167,7 +167,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
167
167
 
168
168
  .. doctest::
169
169
 
170
- >>> from ommx.v1 import Instance, DecisionVariable
170
+ >>> from ommx import Instance, DecisionVariable
171
171
  >>> from ommx_python_mip_adapter import OMMXPythonMIPAdapter
172
172
 
173
173
  >>> x = DecisionVariable.continuous(0, lower=0, upper=1)
@@ -199,7 +199,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
199
199
  return self.model
200
200
 
201
201
  def decode(self, data: mip.Model) -> Solution:
202
- """Convert optimized Python-MIP model and ommx.v1.Instance to ommx.v1.Solution.
202
+ """Convert optimized Python-MIP model and ommx.Instance to ommx.Solution.
203
203
 
204
204
  This method is intended to be used if the model has been acquired with
205
205
  `solver_input` for futher adjustment of the solver parameters, and
@@ -223,7 +223,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
223
223
 
224
224
  .. doctest::
225
225
 
226
- >>> from ommx.v1 import Instance, DecisionVariable
226
+ >>> from ommx import Instance, DecisionVariable
227
227
  >>> from ommx_python_mip_adapter import OMMXPythonMIPAdapter
228
228
 
229
229
  >>> p = [10, 13, 18, 32, 7, 15]
@@ -269,7 +269,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
269
269
 
270
270
  def decode_to_state(self, data: mip.Model) -> State:
271
271
  """
272
- Create an ommx.v1.State from an optimized Python-MIP Model.
272
+ Create an ommx.State from an optimized Python-MIP Model.
273
273
 
274
274
  Examples
275
275
  =========
@@ -279,7 +279,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
279
279
  The following example of solving an unconstrained linear optimization problem with x1 as the objective function.
280
280
 
281
281
  >>> from ommx_python_mip_adapter import OMMXPythonMIPAdapter
282
- >>> from ommx.v1 import Instance, DecisionVariable
282
+ >>> from ommx import Instance, DecisionVariable
283
283
 
284
284
  >>> x1 = DecisionVariable.integer(1, lower=0, upper=5)
285
285
  >>> ommx_instance = Instance.from_components(
@@ -359,7 +359,7 @@ class OMMXPythonMIPAdapter(SolverAdapter):
359
359
  f: Function,
360
360
  ) -> mip.LinExpr:
361
361
  """
362
- Translate ommx.v1.Function to `mip.LinExpr` or `float`.
362
+ Translate ommx.Function to `mip.LinExpr` or `float`.
363
363
  """
364
364
  degree = f.degree()
365
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.v1 import Instance, DecisionVariable, Constraint, Function, Linear
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.v1.Instance from Python-MIP Model.
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.v1.DecisionVariable.
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.v1.Constraint` does not support `GREATER_THAN_OR_EQUAL_TO_ZERO`.
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.v1.Instance.
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.0a7
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.0a7
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.v1.Instance
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.v1.Instance
41
- A->>U: ommx.v1.Solution
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.v1.Instance
53
- U->>O: ommx.v1.Instance and Parameters for other solver
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.v1.Solution
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.v1 import Instance, DecisionVariable
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.v1.Solution` from the `mip.Model`
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.v1.Instance` from a Python-MIP model as the following:
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
@@ -1,3 +1,3 @@
1
- ommx<4.0.0,>=3.0.0a7
1
+ ommx<4.0.0,>=3.0.0a8
2
2
  mip<2.0.0,>=1.17.0
3
3
  cffi<2.0.0,>=1.15.0
@@ -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.0a7"
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.0a7, < 4.0.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
  ]
@@ -1,5 +1,5 @@
1
1
  import pytest
2
- from ommx.v1 import Instance, DecisionVariable
2
+ from ommx import Instance, DecisionVariable
3
3
  from ommx_python_mip_adapter import OMMXPythonMIPAdapter
4
4
  from ommx_python_mip_adapter.exception import OMMXPythonMIPAdapterError
5
5
 
@@ -1,5 +1,5 @@
1
1
  from ommx_python_mip_adapter import OMMXPythonMIPAdapter
2
- from ommx.v1 import Instance, DecisionVariable, Linear
2
+ from ommx import Instance, DecisionVariable, Linear
3
3
  from ommx.adapter import InfeasibleDetected
4
4
  import pytest
5
5
 
@@ -1,6 +1,6 @@
1
1
  import pytest
2
2
 
3
- from ommx.v1 import Instance, DecisionVariable, Solution
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.decision_variable_analysis().irrelevant() == {x[2].id}
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
@@ -1,6 +1,6 @@
1
1
  import mip
2
2
 
3
- from ommx.v1 import DecisionVariable, Instance, Constraint
3
+ from ommx import DecisionVariable, Instance, Constraint
4
4
 
5
5
  from ommx_python_mip_adapter import model_to_instance
6
6
 
@@ -1,5 +1,5 @@
1
1
  from ommx.tracing import capture_trace
2
- from ommx.v1 import DecisionVariable, Instance
2
+ from ommx import DecisionVariable, Instance
3
3
 
4
4
  from ommx_python_mip_adapter import OMMXPythonMIPAdapter
5
5