jijmodeling 2.0.0b1__cp38-abi3-win_amd64.whl → 2.0.0b3__cp38-abi3-win_amd64.whl
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.
Potentially problematic release.
This version of jijmodeling might be problematic. Click here for more details.
- jijmodeling/_jijmodeling.pyd +0 -0
- jijmodeling/_jijmodeling.pyi +2008 -3
- {jijmodeling-2.0.0b1.dist-info → jijmodeling-2.0.0b3.dist-info}/METADATA +1 -1
- jijmodeling-2.0.0b3.dist-info/RECORD +8 -0
- {jijmodeling-2.0.0b1.dist-info → jijmodeling-2.0.0b3.dist-info}/WHEEL +1 -1
- jijmodeling/__init__.pyi +0 -1491
- jijmodeling-2.0.0b1.dist-info/RECORD +0 -9
- {jijmodeling-2.0.0b1.dist-info → jijmodeling-2.0.0b3.dist-info}/licenses/LICENSE.txt +0 -0
jijmodeling/__init__.pyi
DELETED
|
@@ -1,1491 +0,0 @@
|
|
|
1
|
-
# This file is automatically generated by pyo3_stub_gen
|
|
2
|
-
# ruff: noqa: E501, F401
|
|
3
|
-
|
|
4
|
-
import builtins
|
|
5
|
-
import numpy
|
|
6
|
-
import numpy.typing
|
|
7
|
-
import ommx.v1
|
|
8
|
-
import typing
|
|
9
|
-
from . import _jijmodeling
|
|
10
|
-
from enum import Enum
|
|
11
|
-
|
|
12
|
-
__version__: builtins.str
|
|
13
|
-
class CompileError(builtins.Exception):
|
|
14
|
-
...
|
|
15
|
-
|
|
16
|
-
class Compiler:
|
|
17
|
-
def get_constraint_id_by_name(self, name:builtins.str) -> dict:
|
|
18
|
-
r"""
|
|
19
|
-
Obtains a dictionary from subscript to constraint Id.
|
|
20
|
-
"""
|
|
21
|
-
def eval_function(self, expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> ommx.v1.Function: ...
|
|
22
|
-
def eval_constraints(self, constraint:Constraint) -> builtins.list[ommx.v1.Constraint]: ...
|
|
23
|
-
def eval_problem(self, problem:Problem) -> ommx.v1.Instance: ...
|
|
24
|
-
def get_decision_variable_by_name(self, name:builtins.str, subscript:typing.Optional[typing.Sequence[builtins.int]]=None) -> ommx.v1.DecisionVariable: ...
|
|
25
|
-
def __new__(cls, namespace:Namespace, instance_data:typing.Mapping[builtins.str, builtins.int | builtins.float | numpy.typing.NDArray[numpy.float64] | numpy.typing.NDArray[numpy.int64] | list]) -> Compiler: ...
|
|
26
|
-
@staticmethod
|
|
27
|
-
def from_problem(problem:Problem, instance_data:typing.Mapping[builtins.str, builtins.int | builtins.float | numpy.typing.NDArray[numpy.float64] | numpy.typing.NDArray[numpy.int64] | list]) -> Compiler: ...
|
|
28
|
-
|
|
29
|
-
class Constraint:
|
|
30
|
-
@property
|
|
31
|
-
def name(self) -> builtins.str: ...
|
|
32
|
-
@property
|
|
33
|
-
def sense(self) -> ConstraintSense: ...
|
|
34
|
-
@property
|
|
35
|
-
def left(self) -> Expression: ...
|
|
36
|
-
@property
|
|
37
|
-
def right(self) -> Expression: ...
|
|
38
|
-
@property
|
|
39
|
-
def expression(self) -> Expression: ...
|
|
40
|
-
@property
|
|
41
|
-
def is_equality(self) -> builtins.bool:
|
|
42
|
-
r"""
|
|
43
|
-
Returns true if the constraint is an equality constraint.
|
|
44
|
-
|
|
45
|
-
Returns
|
|
46
|
-
--------
|
|
47
|
-
`bool`: True if the constraint is an equality constraint. Otherwise, False.
|
|
48
|
-
|
|
49
|
-
Examples
|
|
50
|
-
---------
|
|
51
|
-
|
|
52
|
-
```python
|
|
53
|
-
>>> import jijmodeling as jm
|
|
54
|
-
>>> N = jm.Placeholder("N")
|
|
55
|
-
>>> i = jm.Element("i", belong_to=N)
|
|
56
|
-
>>> x = jm.BinaryVar("x", shape=(N,))
|
|
57
|
-
>>> constraint = jm.Constraint("constraint", jm.sum(i, x[i]) == 1)
|
|
58
|
-
>>> assert constraint.is_equality()
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
"""
|
|
62
|
-
@property
|
|
63
|
-
def is_inequality(self) -> builtins.bool:
|
|
64
|
-
r"""
|
|
65
|
-
Returns true if the constraint is an inequality constraint.
|
|
66
|
-
|
|
67
|
-
Returns
|
|
68
|
-
--------
|
|
69
|
-
`bool`: True if the constraint is an inequality constraint. Otherwise, False.
|
|
70
|
-
|
|
71
|
-
Examples
|
|
72
|
-
---------
|
|
73
|
-
|
|
74
|
-
```python
|
|
75
|
-
>>> import jijmodeling as jm
|
|
76
|
-
>>> N = jm.Placeholder("N")
|
|
77
|
-
>>> i = jm.Element("i", belong_to=N)
|
|
78
|
-
>>> x = jm.BinaryVar("x", shape=(N,))
|
|
79
|
-
>>> constraint = jm.Constraint("constraint", jm.sum(i, x[i]) <= 1)
|
|
80
|
-
>>> assert constraint.is_inequality()
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
-
"""
|
|
84
|
-
def __repr__(self) -> builtins.str: ...
|
|
85
|
-
def _repr_latex_(self) -> builtins.str: ...
|
|
86
|
-
|
|
87
|
-
class DecisionVar:
|
|
88
|
-
r"""
|
|
89
|
-
A class representing a decision variable in a mathematical model.
|
|
90
|
-
As the decision variables must belong to some namespace, you CANNOT construct it directly.
|
|
91
|
-
Instead, you should use `Problem.DecisionVar`, `Problem.BinaryVar`,
|
|
92
|
-
`Problem.IntegerVar`, `Problem.ContinuousVar`,`Problem.SemiIntegerVar`,
|
|
93
|
-
or `Problem.SemiContinuousVar`.
|
|
94
|
-
|
|
95
|
-
The `DecisonVar` class is used to create a continuous variable.
|
|
96
|
-
The lower and upper bounds of the variable can be any scalar or tensor with the same shape as the variable expression which DOES NOT contain any decision variable.
|
|
97
|
-
|
|
98
|
-
The `DecisionVar` class itself represents a definition of a decision variable,
|
|
99
|
-
but you can use ordinary operations on `Expression`s to create expressions that contain decision variables.
|
|
100
|
-
|
|
101
|
-
Attributes
|
|
102
|
-
-----------
|
|
103
|
-
- `name` (`str`): A name of the continuous variable.
|
|
104
|
-
- `kind` (`DecisionVarKind`): The kind of the decision variable, which can be one of the following:
|
|
105
|
-
- `BINARY`: A binary variable.
|
|
106
|
-
- `INTEGER`: An integer variable.
|
|
107
|
-
- `CONTINUOUS`: A continuous variable.
|
|
108
|
-
- `SEMI_INTEGER`: A semi-integer variable.
|
|
109
|
-
- `SEMI_CONTINUOUS`: A semi-continuous variable.
|
|
110
|
-
- `shape` (`tuple`): A tuple with the size of each dimension of the integer variable. Empty if the variable is not multi-dimensional.
|
|
111
|
-
- `lower_bound`: The lower bound of the variable.
|
|
112
|
-
- `upper_bound`: The upper bound of the variable.
|
|
113
|
-
- `description` (`str`): A description of the continuous variable.
|
|
114
|
-
|
|
115
|
-
Examples
|
|
116
|
-
---------
|
|
117
|
-
Create a scalar continuous variable whose name is "z" and domain is `[-1, 1]`.
|
|
118
|
-
|
|
119
|
-
```python
|
|
120
|
-
>>> import jijmodeling as jm
|
|
121
|
-
>>> problem = jm.Problem("example")
|
|
122
|
-
>>> z = problem.DecisionVar(
|
|
123
|
-
>>> "z",
|
|
124
|
-
>>> kind=jm.DecisionVarKind.CONTINUOUS,
|
|
125
|
-
>>> lower_bound=-1, upper_bound=1
|
|
126
|
-
>>> )
|
|
127
|
-
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
or equivalently:
|
|
131
|
-
|
|
132
|
-
```python
|
|
133
|
-
>>> import jijmodeling as jm
|
|
134
|
-
>>> problem = jm.Problem("example")
|
|
135
|
-
>>> z = problem.ContinuousVar("z", lower_bound=-1, upper_bound=1)
|
|
136
|
-
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
Create a 2-dimensional integer variable...
|
|
140
|
-
- whose name is "x".
|
|
141
|
-
- whose domain is [0, 2].
|
|
142
|
-
- where each dimension has length 2 (making this a 2x2 matrix).
|
|
143
|
-
|
|
144
|
-
```python
|
|
145
|
-
>>> import jijmodeling as jm
|
|
146
|
-
>>> problem = jm.Problem("example")
|
|
147
|
-
>>> x = problem.IntegerVar("x", shape=[2, 2], lower_bound=0, upper_bound=2)
|
|
148
|
-
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
Create a 1-dimensional continuous variable, and construct an expression
|
|
152
|
-
accessing the 123rd component of it..
|
|
153
|
-
|
|
154
|
-
```python
|
|
155
|
-
>>> import jijmodeling as jm
|
|
156
|
-
>>> problem = jm.Problem("example")
|
|
157
|
-
>>> x = problem.ContinuousVar("x", shape=[124], lower_bound=0, upper_bound=2)
|
|
158
|
-
>>> x[123]
|
|
159
|
-
x[123]
|
|
160
|
-
|
|
161
|
-
```
|
|
162
|
-
"""
|
|
163
|
-
@property
|
|
164
|
-
def name(self) -> builtins.str: ...
|
|
165
|
-
@property
|
|
166
|
-
def kind(self) -> DecisionVarKind: ...
|
|
167
|
-
@property
|
|
168
|
-
def description(self) -> builtins.str: ...
|
|
169
|
-
@property
|
|
170
|
-
def ndim(self) -> builtins.int: ...
|
|
171
|
-
@property
|
|
172
|
-
def shape(self) -> tuple: ...
|
|
173
|
-
@property
|
|
174
|
-
def lower_bound(self) -> Expression | builtins.list[Expression]: ...
|
|
175
|
-
@property
|
|
176
|
-
def upper_bound(self) -> Expression | builtins.list[Expression]: ...
|
|
177
|
-
def __repr__(self) -> builtins.str: ...
|
|
178
|
-
def _repr_latex_(self) -> builtins.str: ...
|
|
179
|
-
def __pow__(self, exponent:typing.Any, modulo:typing.Optional[typing.Any]=None) -> Expression: ...
|
|
180
|
-
def __rpow__(self, base:typing.Any, modulo:typing.Optional[typing.Any]=None) -> Expression: ...
|
|
181
|
-
def __add__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
182
|
-
def __radd__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
183
|
-
def __sub__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
184
|
-
def __rsub__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
185
|
-
def __mul__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
186
|
-
def __rmul__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
187
|
-
def __truediv__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
188
|
-
def __rtruediv__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
189
|
-
def __mod__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
190
|
-
def __rmod__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
191
|
-
def min(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
192
|
-
def max(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
193
|
-
def __neg__(self) -> Expression: ...
|
|
194
|
-
def abs(self) -> Expression: ...
|
|
195
|
-
def sqrt(self) -> Expression: ...
|
|
196
|
-
def sin(self) -> Expression: ...
|
|
197
|
-
def cos(self) -> Expression: ...
|
|
198
|
-
def tan(self) -> Expression: ...
|
|
199
|
-
def asin(self) -> Expression: ...
|
|
200
|
-
def acos(self) -> Expression: ...
|
|
201
|
-
def atan(self) -> Expression: ...
|
|
202
|
-
def sinh(self) -> Expression: ...
|
|
203
|
-
def cosh(self) -> Expression: ...
|
|
204
|
-
def tanh(self) -> Expression: ...
|
|
205
|
-
def asinh(self) -> Expression: ...
|
|
206
|
-
def acosh(self) -> Expression: ...
|
|
207
|
-
def atanh(self) -> Expression: ...
|
|
208
|
-
def exp(self) -> Expression: ...
|
|
209
|
-
def ln(self) -> Expression: ...
|
|
210
|
-
def log10(self) -> Expression: ...
|
|
211
|
-
def log2(self) -> Expression: ...
|
|
212
|
-
def ceil(self) -> Expression: ...
|
|
213
|
-
def floor(self) -> Expression: ...
|
|
214
|
-
def map(self, func:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
215
|
-
def roll(self, shift:typing.Any, *, axis:typing.Optional[builtins.int]=None) -> Expression: ...
|
|
216
|
-
def filter(self, predicate:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
217
|
-
def flat_map(self, func:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
218
|
-
def rows(self) -> Expression: ...
|
|
219
|
-
def __getitem__(self, subscripts:typing.Any) -> Expression: ...
|
|
220
|
-
def sum(self, axis:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | builtins.int | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[builtins.int]]=None) -> Expression: ...
|
|
221
|
-
def prod(self, axis:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | builtins.int | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[builtins.int]]=None) -> Expression: ...
|
|
222
|
-
def __eq__(self, other:typing.Any) -> Expression: ... # type: ignore[reportIncompatibleMethodOverride]
|
|
223
|
-
def __ne__(self, other:typing.Any) -> Expression: ... # type: ignore[reportIncompatibleMethodOverride]
|
|
224
|
-
def __lt__(self, other:typing.Any) -> Expression: ...
|
|
225
|
-
def __le__(self, other:typing.Any) -> Expression: ...
|
|
226
|
-
def __gt__(self, other:typing.Any) -> Expression: ...
|
|
227
|
-
def __ge__(self, other:typing.Any) -> Expression: ...
|
|
228
|
-
|
|
229
|
-
class DecoratedProblem(typing.Protocol):
|
|
230
|
-
r"""
|
|
231
|
-
A variant of `Problem` that is only available in Decorator API provided by `Problem.compile`.
|
|
232
|
-
"""
|
|
233
|
-
@typing.overload
|
|
234
|
-
def Constraint(self, name:builtins.str, expressions:typing.Generator[Expression], description:typing.Optional[builtins.str]=None) -> Constraint:
|
|
235
|
-
r"""
|
|
236
|
-
Constructs `Constraint` object with comprehension syntax, __WITHOUT__ registering it to the problem.
|
|
237
|
-
Use `+=` operator to register the constraint to the problem.
|
|
238
|
-
"""
|
|
239
|
-
@typing.overload
|
|
240
|
-
def Constraint(self, name:builtins.str, expression:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], domain:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], description:typing.Optional[builtins.str]=None) -> Constraint:
|
|
241
|
-
r"""
|
|
242
|
-
Constructs `Constraint` object from index set and function to build comparison expression from each index, __WITHOUT__ registering it to the problem.
|
|
243
|
-
Use `+=` operator to register the constraint to the problem.
|
|
244
|
-
"""
|
|
245
|
-
@typing.overload
|
|
246
|
-
def Constraint(self, name:builtins.str, expression:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], description:typing.Optional[builtins.str]=None) -> Constraint:
|
|
247
|
-
r"""
|
|
248
|
-
Constructs `Constraint` object from comparison expression, __WITHOUT__ registering it to the problem.
|
|
249
|
-
Use `+=` operator to register the constraint to the problem.
|
|
250
|
-
"""
|
|
251
|
-
def __iadd__(self, other:typing.Any) -> DecoratedProblem: ...
|
|
252
|
-
def used_placeholders(self) -> builtins.list[Placeholder]: ...
|
|
253
|
-
def get_problem_schema(self) -> dict:
|
|
254
|
-
r"""
|
|
255
|
-
Returns the schema of the problem.
|
|
256
|
-
|
|
257
|
-
Returns
|
|
258
|
-
--------
|
|
259
|
-
- `schema`: The dictionary containing the schema of the problem.
|
|
260
|
-
"""
|
|
261
|
-
def generate_random_dataset(self, _default:typing.Any, _options:typing.Any, _seed:typing.Optional[builtins.int]) -> typing.Any:
|
|
262
|
-
r"""
|
|
263
|
-
Generates a dictionary of random `InstanceDataValue` for a given problem.
|
|
264
|
-
To generate `ommx.v1.Instance` object directly, use `InstanceDataValue.generate_random_instance` instead.
|
|
265
|
-
|
|
266
|
-
Args
|
|
267
|
-
-----
|
|
268
|
-
- `options` (optional): a dictionary of range parameters for each separate placeholders. The key must be the name of the placeholder and the value must be range parameter (as described in "Range Parameters and Range Syntax" below).
|
|
269
|
-
- `default` (optional): default range parameters for placeholders which is not specified in `options`.
|
|
270
|
-
- `seed` (optional): seed for random number generation.
|
|
271
|
-
|
|
272
|
-
Returns
|
|
273
|
-
--------
|
|
274
|
-
`dict`: The dictionary from the name of placeholders to the generated `InstanceDataValue` objects. To be fed to `Interpreter.eval_problem`.
|
|
275
|
-
|
|
276
|
-
Range Parameters and Range Syntax
|
|
277
|
-
----------------------------------
|
|
278
|
-
A range parameter is a dictionary consisting of the following fields:
|
|
279
|
-
- `size` (optional): interval of natural numbers for the size of each array dimension (default: `range(1, 6)`)
|
|
280
|
-
- `value` (optional): interval of real numbers for the value of each array element (default: `range(-1.0, 1.0)` - a uniform distribution on a closed interval $[-1.0, 1.0]$).
|
|
281
|
-
|
|
282
|
-
Example range parameter config:
|
|
283
|
-
|
|
284
|
-
```python
|
|
285
|
-
{"size": range(2, 10), "value": jm.range.value.closed(100.0, 200.0)}
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
Intervals are expressed as a range object.
|
|
289
|
-
Currently, the following syntax is supported for range objects:
|
|
290
|
-
|
|
291
|
-
1. Direct value of type `int` or `float` - it corresponds to a singleton interval $[a, a] = \{a\}$. In random generation context, this just means a constant fixed value.
|
|
292
|
-
2. Use the functions from `jijmodeling.range`, `jijmodeling.range.size`, or `jijmodeling.range.value` modules.
|
|
293
|
-
- Use functions from `jij.modeling.range.size` to specify (non-negative) integer intervals, and `jij.modeling.range.value` for real intervals. `jij.modeling.range` dynamically determines the type of the range based on the input.
|
|
294
|
-
- These three modules provides the following combinators (see the module documents for more details.):
|
|
295
|
-
- `closed(a, b)`: a closed interval $[a, b]$
|
|
296
|
-
- `open(a, b)`: an open interval $(a, b)$
|
|
297
|
-
- `closed_open(a, b)`: an upper half-open interval $[a, b)$
|
|
298
|
-
- `open_closed(a, b)`: a lower half-open interval $(a, b]$
|
|
299
|
-
- `greater_than(a)`: an open interval $(a, \infty)$
|
|
300
|
-
- `at_least(a)`: a closed interval $[a, \infty)$
|
|
301
|
-
- `less_than(a)`: an open interval $(-\infty, a)$
|
|
302
|
-
- `at_most(a)`: a closed interval $(-\infty, a]$
|
|
303
|
-
3. Use `range` builtin function: this is equivalent to `jijmodeling.range.value.closed_open(a, b)`.
|
|
304
|
-
- Any python range object with `step = 1` can be used as a size range; otherwise it results in runtime error.
|
|
305
|
-
4. Use a tuple: raw tuple `(a, b)` is equivalent to `jijmodeling.range.closed_open(a, b)` if `a` and `b` are either `int` or `float`.
|
|
306
|
-
- You can also use bound object as a tuple component; in such case, both tuple components must be one of the following:
|
|
307
|
-
|
|
308
|
-
1. A string `"Unbounded"` means $-\infty$ (in the first component) or $\infty$ (the second).
|
|
309
|
-
2. A dictionary `{"Included": a}` means the endpoint is inclusive.
|
|
310
|
-
3. A dictionary `{"Excluded": a}` means the endpoint is exclusive.
|
|
311
|
-
- Examples:
|
|
312
|
-
- `(1.2, 4)` is equivalent to `closed_open(1.2, 4)`,
|
|
313
|
-
- `(-1, {"Included": 1})` is equivalent to `closed(-1, 1)`,
|
|
314
|
-
- `(-5, {"Excluded": 4})` is equivalent to `closed_open(-5, 4)` and built in function `range(-5, 4)`,
|
|
315
|
-
- `({"Excluded": 1}, {"Excluded": 2.5})` is equivalent to `open(1, 2.5)`,
|
|
316
|
-
- `({"Included": -1}, "Unbounded")` is equivalent to `at_least(-1)`.
|
|
317
|
-
- `(5, "Unbounded")` is **INVALID**; `5` must be bound object.
|
|
318
|
-
5. The range object: A dictionary of form `{"start": lb, "end": ub}`, where both `lb` and `ub` are the bound object described as above.
|
|
319
|
-
|
|
320
|
-
Examples
|
|
321
|
-
---------
|
|
322
|
-
```python
|
|
323
|
-
>>> import jijmodeling as jm
|
|
324
|
-
>>> import builtins
|
|
325
|
-
>>> N = jm.Placeholder("N", dtype=jm.DataType.INTEGER)
|
|
326
|
-
>>> c = jm.Placeholder("c", dtype=jm.DataType.FLOAT, shape=(N,))
|
|
327
|
-
>>> x = jm.BinaryVar("x", shape=(N,))
|
|
328
|
-
>>> i = jm.Element("i", belong_to=N)
|
|
329
|
-
|
|
330
|
-
>>> problem = jm.Problem("problem")
|
|
331
|
-
>>> problem += jm.sum(i, c[i] * x[i])
|
|
332
|
-
|
|
333
|
-
>>> inputs = problem.generate_random_dataset(
|
|
334
|
-
... options={
|
|
335
|
-
... 'N': {"value": builtins.range(10, 20)},
|
|
336
|
-
... 'c': {"value": jm.range.value.closed(-1.0, 1.0)}
|
|
337
|
-
... # You can also specify "size" for the range of jagged array dimension size.
|
|
338
|
-
... },
|
|
339
|
-
... seed=123 # omittable
|
|
340
|
-
... )
|
|
341
|
-
>>> assert set(inputs.keys()) == {"N", "c"}
|
|
342
|
-
>>> inputs
|
|
343
|
-
{'N': 11.0, 'c': array([ 0.93914459, -0.06511935, -0.7460324 , -0.32443706, 0.99981451,
|
|
344
|
-
-0.24407535, 0.31329469, 0.52206453, -0.1291936 , 0.30443087,
|
|
345
|
-
0.53125838])}
|
|
346
|
-
|
|
347
|
-
```
|
|
348
|
-
"""
|
|
349
|
-
def generate_random_instance(self, _default:typing.Any, _options:typing.Any, _seed:typing.Optional[builtins.int], _hints:typing.Optional[typing.Any]) -> typing.Any:
|
|
350
|
-
r"""
|
|
351
|
-
Generates random `ommx.v1.Instance` for a given problem.
|
|
352
|
-
See also `InstanceDataValue.generate_random_dataset`.
|
|
353
|
-
|
|
354
|
-
Args
|
|
355
|
-
-----
|
|
356
|
-
- `options` (optional): a dictionary of range parameters for each separate placeholders. The key must be the name of the placeholder and the value must be range parameter (as described in "Range Parameters and Range Syntax" section in :func:`~jijmodeling.Problem.generate_random_dataset`).
|
|
357
|
-
- `default` (optional): default range parameters for placeholders which is not specified in `options`.
|
|
358
|
-
- `seed` (optional): seed for random number generation.
|
|
359
|
-
- `hints` (optional): the hints to be detected during compilation see `Interpreter.eval_problem` for more details.
|
|
360
|
-
|
|
361
|
-
Returns
|
|
362
|
-
--------
|
|
363
|
-
`instance`: The OMMX v1 instance object.
|
|
364
|
-
|
|
365
|
-
Examples
|
|
366
|
-
---------
|
|
367
|
-
```python
|
|
368
|
-
>>> import jijmodeling as jm
|
|
369
|
-
>>> import builtins
|
|
370
|
-
>>> import ommx.v1
|
|
371
|
-
>>> N = jm.Placeholder("N", dtype=jm.DataType.INTEGER)
|
|
372
|
-
>>> c = jm.Placeholder("c", dtype=jm.DataType.FLOAT, shape=(N,))
|
|
373
|
-
>>> x = jm.BinaryVar("x", shape=(N,))
|
|
374
|
-
>>> i = jm.Element("i", belong_to=N)
|
|
375
|
-
|
|
376
|
-
>>> problem = jm.Problem("problem")
|
|
377
|
-
>>> problem += jm.sum(i, c[i] * x[i])
|
|
378
|
-
|
|
379
|
-
>>> instance = problem.generate_random_instance(
|
|
380
|
-
... options={
|
|
381
|
-
... 'N': {"value": builtins.range(10, 20)},
|
|
382
|
-
... 'c': {"value": jm.range.value.closed(-1.0, 1.0)}
|
|
383
|
-
... },
|
|
384
|
-
... seed=123
|
|
385
|
-
... )
|
|
386
|
-
>>> assert type(instance) is ommx.v1.Instance
|
|
387
|
-
|
|
388
|
-
```
|
|
389
|
-
"""
|
|
390
|
-
def type_of(self, name:builtins.str) -> Type: ...
|
|
391
|
-
def infer(self, expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Type: ...
|
|
392
|
-
def decision_vars(self) -> builtins.dict[builtins.str, DecisionVar]:
|
|
393
|
-
r"""
|
|
394
|
-
Returns a dictionary of decision variables in the problem.
|
|
395
|
-
|
|
396
|
-
Returns
|
|
397
|
-
--------
|
|
398
|
-
`dict[str, DecisionVar]`: Dictionary mapping variable names to DecisionVar objects.
|
|
399
|
-
"""
|
|
400
|
-
def placeholders(self) -> builtins.dict[builtins.str, Placeholder]:
|
|
401
|
-
r"""
|
|
402
|
-
Returns a dictionary of placeholders in the problem.
|
|
403
|
-
|
|
404
|
-
Returns
|
|
405
|
-
--------
|
|
406
|
-
`dict[str, Placeholder]`: Dictionary mapping placeholder names to Placeholder objects.
|
|
407
|
-
"""
|
|
408
|
-
def Placeholder(self, name:typing.Optional[builtins.str]=None, *, ndim:typing.Optional[builtins.int]=None, shape:typing.Optional[typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]=None, dtype:DataType | type | tuple=DataType.FLOAT, jagged:builtins.bool=False, latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> Placeholder: ...
|
|
409
|
-
def Integer(self, name:typing.Optional[builtins.str]=None, *, ndim:typing.Optional[builtins.int]=None, shape:typing.Optional[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]]=None, jagged:builtins.bool=False, latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> Placeholder:
|
|
410
|
-
r"""
|
|
411
|
-
A shorthand for `Problem.Placeholder(dtype=int)`
|
|
412
|
-
"""
|
|
413
|
-
def Float(self, name:typing.Optional[builtins.str]=None, *, ndim:typing.Optional[builtins.int]=None, shape:typing.Optional[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]]=None, jagged:builtins.bool=False, latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> Placeholder:
|
|
414
|
-
r"""
|
|
415
|
-
A shorthand for `Problem.Placeholder(dtype=DataType.FLOAT)`
|
|
416
|
-
"""
|
|
417
|
-
def Natural(self, name:typing.Optional[builtins.str]=None, *, ndim:typing.Optional[builtins.int]=None, shape:typing.Optional[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]]=None, jagged:builtins.bool=False, latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> Placeholder:
|
|
418
|
-
r"""
|
|
419
|
-
A shorthand for `Problem.Placeholder(dtype=DataType.NATURAL)`
|
|
420
|
-
"""
|
|
421
|
-
def Binary(self, name:typing.Optional[builtins.str]=None, *, ndim:typing.Optional[builtins.int]=None, shape:typing.Optional[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]]=None, jagged:builtins.bool=False, latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> Placeholder:
|
|
422
|
-
r"""
|
|
423
|
-
A shorthand for `Problem.Placeholder(dtype=DataType.BINARY)`
|
|
424
|
-
"""
|
|
425
|
-
def DecisionVar(self, name:typing.Optional[builtins.str]=None, *, kind:DecisionVarKind, shape:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]=None, lower_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], upper_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> DecisionVar:
|
|
426
|
-
r"""
|
|
427
|
-
A function to create a decision variable and register to the problem namespace. See `DecisionVar` for more details.
|
|
428
|
-
|
|
429
|
-
Args
|
|
430
|
-
-----
|
|
431
|
-
- `name` (`str`): A name of the binary variable. If omitted, local variable name is used.
|
|
432
|
-
- `kind` (`DecisionVarKind`): A kind of the decision variable.
|
|
433
|
-
- `shape` (`list | tuple`): A sequence with the size of each dimension of the binary variable. Defaults to an empty tuple (a scalar value).
|
|
434
|
-
- Each item in `shape` must be a valid expression evaluating to a non-negative scalar.
|
|
435
|
-
- `lower_bound` and `upper_bound` (`jijmodeling.Expression`): A lower and upper bounds of the binary variable.
|
|
436
|
-
- `kind` (`DecisionVarKind`): A kind of the decision variable.
|
|
437
|
-
- `latex` (`str`, optional): A LaTeX-name of the binary variable to be represented in Jupyter notebook.
|
|
438
|
-
- It is set to `name` by default.
|
|
439
|
-
- `description` (`str`, optional): A description of the binary variable.
|
|
440
|
-
|
|
441
|
-
Examples
|
|
442
|
-
---------
|
|
443
|
-
Create a scalar binary variable whose name is "z".
|
|
444
|
-
|
|
445
|
-
```python
|
|
446
|
-
>>> import jijmodeling as jm
|
|
447
|
-
>>> problem = jm.Problem("my_problem")
|
|
448
|
-
>>> z = problem.DecisionVar("z", kind=jm.DecisionVarKind.BINARY, lower_bound=0, upper_bound=1)
|
|
449
|
-
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
Create a 2-dimensional binary variable whose name is "x" and has a 2x2 shape.
|
|
453
|
-
|
|
454
|
-
```python
|
|
455
|
-
>>> import jijmodeling as jm
|
|
456
|
-
>>> problem = jm.Problem("my_problem")
|
|
457
|
-
>>> x = problem.BinaryVar("x", shape=[2, 2])
|
|
458
|
-
|
|
459
|
-
```
|
|
460
|
-
|
|
461
|
-
Create a 1-dimensional binary variable with the index of `123`.
|
|
462
|
-
|
|
463
|
-
```python
|
|
464
|
-
>>> import jijmodeling as jm
|
|
465
|
-
>>> problem = jm.Problem("my_problem")
|
|
466
|
-
>>> x = jm.BinaryVar("x", shape=[124])
|
|
467
|
-
>>> x[123]
|
|
468
|
-
BinaryVar(name='x', shape=[NumberLit(value=124)])[NumberLit(value=123)]
|
|
469
|
-
|
|
470
|
-
```
|
|
471
|
-
"""
|
|
472
|
-
def BinaryVar(self, name:typing.Optional[builtins.str]=None, *, shape:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]=None, latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> DecisionVar:
|
|
473
|
-
r"""
|
|
474
|
-
A function to create a binary decision variable and register to the problem namespace. See `DecisionVar` for more details.
|
|
475
|
-
|
|
476
|
-
Args
|
|
477
|
-
-----
|
|
478
|
-
- `name` (`str`): A name of the binary variable. If omitted, local variable name is used.
|
|
479
|
-
- `shape` (`list | tuple`): A sequence with the size of each dimension of the binary variable. Defaults to an empty tuple (a scalar value).
|
|
480
|
-
- Each item in `shape` must be a valid expression evaluating to a non-negative scalar.
|
|
481
|
-
- `latex` (`str`, optional): A LaTeX-name of the binary variable to be represented in Jupyter notebook.
|
|
482
|
-
- It is set to `name` by default.
|
|
483
|
-
- `description` (`str`, optional): A description of the binary variable.
|
|
484
|
-
|
|
485
|
-
Examples
|
|
486
|
-
---------
|
|
487
|
-
Create a scalar binary variable whose name is "z".
|
|
488
|
-
|
|
489
|
-
```python
|
|
490
|
-
>>> import jijmodeling as jm
|
|
491
|
-
>>> problem = jm.Problem("my_problem")
|
|
492
|
-
>>> z = problem.BinaryVar("z")
|
|
493
|
-
|
|
494
|
-
```
|
|
495
|
-
|
|
496
|
-
Create a 2-dimensional binary variable whose name is "x" and has a 2x2 shape.
|
|
497
|
-
|
|
498
|
-
```python
|
|
499
|
-
>>> import jijmodeling as jm
|
|
500
|
-
>>> problem = jm.Problem("my_problem")
|
|
501
|
-
>>> x = problem.BinaryVar("x", shape=[2, 2])
|
|
502
|
-
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
Create a 1-dimensional binary variable with the index of `123`.
|
|
506
|
-
|
|
507
|
-
```python
|
|
508
|
-
>>> import jijmodeling as jm
|
|
509
|
-
>>> problem = jm.Problem("my_problem")
|
|
510
|
-
>>> x = problemm.BinaryVar("x", shape=[124])
|
|
511
|
-
>>> x[123]
|
|
512
|
-
x[123]
|
|
513
|
-
|
|
514
|
-
```
|
|
515
|
-
"""
|
|
516
|
-
def IntegerVar(self, name:typing.Optional[builtins.str]=None, *, shape:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]=None, lower_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], upper_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> DecisionVar:
|
|
517
|
-
r"""
|
|
518
|
-
A function to create a decision variable and register to the problem namespace. See `DecisionVar` for more details.
|
|
519
|
-
|
|
520
|
-
Args
|
|
521
|
-
-----
|
|
522
|
-
- `name` (`str): A name of the integer variable. If omitted, local variable name is used.
|
|
523
|
-
- `shape` (`list | tuple`): A sequence with the size of each dimension of the integer variable. Defaults to an empty tuple (a scalar value).
|
|
524
|
-
- Each item in `shape` must be a valid expression evaluating to a non-negative scalar.
|
|
525
|
-
- `lower_bound`: The lower bound of the variable.
|
|
526
|
-
- `upper_bound`: The upper bound of the variable.
|
|
527
|
-
- `latex` (`str`, optional): A LaTeX-name of the integer variable to be represented in Jupyter notebook.
|
|
528
|
-
- It is set to `name` by default.
|
|
529
|
-
- `description` (`str`, optional): A description of the integer variable.
|
|
530
|
-
|
|
531
|
-
Raises
|
|
532
|
-
-------
|
|
533
|
-
`ModelingError`: Raises if a bound is a `Placeholder` or `Subscript` object whose `ndim`
|
|
534
|
-
is neither `0` nor the same value as `ndim` of the integer variable.
|
|
535
|
-
|
|
536
|
-
Examples
|
|
537
|
-
---------
|
|
538
|
-
Create a scalar integer variable whose name is "z" and domain is `[-1, 1]`.
|
|
539
|
-
|
|
540
|
-
```python
|
|
541
|
-
>>> import jijmodeling as jm
|
|
542
|
-
>>> problem = jm.Problem("my_problem")
|
|
543
|
-
>>> z = problem.IntegerVar("z", lower_bound=-1, upper_bound=1)
|
|
544
|
-
|
|
545
|
-
```
|
|
546
|
-
|
|
547
|
-
Create a 2-dimensional integer variable...
|
|
548
|
-
- whose name is "x".
|
|
549
|
-
- whose domain is [0, 2].
|
|
550
|
-
- where each dimension has length 2 (making this a 2x2 matrix).
|
|
551
|
-
|
|
552
|
-
```python
|
|
553
|
-
>>> import jijmodeling as jm
|
|
554
|
-
>>> problem = jm.Problem("my_problem")
|
|
555
|
-
>>> x = problem.IntegerVar("x", shape=[2, 2], lower_bound=0, upper_bound=2)
|
|
556
|
-
|
|
557
|
-
```
|
|
558
|
-
|
|
559
|
-
Create a 1-dimensional integer variable with the index of `123`.
|
|
560
|
-
|
|
561
|
-
```python
|
|
562
|
-
>>> import jijmodeling as jm
|
|
563
|
-
>>> problem = jm.Problem("my_problem")
|
|
564
|
-
>>> x = problem.IntegerVar("x", shape=[124], lower_bound=0, upper_bound=2)
|
|
565
|
-
>>> x[123]
|
|
566
|
-
x[123]
|
|
567
|
-
|
|
568
|
-
```
|
|
569
|
-
"""
|
|
570
|
-
def SemiIntegerVar(self, name:typing.Optional[builtins.str]=None, *, shape:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]=None, lower_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], upper_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> DecisionVar: ...
|
|
571
|
-
def ContinuousVar(self, name:typing.Optional[builtins.str]=None, *, shape:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]=None, lower_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], upper_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> DecisionVar:
|
|
572
|
-
r"""
|
|
573
|
-
A function to create a decision variable and register to the problem namespace. See `DecisionVar` for more details.
|
|
574
|
-
|
|
575
|
-
Args
|
|
576
|
-
-----
|
|
577
|
-
- `name` (`str`): A name of the continuous variable.
|
|
578
|
-
- `shape` (`list | tuple`): A sequence with the size of each dimension of the continuous variable. Defaults to an empty tuple (a scalar value).
|
|
579
|
-
- Each item in `shape` must be a valid expression evaluating to a non-negative scalar.
|
|
580
|
-
- `lower_bound`: The lower bound of the variable.
|
|
581
|
-
- `upper_bound`: The upper bound of the variable.
|
|
582
|
-
- `latex` (`str`, optional): A LaTeX-name of the continuous variable to be represented in Jupyter notebook.
|
|
583
|
-
- It is set to `name` by default.
|
|
584
|
-
- `description` (`str`, optional): A description of the continuous variable.
|
|
585
|
-
|
|
586
|
-
Raises
|
|
587
|
-
-------
|
|
588
|
-
`ModelingError`: Raises if a bound is a `Placeholder` or `Subscript` object whose `ndim` is neither `0` nor the same value as `ndim` of the continuous variable.
|
|
589
|
-
|
|
590
|
-
Examples
|
|
591
|
-
---------
|
|
592
|
-
Create a scalar continuous variable whose name is "z" and domain is `[-1, 1]`.
|
|
593
|
-
|
|
594
|
-
```python
|
|
595
|
-
>>> import jijmodeling as jm
|
|
596
|
-
>>> z = jm.ContinuousVar("z", lower_bound=-1, upper_bound=1)
|
|
597
|
-
|
|
598
|
-
```
|
|
599
|
-
|
|
600
|
-
Create a 2-dimensional continuous variable...
|
|
601
|
-
- whose name is "x".
|
|
602
|
-
- whose domain is [0, 2].
|
|
603
|
-
- where each dimension has length 2 (making this a 2x2 matrix).
|
|
604
|
-
|
|
605
|
-
```python
|
|
606
|
-
>>> import jijmodeling as jm
|
|
607
|
-
>>> x = jm.ContinuousVar("x", shape=[2, 2], lower_bound=0, upper_bound=2)
|
|
608
|
-
|
|
609
|
-
```
|
|
610
|
-
|
|
611
|
-
Create a 1-dimensional continuous variable with the index of `123`.
|
|
612
|
-
|
|
613
|
-
```python
|
|
614
|
-
>>> import jijmodeling as jm
|
|
615
|
-
>>> x = jm.ContinuousVar("x", shape=[124], lower_bound=0, upper_bound=2)
|
|
616
|
-
>>> x[123]
|
|
617
|
-
ContinuousVar(name='x', shape=[NumberLit(value=124)], lower_bound=NumberLit(value=0), upper_bound=NumberLit(value=2))[NumberLit(value=123)]
|
|
618
|
-
|
|
619
|
-
```
|
|
620
|
-
"""
|
|
621
|
-
def SemiContinuousVar(self, name:typing.Optional[builtins.str]=None, *, shape:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]=None, lower_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], upper_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> DecisionVar: ...
|
|
622
|
-
|
|
623
|
-
class DesugaredProblemBuilder:
|
|
624
|
-
def __call__(self) -> None: ...
|
|
625
|
-
|
|
626
|
-
class Expression:
|
|
627
|
-
r"""
|
|
628
|
-
Any expression in Python.
|
|
629
|
-
"""
|
|
630
|
-
def _repr_latex_(self) -> builtins.str: ...
|
|
631
|
-
def __call__(self, *args) -> Expression: ...
|
|
632
|
-
def shape(self) -> Expression: ...
|
|
633
|
-
def len_at(self, axis:builtins.int) -> Expression: ...
|
|
634
|
-
def __repr__(self) -> builtins.str: ...
|
|
635
|
-
def __pow__(self, exponent:typing.Any, modulo:typing.Optional[typing.Any]=None) -> Expression: ...
|
|
636
|
-
def __rpow__(self, base:typing.Any, modulo:typing.Optional[typing.Any]=None) -> Expression: ...
|
|
637
|
-
def __add__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
638
|
-
def __radd__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
639
|
-
def __sub__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
640
|
-
def __rsub__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
641
|
-
def __mul__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
642
|
-
def __rmul__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
643
|
-
def __truediv__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
644
|
-
def __rtruediv__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
645
|
-
def __mod__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
646
|
-
def __rmod__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
647
|
-
def min(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
648
|
-
def max(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
649
|
-
def __neg__(self) -> Expression: ...
|
|
650
|
-
def abs(self) -> Expression: ...
|
|
651
|
-
def sqrt(self) -> Expression: ...
|
|
652
|
-
def sin(self) -> Expression: ...
|
|
653
|
-
def cos(self) -> Expression: ...
|
|
654
|
-
def tan(self) -> Expression: ...
|
|
655
|
-
def asin(self) -> Expression: ...
|
|
656
|
-
def acos(self) -> Expression: ...
|
|
657
|
-
def atan(self) -> Expression: ...
|
|
658
|
-
def sinh(self) -> Expression: ...
|
|
659
|
-
def cosh(self) -> Expression: ...
|
|
660
|
-
def tanh(self) -> Expression: ...
|
|
661
|
-
def asinh(self) -> Expression: ...
|
|
662
|
-
def acosh(self) -> Expression: ...
|
|
663
|
-
def atanh(self) -> Expression: ...
|
|
664
|
-
def exp(self) -> Expression: ...
|
|
665
|
-
def ln(self) -> Expression: ...
|
|
666
|
-
def log10(self) -> Expression: ...
|
|
667
|
-
def log2(self) -> Expression: ...
|
|
668
|
-
def ceil(self) -> Expression: ...
|
|
669
|
-
def floor(self) -> Expression: ...
|
|
670
|
-
def map(self, func:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
671
|
-
def roll(self, shift:typing.Any, *, axis:typing.Optional[builtins.int]=None) -> Expression: ...
|
|
672
|
-
def filter(self, predicate:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
673
|
-
def flat_map(self, func:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
674
|
-
def rows(self) -> Expression: ...
|
|
675
|
-
def __getitem__(self, subscripts:typing.Any) -> Expression: ...
|
|
676
|
-
def sum(self, axis:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | builtins.int | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[builtins.int]]=None) -> Expression: ...
|
|
677
|
-
def prod(self, axis:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | builtins.int | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[builtins.int]]=None) -> Expression: ...
|
|
678
|
-
def __and__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
679
|
-
def __rand__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
680
|
-
def __or__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
681
|
-
def __ror__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
682
|
-
def __xor__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
683
|
-
def __rxor__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
684
|
-
def diff(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
685
|
-
def bnot(self) -> Expression: ...
|
|
686
|
-
def __eq__(self, other:typing.Any) -> Expression: ... # type: ignore[reportIncompatibleMethodOverride]
|
|
687
|
-
def __ne__(self, other:typing.Any) -> Expression: ... # type: ignore[reportIncompatibleMethodOverride]
|
|
688
|
-
def __lt__(self, other:typing.Any) -> Expression: ...
|
|
689
|
-
def __le__(self, other:typing.Any) -> Expression: ...
|
|
690
|
-
def __gt__(self, other:typing.Any) -> Expression: ...
|
|
691
|
-
def __ge__(self, other:typing.Any) -> Expression: ...
|
|
692
|
-
|
|
693
|
-
class ModelingError(builtins.Exception):
|
|
694
|
-
...
|
|
695
|
-
|
|
696
|
-
class Namespace:
|
|
697
|
-
def __new__(cls) -> Namespace: ...
|
|
698
|
-
@staticmethod
|
|
699
|
-
def from_problem(problem:Problem) -> Namespace: ...
|
|
700
|
-
def add_placeholder(self, placeholder:Placeholder) -> None: ...
|
|
701
|
-
def Placeholder(self, name:builtins.str, *, ndim:typing.Optional[builtins.int]=None, shape:typing.Optional[typing.Sequence[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]]=None, dtype:DataType | type | tuple=DataType.FLOAT, jagged:builtins.bool=False, latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> Placeholder: ...
|
|
702
|
-
def add_decision_var(self, var:DecisionVar) -> None: ...
|
|
703
|
-
def type_of(self, name:builtins.str) -> Type: ...
|
|
704
|
-
def infer(self, expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Type: ...
|
|
705
|
-
|
|
706
|
-
class Placeholder:
|
|
707
|
-
r"""
|
|
708
|
-
A spec of a placeholder value.
|
|
709
|
-
|
|
710
|
-
The Placeholder class represents a spec Placeholder, which is maintained in namespace (i.e. Problem).
|
|
711
|
-
It is a symbol to be replaced by a numerical value when you evaluate an optimization problem before solving it.
|
|
712
|
-
|
|
713
|
-
Expressions on Placeholder automatically turns into an `Expression` object.
|
|
714
|
-
|
|
715
|
-
Attributes
|
|
716
|
-
-----------
|
|
717
|
-
- `name` (`str`): A name of the placeholder.
|
|
718
|
-
- `ndim` (`int`): The number of dimensions of the placeholder.
|
|
719
|
-
- `shape` (`tuple` of `Optional[Expression]`, optional): The (partial) shape of the placeholder if given.
|
|
720
|
-
- `dtype` (`DataType`, optional): The data type (`DataType.INT` or `DataType.FLOAT`) of the placeholder.
|
|
721
|
-
- `jagged` (`boolean`, defaut: `False`): `True` if the placeholder will be treated as a jagged array in random data generation. Ignored for scalars.
|
|
722
|
-
- `description` (`str`, optional): A description of the placeholder.
|
|
723
|
-
|
|
724
|
-
Args
|
|
725
|
-
-----
|
|
726
|
-
- `name` (`str`): A name of the placeholder.
|
|
727
|
-
- `ndim` (`Optional[int]`): The number of dimensions of the placeholder. Defaults to `0`. The `ndim` must be set to a non-negative value and must concide with the length of `shape` if both specified. If `None` is given, you must specify `shape` explicitly and the length of `shape` will be used.
|
|
728
|
-
- `shape` (`list[Optional[Expression]]`, optional): The (partial) shape of the placeholder. Used for random data generation.
|
|
729
|
-
- `dtype` (`DataType`, optional): The data type (`DataType.INT` or `DataType.FLOAT`) of the placeholder. Used for random data generation.
|
|
730
|
-
- `jagged` (`boolean`, defaut: `False`): `True` if the placeholder will be treated as a jagged array in random data generation. Ignored for scalars.
|
|
731
|
-
- `latex` (`str`, optional): A LaTeX-name of the placeholder to be represented in Jupyter notebook.
|
|
732
|
-
It is set to `name` by default.
|
|
733
|
-
- `description` (`str`, optional): A description of the placeholder.
|
|
734
|
-
|
|
735
|
-
Raises
|
|
736
|
-
-------
|
|
737
|
-
- `TypeError`: Raises if set a float value to `ndim`.
|
|
738
|
-
- `OverflowError`: Raises if set a negative value to `ndim`.
|
|
739
|
-
|
|
740
|
-
Examples
|
|
741
|
-
---------
|
|
742
|
-
Create a scalar (or `ndim` is `0`) placeholder whose name is "a".
|
|
743
|
-
|
|
744
|
-
```python
|
|
745
|
-
>>> import jijmodeling as jm
|
|
746
|
-
>>> a = jm.Placeholder("a")
|
|
747
|
-
|
|
748
|
-
```
|
|
749
|
-
|
|
750
|
-
Create a 2-dimensional placeholder whose name is "m".
|
|
751
|
-
|
|
752
|
-
```python
|
|
753
|
-
>>> import jijmodeling as jm
|
|
754
|
-
>>> problem = jm.Problem("example")
|
|
755
|
-
>>> m = problem.Placeholder("m", ndim=2)
|
|
756
|
-
|
|
757
|
-
```
|
|
758
|
-
|
|
759
|
-
Create a 1-dimensional placeholder with the index of `123`.
|
|
760
|
-
|
|
761
|
-
```python
|
|
762
|
-
>>> import jijmodeling as jm
|
|
763
|
-
>>> problem = jm.Problem("example")
|
|
764
|
-
>>> a = problem.Placeholder("a", ndim=2)
|
|
765
|
-
>>> a[123]
|
|
766
|
-
a[123]
|
|
767
|
-
>>> problem.get_placeholde("a")
|
|
768
|
-
Placeholder(name='a', ndim=2, shape=None, dtype=typing.float, jagged=False)
|
|
769
|
-
```
|
|
770
|
-
"""
|
|
771
|
-
@property
|
|
772
|
-
def name(self) -> builtins.str: ...
|
|
773
|
-
@property
|
|
774
|
-
def ndim(self) -> builtins.int: ...
|
|
775
|
-
@property
|
|
776
|
-
def shape(self) -> typing.Optional[tuple]: ...
|
|
777
|
-
@property
|
|
778
|
-
def dtype(self) -> DataType | type | tuple: ...
|
|
779
|
-
@property
|
|
780
|
-
def jagged(self) -> builtins.bool: ...
|
|
781
|
-
@property
|
|
782
|
-
def description(self) -> typing.Optional[builtins.str]: ...
|
|
783
|
-
@property
|
|
784
|
-
def custom_latex(self) -> typing.Optional[builtins.str]: ...
|
|
785
|
-
def __repr__(self) -> builtins.str: ...
|
|
786
|
-
def _repr_latex_(self) -> builtins.str: ...
|
|
787
|
-
def len_at(self, index:builtins.int) -> Expression: ...
|
|
788
|
-
def __pow__(self, exponent:typing.Any, modulo:typing.Optional[typing.Any]=None) -> Expression: ...
|
|
789
|
-
def __rpow__(self, base:typing.Any, modulo:typing.Optional[typing.Any]=None) -> Expression: ...
|
|
790
|
-
def __add__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
791
|
-
def __radd__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
792
|
-
def __sub__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
793
|
-
def __rsub__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
794
|
-
def __mul__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
795
|
-
def __rmul__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
796
|
-
def __truediv__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
797
|
-
def __rtruediv__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
798
|
-
def __mod__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
799
|
-
def __rmod__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
800
|
-
def min(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
801
|
-
def max(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
802
|
-
def __neg__(self) -> Expression: ...
|
|
803
|
-
def abs(self) -> Expression: ...
|
|
804
|
-
def sqrt(self) -> Expression: ...
|
|
805
|
-
def sin(self) -> Expression: ...
|
|
806
|
-
def cos(self) -> Expression: ...
|
|
807
|
-
def tan(self) -> Expression: ...
|
|
808
|
-
def asin(self) -> Expression: ...
|
|
809
|
-
def acos(self) -> Expression: ...
|
|
810
|
-
def atan(self) -> Expression: ...
|
|
811
|
-
def sinh(self) -> Expression: ...
|
|
812
|
-
def cosh(self) -> Expression: ...
|
|
813
|
-
def tanh(self) -> Expression: ...
|
|
814
|
-
def asinh(self) -> Expression: ...
|
|
815
|
-
def acosh(self) -> Expression: ...
|
|
816
|
-
def atanh(self) -> Expression: ...
|
|
817
|
-
def exp(self) -> Expression: ...
|
|
818
|
-
def ln(self) -> Expression: ...
|
|
819
|
-
def log10(self) -> Expression: ...
|
|
820
|
-
def log2(self) -> Expression: ...
|
|
821
|
-
def ceil(self) -> Expression: ...
|
|
822
|
-
def floor(self) -> Expression: ...
|
|
823
|
-
def map(self, func:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
824
|
-
def roll(self, shift:typing.Any, *, axis:typing.Optional[builtins.int]=None) -> Expression: ...
|
|
825
|
-
def filter(self, predicate:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
826
|
-
def flat_map(self, func:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
827
|
-
def rows(self) -> Expression: ...
|
|
828
|
-
def __getitem__(self, subscripts:typing.Any) -> Expression: ...
|
|
829
|
-
def sum(self, axis:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | builtins.int | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[builtins.int]]=None) -> Expression: ...
|
|
830
|
-
def prod(self, axis:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | builtins.int | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[builtins.int]]=None) -> Expression: ...
|
|
831
|
-
def __and__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
832
|
-
def __rand__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
833
|
-
def __or__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
834
|
-
def __ror__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
835
|
-
def __xor__(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
836
|
-
def __rxor__(self, lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
837
|
-
def diff(self, rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
838
|
-
def bnot(self) -> Expression: ...
|
|
839
|
-
def __eq__(self, other:typing.Any) -> Expression: ... # type: ignore[reportIncompatibleMethodOverride]
|
|
840
|
-
def __ne__(self, other:typing.Any) -> Expression: ... # type: ignore[reportIncompatibleMethodOverride]
|
|
841
|
-
def __lt__(self, other:typing.Any) -> Expression: ...
|
|
842
|
-
def __le__(self, other:typing.Any) -> Expression: ...
|
|
843
|
-
def __gt__(self, other:typing.Any) -> Expression: ...
|
|
844
|
-
def __ge__(self, other:typing.Any) -> Expression: ...
|
|
845
|
-
|
|
846
|
-
class Problem:
|
|
847
|
-
r"""
|
|
848
|
-
A class for creating an optimization problem
|
|
849
|
-
|
|
850
|
-
The Problem class is used to create an optimization problem.
|
|
851
|
-
|
|
852
|
-
Attributes
|
|
853
|
-
-----------
|
|
854
|
-
- `name` (`str`): A name of the optimization problem.
|
|
855
|
-
- `sense`: Sense of the optimization problem.
|
|
856
|
-
- `objective`: The objective function of the optimization problem.
|
|
857
|
-
- `constraints` (`dict`): A dictionary that stores constraints.
|
|
858
|
-
- A key is the name of a constraint and the value is the constraint object.
|
|
859
|
-
- `custom_penalty_terms` (`dict`): A dictionary that stores custom penalty terms.
|
|
860
|
-
- A key is the name of a custom penalty and the value is the custom penalty object.
|
|
861
|
-
|
|
862
|
-
Args
|
|
863
|
-
-----
|
|
864
|
-
- `name` (`str`): A name of the optimization problem.
|
|
865
|
-
- `sense` (optional): Sense of the optimization problem. Defaults to `ProblemSense.MINIMIZE`.
|
|
866
|
-
"""
|
|
867
|
-
@property
|
|
868
|
-
def objective(self) -> Expression: ...
|
|
869
|
-
@property
|
|
870
|
-
def description(self) -> builtins.str: ...
|
|
871
|
-
@property
|
|
872
|
-
def constraints(self) -> builtins.dict[builtins.str, builtins.list[Constraint]]: ...
|
|
873
|
-
@property
|
|
874
|
-
def used_placeholders(self) -> builtins.list[Placeholder]: ...
|
|
875
|
-
@property
|
|
876
|
-
def decision_vars(self) -> builtins.dict[builtins.str, DecisionVar]:
|
|
877
|
-
r"""
|
|
878
|
-
Returns a dictionary of decision variables in the problem.
|
|
879
|
-
The dictionary may contain decision variables that are not used in the problem.
|
|
880
|
-
|
|
881
|
-
Returns
|
|
882
|
-
--------
|
|
883
|
-
`dict[str, DecisionVar]`: Dictionary mapping variable names to DecisionVar objects.
|
|
884
|
-
"""
|
|
885
|
-
@property
|
|
886
|
-
def placeholders(self) -> builtins.dict[builtins.str, Placeholder]:
|
|
887
|
-
r"""
|
|
888
|
-
Returns a dictionary of placeholders in the problem.
|
|
889
|
-
The dictionary may contain placeholders that are not used in the problem;
|
|
890
|
-
to get only used placeholders, use `used_placeholders` method.
|
|
891
|
-
|
|
892
|
-
Returns
|
|
893
|
-
--------
|
|
894
|
-
`dict[str, Placeholder]`: Dictionary mapping placeholder names to Placeholder objects.
|
|
895
|
-
"""
|
|
896
|
-
def __iadd__(self, other:typing.Any) -> Problem: ...
|
|
897
|
-
def __repr__(self) -> builtins.str: ...
|
|
898
|
-
def _repr_latex_(self) -> builtins.str: ...
|
|
899
|
-
def eval(self, instance_data:dict) -> ommx.v1.Instance: ...
|
|
900
|
-
def Placeholder(self, name:builtins.str, *, ndim:typing.Optional[builtins.int]=None, shape:typing.Optional[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]]=None, dtype:DataType | type | tuple=DataType.FLOAT, jagged:builtins.bool=False, latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> Placeholder: ...
|
|
901
|
-
def Integer(self, name:builtins.str, *, ndim:typing.Optional[builtins.int]=None, shape:typing.Optional[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]]=None, jagged:builtins.bool=False, latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> Placeholder:
|
|
902
|
-
r"""
|
|
903
|
-
A shorthand for `Problem.Placeholder(dtype=int)`
|
|
904
|
-
"""
|
|
905
|
-
def Float(self, name:builtins.str, *, ndim:typing.Optional[builtins.int]=None, shape:typing.Optional[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]]=None, jagged:builtins.bool=False, latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> Placeholder:
|
|
906
|
-
r"""
|
|
907
|
-
A shorthand for `Problem.Placeholder(dtype=float)`
|
|
908
|
-
"""
|
|
909
|
-
def Natural(self, name:builtins.str, *, ndim:typing.Optional[builtins.int]=None, shape:typing.Optional[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]]=None, jagged:builtins.bool=False, latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> Placeholder:
|
|
910
|
-
r"""
|
|
911
|
-
A shorthand for `Problem.Placeholder(dtype=DataType.NATURAL)`
|
|
912
|
-
"""
|
|
913
|
-
def Binary(self, name:builtins.str, *, ndim:typing.Optional[builtins.int]=None, shape:typing.Optional[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]] | typing.Sequence[typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]]=None, jagged:builtins.bool=False, latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> Placeholder:
|
|
914
|
-
r"""
|
|
915
|
-
A shorthand for `Problem.Placeholder(dtype=DataType.BINARY)`
|
|
916
|
-
"""
|
|
917
|
-
def DecisionVar(self, name:builtins.str, *, kind:DecisionVarKind, shape:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]=None, lower_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], upper_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> DecisionVar:
|
|
918
|
-
r"""
|
|
919
|
-
A function to create a decision variable and register to the problem namespace. See `DecisionVar` for more details.
|
|
920
|
-
|
|
921
|
-
Args
|
|
922
|
-
-----
|
|
923
|
-
- `name` (`str`): A name of the binary variable.
|
|
924
|
-
- `kind` (`DecisionVarKind`): A kind of the decision variable.
|
|
925
|
-
- `shape` (`list | tuple`): A sequence with the size of each dimension of the binary variable. Defaults to an empty tuple (a scalar value).
|
|
926
|
-
- Each item in `shape` must be a valid expression evaluating to a non-negative scalar.
|
|
927
|
-
- `lower_bound` and `upper_bound` (`jijmodeling.Expression`): A lower and upper bounds of the binary variable.
|
|
928
|
-
- `kind` (`DecisionVarKind`): A kind of the decision variable.
|
|
929
|
-
- `latex` (`str`, optional): A LaTeX-name of the binary variable to be represented in Jupyter notebook.
|
|
930
|
-
- It is set to `name` by default.
|
|
931
|
-
- `description` (`str`, optional): A description of the binary variable.
|
|
932
|
-
|
|
933
|
-
Examples
|
|
934
|
-
---------
|
|
935
|
-
Create a scalar binary variable whose name is "z".
|
|
936
|
-
|
|
937
|
-
```python
|
|
938
|
-
>>> import jijmodeling as jm
|
|
939
|
-
>>> problem = jm.Problem("my_problem")
|
|
940
|
-
>>> z = problem.DecisionVar("z", kind=jm.DecisionVarKind.BINARY, lower_bound=0, upper_bound=1)
|
|
941
|
-
|
|
942
|
-
```
|
|
943
|
-
|
|
944
|
-
Create a 2-dimensional binary variable whose name is "x" and has a 2x2 shape.
|
|
945
|
-
|
|
946
|
-
```python
|
|
947
|
-
>>> import jijmodeling as jm
|
|
948
|
-
>>> problem = jm.Problem("my_problem")
|
|
949
|
-
>>> x = problem.BinaryVar("x", shape=[2, 2])
|
|
950
|
-
|
|
951
|
-
```
|
|
952
|
-
|
|
953
|
-
Create a 1-dimensional binary variable with the index of `123`.
|
|
954
|
-
|
|
955
|
-
```python
|
|
956
|
-
>>> import jijmodeling as jm
|
|
957
|
-
>>> problem = jm.Problem("my_problem")
|
|
958
|
-
>>> x = jm.BinaryVar("x", shape=[124])
|
|
959
|
-
>>> x[123]
|
|
960
|
-
BinaryVar(name='x', shape=[NumberLit(value=124)])[NumberLit(value=123)]
|
|
961
|
-
|
|
962
|
-
```
|
|
963
|
-
"""
|
|
964
|
-
def BinaryVar(self, name:builtins.str, *, shape:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]=None, latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> DecisionVar:
|
|
965
|
-
r"""
|
|
966
|
-
A function to create a binary decision variable and register to the problem namespace. See `DecisionVar` for more details.
|
|
967
|
-
|
|
968
|
-
Args
|
|
969
|
-
-----
|
|
970
|
-
- `name` (`str`): A name of the binary variable.
|
|
971
|
-
- `shape` (`list | tuple`): A sequence with the size of each dimension of the binary variable. Defaults to an empty tuple (a scalar value).
|
|
972
|
-
- Each item in `shape` must be a valid expression evaluating to a non-negative scalar.
|
|
973
|
-
- `latex` (`str`, optional): A LaTeX-name of the binary variable to be represented in Jupyter notebook.
|
|
974
|
-
- It is set to `name` by default.
|
|
975
|
-
- `description` (`str`, optional): A description of the binary variable.
|
|
976
|
-
|
|
977
|
-
Examples
|
|
978
|
-
---------
|
|
979
|
-
Create a scalar binary variable whose name is "z".
|
|
980
|
-
|
|
981
|
-
```python
|
|
982
|
-
>>> import jijmodeling as jm
|
|
983
|
-
>>> problem = jm.Problem("my_problem")
|
|
984
|
-
>>> z = problem.BinaryVar("z")
|
|
985
|
-
|
|
986
|
-
```
|
|
987
|
-
|
|
988
|
-
Create a 2-dimensional binary variable whose name is "x" and has a 2x2 shape.
|
|
989
|
-
|
|
990
|
-
```python
|
|
991
|
-
>>> import jijmodeling as jm
|
|
992
|
-
>>> problem = jm.Problem("my_problem")
|
|
993
|
-
>>> x = problem.BinaryVar("x", shape=[2, 2])
|
|
994
|
-
|
|
995
|
-
```
|
|
996
|
-
|
|
997
|
-
Create a 1-dimensional binary variable with the index of `123`.
|
|
998
|
-
|
|
999
|
-
```python
|
|
1000
|
-
>>> import jijmodeling as jm
|
|
1001
|
-
>>> problem = jm.Problem("my_problem")
|
|
1002
|
-
>>> x = problemm.BinaryVar("x", shape=[124])
|
|
1003
|
-
>>> x[123]
|
|
1004
|
-
x[123]
|
|
1005
|
-
|
|
1006
|
-
```
|
|
1007
|
-
"""
|
|
1008
|
-
def IntegerVar(self, name:builtins.str, *, shape:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]=None, lower_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], upper_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> DecisionVar:
|
|
1009
|
-
r"""
|
|
1010
|
-
A function to create a decision variable and register to the problem namespace. See `DecisionVar` for more details.
|
|
1011
|
-
|
|
1012
|
-
Args
|
|
1013
|
-
-----
|
|
1014
|
-
- `name` (`str): A name of the integer variable.
|
|
1015
|
-
- `shape` (`list | tuple`): A sequence with the size of each dimension of the integer variable. Defaults to an empty tuple (a scalar value).
|
|
1016
|
-
- Each item in `shape` must be a valid expression evaluating to a non-negative scalar.
|
|
1017
|
-
- `lower_bound`: The lower bound of the variable.
|
|
1018
|
-
- `upper_bound`: The upper bound of the variable.
|
|
1019
|
-
- `latex` (`str`, optional): A LaTeX-name of the integer variable to be represented in Jupyter notebook.
|
|
1020
|
-
- It is set to `name` by default.
|
|
1021
|
-
- `description` (`str`, optional): A description of the integer variable.
|
|
1022
|
-
|
|
1023
|
-
Raises
|
|
1024
|
-
-------
|
|
1025
|
-
`ModelingError`: Raises if a bound is a `Placeholder` or `Subscript` object whose `ndim`
|
|
1026
|
-
is neither `0` nor the same value as `ndim` of the integer variable.
|
|
1027
|
-
|
|
1028
|
-
Examples
|
|
1029
|
-
---------
|
|
1030
|
-
Create a scalar integer variable whose name is "z" and domain is `[-1, 1]`.
|
|
1031
|
-
|
|
1032
|
-
```python
|
|
1033
|
-
>>> import jijmodeling as jm
|
|
1034
|
-
>>> problem = jm.Problem("my_problem")
|
|
1035
|
-
>>> z = problem.IntegerVar("z", lower_bound=-1, upper_bound=1)
|
|
1036
|
-
|
|
1037
|
-
```
|
|
1038
|
-
|
|
1039
|
-
Create a 2-dimensional integer variable...
|
|
1040
|
-
- whose name is "x".
|
|
1041
|
-
- whose domain is [0, 2].
|
|
1042
|
-
- where each dimension has length 2 (making this a 2x2 matrix).
|
|
1043
|
-
|
|
1044
|
-
```python
|
|
1045
|
-
>>> import jijmodeling as jm
|
|
1046
|
-
>>> problem = jm.Problem("my_problem")
|
|
1047
|
-
>>> x = problem.IntegerVar("x", shape=[2, 2], lower_bound=0, upper_bound=2)
|
|
1048
|
-
|
|
1049
|
-
```
|
|
1050
|
-
|
|
1051
|
-
Create a 1-dimensional integer variable with the index of `123`.
|
|
1052
|
-
|
|
1053
|
-
```python
|
|
1054
|
-
>>> import jijmodeling as jm
|
|
1055
|
-
>>> problem = jm.Problem("my_problem")
|
|
1056
|
-
>>> x = problem.IntegerVar("x", shape=[124], lower_bound=0, upper_bound=2)
|
|
1057
|
-
>>> x[123]
|
|
1058
|
-
x[123]
|
|
1059
|
-
|
|
1060
|
-
```
|
|
1061
|
-
"""
|
|
1062
|
-
def SemiIntegerVar(self, name:builtins.str, *, shape:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]=None, lower_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], upper_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> DecisionVar: ...
|
|
1063
|
-
def ContinuousVar(self, name:builtins.str, *, shape:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]=None, lower_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], upper_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> DecisionVar:
|
|
1064
|
-
r"""
|
|
1065
|
-
A function to create a decision variable and register to the problem namespace. See `DecisionVar` for more details.
|
|
1066
|
-
|
|
1067
|
-
Args
|
|
1068
|
-
-----
|
|
1069
|
-
- `name` (`str`): A name of the continuous variable.
|
|
1070
|
-
- `shape` (`list | tuple`): A sequence with the size of each dimension of the continuous variable. Defaults to an empty tuple (a scalar value).
|
|
1071
|
-
- Each item in `shape` must be a valid expression evaluating to a non-negative scalar.
|
|
1072
|
-
- `lower_bound`: The lower bound of the variable.
|
|
1073
|
-
- `upper_bound`: The upper bound of the variable.
|
|
1074
|
-
- `latex` (`str`, optional): A LaTeX-name of the continuous variable to be represented in Jupyter notebook.
|
|
1075
|
-
- It is set to `name` by default.
|
|
1076
|
-
- `description` (`str`, optional): A description of the continuous variable.
|
|
1077
|
-
|
|
1078
|
-
Raises
|
|
1079
|
-
-------
|
|
1080
|
-
`ModelingError`: Raises if a bound is a `Placeholder` or `Subscript` object whose `ndim` is neither `0` nor the same value as `ndim` of the continuous variable.
|
|
1081
|
-
|
|
1082
|
-
Examples
|
|
1083
|
-
---------
|
|
1084
|
-
Create a scalar continuous variable whose name is "z" and domain is `[-1, 1]`.
|
|
1085
|
-
|
|
1086
|
-
```python
|
|
1087
|
-
>>> import jijmodeling as jm
|
|
1088
|
-
>>> z = jm.ContinuousVar("z", lower_bound=-1, upper_bound=1)
|
|
1089
|
-
|
|
1090
|
-
```
|
|
1091
|
-
|
|
1092
|
-
Create a 2-dimensional continuous variable...
|
|
1093
|
-
- whose name is "x".
|
|
1094
|
-
- whose domain is [0, 2].
|
|
1095
|
-
- where each dimension has length 2 (making this a 2x2 matrix).
|
|
1096
|
-
|
|
1097
|
-
```python
|
|
1098
|
-
>>> import jijmodeling as jm
|
|
1099
|
-
>>> x = jm.ContinuousVar("x", shape=[2, 2], lower_bound=0, upper_bound=2)
|
|
1100
|
-
|
|
1101
|
-
```
|
|
1102
|
-
|
|
1103
|
-
Create a 1-dimensional continuous variable with the index of `123`.
|
|
1104
|
-
|
|
1105
|
-
```python
|
|
1106
|
-
>>> import jijmodeling as jm
|
|
1107
|
-
>>> x = jm.ContinuousVar("x", shape=[124], lower_bound=0, upper_bound=2)
|
|
1108
|
-
>>> x[123]
|
|
1109
|
-
ContinuousVar(name='x', shape=[NumberLit(value=124)], lower_bound=NumberLit(value=0), upper_bound=NumberLit(value=2))[NumberLit(value=123)]
|
|
1110
|
-
|
|
1111
|
-
```
|
|
1112
|
-
"""
|
|
1113
|
-
def SemiContinuousVar(self, name:builtins.str, *, shape:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]]=None, lower_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], upper_bound:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any] | typing.Sequence[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]], latex:typing.Optional[builtins.str]=None, description:typing.Optional[builtins.str]=None) -> DecisionVar: ...
|
|
1114
|
-
def namespace(self) -> Namespace: ...
|
|
1115
|
-
def update(self, func:typing.Callable[[DecoratedProblem]]) -> DesugaredProblemBuilder:
|
|
1116
|
-
r"""
|
|
1117
|
-
A function decorator to modify an existing `Problem` using the decorated API.
|
|
1118
|
-
This must be decorated to a function that takes `DecoratedProblem` as the only argument and returns None.
|
|
1119
|
-
You can call `update` multiple times.
|
|
1120
|
-
The given function will automatically be evaluated exactly once by the decocrator, so you DO NOT need to call the original function again.
|
|
1121
|
-
|
|
1122
|
-
Example
|
|
1123
|
-
-------
|
|
1124
|
-
|
|
1125
|
-
```python
|
|
1126
|
-
>>> import jijmodeling as jm
|
|
1127
|
-
>>> problem = jm.Problem("Knapsack Problem", sense=jm.ProblemSense.MAXIMIZE)
|
|
1128
|
-
>>>
|
|
1129
|
-
>>> @problem.update
|
|
1130
|
-
>>> def my_updater(problem: jm.DecoratedProblem):
|
|
1131
|
-
>>> w = problem.Float(ndim=1, description="Weights of the items")
|
|
1132
|
-
>>> N = w.len_at(0)
|
|
1133
|
-
>>> v = problem.Float(ndim=1, description="Values of the items")
|
|
1134
|
-
>>> W = problem.Float(description="Total weight")
|
|
1135
|
-
>>> x = problem.BinaryVar(shape=(N,), description="Selected items")
|
|
1136
|
-
>>>
|
|
1137
|
-
>>> problem += problem.Constraint("weight", jm.sum(w * x) <= W)
|
|
1138
|
-
>>> problem += jm.sum(v * x)
|
|
1139
|
-
>>>
|
|
1140
|
-
>>> w_data = [10, 20, 30]
|
|
1141
|
-
>>> v_data = [60, 100, 120]
|
|
1142
|
-
>>> instance_data = {"w": w_data, "v": v_data, "W": 50}
|
|
1143
|
-
>>> instance = problem.eval(instance_data)
|
|
1144
|
-
```
|
|
1145
|
-
"""
|
|
1146
|
-
def get_problem_schema(self) -> dict:
|
|
1147
|
-
r"""
|
|
1148
|
-
Returns the schema of the problem.
|
|
1149
|
-
|
|
1150
|
-
Returns
|
|
1151
|
-
--------
|
|
1152
|
-
- `schema`: The dictionary containing the schema of the problem.
|
|
1153
|
-
"""
|
|
1154
|
-
def generate_random_dataset(self, _default:typing.Any, _options:typing.Any, _seed:typing.Optional[builtins.int]) -> typing.Any:
|
|
1155
|
-
r"""
|
|
1156
|
-
Generates a dictionary of random `InstanceDataValue` for a given problem.
|
|
1157
|
-
To generate `ommx.v1.Instance` object directly, use `InstanceDataValue.generate_random_instance` instead.
|
|
1158
|
-
|
|
1159
|
-
Args
|
|
1160
|
-
-----
|
|
1161
|
-
- `options` (optional): a dictionary of range parameters for each separate placeholders. The key must be the name of the placeholder and the value must be range parameter (as described in "Range Parameters and Range Syntax" below).
|
|
1162
|
-
- `default` (optional): default range parameters for placeholders which is not specified in `options`.
|
|
1163
|
-
- `seed` (optional): seed for random number generation.
|
|
1164
|
-
|
|
1165
|
-
Returns
|
|
1166
|
-
--------
|
|
1167
|
-
`dict`: The dictionary from the name of placeholders to the generated `InstanceDataValue` objects. To be fed to `Interpreter.eval_problem`.
|
|
1168
|
-
|
|
1169
|
-
Range Parameters and Range Syntax
|
|
1170
|
-
----------------------------------
|
|
1171
|
-
A range parameter is a dictionary consisting of the following fields:
|
|
1172
|
-
- `size` (optional): interval of natural numbers for the size of each array dimension (default: `range(1, 6)`)
|
|
1173
|
-
- `value` (optional): interval of real numbers for the value of each array element (default: `range(-1.0, 1.0)` - a uniform distribution on a closed interval $[-1.0, 1.0]$).
|
|
1174
|
-
|
|
1175
|
-
Example range parameter config:
|
|
1176
|
-
|
|
1177
|
-
```python
|
|
1178
|
-
{"size": range(2, 10), "value": jm.range.value.closed(100.0, 200.0)}
|
|
1179
|
-
```
|
|
1180
|
-
|
|
1181
|
-
Intervals are expressed as a range object.
|
|
1182
|
-
Currently, the following syntax is supported for range objects:
|
|
1183
|
-
|
|
1184
|
-
1. Direct value of type `int` or `float` - it corresponds to a singleton interval $[a, a] = \{a\}$. In random generation context, this just means a constant fixed value.
|
|
1185
|
-
2. Use the functions from `jijmodeling.range`, `jijmodeling.range.size`, or `jijmodeling.range.value` modules.
|
|
1186
|
-
- Use functions from `jij.modeling.range.size` to specify (non-negative) integer intervals, and `jij.modeling.range.value` for real intervals. `jij.modeling.range` dynamically determines the type of the range based on the input.
|
|
1187
|
-
- These three modules provides the following combinators (see the module documents for more details.):
|
|
1188
|
-
- `closed(a, b)`: a closed interval $[a, b]$
|
|
1189
|
-
- `open(a, b)`: an open interval $(a, b)$
|
|
1190
|
-
- `closed_open(a, b)`: an upper half-open interval $[a, b)$
|
|
1191
|
-
- `open_closed(a, b)`: a lower half-open interval $(a, b]$
|
|
1192
|
-
- `greater_than(a)`: an open interval $(a, \infty)$
|
|
1193
|
-
- `at_least(a)`: a closed interval $[a, \infty)$
|
|
1194
|
-
- `less_than(a)`: an open interval $(-\infty, a)$
|
|
1195
|
-
- `at_most(a)`: a closed interval $(-\infty, a]$
|
|
1196
|
-
3. Use `range` builtin function: this is equivalent to `jijmodeling.range.value.closed_open(a, b)`.
|
|
1197
|
-
- Any python range object with `step = 1` can be used as a size range; otherwise it results in runtime error.
|
|
1198
|
-
4. Use a tuple: raw tuple `(a, b)` is equivalent to `jijmodeling.range.closed_open(a, b)` if `a` and `b` are either `int` or `float`.
|
|
1199
|
-
- You can also use bound object as a tuple component; in such case, both tuple components must be one of the following:
|
|
1200
|
-
|
|
1201
|
-
1. A string `"Unbounded"` means $-\infty$ (in the first component) or $\infty$ (the second).
|
|
1202
|
-
2. A dictionary `{"Included": a}` means the endpoint is inclusive.
|
|
1203
|
-
3. A dictionary `{"Excluded": a}` means the endpoint is exclusive.
|
|
1204
|
-
- Examples:
|
|
1205
|
-
- `(1.2, 4)` is equivalent to `closed_open(1.2, 4)`,
|
|
1206
|
-
- `(-1, {"Included": 1})` is equivalent to `closed(-1, 1)`,
|
|
1207
|
-
- `(-5, {"Excluded": 4})` is equivalent to `closed_open(-5, 4)` and built in function `range(-5, 4)`,
|
|
1208
|
-
- `({"Excluded": 1}, {"Excluded": 2.5})` is equivalent to `open(1, 2.5)`,
|
|
1209
|
-
- `({"Included": -1}, "Unbounded")` is equivalent to `at_least(-1)`.
|
|
1210
|
-
- `(5, "Unbounded")` is **INVALID**; `5` must be bound object.
|
|
1211
|
-
5. The range object: A dictionary of form `{"start": lb, "end": ub}`, where both `lb` and `ub` are the bound object described as above.
|
|
1212
|
-
|
|
1213
|
-
Examples
|
|
1214
|
-
---------
|
|
1215
|
-
```python
|
|
1216
|
-
>>> import jijmodeling as jm
|
|
1217
|
-
>>> import builtins
|
|
1218
|
-
>>> N = jm.Placeholder("N", dtype=jm.DataType.INTEGER)
|
|
1219
|
-
>>> c = jm.Placeholder("c", dtype=jm.DataType.FLOAT, shape=(N,))
|
|
1220
|
-
>>> x = jm.BinaryVar("x", shape=(N,))
|
|
1221
|
-
>>> i = jm.Element("i", belong_to=N)
|
|
1222
|
-
|
|
1223
|
-
>>> problem = jm.Problem("problem")
|
|
1224
|
-
>>> problem += jm.sum(i, c[i] * x[i])
|
|
1225
|
-
|
|
1226
|
-
>>> inputs = problem.generate_random_dataset(
|
|
1227
|
-
... options={
|
|
1228
|
-
... 'N': {"value": builtins.range(10, 20)},
|
|
1229
|
-
... 'c': {"value": jm.range.value.closed(-1.0, 1.0)}
|
|
1230
|
-
... # You can also specify "size" for the range of jagged array dimension size.
|
|
1231
|
-
... },
|
|
1232
|
-
... seed=123 # omittable
|
|
1233
|
-
... )
|
|
1234
|
-
>>> assert set(inputs.keys()) == {"N", "c"}
|
|
1235
|
-
>>> inputs
|
|
1236
|
-
{'N': 11.0, 'c': array([ 0.93914459, -0.06511935, -0.7460324 , -0.32443706, 0.99981451,
|
|
1237
|
-
-0.24407535, 0.31329469, 0.52206453, -0.1291936 , 0.30443087,
|
|
1238
|
-
0.53125838])}
|
|
1239
|
-
|
|
1240
|
-
```
|
|
1241
|
-
"""
|
|
1242
|
-
def generate_random_instance(self, _default:typing.Any, _options:typing.Any, _seed:typing.Optional[builtins.int], _hints:typing.Optional[typing.Any]) -> typing.Any:
|
|
1243
|
-
r"""
|
|
1244
|
-
Generates random `ommx.v1.Instance` for a given problem.
|
|
1245
|
-
See also `InstanceDataValue.generate_random_dataset`.
|
|
1246
|
-
|
|
1247
|
-
Args
|
|
1248
|
-
-----
|
|
1249
|
-
- `options` (optional): a dictionary of range parameters for each separate placeholders. The key must be the name of the placeholder and the value must be range parameter (as described in "Range Parameters and Range Syntax" section in :func:`~jijmodeling.Problem.generate_random_dataset`).
|
|
1250
|
-
- `default` (optional): default range parameters for placeholders which is not specified in `options`.
|
|
1251
|
-
- `seed` (optional): seed for random number generation.
|
|
1252
|
-
- `hints` (optional): the hints to be detected during compilation see `Interpreter.eval_problem` for more details.
|
|
1253
|
-
|
|
1254
|
-
Returns
|
|
1255
|
-
--------
|
|
1256
|
-
`instance`: The OMMX v1 instance object.
|
|
1257
|
-
|
|
1258
|
-
Examples
|
|
1259
|
-
---------
|
|
1260
|
-
```python
|
|
1261
|
-
>>> import jijmodeling as jm
|
|
1262
|
-
>>> import builtins
|
|
1263
|
-
>>> import ommx.v1
|
|
1264
|
-
>>> N = jm.Placeholder("N", dtype=jm.DataType.INTEGER)
|
|
1265
|
-
>>> c = jm.Placeholder("c", dtype=jm.DataType.FLOAT, shape=(N,))
|
|
1266
|
-
>>> x = jm.BinaryVar("x", shape=(N,))
|
|
1267
|
-
>>> i = jm.Element("i", belong_to=N)
|
|
1268
|
-
|
|
1269
|
-
>>> problem = jm.Problem("problem")
|
|
1270
|
-
>>> problem += jm.sum(i, c[i] * x[i])
|
|
1271
|
-
|
|
1272
|
-
>>> instance = problem.generate_random_instance(
|
|
1273
|
-
... options={
|
|
1274
|
-
... 'N': {"value": builtins.range(10, 20)},
|
|
1275
|
-
... 'c': {"value": jm.range.value.closed(-1.0, 1.0)}
|
|
1276
|
-
... },
|
|
1277
|
-
... seed=123
|
|
1278
|
-
... )
|
|
1279
|
-
>>> assert type(instance) is ommx.v1.Instance
|
|
1280
|
-
|
|
1281
|
-
```
|
|
1282
|
-
"""
|
|
1283
|
-
def type_of(self, name:builtins.str) -> Type: ...
|
|
1284
|
-
def infer(self, expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Type: ...
|
|
1285
|
-
@typing.overload
|
|
1286
|
-
def Constraint(self, name:builtins.str, expression:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], domain:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], description:typing.Optional[builtins.str]=None) -> Constraint:
|
|
1287
|
-
r"""
|
|
1288
|
-
Constructs `Constraint` object from index set and function to build comparison expression from each index, __WITHOUT__ registering it to the problem.
|
|
1289
|
-
Use `+=` operator to register the constraint to the problem.
|
|
1290
|
-
"""
|
|
1291
|
-
@typing.overload
|
|
1292
|
-
def Constraint(self, name:builtins.str, expression:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], description:typing.Optional[builtins.str]=None) -> Constraint:
|
|
1293
|
-
r"""
|
|
1294
|
-
Constructs `Constraint` object from comparison expression, __WITHOUT__ registering it to the problem.
|
|
1295
|
-
Use `+=` operator to register the constraint to the problem.
|
|
1296
|
-
"""
|
|
1297
|
-
def __new__(cls, name:builtins.str, *, sense:ProblemSense=ProblemSense.MINIMIZE, description:typing.Optional[builtins.str]=None) -> Problem: ...
|
|
1298
|
-
|
|
1299
|
-
class Type:
|
|
1300
|
-
def __eq__(self, other:builtins.object) -> builtins.bool: ...
|
|
1301
|
-
|
|
1302
|
-
class TypeError(builtins.Exception):
|
|
1303
|
-
...
|
|
1304
|
-
|
|
1305
|
-
class ConstraintSense(Enum):
|
|
1306
|
-
EQUAL = ...
|
|
1307
|
-
LESS_THAN_EQUAL = ...
|
|
1308
|
-
GREATER_THAN_EQUAL = ...
|
|
1309
|
-
|
|
1310
|
-
class DataType(Enum):
|
|
1311
|
-
INTEGER = ...
|
|
1312
|
-
FLOAT = ...
|
|
1313
|
-
BINARY = ...
|
|
1314
|
-
NATURAL = ...
|
|
1315
|
-
|
|
1316
|
-
class DecisionVarKind(Enum):
|
|
1317
|
-
BINARY = ...
|
|
1318
|
-
INTEGER = ...
|
|
1319
|
-
CONTINUOUS = ...
|
|
1320
|
-
SEMI_INTEGER = ...
|
|
1321
|
-
SEMI_CONTINUOUS = ...
|
|
1322
|
-
|
|
1323
|
-
class ProblemSense(Enum):
|
|
1324
|
-
r"""
|
|
1325
|
-
An optimization sense
|
|
1326
|
-
"""
|
|
1327
|
-
MINIMIZE = ...
|
|
1328
|
-
MAXIMIZE = ...
|
|
1329
|
-
|
|
1330
|
-
def abs(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1331
|
-
|
|
1332
|
-
def acos(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1333
|
-
|
|
1334
|
-
def acosh(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1335
|
-
|
|
1336
|
-
def asin(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1337
|
-
|
|
1338
|
-
def asinh(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1339
|
-
|
|
1340
|
-
def atan(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1341
|
-
|
|
1342
|
-
def atanh(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1343
|
-
|
|
1344
|
-
def band(lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1345
|
-
|
|
1346
|
-
def bnot(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1347
|
-
|
|
1348
|
-
def bor(lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1349
|
-
|
|
1350
|
-
def ceil(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1351
|
-
|
|
1352
|
-
def cos(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1353
|
-
|
|
1354
|
-
def cosh(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1355
|
-
|
|
1356
|
-
def diff(lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1357
|
-
|
|
1358
|
-
def exp(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1359
|
-
|
|
1360
|
-
def filter(predicate:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], operand:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1361
|
-
|
|
1362
|
-
def flat_map(func:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], arg:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1363
|
-
|
|
1364
|
-
def floor(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1365
|
-
|
|
1366
|
-
def is_same(src:typing.Any, dst:typing.Any) -> builtins.bool:
|
|
1367
|
-
r"""
|
|
1368
|
-
Return `true` if `src` and `dst` are the same object defined by Jijmodeling.
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
Args
|
|
1372
|
-
-----
|
|
1373
|
-
- `src`: An object defined by Jijmodeling module, or an iterable of Jijmodeling objects.
|
|
1374
|
-
- `dst`: An object defined by Jijmodeling module, or an iterable of Jijmodeling objects.
|
|
1375
|
-
|
|
1376
|
-
Returns
|
|
1377
|
-
--------
|
|
1378
|
-
`bool`: `true` if `src` and `dst` is the same object. Otherwise `false`.
|
|
1379
|
-
|
|
1380
|
-
Examples
|
|
1381
|
-
---------
|
|
1382
|
-
Check if the two placeholders are the same.
|
|
1383
|
-
|
|
1384
|
-
```python
|
|
1385
|
-
>>> import jijmodeling as jm
|
|
1386
|
-
>>> problem = jm.Problem("problem")
|
|
1387
|
-
>>> a = problem.Placeholder("name")
|
|
1388
|
-
>>> b = problem.Placeholder("name")
|
|
1389
|
-
>>> assert jm.is_same(a, b)
|
|
1390
|
-
>>> c = problem.Placeholder("name", ndim=2)
|
|
1391
|
-
>>> assert not jm.is_same(a, c) # the value of `ndim` is different
|
|
1392
|
-
```
|
|
1393
|
-
|
|
1394
|
-
Raises
|
|
1395
|
-
-------
|
|
1396
|
-
`TypeError`: Raises if
|
|
1397
|
-
- `src` and `dst` are of different types which are not iterable
|
|
1398
|
-
- called on a type not defined by Jijmodeling (e.g. `str`)
|
|
1399
|
-
|
|
1400
|
-
Note
|
|
1401
|
-
-----
|
|
1402
|
-
This function does not check the following attributes:
|
|
1403
|
-
- `description`
|
|
1404
|
-
- `latex`
|
|
1405
|
-
|
|
1406
|
-
For example,
|
|
1407
|
-
|
|
1408
|
-
```python
|
|
1409
|
-
>>> import jijmodeling as jm
|
|
1410
|
-
>>> problem = jm.Problem("problem")
|
|
1411
|
-
>>> src = problem.Placeholder("placeholder", latex="src")
|
|
1412
|
-
>>> dst = problem.Placeholder("placeholder", latex="dst")
|
|
1413
|
-
>>> assert jm.is_same(src, dst)
|
|
1414
|
-
```
|
|
1415
|
-
|
|
1416
|
-
this code works without any exception.
|
|
1417
|
-
"""
|
|
1418
|
-
|
|
1419
|
-
def ln(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1420
|
-
|
|
1421
|
-
def log10(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1422
|
-
|
|
1423
|
-
def log2(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1424
|
-
|
|
1425
|
-
def map(func:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], arg:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1426
|
-
|
|
1427
|
-
def max(lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1428
|
-
|
|
1429
|
-
def min(lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1430
|
-
|
|
1431
|
-
def neg(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1432
|
-
|
|
1433
|
-
@typing.overload
|
|
1434
|
-
def prod(index:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], operand:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression:
|
|
1435
|
-
r"""
|
|
1436
|
-
Takes an index and an operand representing the product operation in positional style. Eg. `jm.prod(N, lambda i: x[i])`
|
|
1437
|
-
"""
|
|
1438
|
-
|
|
1439
|
-
@typing.overload
|
|
1440
|
-
def prod(operand:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], axis:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]=None) -> Expression:
|
|
1441
|
-
r"""
|
|
1442
|
-
Takes the product of a set or tensor-like expression. You can use `axis` to partially reducing the tensor along specified axes. Eg. `jm.prod(N.map(lambda i: x[i]))`
|
|
1443
|
-
"""
|
|
1444
|
-
|
|
1445
|
-
@typing.overload
|
|
1446
|
-
def prod(x:typing.Generator[Expression]) -> Expression:
|
|
1447
|
-
r"""
|
|
1448
|
-
Comprehension syntax for jm.prod (NOTE: only works with decorated API!)
|
|
1449
|
-
"""
|
|
1450
|
-
|
|
1451
|
-
def product(*sets) -> Expression:
|
|
1452
|
-
r"""
|
|
1453
|
-
Takes the cartesian product of given set-like expressions.
|
|
1454
|
-
"""
|
|
1455
|
-
|
|
1456
|
-
def roll(operand:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], shift:typing.Any, *, axis:typing.Optional[builtins.int]=None) -> Expression: ...
|
|
1457
|
-
|
|
1458
|
-
def rows(array:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1459
|
-
|
|
1460
|
-
def set(operand:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1461
|
-
|
|
1462
|
-
def sin(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1463
|
-
|
|
1464
|
-
def sinh(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1465
|
-
|
|
1466
|
-
def sqrt(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1467
|
-
|
|
1468
|
-
@typing.overload
|
|
1469
|
-
def sum(index:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], operand:typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression:
|
|
1470
|
-
r"""
|
|
1471
|
-
Takes an index and an operand representing the summation operation in positional style. Eg. `jm.sum(N, lambda i: x[i])`
|
|
1472
|
-
"""
|
|
1473
|
-
|
|
1474
|
-
@typing.overload
|
|
1475
|
-
def sum(operand:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], axis:typing.Optional[Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]]=None) -> Expression:
|
|
1476
|
-
r"""
|
|
1477
|
-
Takes the summation of set or tensor-like expression. You can use `axis` to partially reducing the tensor along specified axes. Eg. `jm.sum(N.map(lambda i: x[i]))`
|
|
1478
|
-
"""
|
|
1479
|
-
|
|
1480
|
-
@typing.overload
|
|
1481
|
-
def sum(x:typing.Generator[Expression]) -> Expression:
|
|
1482
|
-
r"""
|
|
1483
|
-
Comprehension syntax for jm.sum (NOTE: only works with decorated API!)
|
|
1484
|
-
"""
|
|
1485
|
-
|
|
1486
|
-
def tan(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1487
|
-
|
|
1488
|
-
def tanh(expr:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1489
|
-
|
|
1490
|
-
def xor(lhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any], rhs:Expression | builtins.int | builtins.float | DecisionVar | Placeholder | list | tuple | typing.Callable[[Expression], typing.Any] | typing.Callable[[Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression], typing.Any] | typing.Callable[[Expression, Expression, Expression, Expression, Expression], typing.Any]) -> Expression: ...
|
|
1491
|
-
|