jijmodeling 0.13.1__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.

Files changed (234) hide show
  1. jijmodeling/__init__.py +1 -154
  2. jijmodeling/__init__.pyi +5152 -0
  3. jijmodeling/_jijmodeling.cp39-win_amd64.pyd +0 -0
  4. jijmodeling/dataset.py +5 -0
  5. jijmodeling/dataset.pyi +106 -0
  6. jijmodeling/experimental.py +13 -0
  7. jijmodeling/experimental.pyi +302 -0
  8. jijmodeling/py.typed +0 -0
  9. jijmodeling/range/__init__.py +14 -0
  10. jijmodeling/range/__init__.pyi +56 -0
  11. jijmodeling/range/size.py +14 -0
  12. jijmodeling/range/size.pyi +54 -0
  13. jijmodeling/range/value.py +14 -0
  14. jijmodeling/range/value.pyi +54 -0
  15. jijmodeling-1.11.0.dist-info/METADATA +235 -0
  16. jijmodeling-1.11.0.dist-info/RECORD +18 -0
  17. {jijmodeling-0.13.1.dist-info → jijmodeling-1.11.0.dist-info}/WHEEL +1 -2
  18. {jijmodeling-0.13.1.dist-info → jijmodeling-1.11.0.dist-info/licenses}/LICENSE.txt +1 -1
  19. jijmodeling/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
  20. jijmodeling/__pycache__/__init__.cpython-39.pyc +0 -0
  21. jijmodeling/__pycache__/_version.cpython-39.opt-1.pyc +0 -0
  22. jijmodeling/__pycache__/_version.cpython-39.pyc +0 -0
  23. jijmodeling/_version.py +0 -4
  24. jijmodeling/deprecation/__init__.py +0 -11
  25. jijmodeling/deprecation/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
  26. jijmodeling/deprecation/__pycache__/__init__.cpython-39.pyc +0 -0
  27. jijmodeling/deprecation/__pycache__/deprecation.cpython-39.opt-1.pyc +0 -0
  28. jijmodeling/deprecation/__pycache__/deprecation.cpython-39.pyc +0 -0
  29. jijmodeling/deprecation/deprecation.py +0 -108
  30. jijmodeling/exceptions/__init__.py +0 -26
  31. jijmodeling/exceptions/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
  32. jijmodeling/exceptions/__pycache__/__init__.cpython-39.pyc +0 -0
  33. jijmodeling/exceptions/__pycache__/exceptions.cpython-39.opt-1.pyc +0 -0
  34. jijmodeling/exceptions/__pycache__/exceptions.cpython-39.pyc +0 -0
  35. jijmodeling/exceptions/exceptions.py +0 -37
  36. jijmodeling/expression/__init__.py +0 -76
  37. jijmodeling/expression/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
  38. jijmodeling/expression/__pycache__/__init__.cpython-39.pyc +0 -0
  39. jijmodeling/expression/__pycache__/condition.cpython-39.opt-1.pyc +0 -0
  40. jijmodeling/expression/__pycache__/condition.cpython-39.pyc +0 -0
  41. jijmodeling/expression/__pycache__/constraint.cpython-39.opt-1.pyc +0 -0
  42. jijmodeling/expression/__pycache__/constraint.cpython-39.pyc +0 -0
  43. jijmodeling/expression/__pycache__/expression.cpython-39.opt-1.pyc +0 -0
  44. jijmodeling/expression/__pycache__/expression.cpython-39.pyc +0 -0
  45. jijmodeling/expression/__pycache__/extract.cpython-39.opt-1.pyc +0 -0
  46. jijmodeling/expression/__pycache__/extract.cpython-39.pyc +0 -0
  47. jijmodeling/expression/__pycache__/from_old_serializable.cpython-39.opt-1.pyc +0 -0
  48. jijmodeling/expression/__pycache__/from_old_serializable.cpython-39.pyc +0 -0
  49. jijmodeling/expression/__pycache__/mathfunc.cpython-39.opt-1.pyc +0 -0
  50. jijmodeling/expression/__pycache__/mathfunc.cpython-39.pyc +0 -0
  51. jijmodeling/expression/__pycache__/prod.cpython-39.opt-1.pyc +0 -0
  52. jijmodeling/expression/__pycache__/prod.cpython-39.pyc +0 -0
  53. jijmodeling/expression/__pycache__/serializable.cpython-39.opt-1.pyc +0 -0
  54. jijmodeling/expression/__pycache__/serializable.cpython-39.pyc +0 -0
  55. jijmodeling/expression/__pycache__/sum.cpython-39.opt-1.pyc +0 -0
  56. jijmodeling/expression/__pycache__/sum.cpython-39.pyc +0 -0
  57. jijmodeling/expression/__pycache__/type_annotations.cpython-39.opt-1.pyc +0 -0
  58. jijmodeling/expression/__pycache__/type_annotations.cpython-39.pyc +0 -0
  59. jijmodeling/expression/__pycache__/utils.cpython-39.opt-1.pyc +0 -0
  60. jijmodeling/expression/__pycache__/utils.cpython-39.pyc +0 -0
  61. jijmodeling/expression/condition.py +0 -378
  62. jijmodeling/expression/constraint.py +0 -428
  63. jijmodeling/expression/expression.py +0 -768
  64. jijmodeling/expression/extract.py +0 -186
  65. jijmodeling/expression/from_old_serializable.py +0 -137
  66. jijmodeling/expression/mathfunc.py +0 -335
  67. jijmodeling/expression/prod.py +0 -172
  68. jijmodeling/expression/serializable.py +0 -142
  69. jijmodeling/expression/sum.py +0 -261
  70. jijmodeling/expression/type_annotations.py +0 -50
  71. jijmodeling/expression/utils.py +0 -202
  72. jijmodeling/expression/variables/__init__.py +0 -39
  73. jijmodeling/expression/variables/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
  74. jijmodeling/expression/variables/__pycache__/__init__.cpython-39.pyc +0 -0
  75. jijmodeling/expression/variables/__pycache__/deci_vars.cpython-39.opt-1.pyc +0 -0
  76. jijmodeling/expression/variables/__pycache__/deci_vars.cpython-39.pyc +0 -0
  77. jijmodeling/expression/variables/__pycache__/jagged_array.cpython-39.opt-1.pyc +0 -0
  78. jijmodeling/expression/variables/__pycache__/jagged_array.cpython-39.pyc +0 -0
  79. jijmodeling/expression/variables/__pycache__/placeholders.cpython-39.opt-1.pyc +0 -0
  80. jijmodeling/expression/variables/__pycache__/placeholders.cpython-39.pyc +0 -0
  81. jijmodeling/expression/variables/__pycache__/variable.cpython-39.opt-1.pyc +0 -0
  82. jijmodeling/expression/variables/__pycache__/variable.cpython-39.pyc +0 -0
  83. jijmodeling/expression/variables/deci_vars.py +0 -212
  84. jijmodeling/expression/variables/jagged_array.py +0 -81
  85. jijmodeling/expression/variables/placeholders.py +0 -132
  86. jijmodeling/expression/variables/variable.py +0 -524
  87. jijmodeling/latex_repr/__init__.py +0 -11
  88. jijmodeling/latex_repr/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
  89. jijmodeling/latex_repr/__pycache__/__init__.cpython-39.pyc +0 -0
  90. jijmodeling/latex_repr/__pycache__/latex_repr.cpython-39.opt-1.pyc +0 -0
  91. jijmodeling/latex_repr/__pycache__/latex_repr.cpython-39.pyc +0 -0
  92. jijmodeling/latex_repr/__pycache__/problem_latex_repr.cpython-39.opt-1.pyc +0 -0
  93. jijmodeling/latex_repr/__pycache__/problem_latex_repr.cpython-39.pyc +0 -0
  94. jijmodeling/latex_repr/latex_repr.py +0 -243
  95. jijmodeling/latex_repr/problem_latex_repr.py +0 -210
  96. jijmodeling/marker/__marker__.cp39-win_amd64.pyd +0 -0
  97. jijmodeling/match/__init__.py +0 -19
  98. jijmodeling/match/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
  99. jijmodeling/match/__pycache__/__init__.cpython-39.pyc +0 -0
  100. jijmodeling/match/__pycache__/condition_same.cpython-39.opt-1.pyc +0 -0
  101. jijmodeling/match/__pycache__/condition_same.cpython-39.pyc +0 -0
  102. jijmodeling/match/__pycache__/constraint_same.cpython-39.opt-1.pyc +0 -0
  103. jijmodeling/match/__pycache__/constraint_same.cpython-39.pyc +0 -0
  104. jijmodeling/match/__pycache__/expand.cpython-39.opt-1.pyc +0 -0
  105. jijmodeling/match/__pycache__/expand.cpython-39.pyc +0 -0
  106. jijmodeling/match/__pycache__/expr_same.cpython-39.opt-1.pyc +0 -0
  107. jijmodeling/match/__pycache__/expr_same.cpython-39.pyc +0 -0
  108. jijmodeling/match/__pycache__/is_same_expr.cpython-39.opt-1.pyc +0 -0
  109. jijmodeling/match/__pycache__/is_same_expr.cpython-39.pyc +0 -0
  110. jijmodeling/match/__pycache__/penalty_same.cpython-39.opt-1.pyc +0 -0
  111. jijmodeling/match/__pycache__/penalty_same.cpython-39.pyc +0 -0
  112. jijmodeling/match/__pycache__/problem_same.cpython-39.opt-1.pyc +0 -0
  113. jijmodeling/match/__pycache__/problem_same.cpython-39.pyc +0 -0
  114. jijmodeling/match/__pycache__/replace.cpython-39.opt-1.pyc +0 -0
  115. jijmodeling/match/__pycache__/replace.cpython-39.pyc +0 -0
  116. jijmodeling/match/condition_same.py +0 -44
  117. jijmodeling/match/constraint_same.py +0 -53
  118. jijmodeling/match/expand.py +0 -84
  119. jijmodeling/match/expr_same.py +0 -32
  120. jijmodeling/match/is_same_expr.py +0 -306
  121. jijmodeling/match/penalty_same.py +0 -31
  122. jijmodeling/match/problem_same.py +0 -44
  123. jijmodeling/match/replace.py +0 -249
  124. jijmodeling/problem/__init__.py +0 -9
  125. jijmodeling/problem/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
  126. jijmodeling/problem/__pycache__/__init__.cpython-39.pyc +0 -0
  127. jijmodeling/problem/__pycache__/problem.cpython-39.opt-1.pyc +0 -0
  128. jijmodeling/problem/__pycache__/problem.cpython-39.pyc +0 -0
  129. jijmodeling/problem/problem.py +0 -186
  130. jijmodeling/protobuf/__init__.py +0 -8
  131. jijmodeling/protobuf/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
  132. jijmodeling/protobuf/__pycache__/__init__.cpython-39.pyc +0 -0
  133. jijmodeling/protobuf/__pycache__/from_protobuf.cpython-39.opt-1.pyc +0 -0
  134. jijmodeling/protobuf/__pycache__/from_protobuf.cpython-39.pyc +0 -0
  135. jijmodeling/protobuf/__pycache__/to_protobuf.cpython-39.opt-1.pyc +0 -0
  136. jijmodeling/protobuf/__pycache__/to_protobuf.cpython-39.pyc +0 -0
  137. jijmodeling/protobuf/__pycache__/type_annotations.cpython-39.opt-1.pyc +0 -0
  138. jijmodeling/protobuf/__pycache__/type_annotations.cpython-39.pyc +0 -0
  139. jijmodeling/protobuf/from_protobuf.py +0 -336
  140. jijmodeling/protobuf/pb2/__init__.py +0 -42
  141. jijmodeling/protobuf/pb2/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
  142. jijmodeling/protobuf/pb2/__pycache__/__init__.cpython-39.pyc +0 -0
  143. jijmodeling/protobuf/pb2/__pycache__/array_length_pb2.cpython-39.opt-1.pyc +0 -0
  144. jijmodeling/protobuf/pb2/__pycache__/array_length_pb2.cpython-39.pyc +0 -0
  145. jijmodeling/protobuf/pb2/__pycache__/binary_op_pb2.cpython-39.opt-1.pyc +0 -0
  146. jijmodeling/protobuf/pb2/__pycache__/binary_op_pb2.cpython-39.pyc +0 -0
  147. jijmodeling/protobuf/pb2/__pycache__/commutative_op_pb2.cpython-39.opt-1.pyc +0 -0
  148. jijmodeling/protobuf/pb2/__pycache__/commutative_op_pb2.cpython-39.pyc +0 -0
  149. jijmodeling/protobuf/pb2/__pycache__/constraint_pb2.cpython-39.opt-1.pyc +0 -0
  150. jijmodeling/protobuf/pb2/__pycache__/constraint_pb2.cpython-39.pyc +0 -0
  151. jijmodeling/protobuf/pb2/__pycache__/custom_penalty_term_pb2.cpython-39.opt-1.pyc +0 -0
  152. jijmodeling/protobuf/pb2/__pycache__/custom_penalty_term_pb2.cpython-39.pyc +0 -0
  153. jijmodeling/protobuf/pb2/__pycache__/decision_var_pb2.cpython-39.opt-1.pyc +0 -0
  154. jijmodeling/protobuf/pb2/__pycache__/decision_var_pb2.cpython-39.pyc +0 -0
  155. jijmodeling/protobuf/pb2/__pycache__/element_pb2.cpython-39.opt-1.pyc +0 -0
  156. jijmodeling/protobuf/pb2/__pycache__/element_pb2.cpython-39.pyc +0 -0
  157. jijmodeling/protobuf/pb2/__pycache__/expression_pb2.cpython-39.opt-1.pyc +0 -0
  158. jijmodeling/protobuf/pb2/__pycache__/expression_pb2.cpython-39.pyc +0 -0
  159. jijmodeling/protobuf/pb2/__pycache__/forall_pb2.cpython-39.opt-1.pyc +0 -0
  160. jijmodeling/protobuf/pb2/__pycache__/forall_pb2.cpython-39.pyc +0 -0
  161. jijmodeling/protobuf/pb2/__pycache__/header_pb2.cpython-39.opt-1.pyc +0 -0
  162. jijmodeling/protobuf/pb2/__pycache__/header_pb2.cpython-39.pyc +0 -0
  163. jijmodeling/protobuf/pb2/__pycache__/index_pb2.cpython-39.opt-1.pyc +0 -0
  164. jijmodeling/protobuf/pb2/__pycache__/index_pb2.cpython-39.pyc +0 -0
  165. jijmodeling/protobuf/pb2/__pycache__/number_lit_pb2.cpython-39.opt-1.pyc +0 -0
  166. jijmodeling/protobuf/pb2/__pycache__/number_lit_pb2.cpython-39.pyc +0 -0
  167. jijmodeling/protobuf/pb2/__pycache__/placeholder_pb2.cpython-39.opt-1.pyc +0 -0
  168. jijmodeling/protobuf/pb2/__pycache__/placeholder_pb2.cpython-39.pyc +0 -0
  169. jijmodeling/protobuf/pb2/__pycache__/problem_pb2.cpython-39.opt-1.pyc +0 -0
  170. jijmodeling/protobuf/pb2/__pycache__/problem_pb2.cpython-39.pyc +0 -0
  171. jijmodeling/protobuf/pb2/__pycache__/reduction_op_pb2.cpython-39.opt-1.pyc +0 -0
  172. jijmodeling/protobuf/pb2/__pycache__/reduction_op_pb2.cpython-39.pyc +0 -0
  173. jijmodeling/protobuf/pb2/__pycache__/subscript_pb2.cpython-39.opt-1.pyc +0 -0
  174. jijmodeling/protobuf/pb2/__pycache__/subscript_pb2.cpython-39.pyc +0 -0
  175. jijmodeling/protobuf/pb2/__pycache__/unary_op_pb2.cpython-39.opt-1.pyc +0 -0
  176. jijmodeling/protobuf/pb2/__pycache__/unary_op_pb2.cpython-39.pyc +0 -0
  177. jijmodeling/protobuf/pb2/array_length_pb2.py +0 -27
  178. jijmodeling/protobuf/pb2/binary_op_pb2.py +0 -27
  179. jijmodeling/protobuf/pb2/commutative_op_pb2.py +0 -27
  180. jijmodeling/protobuf/pb2/constraint_pb2.py +0 -31
  181. jijmodeling/protobuf/pb2/custom_penalty_term_pb2.py +0 -31
  182. jijmodeling/protobuf/pb2/decision_var_pb2.py +0 -31
  183. jijmodeling/protobuf/pb2/element_pb2.py +0 -31
  184. jijmodeling/protobuf/pb2/expression_pb2.py +0 -39
  185. jijmodeling/protobuf/pb2/forall_pb2.py +0 -29
  186. jijmodeling/protobuf/pb2/header_pb2.py +0 -31
  187. jijmodeling/protobuf/pb2/index_pb2.py +0 -25
  188. jijmodeling/protobuf/pb2/number_lit_pb2.py +0 -27
  189. jijmodeling/protobuf/pb2/placeholder_pb2.py +0 -25
  190. jijmodeling/protobuf/pb2/problem_pb2.py +0 -40
  191. jijmodeling/protobuf/pb2/reduction_op_pb2.py +0 -30
  192. jijmodeling/protobuf/pb2/subscript_pb2.py +0 -27
  193. jijmodeling/protobuf/pb2/unary_op_pb2.py +0 -27
  194. jijmodeling/protobuf/to_protobuf.py +0 -631
  195. jijmodeling/protobuf/type_annotations.py +0 -52
  196. jijmodeling/sampleset/__init__.py +0 -33
  197. jijmodeling/sampleset/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
  198. jijmodeling/sampleset/__pycache__/__init__.cpython-39.pyc +0 -0
  199. jijmodeling/sampleset/__pycache__/evaluation.cpython-39.opt-1.pyc +0 -0
  200. jijmodeling/sampleset/__pycache__/evaluation.cpython-39.pyc +0 -0
  201. jijmodeling/sampleset/__pycache__/measuring_time.cpython-39.opt-1.pyc +0 -0
  202. jijmodeling/sampleset/__pycache__/measuring_time.cpython-39.pyc +0 -0
  203. jijmodeling/sampleset/__pycache__/record.cpython-39.opt-1.pyc +0 -0
  204. jijmodeling/sampleset/__pycache__/record.cpython-39.pyc +0 -0
  205. jijmodeling/sampleset/__pycache__/sampleset.cpython-39.opt-1.pyc +0 -0
  206. jijmodeling/sampleset/__pycache__/sampleset.cpython-39.pyc +0 -0
  207. jijmodeling/sampleset/__pycache__/solving_time.cpython-39.opt-1.pyc +0 -0
  208. jijmodeling/sampleset/__pycache__/solving_time.cpython-39.pyc +0 -0
  209. jijmodeling/sampleset/__pycache__/system_time.cpython-39.opt-1.pyc +0 -0
  210. jijmodeling/sampleset/__pycache__/system_time.cpython-39.pyc +0 -0
  211. jijmodeling/sampleset/evaluation.py +0 -289
  212. jijmodeling/sampleset/measuring_time.py +0 -59
  213. jijmodeling/sampleset/record.py +0 -158
  214. jijmodeling/sampleset/sampleset.py +0 -389
  215. jijmodeling/sampleset/solving_time.py +0 -38
  216. jijmodeling/sampleset/system_time.py +0 -48
  217. jijmodeling/type_annotations/__init__.py +0 -44
  218. jijmodeling/type_annotations/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
  219. jijmodeling/type_annotations/__pycache__/__init__.cpython-39.pyc +0 -0
  220. jijmodeling/type_annotations/__pycache__/type_annotations.cpython-39.opt-1.pyc +0 -0
  221. jijmodeling/type_annotations/__pycache__/type_annotations.cpython-39.pyc +0 -0
  222. jijmodeling/type_annotations/type_annotations.py +0 -54
  223. jijmodeling/utils/__init__.py +0 -28
  224. jijmodeling/utils/__pycache__/__init__.cpython-39.opt-1.pyc +0 -0
  225. jijmodeling/utils/__pycache__/__init__.cpython-39.pyc +0 -0
  226. jijmodeling/utils/__pycache__/deprecated.cpython-39.opt-1.pyc +0 -0
  227. jijmodeling/utils/__pycache__/deprecated.cpython-39.pyc +0 -0
  228. jijmodeling/utils/__pycache__/utils.cpython-39.opt-1.pyc +0 -0
  229. jijmodeling/utils/__pycache__/utils.cpython-39.pyc +0 -0
  230. jijmodeling/utils/deprecated.py +0 -17
  231. jijmodeling/utils/utils.py +0 -146
  232. jijmodeling-0.13.1.dist-info/METADATA +0 -60
  233. jijmodeling-0.13.1.dist-info/RECORD +0 -219
  234. jijmodeling-0.13.1.dist-info/top_level.txt +0 -1
