jijmodeling 0.13.2__cp39-cp39-win_amd64.whl → 1.12.0__cp39-cp39-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/__init__.py +1 -154
- jijmodeling/__init__.pyi +5152 -0
- jijmodeling/_jijmodeling.cp39-win_amd64.pyd +0 -0
- jijmodeling/dataset.py +5 -0
- jijmodeling/dataset.pyi +106 -0
- jijmodeling/experimental.py +13 -0
- jijmodeling/experimental.pyi +302 -0
- jijmodeling/py.typed +0 -0
- jijmodeling/range/__init__.py +14 -0
- jijmodeling/range/__init__.pyi +56 -0
- jijmodeling/range/size.py +14 -0
- jijmodeling/range/size.pyi +54 -0
- jijmodeling/range/value.py +14 -0
- jijmodeling/range/value.pyi +54 -0
- jijmodeling-1.12.0.dist-info/METADATA +235 -0
- jijmodeling-1.12.0.dist-info/RECORD +18 -0
- {jijmodeling-0.13.2.dist-info → jijmodeling-1.12.0.dist-info}/WHEEL +1 -2
- {jijmodeling-0.13.2.dist-info → jijmodeling-1.12.0.dist-info/licenses}/LICENSE.txt +1 -1
- jijmodeling/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
- jijmodeling/__pycache__/__init__.cpython-39.pyc +0 -0
- jijmodeling/__pycache__/_version.cpython-39.opt-1.pyc +0 -0
- jijmodeling/__pycache__/_version.cpython-39.pyc +0 -0
- jijmodeling/_version.py +0 -4
- jijmodeling/deprecation/__init__.py +0 -11
- jijmodeling/deprecation/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
- jijmodeling/deprecation/__pycache__/__init__.cpython-39.pyc +0 -0
- jijmodeling/deprecation/__pycache__/deprecation.cpython-39.opt-1.pyc +0 -0
- jijmodeling/deprecation/__pycache__/deprecation.cpython-39.pyc +0 -0
- jijmodeling/deprecation/deprecation.py +0 -108
- jijmodeling/exceptions/__init__.py +0 -26
- jijmodeling/exceptions/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
- jijmodeling/exceptions/__pycache__/__init__.cpython-39.pyc +0 -0
- jijmodeling/exceptions/__pycache__/exceptions.cpython-39.opt-1.pyc +0 -0
- jijmodeling/exceptions/__pycache__/exceptions.cpython-39.pyc +0 -0
- jijmodeling/exceptions/exceptions.py +0 -37
- jijmodeling/expression/__init__.py +0 -76
- jijmodeling/expression/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/__init__.cpython-39.pyc +0 -0
- jijmodeling/expression/__pycache__/condition.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/condition.cpython-39.pyc +0 -0
- jijmodeling/expression/__pycache__/constraint.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/constraint.cpython-39.pyc +0 -0
- jijmodeling/expression/__pycache__/expression.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/expression.cpython-39.pyc +0 -0
- jijmodeling/expression/__pycache__/extract.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/extract.cpython-39.pyc +0 -0
- jijmodeling/expression/__pycache__/from_old_serializable.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/from_old_serializable.cpython-39.pyc +0 -0
- jijmodeling/expression/__pycache__/mathfunc.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/mathfunc.cpython-39.pyc +0 -0
- jijmodeling/expression/__pycache__/prod.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/prod.cpython-39.pyc +0 -0
- jijmodeling/expression/__pycache__/serializable.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/serializable.cpython-39.pyc +0 -0
- jijmodeling/expression/__pycache__/sum.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/sum.cpython-39.pyc +0 -0
- jijmodeling/expression/__pycache__/type_annotations.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/type_annotations.cpython-39.pyc +0 -0
- jijmodeling/expression/__pycache__/utils.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/utils.cpython-39.pyc +0 -0
- jijmodeling/expression/condition.py +0 -378
- jijmodeling/expression/constraint.py +0 -428
- jijmodeling/expression/expression.py +0 -768
- jijmodeling/expression/extract.py +0 -186
- jijmodeling/expression/from_old_serializable.py +0 -137
- jijmodeling/expression/mathfunc.py +0 -335
- jijmodeling/expression/prod.py +0 -172
- jijmodeling/expression/serializable.py +0 -142
- jijmodeling/expression/sum.py +0 -261
- jijmodeling/expression/type_annotations.py +0 -50
- jijmodeling/expression/utils.py +0 -202
- jijmodeling/expression/variables/__init__.py +0 -39
- jijmodeling/expression/variables/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/__init__.cpython-39.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/deci_vars.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/deci_vars.cpython-39.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/jagged_array.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/jagged_array.cpython-39.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/placeholders.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/placeholders.cpython-39.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/variable.cpython-39.opt-1.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/variable.cpython-39.pyc +0 -0
- jijmodeling/expression/variables/deci_vars.py +0 -212
- jijmodeling/expression/variables/jagged_array.py +0 -81
- jijmodeling/expression/variables/placeholders.py +0 -132
- jijmodeling/expression/variables/variable.py +0 -524
- jijmodeling/latex_repr/__init__.py +0 -11
- jijmodeling/latex_repr/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
- jijmodeling/latex_repr/__pycache__/__init__.cpython-39.pyc +0 -0
- jijmodeling/latex_repr/__pycache__/latex_repr.cpython-39.opt-1.pyc +0 -0
- jijmodeling/latex_repr/__pycache__/latex_repr.cpython-39.pyc +0 -0
- jijmodeling/latex_repr/__pycache__/problem_latex_repr.cpython-39.opt-1.pyc +0 -0
- jijmodeling/latex_repr/__pycache__/problem_latex_repr.cpython-39.pyc +0 -0
- jijmodeling/latex_repr/latex_repr.py +0 -243
- jijmodeling/latex_repr/problem_latex_repr.py +0 -210
- jijmodeling/marker/__marker__.cp39-win_amd64.pyd +0 -0
- jijmodeling/match/__init__.py +0 -19
- jijmodeling/match/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/__init__.cpython-39.pyc +0 -0
- jijmodeling/match/__pycache__/condition_same.cpython-39.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/condition_same.cpython-39.pyc +0 -0
- jijmodeling/match/__pycache__/constraint_same.cpython-39.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/constraint_same.cpython-39.pyc +0 -0
- jijmodeling/match/__pycache__/expand.cpython-39.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/expand.cpython-39.pyc +0 -0
- jijmodeling/match/__pycache__/expr_same.cpython-39.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/expr_same.cpython-39.pyc +0 -0
- jijmodeling/match/__pycache__/is_same_expr.cpython-39.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/is_same_expr.cpython-39.pyc +0 -0
- jijmodeling/match/__pycache__/penalty_same.cpython-39.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/penalty_same.cpython-39.pyc +0 -0
- jijmodeling/match/__pycache__/problem_same.cpython-39.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/problem_same.cpython-39.pyc +0 -0
- jijmodeling/match/__pycache__/replace.cpython-39.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/replace.cpython-39.pyc +0 -0
- jijmodeling/match/condition_same.py +0 -44
- jijmodeling/match/constraint_same.py +0 -53
- jijmodeling/match/expand.py +0 -84
- jijmodeling/match/expr_same.py +0 -32
- jijmodeling/match/is_same_expr.py +0 -306
- jijmodeling/match/penalty_same.py +0 -31
- jijmodeling/match/problem_same.py +0 -44
- jijmodeling/match/replace.py +0 -249
- jijmodeling/problem/__init__.py +0 -9
- jijmodeling/problem/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
- jijmodeling/problem/__pycache__/__init__.cpython-39.pyc +0 -0
- jijmodeling/problem/__pycache__/problem.cpython-39.opt-1.pyc +0 -0
- jijmodeling/problem/__pycache__/problem.cpython-39.pyc +0 -0
- jijmodeling/problem/problem.py +0 -186
- jijmodeling/protobuf/__init__.py +0 -8
- jijmodeling/protobuf/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/__pycache__/__init__.cpython-39.pyc +0 -0
- jijmodeling/protobuf/__pycache__/from_protobuf.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/__pycache__/from_protobuf.cpython-39.pyc +0 -0
- jijmodeling/protobuf/__pycache__/to_protobuf.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/__pycache__/to_protobuf.cpython-39.pyc +0 -0
- jijmodeling/protobuf/__pycache__/type_annotations.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/__pycache__/type_annotations.cpython-39.pyc +0 -0
- jijmodeling/protobuf/from_protobuf.py +0 -336
- jijmodeling/protobuf/pb2/__init__.py +0 -42
- jijmodeling/protobuf/pb2/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/__init__.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/array_length_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/array_length_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/binary_op_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/binary_op_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/commutative_op_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/commutative_op_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/constraint_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/constraint_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/custom_penalty_term_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/custom_penalty_term_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/decision_var_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/decision_var_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/element_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/element_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/expression_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/expression_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/forall_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/forall_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/header_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/header_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/index_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/index_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/number_lit_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/number_lit_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/placeholder_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/placeholder_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/problem_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/problem_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/reduction_op_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/reduction_op_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/subscript_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/subscript_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/unary_op_pb2.cpython-39.opt-1.pyc +0 -0
- jijmodeling/protobuf/pb2/__pycache__/unary_op_pb2.cpython-39.pyc +0 -0
- jijmodeling/protobuf/pb2/array_length_pb2.py +0 -27
- jijmodeling/protobuf/pb2/binary_op_pb2.py +0 -27
- jijmodeling/protobuf/pb2/commutative_op_pb2.py +0 -27
- jijmodeling/protobuf/pb2/constraint_pb2.py +0 -31
- jijmodeling/protobuf/pb2/custom_penalty_term_pb2.py +0 -31
- jijmodeling/protobuf/pb2/decision_var_pb2.py +0 -31
- jijmodeling/protobuf/pb2/element_pb2.py +0 -31
- jijmodeling/protobuf/pb2/expression_pb2.py +0 -39
- jijmodeling/protobuf/pb2/forall_pb2.py +0 -29
- jijmodeling/protobuf/pb2/header_pb2.py +0 -31
- jijmodeling/protobuf/pb2/index_pb2.py +0 -25
- jijmodeling/protobuf/pb2/number_lit_pb2.py +0 -27
- jijmodeling/protobuf/pb2/placeholder_pb2.py +0 -25
- jijmodeling/protobuf/pb2/problem_pb2.py +0 -40
- jijmodeling/protobuf/pb2/reduction_op_pb2.py +0 -30
- jijmodeling/protobuf/pb2/subscript_pb2.py +0 -27
- jijmodeling/protobuf/pb2/unary_op_pb2.py +0 -27
- jijmodeling/protobuf/to_protobuf.py +0 -631
- jijmodeling/protobuf/type_annotations.py +0 -52
- jijmodeling/sampleset/__init__.py +0 -33
- jijmodeling/sampleset/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
- jijmodeling/sampleset/__pycache__/__init__.cpython-39.pyc +0 -0
- jijmodeling/sampleset/__pycache__/evaluation.cpython-39.opt-1.pyc +0 -0
- jijmodeling/sampleset/__pycache__/evaluation.cpython-39.pyc +0 -0
- jijmodeling/sampleset/__pycache__/measuring_time.cpython-39.opt-1.pyc +0 -0
- jijmodeling/sampleset/__pycache__/measuring_time.cpython-39.pyc +0 -0
- jijmodeling/sampleset/__pycache__/record.cpython-39.opt-1.pyc +0 -0
- jijmodeling/sampleset/__pycache__/record.cpython-39.pyc +0 -0
- jijmodeling/sampleset/__pycache__/sampleset.cpython-39.opt-1.pyc +0 -0
- jijmodeling/sampleset/__pycache__/sampleset.cpython-39.pyc +0 -0
- jijmodeling/sampleset/__pycache__/solving_time.cpython-39.opt-1.pyc +0 -0
- jijmodeling/sampleset/__pycache__/solving_time.cpython-39.pyc +0 -0
- jijmodeling/sampleset/__pycache__/system_time.cpython-39.opt-1.pyc +0 -0
- jijmodeling/sampleset/__pycache__/system_time.cpython-39.pyc +0 -0
- jijmodeling/sampleset/evaluation.py +0 -289
- jijmodeling/sampleset/measuring_time.py +0 -59
- jijmodeling/sampleset/record.py +0 -158
- jijmodeling/sampleset/sampleset.py +0 -389
- jijmodeling/sampleset/solving_time.py +0 -38
- jijmodeling/sampleset/system_time.py +0 -48
- jijmodeling/type_annotations/__init__.py +0 -44
- jijmodeling/type_annotations/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
- jijmodeling/type_annotations/__pycache__/__init__.cpython-39.pyc +0 -0
- jijmodeling/type_annotations/__pycache__/type_annotations.cpython-39.opt-1.pyc +0 -0
- jijmodeling/type_annotations/__pycache__/type_annotations.cpython-39.pyc +0 -0
- jijmodeling/type_annotations/type_annotations.py +0 -54
- jijmodeling/utils/__init__.py +0 -28
- jijmodeling/utils/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
- jijmodeling/utils/__pycache__/__init__.cpython-39.pyc +0 -0
- jijmodeling/utils/__pycache__/deprecated.cpython-39.opt-1.pyc +0 -0
- jijmodeling/utils/__pycache__/deprecated.cpython-39.pyc +0 -0
- jijmodeling/utils/__pycache__/utils.cpython-39.opt-1.pyc +0 -0
- jijmodeling/utils/__pycache__/utils.cpython-39.pyc +0 -0
- jijmodeling/utils/deprecated.py +0 -17
- jijmodeling/utils/utils.py +0 -146
- jijmodeling-0.13.2.dist-info/METADATA +0 -60
- jijmodeling-0.13.2.dist-info/RECORD +0 -219
- jijmodeling-0.13.2.dist-info/top_level.txt +0 -1
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import abc as _abc
|
|
4
|
-
import typing as tp
|
|
5
|
-
import uuid
|
|
6
|
-
|
|
7
|
-
from abc import abstractmethod
|
|
8
|
-
|
|
9
|
-
import jijmodeling.exceptions.exceptions as _exceptions
|
|
10
|
-
import jijmodeling.expression.expression as _expression
|
|
11
|
-
import jijmodeling.expression.serializable as _serializable
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class Condition(metaclass=_serializable.Serializable):
|
|
15
|
-
"""Super class for Conditions."""
|
|
16
|
-
|
|
17
|
-
def __init__(self) -> None:
|
|
18
|
-
self._uuid = uuid.uuid4().hex
|
|
19
|
-
|
|
20
|
-
def __and__(self, other):
|
|
21
|
-
return AndOperator(self, other)
|
|
22
|
-
|
|
23
|
-
def __xor__(self, other):
|
|
24
|
-
return XorOperator(self, other)
|
|
25
|
-
|
|
26
|
-
def __or__(self, other):
|
|
27
|
-
return OrOperator(self, other)
|
|
28
|
-
|
|
29
|
-
def __bool__(self):
|
|
30
|
-
raise TypeError(
|
|
31
|
-
"Cannot convert jm.Condition to bool to avoid unexpected bahavior. Consider using `jm.expr_same` instead in order to compare `jm.Condition` objects."
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
@abstractmethod
|
|
35
|
-
def expressions(self) -> tp.List[_expression.Expression]:
|
|
36
|
-
pass
|
|
37
|
-
|
|
38
|
-
@property
|
|
39
|
-
def uuid(self) -> str:
|
|
40
|
-
return self._uuid
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class NoneCondition(Condition):
|
|
44
|
-
"""NoneCondition is a special condition that always returns None."""
|
|
45
|
-
|
|
46
|
-
def expressions(self) -> tp.List[_expression.Expression]:
|
|
47
|
-
return []
|
|
48
|
-
|
|
49
|
-
@classmethod
|
|
50
|
-
def operation(cls) -> bool:
|
|
51
|
-
return True
|
|
52
|
-
|
|
53
|
-
def _make_latex(self) -> str:
|
|
54
|
-
"""
|
|
55
|
-
Outputs a latex representation.
|
|
56
|
-
|
|
57
|
-
If `self._latex_repr` is not None, it
|
|
58
|
-
will take precedence. If you want to get the latex representation of
|
|
59
|
-
child objects in `_default_repr_latex_` of each class, use the method.
|
|
60
|
-
|
|
61
|
-
Returns:
|
|
62
|
-
str: latex representation.
|
|
63
|
-
"""
|
|
64
|
-
return ""
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
class CompareCondition(Condition, metaclass=_abc.ABCMeta):
|
|
68
|
-
mark = ""
|
|
69
|
-
|
|
70
|
-
def __init__(
|
|
71
|
-
self,
|
|
72
|
-
left: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
73
|
-
right: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
74
|
-
uuid: tp.Optional[str] = None,
|
|
75
|
-
) -> None:
|
|
76
|
-
_left: _expression.Expression = (
|
|
77
|
-
left
|
|
78
|
-
if isinstance(left, _expression.Expression)
|
|
79
|
-
else _expression.Number(left)
|
|
80
|
-
)
|
|
81
|
-
_right: _expression.Expression = (
|
|
82
|
-
right
|
|
83
|
-
if isinstance(right, _expression.Expression)
|
|
84
|
-
else _expression.Number(right)
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
super().__init__()
|
|
88
|
-
if not _left.is_operatable():
|
|
89
|
-
raise _exceptions.ModelingError(f"{_left} is not operatable.")
|
|
90
|
-
if not _right.is_operatable():
|
|
91
|
-
raise _exceptions.ModelingError(f"{_right} is not operatable.")
|
|
92
|
-
|
|
93
|
-
self._left = _left
|
|
94
|
-
self._right = _right
|
|
95
|
-
# Set uuid
|
|
96
|
-
if uuid is not None:
|
|
97
|
-
self._uuid = uuid
|
|
98
|
-
|
|
99
|
-
def __repr__(self) -> str:
|
|
100
|
-
return str(self.left) + self.mark + str(self.right)
|
|
101
|
-
|
|
102
|
-
def _make_latex(self) -> str:
|
|
103
|
-
"""
|
|
104
|
-
Outputs a latex representation.
|
|
105
|
-
|
|
106
|
-
If `self._latex_repr` is not None, it
|
|
107
|
-
will take precedence. If you want to get the latex representation of
|
|
108
|
-
child objects in `_default_repr_latex_` of each class, use the method.
|
|
109
|
-
|
|
110
|
-
Returns:
|
|
111
|
-
str: latex representation.
|
|
112
|
-
"""
|
|
113
|
-
latex_str = r"{} {} {}".format(
|
|
114
|
-
self.left._make_latex(), self.mark, self.right._make_latex()
|
|
115
|
-
)
|
|
116
|
-
return latex_str
|
|
117
|
-
|
|
118
|
-
def _repr_latex_(self) -> str:
|
|
119
|
-
"""
|
|
120
|
-
Latex representation for Jupyter notebook.
|
|
121
|
-
|
|
122
|
-
Returns:
|
|
123
|
-
str: latex string
|
|
124
|
-
"""
|
|
125
|
-
return f"${self._make_latex()}$"
|
|
126
|
-
|
|
127
|
-
@property
|
|
128
|
-
def left(self) -> _expression.Expression:
|
|
129
|
-
return self._left
|
|
130
|
-
|
|
131
|
-
@property
|
|
132
|
-
def right(self) -> _expression.Expression:
|
|
133
|
-
return self._right
|
|
134
|
-
|
|
135
|
-
def expressions(self) -> tp.List[_expression.Expression]:
|
|
136
|
-
return [self.left, self.right]
|
|
137
|
-
|
|
138
|
-
@classmethod
|
|
139
|
-
@abstractmethod
|
|
140
|
-
def operation(cls, left, right) -> bool:
|
|
141
|
-
pass
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
class Equal(CompareCondition):
|
|
145
|
-
"""Equal condition."""
|
|
146
|
-
|
|
147
|
-
mark = "="
|
|
148
|
-
|
|
149
|
-
def __init__(
|
|
150
|
-
self,
|
|
151
|
-
left: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
152
|
-
right: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
153
|
-
uuid: tp.Optional[str] = None,
|
|
154
|
-
) -> None:
|
|
155
|
-
_left = (
|
|
156
|
-
left
|
|
157
|
-
if isinstance(left, _expression.Expression)
|
|
158
|
-
else _expression.Number(left)
|
|
159
|
-
)
|
|
160
|
-
_right = (
|
|
161
|
-
right
|
|
162
|
-
if isinstance(right, _expression.Expression)
|
|
163
|
-
else _expression.Number(right)
|
|
164
|
-
)
|
|
165
|
-
super().__init__(_left, _right, uuid)
|
|
166
|
-
|
|
167
|
-
@classmethod
|
|
168
|
-
def operation(cls, left: tp.Any, right: tp.Any) -> bool:
|
|
169
|
-
equal: bool = left == right
|
|
170
|
-
return equal
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
class NotEqual(CompareCondition):
|
|
174
|
-
"""NotEqual condition."""
|
|
175
|
-
|
|
176
|
-
mark = "!="
|
|
177
|
-
|
|
178
|
-
def __init__(
|
|
179
|
-
self,
|
|
180
|
-
left: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
181
|
-
right: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
182
|
-
uuid: tp.Optional[str] = None,
|
|
183
|
-
) -> None:
|
|
184
|
-
super().__init__(left, right, uuid)
|
|
185
|
-
|
|
186
|
-
def _make_latex(self) -> str:
|
|
187
|
-
"""
|
|
188
|
-
Outputs a latex representation.
|
|
189
|
-
|
|
190
|
-
If `self._latex_repr` is not None, it
|
|
191
|
-
will take precedence. If you want to get the latex representation of
|
|
192
|
-
child objects in `_default_repr_latex_` of each class, use the method.
|
|
193
|
-
|
|
194
|
-
Returns:
|
|
195
|
-
str: latex representation.
|
|
196
|
-
"""
|
|
197
|
-
latex_str = r"{} \neq {}".format(
|
|
198
|
-
self.left._make_latex(), self.right._make_latex()
|
|
199
|
-
)
|
|
200
|
-
return latex_str
|
|
201
|
-
|
|
202
|
-
@classmethod
|
|
203
|
-
def operation(cls, left, right) -> bool:
|
|
204
|
-
not_eq: bool = left != right
|
|
205
|
-
return not_eq
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
class LessThan(CompareCondition):
|
|
209
|
-
mark = "<"
|
|
210
|
-
|
|
211
|
-
def __init__(
|
|
212
|
-
self,
|
|
213
|
-
left: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
214
|
-
right: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
215
|
-
uuid: tp.Optional[str] = None,
|
|
216
|
-
) -> None:
|
|
217
|
-
super().__init__(left, right, uuid)
|
|
218
|
-
|
|
219
|
-
@classmethod
|
|
220
|
-
def operation(cls, left, right) -> bool:
|
|
221
|
-
less_than: bool = left < right
|
|
222
|
-
return less_than
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
class LessThanEqual(CompareCondition):
|
|
226
|
-
mark = "<="
|
|
227
|
-
|
|
228
|
-
def __init__(
|
|
229
|
-
self,
|
|
230
|
-
left: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
231
|
-
right: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
232
|
-
uuid: tp.Optional[str] = None,
|
|
233
|
-
) -> None:
|
|
234
|
-
super().__init__(left, right, uuid)
|
|
235
|
-
|
|
236
|
-
def _make_latex(self) -> str:
|
|
237
|
-
"""
|
|
238
|
-
Outputs a latex representation.
|
|
239
|
-
|
|
240
|
-
If `self._latex_repr` is not None, it
|
|
241
|
-
will take precedence. If you want to get the latex representation of
|
|
242
|
-
child objects in `_default_repr_latex_` of each class, use the method.
|
|
243
|
-
|
|
244
|
-
Returns:
|
|
245
|
-
str: latex representation.
|
|
246
|
-
"""
|
|
247
|
-
latex_str = r"{} \leq {}".format(
|
|
248
|
-
self.left._make_latex(), self.right._make_latex()
|
|
249
|
-
)
|
|
250
|
-
return latex_str
|
|
251
|
-
|
|
252
|
-
@classmethod
|
|
253
|
-
def operation(cls, left, right) -> bool:
|
|
254
|
-
less_than_eq: bool = left <= right
|
|
255
|
-
return less_than_eq
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
def equal(left: _expression.Expression, right: _expression.Expression) -> Equal:
|
|
259
|
-
"""
|
|
260
|
-
Creadion an Equality condition object (Equal).
|
|
261
|
-
|
|
262
|
-
The equality operator `==` can also be used to generate an equality condition object.
|
|
263
|
-
Args:
|
|
264
|
-
left (Expression): left hand side expression
|
|
265
|
-
right (Expression): right hand side expression
|
|
266
|
-
|
|
267
|
-
Returns:
|
|
268
|
-
Equal: left `==` right
|
|
269
|
-
"""
|
|
270
|
-
return Equal(left, right)
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
def eq(left: _expression.Expression, right: _expression.Expression) -> Equal:
|
|
274
|
-
"""
|
|
275
|
-
Creadion an Equality condition object (Equal).
|
|
276
|
-
"""
|
|
277
|
-
return equal(left, right)
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
def neq(left: _expression.Expression, right: _expression.Expression) -> NotEqual:
|
|
281
|
-
"""
|
|
282
|
-
Creadion a Non Equality condition object (NotEqual) The non equality.
|
|
283
|
-
|
|
284
|
-
operator `!=` can also be used to generate a non equality condition object.
|
|
285
|
-
|
|
286
|
-
Args:
|
|
287
|
-
left (Expression): left hand side expression
|
|
288
|
-
right (Expression): right hand side expression
|
|
289
|
-
|
|
290
|
-
Returns:
|
|
291
|
-
NotEqual: left `!=` right
|
|
292
|
-
"""
|
|
293
|
-
return NotEqual(left, right)
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
class ConditionOperator(Condition, metaclass=_abc.ABCMeta):
|
|
297
|
-
def __init__(
|
|
298
|
-
self,
|
|
299
|
-
left: Condition,
|
|
300
|
-
right: Condition,
|
|
301
|
-
uuid: tp.Optional[str] = None,
|
|
302
|
-
) -> None:
|
|
303
|
-
super().__init__()
|
|
304
|
-
self._left = left
|
|
305
|
-
self._right = right
|
|
306
|
-
# Set uuid
|
|
307
|
-
if uuid is not None:
|
|
308
|
-
self._uuid = uuid
|
|
309
|
-
|
|
310
|
-
@property
|
|
311
|
-
def left(self) -> Condition:
|
|
312
|
-
return self._left
|
|
313
|
-
|
|
314
|
-
@property
|
|
315
|
-
def right(self) -> Condition:
|
|
316
|
-
return self._right
|
|
317
|
-
|
|
318
|
-
def expressions(self) -> tp.List[_expression.Expression]:
|
|
319
|
-
return self.left.expressions() + self.right.expressions()
|
|
320
|
-
|
|
321
|
-
@classmethod
|
|
322
|
-
@abstractmethod
|
|
323
|
-
def operation(cls, left: bool, right: bool) -> bool:
|
|
324
|
-
pass
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
class AndOperator(ConditionOperator):
|
|
328
|
-
def __init__(
|
|
329
|
-
self,
|
|
330
|
-
left: Condition,
|
|
331
|
-
right: Condition,
|
|
332
|
-
uuid: tp.Optional[str] = None,
|
|
333
|
-
) -> None:
|
|
334
|
-
super().__init__(left, right, uuid)
|
|
335
|
-
|
|
336
|
-
@classmethod
|
|
337
|
-
def operation(cls, left: bool, right: bool) -> bool:
|
|
338
|
-
and_ope: bool = left & right
|
|
339
|
-
return and_ope
|
|
340
|
-
|
|
341
|
-
def __repr__(self) -> str:
|
|
342
|
-
return "(" + str(self.left) + ") & (" + str(self.right) + ")"
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
class XorOperator(ConditionOperator):
|
|
346
|
-
def __init__(
|
|
347
|
-
self,
|
|
348
|
-
left: Condition,
|
|
349
|
-
right: Condition,
|
|
350
|
-
uuid: tp.Optional[str] = None,
|
|
351
|
-
) -> None:
|
|
352
|
-
super().__init__(left, right, uuid)
|
|
353
|
-
|
|
354
|
-
@classmethod
|
|
355
|
-
def operation(cls, left, right) -> bool:
|
|
356
|
-
xor: bool = left ^ right
|
|
357
|
-
return xor
|
|
358
|
-
|
|
359
|
-
def __repr__(self) -> str:
|
|
360
|
-
return str(self.left) + " xor " + str(self.right)
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
class OrOperator(ConditionOperator):
|
|
364
|
-
def __init__(
|
|
365
|
-
self,
|
|
366
|
-
left: Condition,
|
|
367
|
-
right: Condition,
|
|
368
|
-
uuid: tp.Optional[str] = None,
|
|
369
|
-
) -> None:
|
|
370
|
-
super().__init__(left, right, uuid)
|
|
371
|
-
|
|
372
|
-
@classmethod
|
|
373
|
-
def operation(cls, left, right) -> bool:
|
|
374
|
-
or_bool: bool = left | right
|
|
375
|
-
return or_bool
|
|
376
|
-
|
|
377
|
-
def __repr__(self) -> str:
|
|
378
|
-
return str(self.left) + " | " + str(self.right)
|