jijmodeling 0.13.2__cp39-cp39-win_amd64.whl → 1.11.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.11.0.dist-info/METADATA +235 -0
- jijmodeling-1.11.0.dist-info/RECORD +18 -0
- {jijmodeling-0.13.2.dist-info → jijmodeling-1.11.0.dist-info}/WHEEL +1 -2
- {jijmodeling-0.13.2.dist-info → jijmodeling-1.11.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,243 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from jijmodeling.expression.condition import (
|
|
4
|
-
AndOperator,
|
|
5
|
-
CompareCondition,
|
|
6
|
-
Condition,
|
|
7
|
-
ConditionOperator,
|
|
8
|
-
Equal,
|
|
9
|
-
LessThan,
|
|
10
|
-
LessThanEqual,
|
|
11
|
-
NoneCondition,
|
|
12
|
-
NotEqual,
|
|
13
|
-
OrOperator,
|
|
14
|
-
XorOperator,
|
|
15
|
-
)
|
|
16
|
-
from jijmodeling.expression.expression import (
|
|
17
|
-
Add,
|
|
18
|
-
BinaryOperator,
|
|
19
|
-
Div,
|
|
20
|
-
Expression,
|
|
21
|
-
Mod,
|
|
22
|
-
Mul,
|
|
23
|
-
Number,
|
|
24
|
-
Power,
|
|
25
|
-
)
|
|
26
|
-
from jijmodeling.expression.mathfunc import (
|
|
27
|
-
AbsoluteValue,
|
|
28
|
-
Ceil,
|
|
29
|
-
Floor,
|
|
30
|
-
Log2,
|
|
31
|
-
UnaryOperator,
|
|
32
|
-
)
|
|
33
|
-
from jijmodeling.expression.prod import ProdOperator
|
|
34
|
-
from jijmodeling.expression.sum import ReductionOperator, SumOperator
|
|
35
|
-
from jijmodeling.expression.variables.placeholders import ArrayShape
|
|
36
|
-
from jijmodeling.expression.variables.variable import Range, Subscripts, Variable
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def condition_latex_repr(expr: Condition) -> str:
|
|
40
|
-
if isinstance(expr, CompareCondition):
|
|
41
|
-
left = expr_latex_repr(expr.left)
|
|
42
|
-
right = expr_latex_repr(expr.right)
|
|
43
|
-
mark = r" \cdot "
|
|
44
|
-
if isinstance(expr, Equal):
|
|
45
|
-
mark = "="
|
|
46
|
-
elif isinstance(expr, NotEqual):
|
|
47
|
-
mark = r"\neq"
|
|
48
|
-
elif isinstance(expr, LessThan):
|
|
49
|
-
mark = "<"
|
|
50
|
-
elif isinstance(expr, LessThanEqual):
|
|
51
|
-
mark = r"\leq"
|
|
52
|
-
return left + f" {mark} " + right
|
|
53
|
-
elif isinstance(expr, ConditionOperator):
|
|
54
|
-
left = condition_latex_repr(expr.left)
|
|
55
|
-
right = condition_latex_repr(expr.right)
|
|
56
|
-
mark = r" \cdot "
|
|
57
|
-
if isinstance(expr, AndOperator):
|
|
58
|
-
mark = r" \ \land \ "
|
|
59
|
-
elif isinstance(expr, OrOperator):
|
|
60
|
-
mark = r" \ \lor \ "
|
|
61
|
-
elif isinstance(expr, XorOperator):
|
|
62
|
-
mark = r" \ \veebar \ "
|
|
63
|
-
return left + f"{mark}" + right
|
|
64
|
-
else:
|
|
65
|
-
return ""
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
def expr_latex_repr(expr: Expression) -> str:
|
|
69
|
-
if expr._latex_repr is not None:
|
|
70
|
-
return expr._latex_repr
|
|
71
|
-
if isinstance(expr, Number):
|
|
72
|
-
return str(expr.value)
|
|
73
|
-
elif isinstance(expr, UnaryOperator):
|
|
74
|
-
return _unary_latex_repr(expr)
|
|
75
|
-
elif isinstance(expr, BinaryOperator):
|
|
76
|
-
return _binary_latex_repr(expr)
|
|
77
|
-
elif isinstance(expr, Variable):
|
|
78
|
-
if isinstance(expr, ArrayShape):
|
|
79
|
-
array = expr_latex_repr(expr.array)
|
|
80
|
-
axis = str(expr.dimension)
|
|
81
|
-
return rf"{array}_{{\mathrm{{shape}}({axis})}}"
|
|
82
|
-
label = expr.label.replace("_", r"\_").replace("^", r"\_")
|
|
83
|
-
if "_" in label:
|
|
84
|
-
label = r"\mathrm{" + label + r"}"
|
|
85
|
-
return label
|
|
86
|
-
elif isinstance(expr, Subscripts):
|
|
87
|
-
label = expr_latex_repr(expr.variable)
|
|
88
|
-
subs = ",".join([expr_latex_repr(x) for x in expr.subscripts])
|
|
89
|
-
return label + r"_{" + subs + r"}"
|
|
90
|
-
elif isinstance(expr, ReductionOperator):
|
|
91
|
-
return _reduction_latex_repr(expr)
|
|
92
|
-
|
|
93
|
-
return rf"\mathrm{{ {str(expr)} }}"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
def _unary_latex_repr(expr: UnaryOperator) -> str:
|
|
97
|
-
operand = expr_latex_repr(expr.operand)
|
|
98
|
-
if isinstance(expr, Ceil):
|
|
99
|
-
return rf"\left\lceil {operand} \right\rceil"
|
|
100
|
-
elif isinstance(expr, Floor):
|
|
101
|
-
return rf"\left\lfloor {operand} \right\rfloor"
|
|
102
|
-
elif isinstance(expr, AbsoluteValue):
|
|
103
|
-
return rf"\left| {operand} \right|"
|
|
104
|
-
elif isinstance(expr, Log2):
|
|
105
|
-
return rf"\log_2 \left( {operand} \right)"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
def _binary_latex_repr(expr: BinaryOperator) -> str:
|
|
109
|
-
left = expr_latex_repr(expr.left)
|
|
110
|
-
right = expr_latex_repr(expr.right)
|
|
111
|
-
|
|
112
|
-
if isinstance(expr, Add):
|
|
113
|
-
return _add_latex_repr(expr, left, right)
|
|
114
|
-
elif isinstance(expr, Mul):
|
|
115
|
-
return _mul_latex_repr(expr, left, right)
|
|
116
|
-
elif isinstance(expr, Power):
|
|
117
|
-
# Check if the base needs parentheses
|
|
118
|
-
if isinstance(expr.left, (BinaryOperator, ReductionOperator)):
|
|
119
|
-
left = rf"\left( {left} \right)"
|
|
120
|
-
return rf"{left} ^ {{ {right} }}"
|
|
121
|
-
elif isinstance(expr, Mod):
|
|
122
|
-
# Check if the left hand side needs parentheses
|
|
123
|
-
if isinstance(expr.left, BinaryOperator):
|
|
124
|
-
left = rf"\left( {left} \right)"
|
|
125
|
-
# Check if the left hand side needs parentheses
|
|
126
|
-
if isinstance(expr.right, BinaryOperator):
|
|
127
|
-
right = rf"\left( {right} \right)"
|
|
128
|
-
return rf"{left} \mod {right}"
|
|
129
|
-
elif isinstance(expr, Div):
|
|
130
|
-
return rf"\frac{{ {left} }}{{ {right} }}"
|
|
131
|
-
else:
|
|
132
|
-
return r"\left(" + str(expr) + r"\right)"
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
def _add_latex_repr(expr: Add, left: str, right: str) -> str:
|
|
136
|
-
symbol = "+"
|
|
137
|
-
is_right_negative = False
|
|
138
|
-
# check if the right hand side has a negative sign
|
|
139
|
-
if (
|
|
140
|
-
isinstance(expr.right, Mul)
|
|
141
|
-
and isinstance(expr.right.left, Number)
|
|
142
|
-
and expr.right.left.value == -1.0
|
|
143
|
-
):
|
|
144
|
-
right = right[2:]
|
|
145
|
-
symbol = "-"
|
|
146
|
-
is_right_negative = True
|
|
147
|
-
|
|
148
|
-
if isinstance(expr.right, Number) and expr.right.value < 0.0:
|
|
149
|
-
num_abs = Number(expr.right.value * -1, dtype=expr.right.dtype)
|
|
150
|
-
return f"{left} - {num_abs}"
|
|
151
|
-
|
|
152
|
-
# check if the left hand side needs parentheses
|
|
153
|
-
# ex: (a mod b) + right
|
|
154
|
-
# ex: (a mod b) - right
|
|
155
|
-
if isinstance(expr.left, Mod):
|
|
156
|
-
left = rf"\left( {left} \right)"
|
|
157
|
-
# check if the right hand side needs parentheses
|
|
158
|
-
# ex: left + (a mod b)
|
|
159
|
-
# ex: left - (a mod b)
|
|
160
|
-
if isinstance(expr.right, Mod) or (
|
|
161
|
-
is_right_negative and isinstance(expr.right.right, Mod)
|
|
162
|
-
):
|
|
163
|
-
right = rf"\left( {right} \right)"
|
|
164
|
-
|
|
165
|
-
return f"{left} {symbol} {right}"
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
def _mul_latex_repr(expr: Mul, left: str, right: str) -> str:
|
|
169
|
-
if isinstance(expr.left, Number):
|
|
170
|
-
coeff = expr.left.value
|
|
171
|
-
if coeff == -1:
|
|
172
|
-
# check if the right hand side needs parentheses
|
|
173
|
-
if isinstance(expr.right, Add):
|
|
174
|
-
return rf"- \left( {right} \right)"
|
|
175
|
-
else:
|
|
176
|
-
return f"- {right}"
|
|
177
|
-
if coeff < 0:
|
|
178
|
-
# check if the right hand side needs parentheses
|
|
179
|
-
if isinstance(expr.right, Add):
|
|
180
|
-
return rf"\left( {left} \right) \cdot \left( {right} \right)"
|
|
181
|
-
else:
|
|
182
|
-
return rf"\left( {left} \right) \cdot {right}"
|
|
183
|
-
if isinstance(expr.right, Number):
|
|
184
|
-
coeff = expr.right.value
|
|
185
|
-
if coeff == -1:
|
|
186
|
-
return f"- {right}"
|
|
187
|
-
if coeff < 0:
|
|
188
|
-
return rf"\left( {right} \right) \cdot {left}"
|
|
189
|
-
|
|
190
|
-
# put coefficient in front of variable terms
|
|
191
|
-
return rf"{right} \cdot {left}"
|
|
192
|
-
|
|
193
|
-
parentheses_required_type = (Add, Mod)
|
|
194
|
-
# check if the left hand side needs parentheses
|
|
195
|
-
if isinstance(expr.left, parentheses_required_type):
|
|
196
|
-
left = rf"\left( {left} \right)"
|
|
197
|
-
# check if the right hand side needs parentheses
|
|
198
|
-
if isinstance(expr.right, parentheses_required_type):
|
|
199
|
-
right = rf"\left( {right} \right)"
|
|
200
|
-
|
|
201
|
-
if left[0] == "-":
|
|
202
|
-
left = rf"\left( {left} \right)"
|
|
203
|
-
if right[0] == "-":
|
|
204
|
-
right = rf"\left( {right} \right)"
|
|
205
|
-
|
|
206
|
-
return left + r" \cdot " + right
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
def _reduction_latex_repr(expr: ReductionOperator) -> str:
|
|
210
|
-
# select operator symbol in LaTeX
|
|
211
|
-
if isinstance(expr, SumOperator):
|
|
212
|
-
operator = r"\sum"
|
|
213
|
-
elif isinstance(expr, ProdOperator):
|
|
214
|
-
operator = r"\prod"
|
|
215
|
-
# NOTE: When is this needed?
|
|
216
|
-
else:
|
|
217
|
-
operator = r"\Otimes"
|
|
218
|
-
|
|
219
|
-
# make condition string in LaTeX
|
|
220
|
-
condition = ""
|
|
221
|
-
if not isinstance(expr.condition, NoneCondition):
|
|
222
|
-
condition = rf",\ {condition_latex_repr(expr.condition)}"
|
|
223
|
-
index = expr_latex_repr(expr.sum_index)
|
|
224
|
-
|
|
225
|
-
# make index string in LaTeX
|
|
226
|
-
# case: index belongs to range
|
|
227
|
-
if isinstance(expr.sum_index.parent, Range):
|
|
228
|
-
start = expr_latex_repr(expr.sum_index.parent.start)
|
|
229
|
-
end = expr_latex_repr(expr.sum_index.parent.last - 1)
|
|
230
|
-
operator = rf"{operator}_{{ {index} = {start}{condition} }}^{{ {end} }}"
|
|
231
|
-
# case: index belongs to a set
|
|
232
|
-
else:
|
|
233
|
-
parent = expr_latex_repr(expr.sum_index.parent)
|
|
234
|
-
operator = rf"{operator}_{{ {index} \in {parent}{condition} }}"
|
|
235
|
-
|
|
236
|
-
operand = expr_latex_repr(expr.operand)
|
|
237
|
-
|
|
238
|
-
# check if the operand needs parentheses
|
|
239
|
-
parentheses_required_type = (Add, Mod)
|
|
240
|
-
if isinstance(expr.operand, parentheses_required_type):
|
|
241
|
-
return rf"{operator} \left( {operand} \right)"
|
|
242
|
-
else:
|
|
243
|
-
return rf"{operator} {operand}"
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import re
|
|
4
|
-
|
|
5
|
-
from itertools import zip_longest
|
|
6
|
-
|
|
7
|
-
from jijmodeling.expression.condition import NoneCondition
|
|
8
|
-
from jijmodeling.expression.constraint import Constraint, Penalty
|
|
9
|
-
from jijmodeling.expression.extract import extract_vars_from_problem
|
|
10
|
-
from jijmodeling.expression.variables.deci_vars import Binary, DecisionVariable, Integer
|
|
11
|
-
from jijmodeling.expression.variables.variable import Range
|
|
12
|
-
from jijmodeling.latex_repr.latex_repr import condition_latex_repr, expr_latex_repr
|
|
13
|
-
from jijmodeling.problem.problem import Problem, ProblemSense
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def range_latex_repr(el_range: Range):
|
|
17
|
-
start_str = expr_latex_repr(el_range.start)
|
|
18
|
-
last_str = expr_latex_repr(el_range.last - 1)
|
|
19
|
-
latex_str: str = rf"\left\{{ {start_str} ,\ldots , {last_str} \right\}}"
|
|
20
|
-
return latex_str
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def escape_latex_special_character(text: str) -> str:
|
|
24
|
-
"""
|
|
25
|
-
Replace characters that matches with the 10 latex special characters.
|
|
26
|
-
|
|
27
|
-
There are 10 latex special characters:
|
|
28
|
-
1. tilde `~`
|
|
29
|
-
2. circumflex `^`
|
|
30
|
-
3. backslash `\`
|
|
31
|
-
4. percent sign `%`
|
|
32
|
-
5. ampersand `&`
|
|
33
|
-
6. dollar sign `$`
|
|
34
|
-
7. number sign `#`
|
|
35
|
-
8. underscore `_`
|
|
36
|
-
9. left brace `{`
|
|
37
|
-
10. right brace `}`
|
|
38
|
-
|
|
39
|
-
https://tex.stackexchange.com/questions/34580/escape-character-in-latex/34586#34586
|
|
40
|
-
|
|
41
|
-
If `latex` has some latex special characters, then replace the characters into other strings by following the below table:
|
|
42
|
-
|
|
43
|
-
| name | src | dst |
|
|
44
|
-
| ------------ | ---- | -------------------- |
|
|
45
|
-
| backslash | "\\" | "\textbackslash{}" |
|
|
46
|
-
| tilde | "~" | "\textasciitilde{}" |
|
|
47
|
-
| circumflex | "^" | "\textasciicircum{}" |
|
|
48
|
-
| ampersand | "&" | "\\&" |
|
|
49
|
-
| percent sign | "%" | "\\%" |
|
|
50
|
-
| dollar sign | "$" | "\\$" |
|
|
51
|
-
| number sign | "#" | "\\#" |
|
|
52
|
-
| underscore | "_" | "\\_" |
|
|
53
|
-
| left brace | "{" | "\\{" |
|
|
54
|
-
| right brace | "}" | "\\}" |
|
|
55
|
-
|
|
56
|
-
Args:
|
|
57
|
-
text (str): string
|
|
58
|
-
|
|
59
|
-
Returns:
|
|
60
|
-
str: string without 10 latex special characters
|
|
61
|
-
"""
|
|
62
|
-
latex_special_chars = "|".join(
|
|
63
|
-
[r"\\", "~", r"\^", "&", "%", r"\$", "#", "_", "{", "}"]
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
replaced_special_chars = []
|
|
67
|
-
for c in re.findall(latex_special_chars, text):
|
|
68
|
-
if c == "\\":
|
|
69
|
-
replaced_special_chars.append(r"\textbackslash{}")
|
|
70
|
-
elif c == "~":
|
|
71
|
-
replaced_special_chars.append(r"\textasciitilde{}")
|
|
72
|
-
elif c == "^":
|
|
73
|
-
replaced_special_chars.append(r"\textasciicircum{}")
|
|
74
|
-
else:
|
|
75
|
-
replaced_special_chars.append(rf"\{c}")
|
|
76
|
-
|
|
77
|
-
text_without_special_chars = re.split(latex_special_chars, text)
|
|
78
|
-
result = "".join(
|
|
79
|
-
[
|
|
80
|
-
no_special_char + replaced_special_char
|
|
81
|
-
for no_special_char, replaced_special_char in zip_longest(
|
|
82
|
-
text_without_special_chars, replaced_special_chars, fillvalue=""
|
|
83
|
-
)
|
|
84
|
-
]
|
|
85
|
-
)
|
|
86
|
-
return result
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def constraint_latex_repr(constraint: Constraint) -> str:
|
|
90
|
-
name = escape_latex_special_character(constraint.label)
|
|
91
|
-
latex_str = rf"\text{{{name}}} :\\ &\quad \quad "
|
|
92
|
-
latex_str += condition_latex_repr(constraint.condition)
|
|
93
|
-
latex_str += ","
|
|
94
|
-
# case: condition has a forall condition
|
|
95
|
-
if len(constraint.forall) > 0:
|
|
96
|
-
for_all_str = ""
|
|
97
|
-
condition_str = ""
|
|
98
|
-
for index, condition in constraint.forall:
|
|
99
|
-
parent_str = (
|
|
100
|
-
range_latex_repr(index.parent)
|
|
101
|
-
if isinstance(index.parent, Range)
|
|
102
|
-
else expr_latex_repr(index.parent)
|
|
103
|
-
)
|
|
104
|
-
for_all_str += rf"\forall {expr_latex_repr(index)} \in {parent_str} "
|
|
105
|
-
condition_str += (
|
|
106
|
-
""
|
|
107
|
-
if isinstance(condition, NoneCondition)
|
|
108
|
-
else condition_latex_repr(condition) + r"\land "
|
|
109
|
-
)
|
|
110
|
-
# for_all_str = for_all_str.rstrip(', ')
|
|
111
|
-
latex_str += rf"\ {for_all_str}"
|
|
112
|
-
|
|
113
|
-
condition_str = condition_str.rstrip(r"\land ")
|
|
114
|
-
if condition_str != "":
|
|
115
|
-
latex_str += rf" \ {condition_str}"
|
|
116
|
-
return latex_str
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
def penalty_latex_repr(penalty: Penalty) -> str:
|
|
120
|
-
name = escape_latex_special_character(penalty.label)
|
|
121
|
-
latex_str = rf"\text{{{name}}} :\\ &\quad \quad "
|
|
122
|
-
latex_str += expr_latex_repr(penalty.penalty_term)
|
|
123
|
-
latex_str += ","
|
|
124
|
-
|
|
125
|
-
# case: penalty has a forall condition
|
|
126
|
-
if len(penalty.forall) > 0:
|
|
127
|
-
for_all_str = ""
|
|
128
|
-
condition_str = ""
|
|
129
|
-
for index, condition in penalty.forall:
|
|
130
|
-
parent_str = (
|
|
131
|
-
range_latex_repr(index.parent)
|
|
132
|
-
if isinstance(index.parent, Range)
|
|
133
|
-
else expr_latex_repr(index.parent)
|
|
134
|
-
)
|
|
135
|
-
for_all_str += rf"\forall {expr_latex_repr(index)} \in {parent_str} "
|
|
136
|
-
condition_str += (
|
|
137
|
-
""
|
|
138
|
-
if isinstance(condition, NoneCondition)
|
|
139
|
-
else condition_latex_repr(condition) + r"\land "
|
|
140
|
-
)
|
|
141
|
-
# for_all_str = for_all_str.rstrip(', ')
|
|
142
|
-
latex_str += rf"\ {for_all_str}"
|
|
143
|
-
|
|
144
|
-
condition_str = condition_str.rstrip(r"\land ")
|
|
145
|
-
if condition_str != "":
|
|
146
|
-
latex_str += rf" \ {condition_str}"
|
|
147
|
-
|
|
148
|
-
return latex_str
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
def problem_latex_repr(problem: Problem) -> str:
|
|
152
|
-
name = escape_latex_special_character(problem.name)
|
|
153
|
-
latex_str = rf"\text{{Problem}} & \text{{: {name}}} \\"
|
|
154
|
-
if problem.sense == ProblemSense.MAXIMUM:
|
|
155
|
-
latex_str += rf"\max & \quad {problem.objective._make_latex()} \\"
|
|
156
|
-
else:
|
|
157
|
-
latex_str += rf"\min & \quad {problem.objective._make_latex()} \\"
|
|
158
|
-
|
|
159
|
-
# case: Problem has more than one penalties.
|
|
160
|
-
if len(problem.penalties) > 0:
|
|
161
|
-
latex_str += r"\text{Penalties} & \\"
|
|
162
|
-
# Shows all penalties.
|
|
163
|
-
for penalty in problem.penalties.values():
|
|
164
|
-
latex_str += rf"& {penalty_latex_repr(penalty)}\\[8pt]"
|
|
165
|
-
|
|
166
|
-
# case: Problem has more than one constraints.
|
|
167
|
-
if len(problem.constraints) > 0:
|
|
168
|
-
latex_str += r"\text{s.t.} & \\"
|
|
169
|
-
# show all constraints
|
|
170
|
-
for _, constraint in problem.constraints.items():
|
|
171
|
-
latex_str += rf"& {constraint_latex_repr(constraint)}\\[8pt]"
|
|
172
|
-
|
|
173
|
-
latex_str += "&"
|
|
174
|
-
|
|
175
|
-
# Extracts all decision variables from the Problem object.
|
|
176
|
-
deci_var_list = {
|
|
177
|
-
var.label: var
|
|
178
|
-
for var in extract_vars_from_problem(problem)
|
|
179
|
-
if isinstance(var, DecisionVariable)
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
# Checks if the problem does not have any decision variable
|
|
183
|
-
if deci_var_list == {}:
|
|
184
|
-
return latex_str
|
|
185
|
-
|
|
186
|
-
used_decision_variable = ""
|
|
187
|
-
for deci_var in deci_var_list.values():
|
|
188
|
-
label = deci_var._make_latex()
|
|
189
|
-
has_subscripts = deci_var.dim > 0
|
|
190
|
-
if has_subscripts:
|
|
191
|
-
subscripts = ""
|
|
192
|
-
for i in range(deci_var.dim):
|
|
193
|
-
subscripts += rf"i_{{{format(str(i))}}},"
|
|
194
|
-
subscripts = subscripts.rstrip(",")
|
|
195
|
-
|
|
196
|
-
used_decision_variable += rf"{label}_{{{subscripts}}}"
|
|
197
|
-
else:
|
|
198
|
-
used_decision_variable += label
|
|
199
|
-
|
|
200
|
-
# case: Binary
|
|
201
|
-
if isinstance(deci_var, Binary):
|
|
202
|
-
used_decision_variable += r" \in \{0, 1\}"
|
|
203
|
-
# case: Integer
|
|
204
|
-
elif isinstance(deci_var, Integer):
|
|
205
|
-
used_decision_variable += r" \in \mathbb{Z}"
|
|
206
|
-
|
|
207
|
-
used_decision_variable += r",\ "
|
|
208
|
-
used_decision_variable = used_decision_variable.rstrip(r",\ ")
|
|
209
|
-
|
|
210
|
-
return rf"{latex_str} {used_decision_variable}"
|
|
Binary file
|
jijmodeling/match/__init__.py
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
from pkgutil import extend_path
|
|
2
|
-
|
|
3
|
-
__path__ = extend_path(__path__, __name__)
|
|
4
|
-
|
|
5
|
-
import jijmodeling.match.condition_same as condition_same
|
|
6
|
-
import jijmodeling.match.constraint_same as constraint_same
|
|
7
|
-
import jijmodeling.match.expr_same as expr_same
|
|
8
|
-
import jijmodeling.match.is_same_expr as is_same_expr
|
|
9
|
-
import jijmodeling.match.penalty_same as penalty_same
|
|
10
|
-
import jijmodeling.match.problem_same as problem_same
|
|
11
|
-
|
|
12
|
-
__all__ = [
|
|
13
|
-
"condition_same",
|
|
14
|
-
"constraint_same",
|
|
15
|
-
"expr_same",
|
|
16
|
-
"is_same_expr",
|
|
17
|
-
"penalty_same",
|
|
18
|
-
"problem_same",
|
|
19
|
-
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import jijmodeling.expression.condition as _condition
|
|
4
|
-
|
|
5
|
-
from jijmodeling.match.expr_same import expr_same
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def condition_same(
|
|
9
|
-
target: _condition.Condition, pattern: _condition.Condition, check_id: bool = True
|
|
10
|
-
) -> bool:
|
|
11
|
-
if target.uuid == pattern.uuid:
|
|
12
|
-
return True
|
|
13
|
-
if not isinstance(target, type(pattern)):
|
|
14
|
-
return False
|
|
15
|
-
|
|
16
|
-
# case: CompareCondition
|
|
17
|
-
if isinstance(target, _condition.CompareCondition) and isinstance(
|
|
18
|
-
pattern, _condition.CompareCondition
|
|
19
|
-
):
|
|
20
|
-
# Check the equality of left hand side
|
|
21
|
-
is_left_same = expr_same(target.left, pattern.left, check_id)
|
|
22
|
-
if is_left_same is False:
|
|
23
|
-
return False
|
|
24
|
-
|
|
25
|
-
# Check the equality of right hand side
|
|
26
|
-
is_right_same = expr_same(target.right, pattern.right, check_id)
|
|
27
|
-
if is_right_same is False:
|
|
28
|
-
return False
|
|
29
|
-
return True
|
|
30
|
-
|
|
31
|
-
# case: ConditionOperator
|
|
32
|
-
elif isinstance(target, _condition.ConditionOperator) and isinstance(
|
|
33
|
-
pattern, _condition.ConditionOperator
|
|
34
|
-
):
|
|
35
|
-
return condition_same(target.left, pattern.left, check_id) & condition_same(
|
|
36
|
-
target.right, pattern.left, check_id
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
elif isinstance(target, _condition.NoneCondition) and isinstance(
|
|
40
|
-
pattern, _condition.NoneCondition
|
|
41
|
-
):
|
|
42
|
-
return True
|
|
43
|
-
|
|
44
|
-
return False
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import jijmodeling.expression.constraint as _constraint
|
|
4
|
-
import jijmodeling.expression.expression as _expression
|
|
5
|
-
|
|
6
|
-
from jijmodeling.match.condition_same import condition_same
|
|
7
|
-
from jijmodeling.match.expr_same import expr_same
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def constraint_same(
|
|
11
|
-
target: _constraint.Constraint,
|
|
12
|
-
pattern: _constraint.Constraint,
|
|
13
|
-
check_id: bool = True,
|
|
14
|
-
) -> bool:
|
|
15
|
-
# Is the same label?
|
|
16
|
-
if target.label != pattern.label:
|
|
17
|
-
return False
|
|
18
|
-
# Is the same `with_penalty`?
|
|
19
|
-
if target.with_penalty != pattern.with_penalty:
|
|
20
|
-
return False
|
|
21
|
-
# Is the same `with_multiplier`?
|
|
22
|
-
if target.with_multiplier != pattern.with_multiplier:
|
|
23
|
-
return False
|
|
24
|
-
# Is the same `auto_qubo`?
|
|
25
|
-
if target.auto_qubo != pattern.auto_qubo:
|
|
26
|
-
return False
|
|
27
|
-
# Is the same `condition`?
|
|
28
|
-
if condition_same(target.condition, pattern.condition, check_id) is False:
|
|
29
|
-
return False
|
|
30
|
-
# Is the same `left_lower`?
|
|
31
|
-
if target.left_lower is None and pattern.left_lower is None:
|
|
32
|
-
is_same_left_lower = True
|
|
33
|
-
elif isinstance(target.left_lower, _expression.Expression) and isinstance(
|
|
34
|
-
pattern.left_lower, _expression.Expression
|
|
35
|
-
):
|
|
36
|
-
is_same_left_lower = expr_same(target.left_lower, pattern.left_lower, check_id)
|
|
37
|
-
else:
|
|
38
|
-
return False
|
|
39
|
-
if is_same_left_lower is False:
|
|
40
|
-
return False
|
|
41
|
-
# Is the same `forall`?
|
|
42
|
-
if len(target.forall) != len(pattern.forall):
|
|
43
|
-
return False
|
|
44
|
-
for target_forall, pattern_forall in zip(target.forall, pattern.forall):
|
|
45
|
-
target_element, target_condition = target_forall
|
|
46
|
-
pattern_element, pattern_condition = pattern_forall
|
|
47
|
-
is_same_forall = expr_same(
|
|
48
|
-
target_element, pattern_element, check_id
|
|
49
|
-
) and condition_same(target_condition, pattern_condition, check_id)
|
|
50
|
-
|
|
51
|
-
if is_same_forall is False:
|
|
52
|
-
return False
|
|
53
|
-
return True
|