@@ -1,524 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import typing as tp
4
- import warnings
5
-
6
- from uuid import uuid4
7
-
8
- from typeguard import check_type
9
-
10
- from jijmodeling.deprecation.deprecation import (
11
- deprecated_kwargs,
12
- JijFutureWarning
13
- )
14
- import jijmodeling.exceptions.exceptions as _exceptions
15
- import jijmodeling.expression.expression as _expression
16
- import jijmodeling.expression.serializable as _serializable
17
- import jijmodeling.expression.type_annotations as _type_annotations
18
-
19
- if tp.TYPE_CHECKING:
20
- import jijmodeling.expression.sum as _sum
21
-
22
-
23
- def type_check_bool(value, cls) -> bool:
24
- """
25
- Do a type_check_and returns whether the validation succeeds or not.
26
-
27
- Args:
28
- value: value to be validated
29
- cls: type
30
-
31
- Returns:
32
- bool: return if `value` matches the `cls` type.
33
- """
34
- try:
35
- check_type(value, cls)
36
- except TypeError:
37
- return False
38
- else:
39
- check_type(value, cls)
40
-
41
- return True
42
-
43
-
44
- class Variable(_expression.Expression):
45
- """Abstract class for variables."""
46
-
47
- def __init__(
48
- self,
49
- label: str,
50
- shape: tp.Union[
51
- tp.Tuple[_type_annotations.ShapeElemInputType, ...],
52
- tp.List[_type_annotations.ShapeElemInputType],
53
- _type_annotations.ShapeElemInputType,
54
- ] = tuple([]),
55
- uuid: tp.Optional[str] = None,
56
- ):
57
- super().__init__(uuid=uuid)
58
- self._label = label
59
-
60
- # convert list to tuple
61
- _shape: tp.Tuple[tp.Optional[_type_annotations.ShapeElementType], ...]
62
- if isinstance(shape, (list, tuple)):
63
- _shape_list: tp.List[tp.Optional[_expression.Expression]] = []
64
- for s in shape:
65
- if s is None:
66
- _shape_list.append(s)
67
- elif isinstance(s, _expression.Expression):
68
- _shape_list.append(s)
69
- elif type_check_bool(s, _expression.NumericValue):
70
- _shape_list.append(_expression.Number(int(s), dtype="int"))
71
- else:
72
- raise TypeError("shape is Expression or int.")
73
- _shape = tuple(_shape_list) # type: ignore
74
- elif shape is None:
75
- _shape = (None,)
76
- else:
77
- _shape = (_expression._numeric_to_expression(shape),)
78
-
79
- from jijmodeling.expression.variables.placeholders import ArrayShape
80
-
81
- _shape_value: tp.List[_type_annotations.ShapeElementType] = []
82
- for d, s in enumerate(_shape):
83
- if s is None:
84
- _shape_value.append(ArrayShape(self, d))
85
- else:
86
- _shape_value.append(s)
87
-
88
- self._shape_without_none = tuple(_shape_value)
89
-
90
- # The _shape should contain "None" to avoid circular references when serializing.
91
- # When serializing, "._shape" is referenced before "@property shape",
92
- # so this way we can avoid the problem of circular references.
93
- self._shape = _shape # _shape attributes is for .children.
94
-
95
- import jijmodeling.expression.utils as _utils
96
-
97
- _utils.check_non_decision_variable(
98
- self._shape_without_none,
99
- "The shape cannot contain any decision variables. Check the shape of `{}`.".format(
100
- label
101
- ),
102
- )
103
-
104
- self._dummy_elements_id = [uuid4().hex for _ in range(self.dim)]
105
-
106
- @property
107
- def label(self) -> str:
108
- return self._label
109
-
110
- @property
111
- def name(self) -> str:
112
- return self._label
113
-
114
- @property
115
- def shape(self) -> tp.Tuple[_type_annotations.ShapeElementType, ...]:
116
- return tuple(self._shape_without_none)
117
-
118
- @property
119
- def dim(self) -> int:
120
- return len(self.shape)
121
-
122
- @property
123
- def ndim(self) -> int:
124
- return len(self.shape)
125
-
126
- def __repr__(self) -> str:
127
- return self.label
128
-
129
- def is_operatable(self) -> bool:
130
- return self.dim == 0
131
-
132
- def children(self) -> tp.List[_expression.Expression]:
133
- return [s for s in self._shape if s is not None]
134
-
135
- def __getitem__(
136
- self,
137
- key: tp.Union[
138
- _type_annotations.SubscriptElemInputType,
139
- tp.List[tp.Union[slice, _type_annotations.SubscriptElemInputType]],
140
- tp.Tuple[tp.Union[slice, _type_annotations.SubscriptElemInputType], ...],
141
- ],
142
- ) -> tp.Union[Subscripts, _sum.SumOperator]:
143
- """
144
- `[]` operator for adding subscripts if the user specifies str for the.
145
-
146
- argument which is available for previous versions of JijModeling
147
- (<=0.8.14), This function throws an error.
148
-
149
- Args:
150
- key : subscripts
151
-
152
- Raises:
153
- ModelingError: If there is a discrepancy between the dimension of the variable and the number of subscripts added.
154
- TypeError: key type check.
155
-
156
- Returns:
157
- Subscripted variable.
158
- """
159
- key_tuple: tp.Tuple[tp.Union[slice, _expression.Expression, int], ...]
160
- if isinstance(key, list):
161
- key_tuple = tuple(key)
162
- elif isinstance(key, (_expression.Expression, slice, int)):
163
- key_tuple = (key,)
164
- elif isinstance(key, tuple):
165
- key_tuple = key
166
- else:
167
- raise TypeError(
168
- "key is tp.List[Expression] or tp.Tuple[Expression] or Expression. not {}.".format(
169
- key.__class__.__name__
170
- )
171
- )
172
-
173
- if self.dim < len(key_tuple):
174
- raise _exceptions.ModelingError(
175
- "{} is {}-dimentional array, not {}-dim.".format(
176
- self, self.dim, len(key_tuple)
177
- )
178
- )
179
-
180
- subscripts: tp.List[_type_annotations.SubscriptElementType] = []
181
- summation_index: tp.List[Element] = []
182
- for i, k in enumerate(key_tuple):
183
- key_element: _expression.Expression
184
- if isinstance(k, slice):
185
- # syntax sugar
186
- # x[:] => Sum({':x_0': x.shape[0]}, x[':x_0'])
187
-
188
- subscripted_var = Subscripts(self, subscripts=subscripts[:i])
189
- element_set: _type_annotations.ShapeElementType = subscripted_var.shape[
190
- 0
191
- ]
192
- with warnings.catch_warnings():
193
- warnings.simplefilter("ignore", category=JijFutureWarning)
194
- sum_element = Element(
195
- f":{self.label}_{i}", belong_to=element_set, uuid=self._dummy_elements_id[i]
196
- ).set_latex(rf"\bar{{i}}_{{{str(i)}}}")
197
- summation_index.append(sum_element)
198
- key_element = sum_element
199
- elif isinstance(k, _expression.Expression):
200
- key_element = k
201
- elif isinstance(k, int):
202
- key_element = _expression.Number(k, dtype="int")
203
- else:
204
- raise TypeError(
205
- "subscripts of {} is ".format(k)
206
- + "`int` or `Expression`, not {}.".format(type(k))
207
- )
208
- subscripts.append(key_element)
209
-
210
- variable: tp.Union[_sum.SumOperator, Subscripts] = Subscripts(
211
- self, subscripts=subscripts
212
- )
213
- import jijmodeling.expression.sum as _sum
214
-
215
- for index in summation_index:
216
- variable = _sum.sum(index, variable)
217
- return variable
218
-
219
- def __hash__(self) -> int:
220
- return hash(self.label) + self.uuid.__hash__()
221
-
222
-
223
- class Subscripts(_expression.Expression):
224
- def __init__(
225
- self,
226
- variable: Variable,
227
- subscripts: tp.List[_type_annotations.SubscriptElementType],
228
- uuid: tp.Optional[str] = None,
229
- ):
230
- super().__init__(uuid=uuid)
231
-
232
- self._variable = variable
233
- self._subscripts = subscripts
234
-
235
- from jijmodeling.expression.type_annotations import SubscriptElementType
236
- from jijmodeling.expression.utils import check_non_decision_variable
237
-
238
- check_type(subscripts, tp.List[SubscriptElementType])
239
- check_non_decision_variable(
240
- subscripts,
241
- "The subscripts cannot contain any decision variables. Check the shape of `{}`.".format(
242
- variable.label
243
- ),
244
- )
245
- for index in subscripts:
246
- if not index.is_operatable():
247
- raise _exceptions.ModelingError(
248
- f"subscripts is operatable. `{index}` is not operatable (scalar) in which {self}. check the dimension of `{index}`."
249
- )
250
-
251
- @property
252
- def variable(self) -> Variable:
253
- return self._variable
254
-
255
- @property
256
- def subscripts(self) -> tp.List[_type_annotations.SubscriptElementType]:
257
- return self._subscripts
258
-
259
- @property
260
- def label(self):
261
- return self._variable.label
262
-
263
- def children(self) -> tp.List[_expression.Expression]:
264
- var_list: tp.List[_expression.Expression] = [self.variable]
265
- # type: ignore
266
- subscripts: tp.List[_expression.Expression] = self.subscripts
267
- return var_list + subscripts
268
-
269
- def is_operatable(self) -> bool:
270
- """
271
- Check scalar or not.
272
-
273
- If the subscripts are specified as many times as the dimension of the variable,
274
- the Subscripts object is 'operatable' because it is a scalar.
275
-
276
- Returns:
277
- bool: is operatable or not.
278
- """
279
- return self.variable.dim == len(self.subscripts)
280
-
281
- @property
282
- def shape(self):
283
- import jijmodeling.expression.variables.jagged_array as _jagged_array
284
-
285
- if isinstance(self.variable, _jagged_array.JaggedArray):
286
- import jijmodeling.expression.variables.placeholders as _placeholders
287
-
288
- return (_placeholders.ArrayShape(self, dimension=0),)
289
- else:
290
- return self.variable.shape[len(self.subscripts) :]
291
-
292
- @property
293
- def dim(self) -> int:
294
- return self.variable.dim - len(self.subscripts)
295
-
296
- def __repr__(self) -> str:
297
- subs = ",".join([str(s) for s in self.subscripts])
298
- repr_str: str = self.label + "[" + subs + "]"
299
- return repr_str
300
-
301
- def __getitem__(
302
- self,
303
- key: tp.Union[
304
- _type_annotations.SubscriptElemInputType,
305
- tp.List[tp.Union[slice, _type_annotations.SubscriptElemInputType]],
306
- tp.Tuple[tp.Union[slice, _type_annotations.SubscriptElemInputType], ...],
307
- ],
308
- ) -> tp.Union["Subscripts", _sum.SumOperator]:
309
- """
310
- Overload `[]` operator for adding subscripts if the user specifies str.
311
-
312
- for the argument which is available for previous versions of
313
- JijModeling (<=0.8.14), This function throws an error.
314
-
315
- Args:
316
- key : subscripts
317
-
318
- Raises:
319
- TypeError: key type check.
320
-
321
- Returns:
322
- Subscripted variable.
323
- """
324
-
325
- # convert to list
326
- key_list: tp.List[_type_annotations.SubscriptElemInputType]
327
- if isinstance(key, list):
328
- key_list = key
329
- elif isinstance(key, (_expression.Expression, slice)):
330
- key_list = [key]
331
- elif isinstance(key, int):
332
- key_list = [_expression.Number(key)]
333
- elif isinstance(key, tuple):
334
- key_list = list(key)
335
- else:
336
- raise TypeError(
337
- "key is tp.List[Expression] or tp.Tuple[Expression] or Expression. not {}.".format(
338
- key.__class__.__name__
339
- )
340
- )
341
-
342
- # concat subscripts
343
- concat_subs: tp.List[tp.Union[slice, _expression.Expression, int]] = (
344
- self.subscripts + key_list
345
- ) # type: ignore
346
- return self.variable[concat_subs]
347
-
348
-
349
- class Element(Variable):
350
- @tp.overload
351
- def __init__(
352
- self,
353
- name: str,
354
- *,
355
- belong_to,
356
- ): ...
357
-
358
- @deprecated_kwargs(
359
- name="Element",
360
- pos_len=1,
361
- changes={"label":"name", "parent":"belong_to"},
362
- removes=["uuid"]
363
- )
364
- def __init__(self, label: str, parent, uuid: tp.Optional[str] = None):
365
- """
366
- Element object.
367
-
368
- Args:
369
- label (str): variable label
370
- parent (tp.Union[tp.Tuple[tp.Union[int, Expression], tp.Union[int, Expression]], Expression, int, Range]): parent of element
371
-
372
- Examples:
373
- ```python
374
- >>> import jijmodeling as jm
375
- >>> n = jm.Placeholder("n")
376
- >>> i = jm.Element("i", belong_to=n)
377
- >>> i.belong_to
378
- (0, n)
379
- >>> jm.Element("i", belong_to=(1, n)).belong_to
380
- (1, n)
381
- >>> V = jm.Placeholder("V")
382
- >>> i = jm.Element("i", belong_to=V) # represents i in V
383
- >>> i.belong_to
384
- V
385
- ````
386
- """
387
- if isinstance(parent, tuple):
388
- self._parent: tp.Union[Range, Variable] = Range(parent[0], parent[1])
389
- elif isinstance(parent, _expression.Expression):
390
- if parent.is_operatable():
391
- # operatable means belong_to is scalar.
392
- self._parent = Range(start=0, last=parent)
393
- else:
394
- # belong_to is not scalar. ex. i in V
395
- self._parent = parent # type: ignore
396
- elif isinstance(parent, (int, float)):
397
- # belong_to is range. ex. i in V
398
- self._parent = Range(start=0, last=int(parent))
399
- elif isinstance(parent, Range):
400
- self._parent = parent
401
- else:
402
- raise TypeError(
403
- "'parent' is 'int', 'Expression' or 'tuple' not {}.".format(
404
- type(parent)
405
- )
406
- )
407
-
408
- super().__init__(label, uuid=uuid)
409
-
410
- @property
411
- def label(self) -> str:
412
- return self._label
413
-
414
- @property
415
- def parent(self) -> _type_annotations.ElementParentType:
416
- return self._parent
417
-
418
- @property
419
- def belong_to(self) -> _type_annotations.ElementParentType:
420
- return self._parent
421
-
422
- def children(self) -> tp.List[_expression.Expression]:
423
- if isinstance(self.parent, Range):
424
- return [self.parent.start, self.parent.last]
425
- else:
426
- return [self.parent]
427
-
428
- @property
429
- def dim(self) -> int:
430
- if isinstance(self.parent, Range):
431
- return 0
432
- else:
433
- parant_dim = self.parent.dim
434
- return parant_dim - 1
435
-
436
- @property
437
- def ndim(self) -> int:
438
- return self.dim
439
-
440
- def is_operatable(self) -> bool:
441
- return self.dim == 0
442
-
443
- @property
444
- def shape(self) -> tp.Tuple[_type_annotations.ShapeElementType, ...]:
445
- from jijmodeling.expression.variables.placeholders import Placeholder
446
-
447
- if isinstance(self.parent, Range):
448
- return (self.parent.length(),)
449
- elif isinstance(self.parent, Placeholder):
450
- return self.parent.shape[1:]
451
- elif not self.is_operatable():
452
- from jijmodeling.expression.variables.placeholders import ArrayShape
453
-
454
- return (ArrayShape(self, dimension=0),)
455
- else:
456
- return ()
457
-
458
-
459
- class Range(metaclass=_serializable.Serializable):
460
- def __init__(
461
- self,
462
- start: tp.Union[_expression.Expression, int],
463
- last: tp.Union[_expression.Expression, int],
464
- uuid: tp.Optional[str] = None,
465
- ) -> None:
466
- """
467
- Range object.
468
-
469
- Args:
470
- start (tp.Union[Expression, int]): range start
471
- last (tp.Union[Expression, int]): range last
472
-
473
- Examples:
474
- ```python
475
- >>> import jijmodeling as jm
476
- >>> n = jm.Placeholder('n')
477
- >>> r = jm.expression.variables.variable.Range(0,n)
478
- >>> r.start
479
- 0
480
- >>> r.last
481
- n
482
- ```
483
- """
484
- if isinstance(start, _expression.Expression) and not start.is_operatable():
485
- raise _exceptions.ModelingError(
486
- "Range's start should be operatable. {} is not operatable.".format(
487
- start
488
- )
489
- )
490
- if isinstance(last, _expression.Expression) and not last.is_operatable():
491
- raise _exceptions.ModelingError(
492
- "Range's last should be operatable. {} is not operatable.".format(last)
493
- )
494
-
495
- if not isinstance(start, _expression.Expression):
496
- self._start: _expression.Expression = _expression.Number(start, dtype="int")
497
- else:
498
- self._start = start
499
-
500
- if not isinstance(last, _expression.Expression):
501
- self._last: _expression.Expression = _expression.Number(last, dtype="int")
502
- else:
503
- self._last = last
504
-
505
- if uuid is None:
506
- self._uuid = uuid4().hex
507
- else:
508
- self._uuid = uuid
509
-
510
- @property
511
- def start(self) -> _expression.Expression:
512
- return self._start
513
-
514
- @property
515
- def last(self) -> _expression.Expression:
516
- return self._last
517
-
518
- @property
519
- def uuid(self) -> str:
520
- return self._uuid
521
-
522
- def length(self) -> _expression.Expression:
523
- length: _expression.Expression = self.last - self.start
524
- return length
@@ -1,11 +0,0 @@
1
- from pkgutil import extend_path
2
-
3
- __path__ = extend_path(__path__, __name__)
4
-
5
- import jijmodeling.latex_repr.latex_repr as latex_repr
6
- import jijmodeling.latex_repr.problem_latex_repr as problem_latex_repr
7
-
8
- __all__ = [
9
- "latex_repr",
10
- "problem_latex_repr",
11
- ]