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,389 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import datetime as dt
4
-
5
- from copy import deepcopy
6
- from dataclasses import asdict, dataclass
7
- from typing import Dict, List, Optional, Tuple, Union
8
-
9
- import numpy as np
10
- import orjson
11
- import pandas as pd
12
-
13
- from jijmodeling.exceptions import SampleSetNotEvaluatedError, SerializeSampleSetError
14
- from jijmodeling.sampleset.evaluation import Evaluation
15
- from jijmodeling.sampleset.measuring_time import MeasuringTime
16
- from jijmodeling.sampleset.record import Record
17
-
18
-
19
- @dataclass
20
- class SampleSet:
21
- """Schema for sampleset.
22
-
23
- Attributes:
24
- record (Record): Record object. This means basic infomation of solutions.
25
- evaluation (Evaluation): Evaluation object. This means evaluation results of solutions.
26
- measuring_time (MeasuringTime): MeasuringTime object. This means measuring time of various processing until solutions is obtained.
27
- """
28
-
29
- record: Record
30
- evaluation: Evaluation
31
- measuring_time: MeasuringTime
32
-
33
- def __post_init__(self):
34
- self._is_dense = False
35
- self._current_index = 0
36
- self._metadata = {}
37
-
38
- def __len__(self) -> int:
39
- """
40
- Perform the operation __len__.
41
- """
42
- return self.record.__len__()
43
-
44
- def __iter__(self):
45
- """
46
- Perform the operation __iter__.
47
- """
48
- return self
49
-
50
- def __next__(self):
51
- """
52
- Perform the operation __next__.
53
- """
54
- if self._current_index == len(self):
55
- self._current_index = 0
56
- raise StopIteration()
57
- ret = self[self._current_index]
58
- self._current_index += 1
59
- return ret
60
-
61
- def __getitem__(
62
- self, item: Union[int, slice, List[int], Tuple[int], np.ndarray]
63
- ) -> SampleSet:
64
- """Perform the operation __getitem__.
65
-
66
- Args:
67
- item (Union[int, slice, List[int], Tuple[int], np.ndarray]): Index of sampleset.
68
-
69
- Returns:
70
- Record: SampleSet object.
71
- """
72
- record = self.record[item]
73
- evaluation = self.evaluation[item]
74
- return SampleSet(
75
- record=record, evaluation=evaluation, measuring_time=self.measuring_time
76
- )
77
-
78
- @property
79
- def is_dense(self) -> bool:
80
- """SparseSolution or DenseSolution:
81
- - If True, DenseSolution,
82
- - Else, SparseSolution.
83
-
84
- Returns:
85
- bool: True or False.
86
- """
87
- return self._is_dense
88
-
89
- @property
90
- def metadata(self) -> Dict:
91
- """Store information which is not in SampleSet schema.
92
-
93
- Returns:
94
- dict: Metadata.
95
- """
96
- return self._metadata
97
-
98
- @is_dense.setter
99
- def is_dense(self, b: bool):
100
- self._is_dense = b
101
-
102
- def to_pandas_dataframe(self) -> pd.DataFrame:
103
- """Convert SampleSet object to pandas.DataFrame object.
104
-
105
- Returns:
106
- pandas.DataFrame: pandas.DataFrame object.
107
- """
108
- record = self.record.to_pandas_dataframe()
109
- evaluation = self.evaluation.to_pandas_dataframe()
110
-
111
- return pd.concat([record, evaluation], axis=1)
112
-
113
- def to_dense(self, inplace: bool = False) -> SampleSet | None:
114
- """Convert SparseSolution to DenseSolution.
115
-
116
- Args:
117
- inplace (bool, optional): Modify the SampleSet object in place (do not create a new object). Defaults to False.
118
-
119
- Returns:
120
- SampleSet or None: SampleSet with dense solution or None if inplace=True.
121
- """
122
- if self.is_dense:
123
- if inplace:
124
- return None
125
- else:
126
- return self
127
- elif inplace:
128
- self.record.to_dense(inplace=inplace)
129
- self._is_dense = True
130
- return None
131
- else:
132
- record = self.record.to_dense(inplace=inplace)
133
- sampleset = SampleSet(
134
- record=record,
135
- evaluation=self.evaluation,
136
- measuring_time=self.measuring_time,
137
- )
138
- sampleset.is_dense = True
139
- return sampleset
140
-
141
- @classmethod
142
- def from_serializable(cls, obj: Dict):
143
- """To SampleSet object from Dict of SampleSet.
144
-
145
- Args:
146
- obj (Dict): Dict of SampleSet.
147
-
148
- Returns:
149
- SampleSet: SampleSet obj.
150
- """
151
- for key in ["record", "evaluation", "measuring_time"]:
152
- if key not in obj.keys():
153
- raise SerializeSampleSetError(f'"obj" does not contain "{key}" key')
154
-
155
- if "metadata" in obj:
156
- if isinstance(obj["metadata"], dict):
157
- metadata = obj["metadata"]
158
- else:
159
- raise TypeError('Type of "metadata" must be dict')
160
- else:
161
- metadata = {}
162
-
163
- solution = {}
164
- for k, v in obj["record"]["solution"].items():
165
- solution[k] = [(tuple(vi[0]), vi[1], tuple(vi[2])) for vi in v]
166
- obj["record"]["solution"] = solution
167
-
168
- record = Record.from_serializable(obj["record"])
169
- evaluation = Evaluation.from_serializable(obj["evaluation"])
170
- measuring_time = MeasuringTime.from_serializable(obj["measuring_time"])
171
-
172
- sampleset = cls(
173
- record=record,
174
- evaluation=evaluation,
175
- measuring_time=measuring_time,
176
- )
177
- sampleset.metadata.update(metadata)
178
-
179
- return sampleset
180
-
181
- def to_serializable(self) -> Dict:
182
- """To Dict of SampleSet from SampleSet object.
183
-
184
- Returns:
185
- SampleSet: Dict of SampleSet.
186
- """
187
-
188
- def default(obj):
189
- if isinstance(obj, np.ndarray):
190
- return obj.tolist()
191
- else:
192
- return obj
193
-
194
- evaluation_to_serializable_obj = self.evaluation.to_serializable()
195
- to_serializable_obj = asdict(self)
196
- to_serializable_obj["evaluation"] = evaluation_to_serializable_obj
197
- json_metadata = orjson.dumps(
198
- self.metadata,
199
- default=default,
200
- option=orjson.OPT_SERIALIZE_NUMPY,
201
- )
202
- to_serializable_obj["metadata"] = orjson.loads(json_metadata)
203
- return to_serializable_obj
204
-
205
- def feasible(self, rtol: float = 1e-05, atol: float = 1e-08):
206
- """Return feasible solutions.
207
- This function uses `np.isclose` to check feasibility.
208
-
209
- Args:
210
- rel_tol (float, optional): Relative tolerance. Defaults to 1e-05.
211
- abs_tol (float, optional): Absolute tolerance. Defaults to 1e-08.
212
-
213
- Returns:
214
- SampleSet: Output only feasible solutions from self.record.solution.
215
- """
216
-
217
- if self.evaluation.constraint_violations is None:
218
- raise SampleSetNotEvaluatedError("Your SampleSet object is not evaluated.")
219
- else:
220
- constraint_violations = np.array(
221
- list(self.evaluation.constraint_violations.values())
222
- )
223
- if len(constraint_violations):
224
- is_feas = np.isclose(
225
- constraint_violations.sum(axis=0),
226
- 0,
227
- rtol=rtol,
228
- atol=atol,
229
- )
230
- return SampleSet(
231
- record=self.record[is_feas],
232
- evaluation=self.evaluation[is_feas],
233
- measuring_time=self.measuring_time,
234
- )
235
- else:
236
- return self
237
-
238
- def infeasible(self):
239
- """Return infeasible solutions.
240
-
241
- Returns:
242
- SampleSet: Output only feasible solutions from self.record.solution.
243
- """
244
- if self.evaluation.constraint_violations is None:
245
- raise SampleSetNotEvaluatedError("Your SampleSet object is not evaluated.")
246
- else:
247
- constraint_violations = np.array(
248
- list(self.evaluation.constraint_violations.values())
249
- )
250
- if len(constraint_violations):
251
- is_infeas = constraint_violations.sum(axis=0) != 0
252
- return SampleSet(
253
- record=self.record[is_infeas],
254
- evaluation=self.evaluation[is_infeas],
255
- measuring_time=self.measuring_time,
256
- )
257
- else:
258
- return self[[]]
259
-
260
- def lowest(self):
261
- """Return solutions with lowest objective in feasible solutions.
262
-
263
- Returns:
264
- SampleSet: Output only lowest objecive solutions in feasibles from self.record.solution.
265
- """
266
-
267
- if self.evaluation.objective is None:
268
- raise SampleSetNotEvaluatedError("Your SampleSet object is not evaluated.")
269
- else:
270
- feas = self.feasible()
271
- objective = np.array(feas.evaluation.objective)
272
- is_lowest = objective == objective.min() if len(objective) else []
273
- return SampleSet(
274
- record=feas.record[is_lowest],
275
- evaluation=feas.evaluation[is_lowest],
276
- measuring_time=feas.measuring_time,
277
- )
278
-
279
- def get_backend_calculation_time(self):
280
- """You can check calculation time for each process in detail.
281
-
282
- Returns:
283
- Dict: Processed metadata for describing JijZept backends.
284
- """
285
-
286
- def _get_root_keys(obj: Dict):
287
- if not isinstance(obj, dict):
288
- raise TypeError(f"Type of 'obj' must be Dict, not {obj.__class__}.")
289
-
290
- root_keys = []
291
- for k, v in obj.items():
292
- if isinstance(v, dict):
293
- parent_id = v.get("parent_id", "")
294
- if parent_id is None:
295
- root_keys.append(k)
296
- return root_keys
297
-
298
- def _timedelta(start: str, end: str):
299
- s = dt.datetime.strptime(start, "%Y-%m-%dT%H:%M:%S.%fZ")
300
- e = dt.datetime.strptime(end, "%Y-%m-%dT%H:%M:%S.%fZ")
301
- return (e - s).total_seconds()
302
-
303
- def _get_timedelata_by_span(obj: Dict, res: Optional[Dict] = None):
304
- if res is None:
305
- res = {}
306
-
307
- for k, v in obj.items():
308
- if isinstance(v, dict):
309
- if "start_time" in v:
310
- res[k] = {
311
- "time": _timedelta(v["start_time"], v["end_time"]),
312
- "span_id": v["context"]["span_id"],
313
- "parent_id": v["parent_id"],
314
- }
315
- else:
316
- res[k] = _get_timedelata_by_span(v, {})
317
- return res
318
-
319
- def _aggregate(obj: Dict, root_key: str, res: Optional[Dict] = None):
320
- if res is None:
321
- v = obj.pop(root_key, None)
322
- if v is None:
323
- return {}
324
- else:
325
- res = {
326
- root_key: {
327
- "id": v["span_id"],
328
- "time": v["time"],
329
- }
330
- }
331
- for v_res in res.values():
332
- time_map = {
333
- k: {"id": v["span_id"], "time": v["time"]}
334
- for k, v in obj.items()
335
- if v.get("parent_id", "") == v_res["id"]
336
- }
337
-
338
- if time_map:
339
- del v_res["id"], v_res["time"]
340
- v_res.update(_aggregate(obj, root_key, time_map))
341
- else:
342
- del v_res["id"]
343
- return res
344
-
345
- def _reformat(obj: Dict):
346
- for k, v in obj.items():
347
- if isinstance(v, dict):
348
- if "time" in v:
349
- obj[k] = v["time"]
350
- else:
351
- obj[k] = _reformat(v)
352
- return obj
353
-
354
- root_keys = _get_root_keys(self.metadata)
355
- time = {}
356
- for root_key in root_keys:
357
- metadata = _get_timedelata_by_span(self.metadata)
358
- metadata = _aggregate(metadata, root_key)
359
- metadata = _reformat(metadata)
360
- time.update(metadata)
361
- return time
362
-
363
- def _extend(self, other):
364
- self.record._extend(other.record)
365
- self.evaluation._extend(other.evaluation)
366
- # TODO: concatenates MeasuringTime objects
367
-
368
-
369
- def concatenate(
370
- jm_sampleset_list: List[SampleSet],
371
- ) -> SampleSet:
372
- """
373
- Concatenates SampleSet objects into a single SampleSet object.
374
-
375
- Args:
376
- jm_sampleset_list (List[SampleSet]): a list of SampleSet objects
377
-
378
- Returns:
379
- SampleSet: a SampleSet object that be concatenated
380
- """
381
- if len(jm_sampleset_list) == 0:
382
- raise ValueError("empty list is invalid")
383
- elif len(jm_sampleset_list) == 1:
384
- return jm_sampleset_list[0]
385
- else:
386
- concat_sampleset = deepcopy(jm_sampleset_list[0])
387
- for jm_sampleset in jm_sampleset_list[1:]:
388
- concat_sampleset._extend(jm_sampleset)
389
- return concat_sampleset
@@ -1,38 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from dataclasses import dataclass
4
- from typing import Dict, Optional
5
-
6
- from jijmodeling.exceptions import SerializeSampleSetError
7
-
8
-
9
- @dataclass
10
- class SolvingTime:
11
- """Schema for solver running time.
12
-
13
- Attributes:
14
- preprocess (Optional[float], optional): Time to preprocess. Defaults to None.
15
- solve (Optional[float], optional): Time to solve. Defaults to None.
16
- postprocess (Optional[float], optional): Time to postprocess. Defaults to None.
17
- """
18
-
19
- preprocess: Optional[float] = None
20
- solve: Optional[float] = None
21
- postprocess: Optional[float] = None
22
-
23
- @classmethod
24
- def from_serializable(cls, obj: Dict):
25
- """To SolvingTime object from Dict of SampleSet.
26
-
27
- Args:
28
- obj (Dict): Dict of SolvingTime.
29
-
30
- Returns:
31
- SolvingTime: SolvingTime obj.
32
- """
33
-
34
- for key in ["preprocess", "solve", "postprocess"]:
35
- if key not in obj.keys():
36
- raise SerializeSampleSetError(f'"obj" does not contain "{key}" key')
37
-
38
- return cls(**obj)
@@ -1,48 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from dataclasses import dataclass
4
- from typing import Dict, Optional
5
-
6
- from jijmodeling.exceptions import SerializeSampleSetError
7
-
8
-
9
- @dataclass
10
- class SystemTime:
11
- """Schema for system of jijzept running time.
12
-
13
- Args:
14
- post_problem_and_instance_data (Optional[float], optional): Time to upload problem and instance_data to blob. Defaults to None.
15
- request_queue (Optional[float], optional): Time to send request to queue. Defaults to None.
16
- fetch_problem_and_instance_data (Optional[float], optional): Time to fetch problme and instance_data from blob. Defaults to None.
17
- fetch_result (Optional[float], optional): Time to fetch result. Defaults to None.
18
- deserialize_solution (Optional[float], optional): Time to deserialize json object. Defaults to None.
19
- """
20
-
21
- post_problem_and_instance_data: Optional[float] = None
22
- request_queue: Optional[float] = None
23
- fetch_problem_and_instance_data: Optional[float] = None
24
- fetch_result: Optional[float] = None
25
- deserialize_solution: Optional[float] = None
26
-
27
- @classmethod
28
- def from_serializable(cls, obj: Dict):
29
- """To SystemTime object from Dict of SampleSet.
30
-
31
- Args:
32
- obj (Dict): Dict of SystemTime.
33
-
34
- Returns:
35
- SystemTime: SystemTime obj.
36
- """
37
-
38
- for key in [
39
- "post_problem_and_instance_data",
40
- "request_queue",
41
- "fetch_problem_and_instance_data",
42
- "fetch_result",
43
- "deserialize_solution",
44
- ]:
45
- if key not in obj.keys():
46
- raise SerializeSampleSetError(f'"obj" does not contain "{key}" key')
47
-
48
- return cls(**obj)
@@ -1,44 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from pkgutil import extend_path
4
-
5
- __path__ = extend_path(__path__, __name__)
6
-
7
- import jijmodeling.type_annotations.type_annotations as type_annotations
8
-
9
- from jijmodeling.type_annotations.type_annotations import (
10
- DECI_VALUES_INTEREFACE,
11
- DECISION_VALUES,
12
- FIXED_VARIABLES,
13
- FIXED_VARS_INTERFACE,
14
- PH_VALUES_INTERFACE,
15
- PLACEHOLDER_VALUES,
16
- VARIABLE_KEY,
17
- ConstraintExpressionValuesType,
18
- DenseSolution,
19
- ForallIndexType,
20
- ForallValuesType,
21
- ListValue,
22
- NumberValue,
23
- SparseSolution,
24
- TensorValue,
25
- )
26
-
27
- __all__ = [
28
- "type_annotations",
29
- "ConstraintExpressionValuesType",
30
- "ForallIndexType",
31
- "ForallValuesType",
32
- "NumberValue",
33
- "TensorValue",
34
- "ListValue",
35
- "VARIABLE_KEY",
36
- "PH_VALUES_INTERFACE",
37
- "PLACEHOLDER_VALUES",
38
- "DECI_VALUES_INTEREFACE",
39
- "DECISION_VALUES",
40
- "FIXED_VARS_INTERFACE",
41
- "FIXED_VARIABLES",
42
- "SparseSolution",
43
- "DenseSolution",
44
- ]
@@ -1,54 +0,0 @@
1
- from __future__ import annotations
2
-
3
- """TYPE ANNOTATIONS.
4
-
5
- Describe the types related to the data needed to change from JijModeling to another type, such as to_pyqubo or calc_value.
6
- """
7
-
8
- import typing as tp
9
-
10
- import numpy as np
11
-
12
- from jijmodeling.expression.variables.deci_vars import DecisionVariable
13
- from jijmodeling.expression.variables.placeholders import Placeholder
14
-
15
- NumberValue = tp.Union[int, float]
16
- TensorValue = tp.Union[NumberValue, np.ndarray]
17
- ListValue = tp.List[NumberValue]
18
- NonZeroIndices = tp.Tuple[tp.List[int], ...]
19
- NonZeroValues = tp.Union[tp.List[tp.Union[int, float]], tp.Union[int, float]]
20
- Shape = tp.Tuple[int, ...]
21
- SparseSolution = tp.Tuple[
22
- NonZeroIndices,
23
- NonZeroValues,
24
- Shape,
25
- ]
26
- DenseSolution = np.ndarray
27
-
28
- ForallIndexType = tp.Dict[str, tp.List[tp.List[int]]]
29
- ForallValuesType = tp.Dict[str, tp.List[float]]
30
- ConstraintExpressionValuesType = tp.Dict[str, tp.Dict[tp.Tuple[int, ...], float]]
31
-
32
-
33
- ForallIndexType = tp.Dict[str, tp.List[tp.List[int]]]
34
- ForallValuesType = tp.Dict[str, tp.List[float]]
35
- ConstraintExpressionValuesType = tp.Dict[str, tp.Dict[tp.Tuple[int, ...], float]]
36
-
37
-
38
- VARIABLE_KEY = tp.Union[str, Placeholder]
39
- # User interface for values of placeholder.
40
- PH_VALUES_INTERFACE = tp.Dict[VARIABLE_KEY, tp.Union[TensorValue, ListValue]]
41
- # type of value of placholders for inner handling.
42
- PLACEHOLDER_VALUES = tp.Dict[Placeholder, tp.Union[TensorValue, ListValue]]
43
-
44
- DECI_VALUES_INTEREFACE = tp.Dict[tp.Union[str, DecisionVariable], TensorValue]
45
- DECISION_VALUES = tp.Dict[DecisionVariable, TensorValue]
46
-
47
- # fixed variable
48
- # ex. fix array element : {"x": {(0, 1, 2): 1}} means x[0, 1, 2] = 1
49
- # fix scalar variable: {"y": {(): 0}} means y = 0
50
- FIXED_VARS_INTERFACE = tp.Dict[
51
- tp.Union[str, DecisionVariable],
52
- tp.Dict[tp.Tuple[int, ...], NumberValue],
53
- ]
54
- FIXED_VARIABLES = tp.Dict[DecisionVariable, tp.Dict[tp.Tuple[int, ...], NumberValue]]
@@ -1,28 +0,0 @@
1
- from pkgutil import extend_path
2
-
3
- __path__ = extend_path(__path__, __name__)
4
-
5
- import jijmodeling.utils.utils as utils
6
-
7
- from jijmodeling.utils.utils import (
8
- FixedVariables,
9
- SerializedFixedVariables,
10
- deserialize_fixed_var,
11
- serialize_fixed_var,
12
- simple_dict_validation,
13
- simple_list_validation,
14
- validate_value,
15
- with_measuring_time,
16
- )
17
-
18
- __all__ = [
19
- "utils",
20
- "validate_value",
21
- "FixedVariables",
22
- "SerializedFixedVariables",
23
- "simple_list_validation",
24
- "simple_dict_validation",
25
- "with_measuring_time",
26
- "serialize_fixed_var",
27
- "deserialize_fixed_var",
28
- ]
@@ -1,17 +0,0 @@
1
- import typing as typ
2
- import warnings
3
-
4
- ARG_VAL_TYPE = typ.TypeVar("ARG_VAL_TYPE")
5
-
6
-
7
- def is_deprecated(
8
- arg_name,
9
- arg_value: typ.Optional[ARG_VAL_TYPE],
10
- default_value=None,
11
- additional_msg="",
12
- ) -> typ.Optional[ARG_VAL_TYPE]:
13
- if arg_value is not None:
14
- warnings.warn(f"{arg_name} is deprecated. " + additional_msg, FutureWarning)
15
- return arg_value
16
- else:
17
- return default_value