gamspy 1.19.0__py3-none-any.whl → 1.19.2__py3-none-any.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.
Files changed (89) hide show
  1. gamspy/__init__.py +86 -86
  2. gamspy/__main__.py +6 -6
  3. gamspy/_algebra/__init__.py +13 -13
  4. gamspy/_algebra/condition.py +290 -290
  5. gamspy/_algebra/domain.py +103 -103
  6. gamspy/_algebra/expression.py +820 -820
  7. gamspy/_algebra/number.py +79 -79
  8. gamspy/_algebra/operable.py +185 -185
  9. gamspy/_algebra/operation.py +948 -948
  10. gamspy/_backend/backend.py +313 -313
  11. gamspy/_backend/engine.py +960 -960
  12. gamspy/_backend/local.py +124 -124
  13. gamspy/_backend/neos.py +567 -567
  14. gamspy/_cli/__init__.py +1 -1
  15. gamspy/_cli/cli.py +64 -64
  16. gamspy/_cli/gdx.py +377 -377
  17. gamspy/_cli/install.py +375 -375
  18. gamspy/_cli/list.py +94 -94
  19. gamspy/_cli/mps2gms.py +128 -128
  20. gamspy/_cli/probe.py +52 -52
  21. gamspy/_cli/retrieve.py +79 -79
  22. gamspy/_cli/run.py +158 -158
  23. gamspy/_cli/show.py +246 -246
  24. gamspy/_cli/uninstall.py +165 -165
  25. gamspy/_cli/util.py +94 -94
  26. gamspy/_communication.py +215 -215
  27. gamspy/_config.py +132 -132
  28. gamspy/_container.py +1716 -1694
  29. gamspy/_convert.py +720 -720
  30. gamspy/_database.py +271 -271
  31. gamspy/_extrinsic.py +181 -181
  32. gamspy/_miro.py +356 -356
  33. gamspy/_model.py +1803 -1803
  34. gamspy/_model_instance.py +701 -701
  35. gamspy/_options.py +780 -780
  36. gamspy/_serialization.py +156 -156
  37. gamspy/_symbols/__init__.py +17 -17
  38. gamspy/_symbols/alias.py +305 -305
  39. gamspy/_symbols/equation.py +1407 -1407
  40. gamspy/_symbols/implicits/__init__.py +11 -11
  41. gamspy/_symbols/implicits/implicit_equation.py +186 -186
  42. gamspy/_symbols/implicits/implicit_parameter.py +272 -272
  43. gamspy/_symbols/implicits/implicit_set.py +124 -124
  44. gamspy/_symbols/implicits/implicit_symbol.py +315 -315
  45. gamspy/_symbols/implicits/implicit_variable.py +255 -255
  46. gamspy/_symbols/parameter.py +648 -648
  47. gamspy/_symbols/set.py +985 -985
  48. gamspy/_symbols/symbol.py +395 -395
  49. gamspy/_symbols/universe_alias.py +182 -182
  50. gamspy/_symbols/variable.py +1101 -1101
  51. gamspy/_types.py +7 -7
  52. gamspy/_validation.py +736 -735
  53. gamspy/_workspace.py +72 -72
  54. gamspy/exceptions.py +128 -128
  55. gamspy/formulations/__init__.py +46 -46
  56. gamspy/formulations/ml/__init__.py +11 -11
  57. gamspy/formulations/ml/decision_tree_struct.py +80 -80
  58. gamspy/formulations/ml/gradient_boosting.py +203 -203
  59. gamspy/formulations/ml/random_forest.py +187 -187
  60. gamspy/formulations/ml/regression_tree.py +533 -533
  61. gamspy/formulations/nn/__init__.py +19 -19
  62. gamspy/formulations/nn/avgpool2d.py +232 -232
  63. gamspy/formulations/nn/conv1d.py +533 -533
  64. gamspy/formulations/nn/conv2d.py +529 -529
  65. gamspy/formulations/nn/linear.py +341 -341
  66. gamspy/formulations/nn/maxpool2d.py +88 -88
  67. gamspy/formulations/nn/minpool2d.py +88 -88
  68. gamspy/formulations/nn/mpool2d.py +245 -245
  69. gamspy/formulations/nn/torch_sequential.py +278 -278
  70. gamspy/formulations/piecewise.py +682 -682
  71. gamspy/formulations/result.py +119 -119
  72. gamspy/formulations/shape.py +188 -188
  73. gamspy/formulations/utils.py +173 -173
  74. gamspy/math/__init__.py +215 -215
  75. gamspy/math/activation.py +783 -783
  76. gamspy/math/log_power.py +435 -435
  77. gamspy/math/matrix.py +534 -534
  78. gamspy/math/misc.py +1709 -1709
  79. gamspy/math/probability.py +170 -170
  80. gamspy/math/trigonometric.py +232 -232
  81. gamspy/utils.py +810 -810
  82. gamspy/version.py +5 -5
  83. {gamspy-1.19.0.dist-info → gamspy-1.19.2.dist-info}/METADATA +90 -90
  84. gamspy-1.19.2.dist-info/RECORD +90 -0
  85. {gamspy-1.19.0.dist-info → gamspy-1.19.2.dist-info}/licenses/LICENSE +22 -22
  86. gamspy-1.19.0.dist-info/RECORD +0 -90
  87. {gamspy-1.19.0.dist-info → gamspy-1.19.2.dist-info}/WHEEL +0 -0
  88. {gamspy-1.19.0.dist-info → gamspy-1.19.2.dist-info}/entry_points.txt +0 -0
  89. {gamspy-1.19.0.dist-info → gamspy-1.19.2.dist-info}/top_level.txt +0 -0
