jijmodeling 0.10.18__cp310-cp310-win_amd64.whl → 1.11.0__cp310-cp310-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 -148
- jijmodeling/__init__.pyi +5152 -0
- jijmodeling/_jijmodeling.cp310-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.10.18.dist-info → jijmodeling-1.11.0.dist-info}/WHEEL +1 -2
- {jijmodeling-0.10.18.dist-info → jijmodeling-1.11.0.dist-info/licenses}/LICENSE.txt +1 -1
- jijmodeling/__pycache__/__init__.cpython-310.opt-1.pyc +0 -0
- jijmodeling/__pycache__/__init__.cpython-310.pyc +0 -0
- jijmodeling/__pycache__/_version.cpython-310.opt-1.pyc +0 -0
- jijmodeling/__pycache__/_version.cpython-310.pyc +0 -0
- jijmodeling/_version.py +0 -4
- jijmodeling/exceptions/__init__.py +0 -26
- jijmodeling/exceptions/__pycache__/__init__.cpython-310.opt-1.pyc +0 -0
- jijmodeling/exceptions/__pycache__/__init__.cpython-310.pyc +0 -0
- jijmodeling/exceptions/__pycache__/exceptions.cpython-310.opt-1.pyc +0 -0
- jijmodeling/exceptions/__pycache__/exceptions.cpython-310.pyc +0 -0
- jijmodeling/exceptions/exceptions.py +0 -37
- jijmodeling/expression/__init__.py +0 -74
- jijmodeling/expression/__pycache__/__init__.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/__init__.cpython-310.pyc +0 -0
- jijmodeling/expression/__pycache__/condition.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/condition.cpython-310.pyc +0 -0
- jijmodeling/expression/__pycache__/constraint.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/constraint.cpython-310.pyc +0 -0
- jijmodeling/expression/__pycache__/expression.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/expression.cpython-310.pyc +0 -0
- jijmodeling/expression/__pycache__/extract.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/extract.cpython-310.pyc +0 -0
- jijmodeling/expression/__pycache__/from_old_serializable.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/from_old_serializable.cpython-310.pyc +0 -0
- jijmodeling/expression/__pycache__/mathfunc.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/mathfunc.cpython-310.pyc +0 -0
- jijmodeling/expression/__pycache__/prod.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/prod.cpython-310.pyc +0 -0
- jijmodeling/expression/__pycache__/serializable.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/serializable.cpython-310.pyc +0 -0
- jijmodeling/expression/__pycache__/sum.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/sum.cpython-310.pyc +0 -0
- jijmodeling/expression/__pycache__/type_annotations.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/type_annotations.cpython-310.pyc +0 -0
- jijmodeling/expression/__pycache__/utils.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/__pycache__/utils.cpython-310.pyc +0 -0
- jijmodeling/expression/condition.py +0 -362
- jijmodeling/expression/constraint.py +0 -340
- jijmodeling/expression/expression.py +0 -706
- jijmodeling/expression/extract.py +0 -139
- jijmodeling/expression/from_old_serializable.py +0 -133
- jijmodeling/expression/mathfunc.py +0 -269
- jijmodeling/expression/prod.py +0 -117
- jijmodeling/expression/serializable.py +0 -132
- jijmodeling/expression/sum.py +0 -197
- jijmodeling/expression/type_annotations.py +0 -50
- jijmodeling/expression/utils.py +0 -201
- jijmodeling/expression/variables/__init__.py +0 -35
- jijmodeling/expression/variables/__pycache__/__init__.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/__init__.cpython-310.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/deci_vars.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/deci_vars.cpython-310.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/jagged_array.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/jagged_array.cpython-310.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/placeholders.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/placeholders.cpython-310.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/variable.cpython-310.opt-1.pyc +0 -0
- jijmodeling/expression/variables/__pycache__/variable.cpython-310.pyc +0 -0
- jijmodeling/expression/variables/deci_vars.py +0 -136
- jijmodeling/expression/variables/jagged_array.py +0 -73
- jijmodeling/expression/variables/placeholders.py +0 -107
- jijmodeling/expression/variables/variable.py +0 -485
- jijmodeling/latex_repr/__init__.py +0 -11
- jijmodeling/latex_repr/__pycache__/__init__.cpython-310.opt-1.pyc +0 -0
- jijmodeling/latex_repr/__pycache__/__init__.cpython-310.pyc +0 -0
- jijmodeling/latex_repr/__pycache__/latex_repr.cpython-310.opt-1.pyc +0 -0
- jijmodeling/latex_repr/__pycache__/latex_repr.cpython-310.pyc +0 -0
- jijmodeling/latex_repr/__pycache__/problem_latex_repr.cpython-310.opt-1.pyc +0 -0
- jijmodeling/latex_repr/__pycache__/problem_latex_repr.cpython-310.pyc +0 -0
- jijmodeling/latex_repr/latex_repr.py +0 -243
- jijmodeling/latex_repr/problem_latex_repr.py +0 -209
- jijmodeling/marker/__marker__.cp310-win_amd64.pyd +0 -0
- jijmodeling/match/__init__.py +0 -19
- jijmodeling/match/__pycache__/__init__.cpython-310.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/__init__.cpython-310.pyc +0 -0
- jijmodeling/match/__pycache__/condition_same.cpython-310.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/condition_same.cpython-310.pyc +0 -0
- jijmodeling/match/__pycache__/constraint_same.cpython-310.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/constraint_same.cpython-310.pyc +0 -0
- jijmodeling/match/__pycache__/expr_same.cpython-310.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/expr_same.cpython-310.pyc +0 -0
- jijmodeling/match/__pycache__/is_same_expr.cpython-310.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/is_same_expr.cpython-310.pyc +0 -0
- jijmodeling/match/__pycache__/penalty_same.cpython-310.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/penalty_same.cpython-310.pyc +0 -0
- jijmodeling/match/__pycache__/problem_same.cpython-310.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/problem_same.cpython-310.pyc +0 -0
- jijmodeling/match/__pycache__/replace.cpython-310.opt-1.pyc +0 -0
- jijmodeling/match/__pycache__/replace.cpython-310.pyc +0 -0
- jijmodeling/match/condition_same.py +0 -44
- jijmodeling/match/constraint_same.py +0 -53
- jijmodeling/match/expr_same.py +0 -32
- jijmodeling/match/is_same_expr.py +0 -304
- jijmodeling/match/penalty_same.py +0 -31
- jijmodeling/match/problem_same.py +0 -44
- jijmodeling/match/replace.py +0 -210
- jijmodeling/problem/__init__.py +0 -9
- jijmodeling/problem/__pycache__/__init__.cpython-310.opt-1.pyc +0 -0
- jijmodeling/problem/__pycache__/__init__.cpython-310.pyc +0 -0
- jijmodeling/problem/__pycache__/problem.cpython-310.opt-1.pyc +0 -0
- jijmodeling/problem/__pycache__/problem.cpython-310.pyc +0 -0
- jijmodeling/problem/problem.py +0 -166
- jijmodeling/protobuf/__init__.py +0 -8
- jijmodeling/protobuf/__pycache__/__init__.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/__pycache__/__init__.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__init__.py +0 -47
- jijmodeling/protobuf/from_protobuf/__pycache__/__init__.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/__init__.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/extract_attribute_value_from_header.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/extract_attribute_value_from_header.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/from_protobuf.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/from_protobuf.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_array_shape.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_array_shape.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_binary_op.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_binary_op.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_binary_var.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_binary_var.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_constraint.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_constraint.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_element.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_element.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_expression.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_expression.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_forall.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_forall.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_integer_var.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_integer_var.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_jagged_array.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_jagged_array.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_number_lit.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_number_lit.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_penalty.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_penalty.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_placeholder.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_placeholder.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_problem.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_problem.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_reduction_op.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_reduction_op.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_subscript_op.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_subscript_op.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_unary_op.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/__pycache__/message_to_unary_op.cpython-310.pyc +0 -0
- jijmodeling/protobuf/from_protobuf/extract_attribute_value_from_header.py +0 -26
- jijmodeling/protobuf/from_protobuf/from_protobuf.py +0 -38
- jijmodeling/protobuf/from_protobuf/message_to_array_shape.py +0 -35
- jijmodeling/protobuf/from_protobuf/message_to_binary_op.py +0 -83
- jijmodeling/protobuf/from_protobuf/message_to_binary_var.py +0 -46
- jijmodeling/protobuf/from_protobuf/message_to_constraint.py +0 -48
- jijmodeling/protobuf/from_protobuf/message_to_element.py +0 -30
- jijmodeling/protobuf/from_protobuf/message_to_expression.py +0 -92
- jijmodeling/protobuf/from_protobuf/message_to_forall.py +0 -33
- jijmodeling/protobuf/from_protobuf/message_to_integer_var.py +0 -54
- jijmodeling/protobuf/from_protobuf/message_to_jagged_array.py +0 -25
- jijmodeling/protobuf/from_protobuf/message_to_number_lit.py +0 -41
- jijmodeling/protobuf/from_protobuf/message_to_penalty.py +0 -36
- jijmodeling/protobuf/from_protobuf/message_to_placeholder.py +0 -47
- jijmodeling/protobuf/from_protobuf/message_to_problem.py +0 -51
- jijmodeling/protobuf/from_protobuf/message_to_reduction_op.py +0 -52
- jijmodeling/protobuf/from_protobuf/message_to_subscript_op.py +0 -46
- jijmodeling/protobuf/from_protobuf/message_to_unary_op.py +0 -47
- jijmodeling/protobuf/to_protobuf/__init__.py +0 -43
- jijmodeling/protobuf/to_protobuf/__pycache__/__init__.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/__init__.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/add_header_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/add_header_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/array_shape_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/array_shape_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/binary_op_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/binary_op_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/binary_var_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/binary_var_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/constraint_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/constraint_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/element_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/element_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/expression_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/expression_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/forall_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/forall_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/integer_var_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/integer_var_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/jagged_array_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/jagged_array_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/number_lit_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/number_lit_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/penalty_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/penalty_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/placeholder_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/placeholder_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/problem_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/problem_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/reduction_op_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/reduction_op_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/subscript_op_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/subscript_op_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/to_protobuf.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/to_protobuf.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/unary_op_to_message.cpython-310.opt-1.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/__pycache__/unary_op_to_message.cpython-310.pyc +0 -0
- jijmodeling/protobuf/to_protobuf/add_header_to_message.py +0 -35
- jijmodeling/protobuf/to_protobuf/array_shape_to_message.py +0 -43
- jijmodeling/protobuf/to_protobuf/binary_op_to_message.py +0 -101
- jijmodeling/protobuf/to_protobuf/binary_var_to_message.py +0 -49
- jijmodeling/protobuf/to_protobuf/constraint_to_message.py +0 -52
- jijmodeling/protobuf/to_protobuf/element_to_message.py +0 -43
- jijmodeling/protobuf/to_protobuf/expression_to_message.py +0 -89
- jijmodeling/protobuf/to_protobuf/forall_to_message.py +0 -32
- jijmodeling/protobuf/to_protobuf/integer_var_to_message.py +0 -54
- jijmodeling/protobuf/to_protobuf/jagged_array_to_message.py +0 -37
- jijmodeling/protobuf/to_protobuf/number_lit_to_message.py +0 -52
- jijmodeling/protobuf/to_protobuf/penalty_to_message.py +0 -42
- jijmodeling/protobuf/to_protobuf/placeholder_to_message.py +0 -58
- jijmodeling/protobuf/to_protobuf/problem_to_message.py +0 -54
- jijmodeling/protobuf/to_protobuf/reduction_op_to_message.py +0 -64
- jijmodeling/protobuf/to_protobuf/subscript_op_to_message.py +0 -48
- jijmodeling/protobuf/to_protobuf/to_protobuf.py +0 -36
- jijmodeling/protobuf/to_protobuf/unary_op_to_message.py +0 -58
- jijmodeling/sampleset/__init__.py +0 -33
- jijmodeling/sampleset/__pycache__/__init__.cpython-310.opt-1.pyc +0 -0
- jijmodeling/sampleset/__pycache__/__init__.cpython-310.pyc +0 -0
- jijmodeling/sampleset/__pycache__/evaluation.cpython-310.opt-1.pyc +0 -0
- jijmodeling/sampleset/__pycache__/evaluation.cpython-310.pyc +0 -0
- jijmodeling/sampleset/__pycache__/measuring_time.cpython-310.opt-1.pyc +0 -0
- jijmodeling/sampleset/__pycache__/measuring_time.cpython-310.pyc +0 -0
- jijmodeling/sampleset/__pycache__/record.cpython-310.opt-1.pyc +0 -0
- jijmodeling/sampleset/__pycache__/record.cpython-310.pyc +0 -0
- jijmodeling/sampleset/__pycache__/sampleset.cpython-310.opt-1.pyc +0 -0
- jijmodeling/sampleset/__pycache__/sampleset.cpython-310.pyc +0 -0
- jijmodeling/sampleset/__pycache__/solving_time.cpython-310.opt-1.pyc +0 -0
- jijmodeling/sampleset/__pycache__/solving_time.cpython-310.pyc +0 -0
- jijmodeling/sampleset/__pycache__/system_time.cpython-310.opt-1.pyc +0 -0
- jijmodeling/sampleset/__pycache__/system_time.cpython-310.pyc +0 -0
- jijmodeling/sampleset/evaluation.py +0 -288
- jijmodeling/sampleset/measuring_time.py +0 -59
- jijmodeling/sampleset/record.py +0 -158
- jijmodeling/sampleset/sampleset.py +0 -379
- 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-310.opt-1.pyc +0 -0
- jijmodeling/type_annotations/__pycache__/__init__.cpython-310.pyc +0 -0
- jijmodeling/type_annotations/__pycache__/type_annotations.cpython-310.opt-1.pyc +0 -0
- jijmodeling/type_annotations/__pycache__/type_annotations.cpython-310.pyc +0 -0
- jijmodeling/type_annotations/type_annotations.py +0 -54
- jijmodeling/utils/__init__.py +0 -28
- jijmodeling/utils/__pycache__/__init__.cpython-310.opt-1.pyc +0 -0
- jijmodeling/utils/__pycache__/__init__.cpython-310.pyc +0 -0
- jijmodeling/utils/__pycache__/utils.cpython-310.opt-1.pyc +0 -0
- jijmodeling/utils/__pycache__/utils.cpython-310.pyc +0 -0
- jijmodeling/utils/utils.py +0 -146
- jijmodeling-0.10.18.dist-info/METADATA +0 -60
- jijmodeling-0.10.18.dist-info/RECORD +0 -258
- jijmodeling-0.10.18.dist-info/top_level.txt +0 -1
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import abc as _abc
|
|
4
|
-
import enum as _enum
|
|
5
|
-
import inspect as _inspect
|
|
6
|
-
import typing as tp
|
|
7
|
-
import uuid as _uuid
|
|
8
|
-
|
|
9
|
-
from typeguard import typechecked
|
|
10
|
-
|
|
11
|
-
import jijmodeling
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class Serializable(_abc.ABCMeta):
|
|
15
|
-
"""
|
|
16
|
-
Meta class that can call `to_serializable()` and `from_serializable()`.
|
|
17
|
-
|
|
18
|
-
Args:
|
|
19
|
-
ABCMeta ([type]): [description]
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
def __new__(cls, cls_name, cls_bases, cls_dict):
|
|
23
|
-
if "__init__" in cls_dict:
|
|
24
|
-
# serializeで用いるためExpressionクラスはコンストラクタの引数と対応する同じ名前の
|
|
25
|
-
# @property を持つ必要があるので, それが実装されているかをチェックする
|
|
26
|
-
init_func = _inspect.signature(cls_dict["__init__"])
|
|
27
|
-
params = [param for param in init_func.parameters if param != "self"]
|
|
28
|
-
for param in params:
|
|
29
|
-
if param not in cls_dict:
|
|
30
|
-
bases_has_property = False
|
|
31
|
-
for bases in cls_bases:
|
|
32
|
-
if param in dir(bases):
|
|
33
|
-
bases_has_property = True
|
|
34
|
-
if not bases_has_property:
|
|
35
|
-
raise NotImplementedError(
|
|
36
|
-
f"propety '{param}' must be" + f" define in {cls_name}."
|
|
37
|
-
)
|
|
38
|
-
return super().__new__(cls, cls_name, cls_bases, cls_dict)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def to_serializable(expression: Serializable) -> dict:
|
|
42
|
-
"""
|
|
43
|
-
Serialize an serializable object.
|
|
44
|
-
|
|
45
|
-
Args:
|
|
46
|
-
expression (Serializable): e.g. mathematical expression, problem, ...
|
|
47
|
-
|
|
48
|
-
Returns:
|
|
49
|
-
dict: serialized object
|
|
50
|
-
"""
|
|
51
|
-
seri = obj_to_seri(expression)
|
|
52
|
-
return {"version": "0.10.0", "object": seri}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def obj_to_seri(obj):
|
|
56
|
-
if isinstance(obj.__class__, Serializable):
|
|
57
|
-
return expression_to_seri(obj)
|
|
58
|
-
elif isinstance(obj, (list, tuple)):
|
|
59
|
-
return {
|
|
60
|
-
"iteratable": "list" if isinstance(obj, list) else "tuple",
|
|
61
|
-
"value": [obj_to_seri(v) for v in obj],
|
|
62
|
-
}
|
|
63
|
-
elif isinstance(obj, dict):
|
|
64
|
-
return {k: obj_to_seri(v) for k, v in obj.items()}
|
|
65
|
-
elif isinstance(obj, _uuid.UUID):
|
|
66
|
-
return obj.hex
|
|
67
|
-
elif isinstance(obj, _enum.Enum):
|
|
68
|
-
if isinstance(obj, jijmodeling.expression.expression.DataType):
|
|
69
|
-
return obj.value.lower()
|
|
70
|
-
else:
|
|
71
|
-
return obj.value
|
|
72
|
-
else:
|
|
73
|
-
return obj
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def expression_to_seri(expression: Serializable) -> dict:
|
|
77
|
-
exp_module = expression.__class__.__module__
|
|
78
|
-
exp_cls = expression.__class__.__name__
|
|
79
|
-
serializable: tp.Dict[str, tp.Any] = {"class": exp_module + "." + exp_cls}
|
|
80
|
-
|
|
81
|
-
init_args_keys = _inspect.getfullargspec(expression.__class__.__init__).args
|
|
82
|
-
init_params = {}
|
|
83
|
-
for key in init_args_keys:
|
|
84
|
-
# Ignore `self` because it is not used as a key for a serialized object
|
|
85
|
-
if key == "self":
|
|
86
|
-
continue
|
|
87
|
-
# Expression class の constructor の引数名と同じpropertyを必ず各クラスは持っているので
|
|
88
|
-
# それを情報としてserializeする
|
|
89
|
-
if f"_{key}" in dir(expression):
|
|
90
|
-
value = eval(f"expression._{key}")
|
|
91
|
-
else:
|
|
92
|
-
value = eval(f"expression.{key}")
|
|
93
|
-
init_params[key] = obj_to_seri(value)
|
|
94
|
-
serializable["attributes"] = init_params
|
|
95
|
-
return serializable
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
@typechecked
|
|
99
|
-
def from_serializable(serializable: tp.Union[dict, list]):
|
|
100
|
-
"""Convert to Expression from serializable object (dict)."""
|
|
101
|
-
if isinstance(serializable, dict) and "object" in serializable:
|
|
102
|
-
obj = serializable["object"]
|
|
103
|
-
else:
|
|
104
|
-
raise ValueError("version mismatch")
|
|
105
|
-
return obj_from_seri(obj)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
def obj_from_seri(obj):
|
|
109
|
-
if isinstance(obj, dict) and "class" in obj:
|
|
110
|
-
modulePath = obj["class"].split(".")[1:]
|
|
111
|
-
module = jijmodeling
|
|
112
|
-
for m in modulePath:
|
|
113
|
-
module = getattr(module, m)
|
|
114
|
-
# get name of arguments of __init__ of Expression object
|
|
115
|
-
init_args = _inspect.getfullargspec(module.__init__).args
|
|
116
|
-
init_arg_values = {
|
|
117
|
-
arg: obj_from_seri(obj["attributes"][arg])
|
|
118
|
-
for arg in init_args
|
|
119
|
-
if arg != "self"
|
|
120
|
-
}
|
|
121
|
-
return module(**init_arg_values)
|
|
122
|
-
elif isinstance(obj, dict) and "iteratable" in obj:
|
|
123
|
-
if obj["iteratable"] == "list":
|
|
124
|
-
return [obj_from_seri(s) for s in obj["value"]]
|
|
125
|
-
elif obj["iteratable"] == "tuple":
|
|
126
|
-
return tuple(obj_from_seri(s) for s in obj["value"])
|
|
127
|
-
elif isinstance(obj, list):
|
|
128
|
-
return [obj_from_seri(s) for s in obj]
|
|
129
|
-
elif isinstance(obj, dict):
|
|
130
|
-
return {k: obj_from_seri(v) for k, v in obj.items()}
|
|
131
|
-
|
|
132
|
-
return obj
|
jijmodeling/expression/sum.py
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import typing as tp
|
|
4
|
-
|
|
5
|
-
import typeguard as _typeguard
|
|
6
|
-
|
|
7
|
-
from typeguard import typechecked
|
|
8
|
-
|
|
9
|
-
import jijmodeling.exceptions.exceptions as _exceptions
|
|
10
|
-
import jijmodeling.expression.condition as _conditions
|
|
11
|
-
import jijmodeling.expression.expression as _expression
|
|
12
|
-
import jijmodeling.expression.extract as _extract
|
|
13
|
-
|
|
14
|
-
# type validation
|
|
15
|
-
import jijmodeling.expression.type_annotations as _type_annotations
|
|
16
|
-
import jijmodeling.expression.variables.variable as _variable
|
|
17
|
-
import jijmodeling.utils.utils as _utils
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class ReductionOperator(_expression.Expression):
|
|
21
|
-
def __init__(
|
|
22
|
-
self,
|
|
23
|
-
sum_index: _variable.Element,
|
|
24
|
-
operand: _expression.Expression,
|
|
25
|
-
condition: tp.Optional[_conditions.Condition] = None,
|
|
26
|
-
uuid: tp.Optional[str] = None,
|
|
27
|
-
) -> None:
|
|
28
|
-
|
|
29
|
-
super().__init__(uuid=uuid)
|
|
30
|
-
|
|
31
|
-
self._sum_index = sum_index
|
|
32
|
-
self._operand = operand
|
|
33
|
-
self._condition: _conditions.Condition = (
|
|
34
|
-
_conditions.NoneCondition() if condition is None else condition
|
|
35
|
-
)
|
|
36
|
-
if uuid is not None:
|
|
37
|
-
self._uuid = uuid
|
|
38
|
-
|
|
39
|
-
if _extract.condition_has_decivar(self._condition):
|
|
40
|
-
raise _exceptions.CannotContainDecisionVarError(
|
|
41
|
-
"condition for sum index cannot contain decision variable."
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
ConditionType = tp.Optional[_conditions.Condition]
|
|
45
|
-
_typeguard.check_type(
|
|
46
|
-
"self._sum_index", self._sum_index, _type_annotations.SumIndexType
|
|
47
|
-
)
|
|
48
|
-
_typeguard.check_type(
|
|
49
|
-
"self._operand", self._operand, _type_annotations.OperandType
|
|
50
|
-
)
|
|
51
|
-
_typeguard.check_type("self._condition", self._condition, ConditionType)
|
|
52
|
-
|
|
53
|
-
@property
|
|
54
|
-
def sum_index(self) -> _variable.Element:
|
|
55
|
-
"""Summation index."""
|
|
56
|
-
return self._sum_index
|
|
57
|
-
|
|
58
|
-
@property
|
|
59
|
-
def operand(self) -> _expression.Expression:
|
|
60
|
-
"""Summation operand."""
|
|
61
|
-
return self._operand
|
|
62
|
-
|
|
63
|
-
@property
|
|
64
|
-
def condition(self) -> _conditions.Condition:
|
|
65
|
-
"""Summation condition."""
|
|
66
|
-
return self._condition
|
|
67
|
-
|
|
68
|
-
def children(self) -> list:
|
|
69
|
-
"""[sum_index, operand, condition]."""
|
|
70
|
-
return [self._sum_index, self._operand] + self.condition.expressions()
|
|
71
|
-
|
|
72
|
-
def is_operatable(self) -> bool:
|
|
73
|
-
return True
|
|
74
|
-
|
|
75
|
-
def __repr__(self) -> str:
|
|
76
|
-
sum_index = ""
|
|
77
|
-
if isinstance(self.sum_index.parent, _variable.Range):
|
|
78
|
-
sum_index = "{" + "{}={}".format(
|
|
79
|
-
self.sum_index, self.sum_index.parent.start
|
|
80
|
-
)
|
|
81
|
-
sum_index = sum_index + "}"
|
|
82
|
-
sum_index = sum_index + "^{" + str(self.sum_index.parent.last) + "}"
|
|
83
|
-
else:
|
|
84
|
-
sum_index = "{" + f"{self.sum_index} in {self.sum_index.parent}"
|
|
85
|
-
sum_index = sum_index + "}"
|
|
86
|
-
|
|
87
|
-
return "Sum_" + sum_index + "(" + str(self.operand) + ")"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
class SumOperator(ReductionOperator):
|
|
91
|
-
"""
|
|
92
|
-
Class that represents the sum.
|
|
93
|
-
|
|
94
|
-
Example:
|
|
95
|
-
Create $`\\sum_{i=0}^n d_i x_i`$
|
|
96
|
-
|
|
97
|
-
>>> from jijmodeling import Placeholder, Binary, SumOperator
|
|
98
|
-
>>> from jijmodeling import Element
|
|
99
|
-
>>> d = Placeholder('d', dim=1)
|
|
100
|
-
>>> n = d.shape[0]
|
|
101
|
-
>>> x = Binary('x', shape=n)
|
|
102
|
-
>>> i = Element("i", n)
|
|
103
|
-
>>> SumOperator(sum_index=i, operand=d[i]*x[i], condition=None)
|
|
104
|
-
Σ_{i}(d[i]x[i])
|
|
105
|
-
"""
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
INDEXWITHCOND = tp.Union[
|
|
109
|
-
_variable.Element, tp.Tuple[_variable.Element, _conditions.Condition]
|
|
110
|
-
]
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def Sum(
|
|
114
|
-
indices: tp.Union[INDEXWITHCOND, tp.List[INDEXWITHCOND]],
|
|
115
|
-
term: _expression.Expression,
|
|
116
|
-
) -> SumOperator:
|
|
117
|
-
"""
|
|
118
|
-
Sum function.
|
|
119
|
-
|
|
120
|
-
Args:
|
|
121
|
-
indices: summation index dict or list of index.
|
|
122
|
-
term (Expression): operand of summation
|
|
123
|
-
|
|
124
|
-
Returns:
|
|
125
|
-
SumOperator: SumOperator object.
|
|
126
|
-
|
|
127
|
-
Example:
|
|
128
|
-
Create $`\\sum_{i=0}^n d_i x_i`$
|
|
129
|
-
|
|
130
|
-
>>> import jijmodeling as jm
|
|
131
|
-
>>> d = jm.Placeholder('d', dim=1)
|
|
132
|
-
>>> n = d.shape[0]
|
|
133
|
-
>>> x = jm.Binary('x', shape=n)
|
|
134
|
-
>>> i = jm.Element('i', n)
|
|
135
|
-
>>> jm.Sum(i, d[i]*x[i])
|
|
136
|
-
Σ_{i}(d[i]x[i])
|
|
137
|
-
|
|
138
|
-
Create $`\\sum_{i}\\sum_j d_{ij}x_i x_j`$
|
|
139
|
-
|
|
140
|
-
>>> import jijmodeling as jm
|
|
141
|
-
>>> d = jm.Placeholder('d', dim = 2)
|
|
142
|
-
>>> n = d.shape[0]
|
|
143
|
-
>>> x = jm.Binary('x', shape=n)
|
|
144
|
-
>>> i = jm.Element('i', n)
|
|
145
|
-
>>> j = jm.Element('j', n)
|
|
146
|
-
>>> jm.Sum([i, j], d[i, j]*x[i]*x[j])
|
|
147
|
-
|
|
148
|
-
Conditional sum
|
|
149
|
-
>>> import jijmodeling as jm
|
|
150
|
-
>>> d = jm.Placeholder('d', dim = 2)
|
|
151
|
-
>>> n = d.shape[0]
|
|
152
|
-
>>> i, j = jm.Element("i", n), jm.Element("j", n)
|
|
153
|
-
>>> x = jm.Binary('x', shape=n)
|
|
154
|
-
>>> jm.Sum([i, (j, i < j)], d[i, j]*x[i]*x[j])
|
|
155
|
-
"""
|
|
156
|
-
|
|
157
|
-
# convert indices and condition to list-type object
|
|
158
|
-
# ex. i -> [i]
|
|
159
|
-
indices_list = indices if isinstance(indices, list) else [indices] # type: ignore
|
|
160
|
-
|
|
161
|
-
# element type from users
|
|
162
|
-
IndexType = tp.Union[
|
|
163
|
-
_variable.Element,
|
|
164
|
-
tp.Tuple[_variable.Element, tp.Optional[_conditions.Condition]],
|
|
165
|
-
]
|
|
166
|
-
|
|
167
|
-
@typechecked
|
|
168
|
-
def convert_to_element(
|
|
169
|
-
index: IndexType,
|
|
170
|
-
) -> tp.Tuple[_variable.Element, tp.Optional[_conditions.Condition]]:
|
|
171
|
-
if isinstance(index, tuple): # Tuple[ElementType, Optional[Condition]]
|
|
172
|
-
elem, cond = index
|
|
173
|
-
return (elem, cond)
|
|
174
|
-
else: # ElementType
|
|
175
|
-
return (index, None)
|
|
176
|
-
|
|
177
|
-
elems_and_conds: tp.List[
|
|
178
|
-
tp.Tuple[_variable.Element, tp.Optional[_conditions.Condition]]
|
|
179
|
-
] = [convert_to_element(index) for index in indices_list]
|
|
180
|
-
elements = [elem for elem, _ in elems_and_conds]
|
|
181
|
-
condition_list = [cond for _, cond in elems_and_conds]
|
|
182
|
-
|
|
183
|
-
# list length validation
|
|
184
|
-
_utils.validate_value("len(indices) > 0", len(elements) > 0)
|
|
185
|
-
_utils.validate_value("len(condition_list) > 0", len(condition_list) > 0)
|
|
186
|
-
_utils.validate_value(
|
|
187
|
-
"len(indices_list) == len(condition_list)",
|
|
188
|
-
len(indices_list) == len(condition_list),
|
|
189
|
-
)
|
|
190
|
-
sum_term = term
|
|
191
|
-
for sum_index, cond in zip(elements[::-1], condition_list[::-1]):
|
|
192
|
-
sum_term = SumOperator(
|
|
193
|
-
sum_index=sum_index,
|
|
194
|
-
operand=sum_term,
|
|
195
|
-
condition=cond if cond is not None else _conditions.NoneCondition(),
|
|
196
|
-
)
|
|
197
|
-
return sum_term # type: ignore
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import typing as tp
|
|
4
|
-
|
|
5
|
-
from jijmodeling.expression.expression import BinaryOperator, Expression, Number
|
|
6
|
-
from jijmodeling.expression.mathfunc import UnaryOperator
|
|
7
|
-
from jijmodeling.expression.variables.placeholders import ArrayShape, Placeholder
|
|
8
|
-
from jijmodeling.expression.variables.variable import (
|
|
9
|
-
Element,
|
|
10
|
-
Range,
|
|
11
|
-
Subscripts,
|
|
12
|
-
Variable,
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
# Type of subscript element
|
|
16
|
-
SubscriptElementType = (
|
|
17
|
-
Expression # tp.TypeVar("SubscriptElementType", bound=Expression)
|
|
18
|
-
)
|
|
19
|
-
# User Input type for subscript element
|
|
20
|
-
SubscriptElemInputType = tp.Union[slice, SubscriptElementType, int]
|
|
21
|
-
|
|
22
|
-
# Type of shape element
|
|
23
|
-
# tp.TypeVar("ShapeElementType", bound=Expression)
|
|
24
|
-
ShapeElementType = Expression
|
|
25
|
-
# User input type for shape element
|
|
26
|
-
ShapeElemInputType = tp.Union[ShapeElementType, int, None]
|
|
27
|
-
|
|
28
|
-
ElementParentType = tp.Union[Range, Variable, Subscripts]
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
NumericInt = int
|
|
32
|
-
ExprOrNum = tp.Union[Expression, int, float]
|
|
33
|
-
|
|
34
|
-
IntExpr = tp.Union[Expression, int]
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
ElementSetType = tp.Union[Range, Variable, Subscripts]
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
Operator = tp.Union[BinaryOperator, UnaryOperator]
|
|
41
|
-
|
|
42
|
-
StrictShapeElemType = tp.Union[
|
|
43
|
-
Number,
|
|
44
|
-
Placeholder,
|
|
45
|
-
Operator,
|
|
46
|
-
ArrayShape,
|
|
47
|
-
]
|
|
48
|
-
RangeBoundType = tp.TypeVar("RangeBoundType", bound=Expression)
|
|
49
|
-
SumIndexType = tp.TypeVar("SumIndexType", bound=Element)
|
|
50
|
-
OperandType = tp.TypeVar("OperandType", bound=Expression)
|
jijmodeling/expression/utils.py
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import itertools as it
|
|
4
|
-
import typing as tp
|
|
5
|
-
|
|
6
|
-
import typeguard as _typeguard
|
|
7
|
-
|
|
8
|
-
import jijmodeling.exceptions.exceptions as _exceptions
|
|
9
|
-
import jijmodeling.expression.condition as _condition
|
|
10
|
-
import jijmodeling.expression.expression as _expression
|
|
11
|
-
import jijmodeling.expression.extract as _extract
|
|
12
|
-
import jijmodeling.expression.sum as _sum
|
|
13
|
-
import jijmodeling.expression.variables.deci_vars as _deci_vars
|
|
14
|
-
import jijmodeling.expression.variables.variable as _variable
|
|
15
|
-
|
|
16
|
-
T = tp.TypeVar("T")
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def type_check_bool(value, cls) -> bool:
|
|
20
|
-
try:
|
|
21
|
-
_typeguard.check_type("a", value, cls)
|
|
22
|
-
except TypeError:
|
|
23
|
-
return False
|
|
24
|
-
else:
|
|
25
|
-
return True
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def extract_nodes(tree: _expression.Expression, cls: tp.Type[T]) -> tp.List[T]:
|
|
29
|
-
"""
|
|
30
|
-
Extract specified class object from Expression tree.
|
|
31
|
-
|
|
32
|
-
Args:
|
|
33
|
-
tree (Expression): Target expression tree.
|
|
34
|
-
cls (Type): Target class.
|
|
35
|
-
|
|
36
|
-
Returns:
|
|
37
|
-
List: `cls` object list are included in `tree`.
|
|
38
|
-
|
|
39
|
-
Examples:
|
|
40
|
-
```python
|
|
41
|
-
>>> import jijmodeling as jm
|
|
42
|
-
>>> d = jm.Placheolder("d", dim=1)
|
|
43
|
-
>>> n = d.shape[0]
|
|
44
|
-
>>> x = jm.Binary("x", shape=(n, ))
|
|
45
|
-
>>> i = jm.Element("i", n)
|
|
46
|
-
>>> term = jm.Sum(i, d[i]*x[i])
|
|
47
|
-
>>> jm.extract_nodes(term, jm.DecisionVariable)
|
|
48
|
-
[x]
|
|
49
|
-
```
|
|
50
|
-
"""
|
|
51
|
-
if type_check_bool(tree, cls):
|
|
52
|
-
nodes = [tree]
|
|
53
|
-
else:
|
|
54
|
-
nodes = []
|
|
55
|
-
for child in tree.children():
|
|
56
|
-
nodes = nodes + extract_nodes(child, cls) # type: ignore
|
|
57
|
-
return nodes # type: ignore
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def get_order(expression: _expression.Expression) -> int:
|
|
61
|
-
"""
|
|
62
|
-
Get an order of polynomial.
|
|
63
|
-
|
|
64
|
-
For example, x_i * y_i + x_i -> 2 if x and y is a decision variable.
|
|
65
|
-
|
|
66
|
-
Args:
|
|
67
|
-
expression (Expression): expression
|
|
68
|
-
|
|
69
|
-
Returns:
|
|
70
|
-
int: Integer
|
|
71
|
-
"""
|
|
72
|
-
if isinstance(expression, _deci_vars.DecisionVariable):
|
|
73
|
-
return 1
|
|
74
|
-
if isinstance(expression, _variable.Subscripts):
|
|
75
|
-
if isinstance(expression.variable, _deci_vars.DecisionVariable):
|
|
76
|
-
return 1
|
|
77
|
-
else:
|
|
78
|
-
return 0
|
|
79
|
-
if isinstance(expression, (_expression.Add, _expression.Div)):
|
|
80
|
-
child_order = [get_order(child) for child in expression.children()]
|
|
81
|
-
return max(child_order)
|
|
82
|
-
if isinstance(expression, _expression.Mul):
|
|
83
|
-
child_order = [get_order(child) for child in expression.children()]
|
|
84
|
-
return sum(child_order)
|
|
85
|
-
if isinstance(expression, _expression.Power):
|
|
86
|
-
base_order = get_order(expression.left)
|
|
87
|
-
if base_order > 0:
|
|
88
|
-
if isinstance(expression.right, _expression.Number):
|
|
89
|
-
return base_order * int(expression.right.value)
|
|
90
|
-
else:
|
|
91
|
-
raise _exceptions.ModelingError("exponent should be number.")
|
|
92
|
-
if isinstance(expression, _sum.SumOperator):
|
|
93
|
-
return get_order(expression.operand)
|
|
94
|
-
else:
|
|
95
|
-
return 0
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def expression_indices(
|
|
99
|
-
expression: _expression.Expression,
|
|
100
|
-
) -> tp.List[_variable.Element]:
|
|
101
|
-
"""
|
|
102
|
-
Extract all indices from the expression.
|
|
103
|
-
|
|
104
|
-
Args:
|
|
105
|
-
expression (Expression): expression
|
|
106
|
-
|
|
107
|
-
Returns:
|
|
108
|
-
List[Element]:
|
|
109
|
-
"""
|
|
110
|
-
# TODO: implement expression_indices for each expression?
|
|
111
|
-
indices: tp.List[_variable.Element]
|
|
112
|
-
if isinstance(expression, _variable.Element):
|
|
113
|
-
set_indices: tp.List[_variable.Element] = []
|
|
114
|
-
for child in expression.children():
|
|
115
|
-
set_indices = set_indices + expression_indices(child)
|
|
116
|
-
indices = [expression] + set_indices
|
|
117
|
-
elif isinstance(expression, _expression.Number):
|
|
118
|
-
indices = []
|
|
119
|
-
elif isinstance(expression, _variable.Variable):
|
|
120
|
-
indices = []
|
|
121
|
-
elif isinstance(expression, _variable.Subscripts):
|
|
122
|
-
indices = []
|
|
123
|
-
for subs in expression.subscripts:
|
|
124
|
-
indices = indices + expression_indices(subs)
|
|
125
|
-
elif isinstance(expression, _expression.Expression):
|
|
126
|
-
indices = []
|
|
127
|
-
for child in expression.children():
|
|
128
|
-
if child is not None:
|
|
129
|
-
indices = indices + expression_indices(child)
|
|
130
|
-
else:
|
|
131
|
-
raise TypeError(f"expression is Expression, not {type(expression)}")
|
|
132
|
-
|
|
133
|
-
# check duplicated element
|
|
134
|
-
el_label = []
|
|
135
|
-
if isinstance(expression, _sum.ReductionOperator):
|
|
136
|
-
el_label = [expression.sum_index.label]
|
|
137
|
-
|
|
138
|
-
unique_indices: tp.List[_variable.Element] = []
|
|
139
|
-
for index in indices:
|
|
140
|
-
if index.label not in el_label:
|
|
141
|
-
el_label.append(index.label)
|
|
142
|
-
unique_indices.append(index)
|
|
143
|
-
return unique_indices
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
def condition_indices(condition: _condition.Condition) -> tp.List[_variable.Element]:
|
|
147
|
-
if isinstance(condition, _condition.CompareCondition):
|
|
148
|
-
left_indices = expression_indices(condition.left)
|
|
149
|
-
right_indices = expression_indices(condition.right)
|
|
150
|
-
return left_indices + right_indices
|
|
151
|
-
elif isinstance(condition, _condition.ConditionOperator):
|
|
152
|
-
left_indices = condition_indices(condition.left)
|
|
153
|
-
right_indices = condition_indices(condition.right)
|
|
154
|
-
return left_indices + right_indices
|
|
155
|
-
else:
|
|
156
|
-
return []
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
def check_non_decision_variable(
|
|
160
|
-
exp_list: tp.Iterable[_expression.Expression], error_msg: str
|
|
161
|
-
):
|
|
162
|
-
"""
|
|
163
|
-
Check if list has decision variable or not.
|
|
164
|
-
|
|
165
|
-
Args:
|
|
166
|
-
exp_list (Iterable[Expression]): target iterator.
|
|
167
|
-
error_msg (str): error message.
|
|
168
|
-
|
|
169
|
-
Raises:
|
|
170
|
-
CannotContainDecisionVarError: if list has decision variable.
|
|
171
|
-
"""
|
|
172
|
-
for e in exp_list:
|
|
173
|
-
variables = _extract.extract_variables(e)
|
|
174
|
-
for v in variables:
|
|
175
|
-
if isinstance(v, _deci_vars.DecisionVariable):
|
|
176
|
-
raise _exceptions.CannotContainDecisionVarError(error_msg)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
def flatten_binary_operator(
|
|
180
|
-
expression: _expression.Expression,
|
|
181
|
-
op_type: tp.Type[_expression.BinaryOperator] = _expression.Add,
|
|
182
|
-
) -> tp.List[_expression.Expression]:
|
|
183
|
-
"""
|
|
184
|
-
Flatten `op_type` binary operator to list.
|
|
185
|
-
This function flattens a given node to the following:
|
|
186
|
-
node1 <> node2 <> node3 <> ... <> nodeN -> [node1, node2, node3, ..., nodeN]
|
|
187
|
-
where <> is a specified binary operator by `op_type`.
|
|
188
|
-
|
|
189
|
-
Args:
|
|
190
|
-
expression (Expression): target expression.
|
|
191
|
-
op_type (Type[BinaryOperator]): target binary operator.
|
|
192
|
-
|
|
193
|
-
Returns:
|
|
194
|
-
List[Expression]: list of expression. Each element is not binary operator.
|
|
195
|
-
"""
|
|
196
|
-
if isinstance(expression, op_type):
|
|
197
|
-
left = flatten_binary_operator(expression.left, op_type)
|
|
198
|
-
right = flatten_binary_operator(expression.right, op_type)
|
|
199
|
-
return list(it.chain.from_iterable([left, right]))
|
|
200
|
-
else:
|
|
201
|
-
return [expression]
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
from pkgutil import extend_path
|
|
2
|
-
|
|
3
|
-
__path__ = extend_path(__path__, __name__)
|
|
4
|
-
|
|
5
|
-
import jijmodeling.expression.variables.deci_vars as deci_vars
|
|
6
|
-
import jijmodeling.expression.variables.jagged_array as jagged_array
|
|
7
|
-
import jijmodeling.expression.variables.placeholders as placeholders
|
|
8
|
-
import jijmodeling.expression.variables.variable as variable
|
|
9
|
-
|
|
10
|
-
from jijmodeling.expression.variables.deci_vars import (
|
|
11
|
-
Binary,
|
|
12
|
-
DecisionVariable,
|
|
13
|
-
Integer,
|
|
14
|
-
LogEncInteger,
|
|
15
|
-
)
|
|
16
|
-
from jijmodeling.expression.variables.jagged_array import JaggedArray
|
|
17
|
-
from jijmodeling.expression.variables.placeholders import ArrayShape, Placeholder
|
|
18
|
-
from jijmodeling.expression.variables.variable import Element, Subscripts, Variable
|
|
19
|
-
|
|
20
|
-
__all__ = [
|
|
21
|
-
"deci_vars",
|
|
22
|
-
"jagged_array",
|
|
23
|
-
"placeholders",
|
|
24
|
-
"variable",
|
|
25
|
-
"Variable",
|
|
26
|
-
"Subscripts",
|
|
27
|
-
"Element",
|
|
28
|
-
"Placeholder",
|
|
29
|
-
"ArrayShape",
|
|
30
|
-
"JaggedArray",
|
|
31
|
-
"DecisionVariable",
|
|
32
|
-
"Binary",
|
|
33
|
-
"LogEncInteger",
|
|
34
|
-
"Integer",
|
|
35
|
-
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|