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,362 +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
|
-
def __init__(self) -> None:
|
|
16
|
-
self._uuid = uuid.uuid4().hex
|
|
17
|
-
|
|
18
|
-
def __and__(self, other):
|
|
19
|
-
return AndOperator(self, other)
|
|
20
|
-
|
|
21
|
-
def __xor__(self, other):
|
|
22
|
-
return XorOperator(self, other)
|
|
23
|
-
|
|
24
|
-
def __or__(self, other):
|
|
25
|
-
return OrOperator(self, other)
|
|
26
|
-
|
|
27
|
-
@abstractmethod
|
|
28
|
-
def expressions(self) -> tp.List[_expression.Expression]:
|
|
29
|
-
pass
|
|
30
|
-
|
|
31
|
-
@property
|
|
32
|
-
def uuid(self) -> str:
|
|
33
|
-
return self._uuid
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
class NoneCondition(Condition):
|
|
37
|
-
def expressions(self) -> tp.List[_expression.Expression]:
|
|
38
|
-
return []
|
|
39
|
-
|
|
40
|
-
@classmethod
|
|
41
|
-
def operation(cls) -> bool:
|
|
42
|
-
return True
|
|
43
|
-
|
|
44
|
-
def _make_latex(self) -> str:
|
|
45
|
-
"""
|
|
46
|
-
Outputs a latex representation.
|
|
47
|
-
|
|
48
|
-
If `self._latex_repr` is not None, it
|
|
49
|
-
will take precedence. If you want to get the latex representation of
|
|
50
|
-
child objects in `_default_repr_latex_` of each class, use the method.
|
|
51
|
-
|
|
52
|
-
Returns:
|
|
53
|
-
str: latex representation.
|
|
54
|
-
"""
|
|
55
|
-
return ""
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
class CompareCondition(Condition, metaclass=_abc.ABCMeta):
|
|
59
|
-
mark = ""
|
|
60
|
-
|
|
61
|
-
def __init__(
|
|
62
|
-
self,
|
|
63
|
-
left: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
64
|
-
right: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
65
|
-
uuid: tp.Optional[str] = None,
|
|
66
|
-
) -> None:
|
|
67
|
-
_left: _expression.Expression = (
|
|
68
|
-
left
|
|
69
|
-
if isinstance(left, _expression.Expression)
|
|
70
|
-
else _expression.Number(left)
|
|
71
|
-
)
|
|
72
|
-
_right: _expression.Expression = (
|
|
73
|
-
right
|
|
74
|
-
if isinstance(right, _expression.Expression)
|
|
75
|
-
else _expression.Number(right)
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
super().__init__()
|
|
79
|
-
if not _left.is_operatable():
|
|
80
|
-
raise _exceptions.ModelingError(f"{_left} is not operatable.")
|
|
81
|
-
if not _right.is_operatable():
|
|
82
|
-
raise _exceptions.ModelingError(f"{_right} is not operatable.")
|
|
83
|
-
|
|
84
|
-
self._left = _left
|
|
85
|
-
self._right = _right
|
|
86
|
-
# Set uuid
|
|
87
|
-
if uuid is not None:
|
|
88
|
-
self._uuid = uuid
|
|
89
|
-
|
|
90
|
-
def __repr__(self) -> str:
|
|
91
|
-
return str(self.left) + self.mark + str(self.right)
|
|
92
|
-
|
|
93
|
-
def _make_latex(self) -> str:
|
|
94
|
-
"""
|
|
95
|
-
Outputs a latex representation.
|
|
96
|
-
|
|
97
|
-
If `self._latex_repr` is not None, it
|
|
98
|
-
will take precedence. If you want to get the latex representation of
|
|
99
|
-
child objects in `_default_repr_latex_` of each class, use the method.
|
|
100
|
-
|
|
101
|
-
Returns:
|
|
102
|
-
str: latex representation.
|
|
103
|
-
"""
|
|
104
|
-
latex_str = r"{} {} {}".format(
|
|
105
|
-
self.left._make_latex(), self.mark, self.right._make_latex()
|
|
106
|
-
)
|
|
107
|
-
return latex_str
|
|
108
|
-
|
|
109
|
-
def _repr_latex_(self) -> str:
|
|
110
|
-
"""
|
|
111
|
-
Latex representation for Jupyter notebook.
|
|
112
|
-
|
|
113
|
-
Returns:
|
|
114
|
-
str: latex string
|
|
115
|
-
"""
|
|
116
|
-
return f"${self._make_latex()}$"
|
|
117
|
-
|
|
118
|
-
@property
|
|
119
|
-
def left(self) -> _expression.Expression:
|
|
120
|
-
return self._left
|
|
121
|
-
|
|
122
|
-
@property
|
|
123
|
-
def right(self) -> _expression.Expression:
|
|
124
|
-
return self._right
|
|
125
|
-
|
|
126
|
-
def expressions(self) -> tp.List[_expression.Expression]:
|
|
127
|
-
return [self.left, self.right]
|
|
128
|
-
|
|
129
|
-
@classmethod
|
|
130
|
-
@abstractmethod
|
|
131
|
-
def operation(cls, left, right) -> bool:
|
|
132
|
-
pass
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
class Equal(CompareCondition):
|
|
136
|
-
mark = "="
|
|
137
|
-
|
|
138
|
-
def __init__(
|
|
139
|
-
self,
|
|
140
|
-
left: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
141
|
-
right: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
142
|
-
uuid: tp.Optional[str] = None,
|
|
143
|
-
) -> None:
|
|
144
|
-
_left = (
|
|
145
|
-
left
|
|
146
|
-
if isinstance(left, _expression.Expression)
|
|
147
|
-
else _expression.Number(left)
|
|
148
|
-
)
|
|
149
|
-
_right = (
|
|
150
|
-
right
|
|
151
|
-
if isinstance(right, _expression.Expression)
|
|
152
|
-
else _expression.Number(right)
|
|
153
|
-
)
|
|
154
|
-
super().__init__(_left, _right, uuid)
|
|
155
|
-
|
|
156
|
-
@classmethod
|
|
157
|
-
def operation(cls, left: tp.Any, right: tp.Any) -> bool:
|
|
158
|
-
equal: bool = left == right
|
|
159
|
-
return equal
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
class NotEqual(CompareCondition):
|
|
163
|
-
mark = "!="
|
|
164
|
-
|
|
165
|
-
def __init__(
|
|
166
|
-
self,
|
|
167
|
-
left: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
168
|
-
right: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
169
|
-
uuid: tp.Optional[str] = None,
|
|
170
|
-
) -> None:
|
|
171
|
-
super().__init__(left, right, uuid)
|
|
172
|
-
|
|
173
|
-
def _make_latex(self) -> str:
|
|
174
|
-
"""
|
|
175
|
-
Outputs a latex representation.
|
|
176
|
-
|
|
177
|
-
If `self._latex_repr` is not None, it
|
|
178
|
-
will take precedence. If you want to get the latex representation of
|
|
179
|
-
child objects in `_default_repr_latex_` of each class, use the method.
|
|
180
|
-
|
|
181
|
-
Returns:
|
|
182
|
-
str: latex representation.
|
|
183
|
-
"""
|
|
184
|
-
latex_str = r"{} \neq {}".format(
|
|
185
|
-
self.left._make_latex(), self.right._make_latex()
|
|
186
|
-
)
|
|
187
|
-
return latex_str
|
|
188
|
-
|
|
189
|
-
@classmethod
|
|
190
|
-
def operation(cls, left, right) -> bool:
|
|
191
|
-
not_eq: bool = left != right
|
|
192
|
-
return not_eq
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
class LessThan(CompareCondition):
|
|
196
|
-
mark = "<"
|
|
197
|
-
|
|
198
|
-
def __init__(
|
|
199
|
-
self,
|
|
200
|
-
left: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
201
|
-
right: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
202
|
-
uuid: tp.Optional[str] = None,
|
|
203
|
-
) -> None:
|
|
204
|
-
super().__init__(left, right, uuid)
|
|
205
|
-
|
|
206
|
-
@classmethod
|
|
207
|
-
def operation(cls, left, right) -> bool:
|
|
208
|
-
less_than: bool = left < right
|
|
209
|
-
return less_than
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
class LessThanEqual(CompareCondition):
|
|
213
|
-
mark = "<="
|
|
214
|
-
|
|
215
|
-
def __init__(
|
|
216
|
-
self,
|
|
217
|
-
left: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
218
|
-
right: tp.Union[_expression.Expression, _expression.NumericValue],
|
|
219
|
-
uuid: tp.Optional[str] = None,
|
|
220
|
-
) -> None:
|
|
221
|
-
super().__init__(left, right, uuid)
|
|
222
|
-
|
|
223
|
-
def _make_latex(self) -> str:
|
|
224
|
-
"""
|
|
225
|
-
Outputs a latex representation.
|
|
226
|
-
|
|
227
|
-
If `self._latex_repr` is not None, it
|
|
228
|
-
will take precedence. If you want to get the latex representation of
|
|
229
|
-
child objects in `_default_repr_latex_` of each class, use the method.
|
|
230
|
-
|
|
231
|
-
Returns:
|
|
232
|
-
str: latex representation.
|
|
233
|
-
"""
|
|
234
|
-
latex_str = r"{} \leq {}".format(
|
|
235
|
-
self.left._make_latex(), self.right._make_latex()
|
|
236
|
-
)
|
|
237
|
-
return latex_str
|
|
238
|
-
|
|
239
|
-
@classmethod
|
|
240
|
-
def operation(cls, left, right) -> bool:
|
|
241
|
-
less_than_eq: bool = left <= right
|
|
242
|
-
return less_than_eq
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
def equal(left: _expression.Expression, right: _expression.Expression) -> Equal:
|
|
246
|
-
"""
|
|
247
|
-
Creadion an Equality condition object (Equal).
|
|
248
|
-
|
|
249
|
-
The equality operator `==` can also be used to generate an equality condition object.
|
|
250
|
-
Args:
|
|
251
|
-
left (Expression): left hand side expression
|
|
252
|
-
right (Expression): right hand side expression
|
|
253
|
-
|
|
254
|
-
Returns:
|
|
255
|
-
Equal: left `==` right
|
|
256
|
-
"""
|
|
257
|
-
return Equal(left, right)
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
def eq(left: _expression.Expression, right: _expression.Expression) -> Equal:
|
|
261
|
-
return equal(left, right)
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
def neq(left: _expression.Expression, right: _expression.Expression) -> NotEqual:
|
|
265
|
-
"""
|
|
266
|
-
Creadion a Non Equality condition object (NotEqual) The non equality.
|
|
267
|
-
|
|
268
|
-
operator `!=` can also be used to generate a non equality condition object.
|
|
269
|
-
|
|
270
|
-
Args:
|
|
271
|
-
left (Expression): left hand side expression
|
|
272
|
-
right (Expression): right hand side expression
|
|
273
|
-
|
|
274
|
-
Returns:
|
|
275
|
-
NotEqual: left `!=` right
|
|
276
|
-
"""
|
|
277
|
-
return NotEqual(left, right)
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
class ConditionOperator(Condition, metaclass=_abc.ABCMeta):
|
|
281
|
-
def __init__(
|
|
282
|
-
self,
|
|
283
|
-
left: Condition,
|
|
284
|
-
right: Condition,
|
|
285
|
-
uuid: tp.Optional[str] = None,
|
|
286
|
-
) -> None:
|
|
287
|
-
super().__init__()
|
|
288
|
-
self._left = left
|
|
289
|
-
self._right = right
|
|
290
|
-
# Set uuid
|
|
291
|
-
if uuid is not None:
|
|
292
|
-
self._uuid = uuid
|
|
293
|
-
|
|
294
|
-
@property
|
|
295
|
-
def left(self) -> Condition:
|
|
296
|
-
return self._left
|
|
297
|
-
|
|
298
|
-
@property
|
|
299
|
-
def right(self) -> Condition:
|
|
300
|
-
return self._right
|
|
301
|
-
|
|
302
|
-
def expressions(self) -> tp.List[_expression.Expression]:
|
|
303
|
-
return self.left.expressions() + self.right.expressions()
|
|
304
|
-
|
|
305
|
-
@classmethod
|
|
306
|
-
@abstractmethod
|
|
307
|
-
def operation(cls, left: bool, right: bool) -> bool:
|
|
308
|
-
pass
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
class AndOperator(ConditionOperator):
|
|
312
|
-
def __init__(
|
|
313
|
-
self,
|
|
314
|
-
left: Condition,
|
|
315
|
-
right: Condition,
|
|
316
|
-
uuid: tp.Optional[str] = None,
|
|
317
|
-
) -> None:
|
|
318
|
-
super().__init__(left, right, uuid)
|
|
319
|
-
|
|
320
|
-
@classmethod
|
|
321
|
-
def operation(cls, left: bool, right: bool) -> bool:
|
|
322
|
-
and_ope: bool = left & right
|
|
323
|
-
return and_ope
|
|
324
|
-
|
|
325
|
-
def __repr__(self) -> str:
|
|
326
|
-
return "(" + str(self.left) + ") & (" + str(self.right) + ")"
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
class XorOperator(ConditionOperator):
|
|
330
|
-
def __init__(
|
|
331
|
-
self,
|
|
332
|
-
left: Condition,
|
|
333
|
-
right: Condition,
|
|
334
|
-
uuid: tp.Optional[str] = None,
|
|
335
|
-
) -> None:
|
|
336
|
-
super().__init__(left, right, uuid)
|
|
337
|
-
|
|
338
|
-
@classmethod
|
|
339
|
-
def operation(cls, left, right) -> bool:
|
|
340
|
-
xor: bool = left ^ right
|
|
341
|
-
return xor
|
|
342
|
-
|
|
343
|
-
def __repr__(self) -> str:
|
|
344
|
-
return str(self.left) + " xor " + str(self.right)
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
class OrOperator(ConditionOperator):
|
|
348
|
-
def __init__(
|
|
349
|
-
self,
|
|
350
|
-
left: Condition,
|
|
351
|
-
right: Condition,
|
|
352
|
-
uuid: tp.Optional[str] = None,
|
|
353
|
-
) -> None:
|
|
354
|
-
super().__init__(left, right, uuid)
|
|
355
|
-
|
|
356
|
-
@classmethod
|
|
357
|
-
def operation(cls, left, right) -> bool:
|
|
358
|
-
or_bool: bool = left | right
|
|
359
|
-
return or_bool
|
|
360
|
-
|
|
361
|
-
def __repr__(self) -> str:
|
|
362
|
-
return str(self.left) + " | " + str(self.right)
|
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import List, Optional, Tuple, Union
|
|
4
|
-
|
|
5
|
-
from typeguard import check_type, typechecked
|
|
6
|
-
|
|
7
|
-
import jijmodeling.exceptions.exceptions as _exceptions
|
|
8
|
-
import jijmodeling.expression.condition as _condition
|
|
9
|
-
import jijmodeling.expression.expression as _expression
|
|
10
|
-
import jijmodeling.expression.serializable as _serializable
|
|
11
|
-
import jijmodeling.expression.sum as _sum
|
|
12
|
-
import jijmodeling.expression.variables.variable as _variable
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class Penalty(metaclass=_serializable.Serializable):
|
|
16
|
-
"""
|
|
17
|
-
Penalty term without constraint.
|
|
18
|
-
|
|
19
|
-
Incorporate it into the model as a penalty term. It is not evaluated
|
|
20
|
-
as a constraint, so it is not used to determine if a solution is
|
|
21
|
-
feasible. However, it is evaluated separately from the objective
|
|
22
|
-
function. It is mainly used to include conditions that you want to
|
|
23
|
-
treat as soft constraints as penalty terms. The penalty class can
|
|
24
|
-
also be used when you would like to express the constraint as a
|
|
25
|
-
penalty that you define, rather than one that is automatically
|
|
26
|
-
changed by QUBO.
|
|
27
|
-
"""
|
|
28
|
-
|
|
29
|
-
def __init__(
|
|
30
|
-
self,
|
|
31
|
-
label: str,
|
|
32
|
-
penalty_term: _expression.Expression,
|
|
33
|
-
forall: Union[
|
|
34
|
-
_variable.Element,
|
|
35
|
-
Tuple[_variable.Element, Optional[_condition.Condition]],
|
|
36
|
-
List[
|
|
37
|
-
Union[
|
|
38
|
-
_variable.Element,
|
|
39
|
-
Tuple[_variable.Element, Optional[_condition.Condition]],
|
|
40
|
-
]
|
|
41
|
-
],
|
|
42
|
-
] = [],
|
|
43
|
-
with_multiplier: bool = True,
|
|
44
|
-
):
|
|
45
|
-
"""
|
|
46
|
-
Initialize
|
|
47
|
-
|
|
48
|
-
Args:
|
|
49
|
-
label (str): label of penalty term
|
|
50
|
-
penalty_term (Expression): penalty term
|
|
51
|
-
with_multiplier (bool, optional): with multiplier or not. Defaults to True.
|
|
52
|
-
|
|
53
|
-
Examples:
|
|
54
|
-
```python
|
|
55
|
-
>>> import jijmodeling as jm
|
|
56
|
-
>>> n = jm.Placeholder('n')
|
|
57
|
-
>>> x = jm.Binary('x', shape=n)
|
|
58
|
-
>>> pe = jm.Penalty('p', (x[:]-1)**2) # one-hot constraint
|
|
59
|
-
```
|
|
60
|
-
"""
|
|
61
|
-
self._label = label
|
|
62
|
-
self._penalty_term = penalty_term
|
|
63
|
-
self._with_multiplier = with_multiplier
|
|
64
|
-
|
|
65
|
-
# convert forall to list-type object
|
|
66
|
-
forall_list = forall if isinstance(forall, list) else [forall]
|
|
67
|
-
# element type from users
|
|
68
|
-
IndexType = Union[
|
|
69
|
-
_variable.Element, Tuple[_variable.Element, Optional[_condition.Condition]]
|
|
70
|
-
]
|
|
71
|
-
|
|
72
|
-
@typechecked
|
|
73
|
-
def convert_to_element(
|
|
74
|
-
index: IndexType,
|
|
75
|
-
) -> Tuple[_variable.Element, _condition.Condition]:
|
|
76
|
-
if isinstance(index, tuple): # Tuple[ElementType, Condition]
|
|
77
|
-
elem, cond = index
|
|
78
|
-
if cond is not None:
|
|
79
|
-
return (elem, cond)
|
|
80
|
-
else:
|
|
81
|
-
return (elem, _condition.NoneCondition())
|
|
82
|
-
else: # ElementType
|
|
83
|
-
return (index, _condition.NoneCondition())
|
|
84
|
-
|
|
85
|
-
ForallType = List[Tuple[_variable.Element, _condition.Condition]]
|
|
86
|
-
self._forall: ForallType = [convert_to_element(elem) for elem in forall_list]
|
|
87
|
-
|
|
88
|
-
# type validation
|
|
89
|
-
check_type("self.label", self.label, str)
|
|
90
|
-
check_type("self._penalty_term", self._penalty_term, _expression.Expression)
|
|
91
|
-
check_type("self._with_multiplier", self._with_multiplier, bool)
|
|
92
|
-
|
|
93
|
-
@property
|
|
94
|
-
def label(self) -> str:
|
|
95
|
-
return self._label
|
|
96
|
-
|
|
97
|
-
@property
|
|
98
|
-
def penalty_term(self) -> _expression.Expression:
|
|
99
|
-
"""Penalty term (without multiplier)."""
|
|
100
|
-
return self._penalty_term
|
|
101
|
-
|
|
102
|
-
@property
|
|
103
|
-
def with_multiplier(self) -> bool:
|
|
104
|
-
"""Penalty term has lagrange muliplier or not."""
|
|
105
|
-
return self._with_multiplier
|
|
106
|
-
|
|
107
|
-
@property
|
|
108
|
-
def forall(self):
|
|
109
|
-
return self._forall
|
|
110
|
-
|
|
111
|
-
def children(self):
|
|
112
|
-
return [self.penalty_term]
|
|
113
|
-
|
|
114
|
-
def __repr__(self) -> str:
|
|
115
|
-
return f"Pena({self.label}: {self.penalty_term})"
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
ConstraintConditionType = Union[_condition.Equal, _condition.LessThanEqual]
|
|
119
|
-
ConstraintCondTypeValue = (_condition.Equal, _condition.LessThanEqual)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
class Constraint(metaclass=_serializable.Serializable):
|
|
123
|
-
"""Constraint of optimization model."""
|
|
124
|
-
|
|
125
|
-
def __init__(
|
|
126
|
-
self,
|
|
127
|
-
label: str,
|
|
128
|
-
condition: Union[_expression.Expression, ConstraintConditionType],
|
|
129
|
-
forall: Union[
|
|
130
|
-
_variable.Element,
|
|
131
|
-
Tuple[_variable.Element, Optional[_condition.Condition]],
|
|
132
|
-
List[
|
|
133
|
-
Union[
|
|
134
|
-
_variable.Element,
|
|
135
|
-
Tuple[_variable.Element, Optional[_condition.Condition]],
|
|
136
|
-
]
|
|
137
|
-
],
|
|
138
|
-
] = [],
|
|
139
|
-
with_penalty: bool = True,
|
|
140
|
-
with_multiplier: bool = True,
|
|
141
|
-
left_lower: Union[
|
|
142
|
-
_expression.NumericValue, _expression.Expression, None
|
|
143
|
-
] = None,
|
|
144
|
-
auto_qubo: Optional[bool] = None,
|
|
145
|
-
):
|
|
146
|
-
"""
|
|
147
|
-
Initialize
|
|
148
|
-
|
|
149
|
-
Args:
|
|
150
|
-
label (str): label of consraint
|
|
151
|
-
condition (Union[CompareCondition, Expression]): constraint condition.
|
|
152
|
-
forall (Element | Tuple[Element, Optional[Condition]] | List[Element | Tuple[Element, Optional[Condition]]], optional): forall indices.
|
|
153
|
-
Defaults to [].
|
|
154
|
-
with_penalty (bool, optional): Add constraints as penalty. Defaults to True.
|
|
155
|
-
with_multiplier (bool, optional): prod a multiplier on the penalty term. Defaults to True.
|
|
156
|
-
left_lower: left hand side lower value. usually used for slack variables
|
|
157
|
-
auto_qubo: auto qubo convert.
|
|
158
|
-
|
|
159
|
-
Examples:
|
|
160
|
-
```python
|
|
161
|
-
>>> import jijmodeling as jm
|
|
162
|
-
>>> n = jm.Placeholder("n")
|
|
163
|
-
>>> x = jm.Binary("x", shape=(n, ))
|
|
164
|
-
>>> term = jm.Constraint("const", x[:] == 1)
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
constraint with forall
|
|
168
|
-
|
|
169
|
-
```python
|
|
170
|
-
>>> import jijmodeling as jm
|
|
171
|
-
>>> d = jm.Placeholder("d", dim=1)
|
|
172
|
-
>>> n = d.shape[0]
|
|
173
|
-
>>> x = jm.Binary("x", shape=(n, n))
|
|
174
|
-
>>> i = jm.Element("i", n)
|
|
175
|
-
>>> term = jm.Constraint("const2", x[i, :] == 1, forall=(i, d[i] > 0))
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
Raises:
|
|
179
|
-
TypeError: condition is not `CompareCondition` or `Experssion`.
|
|
180
|
-
ExpressionValiddteError: right hand side has a desicision variable.
|
|
181
|
-
TypeError: `left_lower` is not `numbers.Number` or `Expression`.
|
|
182
|
-
TypeError: forall is not `Element`, `dict`, `tuple` or `list`.
|
|
183
|
-
ExpressionIndexError: The indices have not been reduced and remains. Ex: `Sum(i, x[i,j,k]) == 1, forall=[j]`, In this case "k" is needed in forall.
|
|
184
|
-
ExpressionIndexError: The conditions of indices have inconsistency.
|
|
185
|
-
"""
|
|
186
|
-
|
|
187
|
-
self._label = label
|
|
188
|
-
self._with_penalty = with_penalty
|
|
189
|
-
self._with_multiplier = with_multiplier
|
|
190
|
-
|
|
191
|
-
# auto_qubo setting (automatically disabled if order >= 2 or term is
|
|
192
|
-
# not a Condition)
|
|
193
|
-
import jijmodeling.expression.utils as _utils
|
|
194
|
-
|
|
195
|
-
if isinstance(condition, ConstraintCondTypeValue):
|
|
196
|
-
order = max(
|
|
197
|
-
_utils.get_order(condition.left), _utils.get_order(condition.right)
|
|
198
|
-
)
|
|
199
|
-
if order >= 2 and auto_qubo is None:
|
|
200
|
-
auto_qubo = False
|
|
201
|
-
elif isinstance(condition, _expression.Expression):
|
|
202
|
-
if auto_qubo is None:
|
|
203
|
-
auto_qubo = False
|
|
204
|
-
else:
|
|
205
|
-
raise TypeError(
|
|
206
|
-
"condition of Constraint is <=, == or Expression, not {}.".format(
|
|
207
|
-
condition.__class__.__name__
|
|
208
|
-
)
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
self._auto_qubo: bool = auto_qubo if auto_qubo is not None else True
|
|
212
|
-
|
|
213
|
-
# convert Expression to Condition object
|
|
214
|
-
self._condition: ConstraintConditionType = (
|
|
215
|
-
condition
|
|
216
|
-
if isinstance(condition, _condition.CompareCondition)
|
|
217
|
-
else _condition.Equal(condition, _expression.Number(0))
|
|
218
|
-
)
|
|
219
|
-
|
|
220
|
-
# convert number object to Number object
|
|
221
|
-
self._left_lower: Optional[_expression.Expression] = (
|
|
222
|
-
_expression.Number(left_lower)
|
|
223
|
-
if isinstance(left_lower, (int, float))
|
|
224
|
-
else left_lower
|
|
225
|
-
)
|
|
226
|
-
|
|
227
|
-
# convert forall to list-type object
|
|
228
|
-
forall_list = forall if isinstance(forall, list) else [forall]
|
|
229
|
-
# element type from users
|
|
230
|
-
IndexType = Union[
|
|
231
|
-
_variable.Element, Tuple[_variable.Element, Optional[_condition.Condition]]
|
|
232
|
-
]
|
|
233
|
-
|
|
234
|
-
@typechecked
|
|
235
|
-
def convert_to_element(
|
|
236
|
-
index: IndexType,
|
|
237
|
-
) -> Tuple[_variable.Element, _condition.Condition]:
|
|
238
|
-
if isinstance(index, tuple): # Tuple[ElementType, Condition]
|
|
239
|
-
elem, cond = index
|
|
240
|
-
if cond is not None:
|
|
241
|
-
return (elem, cond)
|
|
242
|
-
else:
|
|
243
|
-
return (elem, _condition.NoneCondition())
|
|
244
|
-
else: # ElementType
|
|
245
|
-
return (index, _condition.NoneCondition())
|
|
246
|
-
|
|
247
|
-
ForallType = List[Tuple[_variable.Element, _condition.Condition]]
|
|
248
|
-
self._forall: ForallType = [convert_to_element(elem) for elem in forall_list]
|
|
249
|
-
|
|
250
|
-
# type validation
|
|
251
|
-
LeftLowerType = Optional[_expression.Expression]
|
|
252
|
-
check_type("self.label", self.label, str)
|
|
253
|
-
check_type("self._condition", self._condition, _condition.CompareCondition)
|
|
254
|
-
check_type("self._forall", self._forall, ForallType)
|
|
255
|
-
check_type("self._with_penalty", self._with_penalty, bool)
|
|
256
|
-
check_type("self._with_multiplier", self._with_multiplier, bool)
|
|
257
|
-
check_type("self._left_lower", self._left_lower, LeftLowerType)
|
|
258
|
-
check_type("self._auto_qubo", self._auto_qubo, bool)
|
|
259
|
-
|
|
260
|
-
import jijmodeling.expression.extract as _extract
|
|
261
|
-
|
|
262
|
-
if isinstance(self._left_lower, _expression.Expression):
|
|
263
|
-
if _extract.has_decivar(self._left_lower):
|
|
264
|
-
raise _exceptions.CannotContainDecisionVarError(
|
|
265
|
-
"You cannot include decision variables in left_lower."
|
|
266
|
-
)
|
|
267
|
-
|
|
268
|
-
# check forall index reduction
|
|
269
|
-
indices = _utils.condition_indices(self._condition)
|
|
270
|
-
forall_labels = [index[0].label for index in self._forall]
|
|
271
|
-
for index in indices:
|
|
272
|
-
if index.label not in forall_labels:
|
|
273
|
-
raise _exceptions.ExpressionIndexError(
|
|
274
|
-
"Constraint cannot have unreducted subscripts."
|
|
275
|
-
+ " Please check your formulation or"
|
|
276
|
-
+ f" use forall to reduct index '{index.label}'."
|
|
277
|
-
)
|
|
278
|
-
# condition index check
|
|
279
|
-
# 添字に対する条件に入る添字間の依存性に矛盾がないようにする
|
|
280
|
-
# 例えば [(i, i < j), j] は j が外のループで処理されるので良いが,
|
|
281
|
-
# [j, (i, i < j)] は jが内側のループで処理されるのでダメ.
|
|
282
|
-
for i, (_, cond) in enumerate(self._forall):
|
|
283
|
-
if isinstance(cond, _condition.NoneCondition):
|
|
284
|
-
continue
|
|
285
|
-
cond_indices = _utils.condition_indices(cond)
|
|
286
|
-
for ind in cond_indices:
|
|
287
|
-
# 条件に含まれている添字が内側のforallに含まれているか確認する
|
|
288
|
-
if not (ind.label in forall_labels[: i + 1]):
|
|
289
|
-
raise _exceptions.ExpressionIndexError(
|
|
290
|
-
"Check the conditions you are including in forall. There is a discrepancy in the subscript dependency."
|
|
291
|
-
)
|
|
292
|
-
|
|
293
|
-
@property
|
|
294
|
-
def label(self) -> str:
|
|
295
|
-
return self._label
|
|
296
|
-
|
|
297
|
-
@property
|
|
298
|
-
def condition(self) -> ConstraintConditionType:
|
|
299
|
-
return self._condition
|
|
300
|
-
|
|
301
|
-
@property
|
|
302
|
-
def term(
|
|
303
|
-
self,
|
|
304
|
-
) -> Union[_condition.Equal, _condition.LessThanEqual, _condition.LessThan]:
|
|
305
|
-
return self.condition
|
|
306
|
-
|
|
307
|
-
@property
|
|
308
|
-
def with_penalty(self) -> bool:
|
|
309
|
-
return self._with_penalty
|
|
310
|
-
|
|
311
|
-
@property
|
|
312
|
-
def with_multiplier(self) -> bool:
|
|
313
|
-
return self._with_multiplier
|
|
314
|
-
|
|
315
|
-
@property
|
|
316
|
-
def forall(self) -> List[Tuple[_variable.Element, _condition.Condition]]:
|
|
317
|
-
return self._forall
|
|
318
|
-
|
|
319
|
-
@property
|
|
320
|
-
def left_lower(self) -> Optional[_expression.Expression]:
|
|
321
|
-
return self._left_lower
|
|
322
|
-
|
|
323
|
-
@property
|
|
324
|
-
def auto_qubo(self):
|
|
325
|
-
return self._auto_qubo
|
|
326
|
-
|
|
327
|
-
def _forall_to_sum(self, expression):
|
|
328
|
-
indices = self.forall[::-1]
|
|
329
|
-
if indices is None:
|
|
330
|
-
return expression
|
|
331
|
-
term = expression
|
|
332
|
-
for i, index in enumerate(indices):
|
|
333
|
-
if index is None:
|
|
334
|
-
return expression
|
|
335
|
-
cond = indices[i][1]
|
|
336
|
-
term = _sum.Sum((index[0], cond), term)
|
|
337
|
-
return term
|
|
338
|
-
|
|
339
|
-
def __repr__(self):
|
|
340
|
-
return "Cons(" + self.label + ")[" + str(self.condition) + "]"
|