@@ -1,182 +1,182 @@
1
- from __future__ import annotations
2
-
3
- import os
4
- import threading
5
- from typing import TYPE_CHECKING
6
-
7
- import gams.transfer as gt
8
- from gams.core.gdx import GMS_DT_ALIAS
9
-
10
- import gamspy as gp
11
- import gamspy._algebra.condition as condition
12
- import gamspy._validation as validation
13
- from gamspy.exceptions import ValidationError
14
-
15
- if TYPE_CHECKING:
16
- from gamspy import Container
17
-
18
-
19
- class UniverseAlias(gt.UniverseAlias):
20
- """
21
- Represents a UniverseAlias symbol in GAMS.
22
-
23
- Parameters
24
- ----------
25
- container : Container
26
- name : str
27
-
28
- Examples
29
- --------
30
- >>> import gamspy as gp
31
- >>> m = gp.Container()
32
- >>> universe = gp.UniverseAlias(m)
33
- >>> universe.records
34
- Empty DataFrame
35
- Columns: [uni]
36
- Index: []
37
- >>> i = gp.Set(m, "i", records=['i1', 'i2'])
38
- >>> universe.records
39
- uni
40
- 0 i1
41
- 1 i2
42
-
43
- """
44
-
45
- @classmethod
46
- def _constructor_bypass(cls, container: Container, name: str):
47
- # create new symbol object
48
- obj = UniverseAlias.__new__(cls, container, name)
49
-
50
- # set private properties directly
51
- obj._requires_state_check = False
52
- obj._container = container
53
- container._requires_state_check = True
54
- obj._name = name
55
- obj._modified = True
56
-
57
- # typing
58
- obj._gams_type = GMS_DT_ALIAS
59
- obj._gams_subtype = 0
60
-
61
- # add to container
62
- container.data.update({name: obj})
63
-
64
- # gamspy attributes
65
- obj.where = condition.Condition(obj)
66
- obj._latex_name = name.replace("_", r"\_")
67
-
68
- # add statement
69
- obj.container._add_statement(obj)
70
-
71
- return obj
72
-
73
- def __new__(cls, container: Container | None = None, name: str = "universe"):
74
- if container is not None and not isinstance(container, gp.Container):
75
- raise TypeError(
76
- f"Container must of type `Container` but found {type(container)}"
77
- )
78
-
79
- if not isinstance(name, str):
80
- raise TypeError(f"Name must of type `str` but found {type(name)}")
81
-
82
- try:
83
- if not container:
84
- container = gp._ctx_managers[(os.getpid(), threading.get_native_id())]
85
-
86
- symbol = container[name]
87
- if isinstance(symbol, cls):
88
- return symbol
89
-
90
- raise TypeError(
91
- f"Cannot overwrite symbol `{name}` in container"
92
- " because it is not a UniverseAlias object)"
93
- )
94
- except KeyError:
95
- return object.__new__(cls)
96
-
97
- def __init__(self, container: Container | None = None, name: str = "universe"):
98
- # check if the name is a reserved word
99
- if name is not None:
100
- name = validation.validate_name(name)
101
- else:
102
- name = container._get_symbol_name(prefix="u")
103
-
104
- if container is None:
105
- try:
106
- container = gp._ctx_managers[(os.getpid(), threading.get_native_id())]
107
- except KeyError as e:
108
- raise ValidationError("UniverseAlias requires a container.") from e
109
-
110
- super().__init__(container, name)
111
- self._latex_name = self.name.replace("_", r"\_")
112
-
113
- # allow conditions
114
- self.where = condition.Condition(self)
115
-
116
- self.container._add_statement(self)
117
- self.container._synch_with_gams()
118
-
119
- def _serialize(self) -> dict:
120
- return {}
121
-
122
- def _deserialize(self, info: dict) -> None: ...
123
-
124
- def __repr__(self) -> str:
125
- return f"UniverseAlias(name='{self.name}')"
126
-
127
- def gamsRepr(self) -> str:
128
- """
129
- Representation of the UniverseAlias in GAMS language.
130
-
131
- Returns
132
- -------
133
- str
134
-
135
- Examples
136
- --------
137
- >>> import gamspy as gp
138
- >>> m = gp.Container()
139
- >>> i = gp.UniverseAlias(m, name="universe")
140
- >>> i.gamsRepr()
141
- 'universe'
142
-
143
- """
144
- return self.name
145
-
146
- def latexRepr(self) -> str:
147
- """
148
- Representation of the UniverseAlias in LaTeX.
149
-
150
- Returns
151
- -------
152
- str
153
-
154
- Examples
155
- --------
156
- >>> import gamspy as gp
157
- >>> m = gp.Container()
158
- >>> i = gp.UniverseAlias(m, name="universe_alias")
159
- >>> i.latexRepr()
160
- 'universe\\_alias'
161
-
162
- """
163
- return self._latex_name
164
-
165
- def getDeclaration(self) -> str:
166
- """
167
- Declaration of the UniverseAlias in GAMS
168
-
169
- Returns
170
- -------
171
- str
172
-
173
- Examples
174
- --------
175
- >>> import gamspy as gp
176
- >>> m = gp.Container()
177
- >>> i = gp.UniverseAlias(m, name="universe")
178
- >>> i.getDeclaration()
179
- 'Alias(universe,*);'
180
-
181
- """
182
- return f"Alias({self.name},*);"
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import threading
5
+ from typing import TYPE_CHECKING
6
+
7
+ import gams.transfer as gt
8
+ from gams.core.gdx import GMS_DT_ALIAS
9
+
10
+ import gamspy as gp
11
+ import gamspy._algebra.condition as condition
12
+ import gamspy._validation as validation
13
+ from gamspy.exceptions import ValidationError
14
+
15
+ if TYPE_CHECKING:
16
+ from gamspy import Container
17
+
18
+
19
+ class UniverseAlias(gt.UniverseAlias):
20
+ """
21
+ Represents a UniverseAlias symbol in GAMS.
22
+
23
+ Parameters
24
+ ----------
25
+ container : Container
26
+ name : str
27
+
28
+ Examples
29
+ --------
30
+ >>> import gamspy as gp
31
+ >>> m = gp.Container()
32
+ >>> universe = gp.UniverseAlias(m)
33
+ >>> universe.records
34
+ Empty DataFrame
35
+ Columns: [uni]
36
+ Index: []
37
+ >>> i = gp.Set(m, "i", records=['i1', 'i2'])
38
+ >>> universe.records
39
+ uni
40
+ 0 i1
41
+ 1 i2
42
+
43
+ """
44
+
45
+ @classmethod
46
+ def _constructor_bypass(cls, container: Container, name: str):
47
+ # create new symbol object
48
+ obj = UniverseAlias.__new__(cls, container, name)
49
+
50
+ # set private properties directly
51
+ obj._requires_state_check = False
52
+ obj._container = container
53
+ container._requires_state_check = True
54
+ obj._name = name
55
+ obj._modified = True
56
+
57
+ # typing
58
+ obj._gams_type = GMS_DT_ALIAS
59
+ obj._gams_subtype = 0
60
+
61
+ # add to container
62
+ container.data.update({name: obj})
63
+
64
+ # gamspy attributes
65
+ obj.where = condition.Condition(obj)
66
+ obj._latex_name = name.replace("_", r"\_")
67
+
68
+ # add statement
69
+ obj.container._add_statement(obj)
70
+
71
+ return obj
72
+
73
+ def __new__(cls, container: Container | None = None, name: str = "universe"):
74
+ if container is not None and not isinstance(container, gp.Container):
75
+ raise TypeError(
76
+ f"Container must of type `Container` but found {type(container)}"
77
+ )
78
+
79
+ if not isinstance(name, str):
80
+ raise TypeError(f"Name must of type `str` but found {type(name)}")
81
+
82
+ try:
83
+ if not container:
84
+ container = gp._ctx_managers[(os.getpid(), threading.get_native_id())]
85
+
86
+ symbol = container[name]
87
+ if isinstance(symbol, cls):
88
+ return symbol
89
+
90
+ raise TypeError(
91
+ f"Cannot overwrite symbol `{name}` in container"
92
+ " because it is not a UniverseAlias object)"
93
+ )
94
+ except KeyError:
95
+ return object.__new__(cls)
96
+
97
+ def __init__(self, container: Container | None = None, name: str = "universe"):
98
+ # check if the name is a reserved word
99
+ if name is not None:
100
+ name = validation.validate_name(name)
101
+ else:
102
+ name = container._get_symbol_name(prefix="u")
103
+
104
+ if container is None:
105
+ try:
106
+ container = gp._ctx_managers[(os.getpid(), threading.get_native_id())]
107
+ except KeyError as e:
108
+ raise ValidationError("UniverseAlias requires a container.") from e
109
+
110
+ super().__init__(container, name)
111
+ self._latex_name = self.name.replace("_", r"\_")
112
+
113
+ # allow conditions
114
+ self.where = condition.Condition(self)
115
+
116
+ self.container._add_statement(self)
117
+ self.container._synch_with_gams()
118
+
119
+ def _serialize(self) -> dict:
120
+ return {}
121
+
122
+ def _deserialize(self, info: dict) -> None: ...
123
+
124
+ def __repr__(self) -> str:
125
+ return f"UniverseAlias(name='{self.name}')"
126
+
127
+ def gamsRepr(self) -> str:
128
+ """
129
+ Representation of the UniverseAlias in GAMS language.
130
+
131
+ Returns
132
+ -------
133
+ str
134
+
135
+ Examples
136
+ --------
137
+ >>> import gamspy as gp
138
+ >>> m = gp.Container()
139
+ >>> i = gp.UniverseAlias(m, name="universe")
140
+ >>> i.gamsRepr()
141
+ 'universe'
142
+
143
+ """
144
+ return self.name
145
+
146
+ def latexRepr(self) -> str:
147
+ """
148
+ Representation of the UniverseAlias in LaTeX.
149
+
150
+ Returns
151
+ -------
152
+ str
153
+
154
+ Examples
155
+ --------
156
+ >>> import gamspy as gp
157
+ >>> m = gp.Container()
158
+ >>> i = gp.UniverseAlias(m, name="universe_alias")
159
+ >>> i.latexRepr()
160
+ 'universe\\_alias'
161
+
162
+ """
163
+ return self._latex_name
164
+
165
+ def getDeclaration(self) -> str:
166
+ """
167
+ Declaration of the UniverseAlias in GAMS
168
+
169
+ Returns
170
+ -------
171
+ str
172
+
173
+ Examples
174
+ --------
175
+ >>> import gamspy as gp
176
+ >>> m = gp.Container()
177
+ >>> i = gp.UniverseAlias(m, name="universe")
178
+ >>> i.getDeclaration()
179
+ 'Alias(universe,*);'
180
+
181
+ """
182
+ return f"Alias({self.name},*);"