gamspy 1.18.3__py3-none-any.whl → 1.19.0__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.
- gamspy/__init__.py +86 -98
- gamspy/__main__.py +6 -6
- gamspy/_algebra/__init__.py +13 -13
- gamspy/_algebra/condition.py +290 -194
- gamspy/_algebra/domain.py +103 -93
- gamspy/_algebra/expression.py +820 -799
- gamspy/_algebra/number.py +79 -70
- gamspy/_algebra/operable.py +185 -185
- gamspy/_algebra/operation.py +948 -845
- gamspy/_backend/backend.py +313 -311
- gamspy/_backend/engine.py +960 -960
- gamspy/_backend/local.py +124 -124
- gamspy/_backend/neos.py +567 -567
- gamspy/_cli/__init__.py +1 -1
- gamspy/_cli/cli.py +64 -64
- gamspy/_cli/gdx.py +377 -377
- gamspy/_cli/install.py +375 -372
- gamspy/_cli/list.py +94 -94
- gamspy/_cli/mps2gms.py +128 -128
- gamspy/_cli/probe.py +52 -52
- gamspy/_cli/retrieve.py +79 -79
- gamspy/_cli/run.py +158 -158
- gamspy/_cli/show.py +246 -255
- gamspy/_cli/uninstall.py +165 -165
- gamspy/_cli/util.py +94 -94
- gamspy/_communication.py +215 -215
- gamspy/_config.py +132 -132
- gamspy/_container.py +1694 -1452
- gamspy/_convert.py +720 -720
- gamspy/_database.py +271 -271
- gamspy/_extrinsic.py +181 -181
- gamspy/_miro.py +356 -352
- gamspy/_model.py +1803 -1615
- gamspy/_model_instance.py +701 -701
- gamspy/_options.py +780 -700
- gamspy/_serialization.py +156 -144
- gamspy/_symbols/__init__.py +17 -17
- gamspy/_symbols/alias.py +305 -299
- gamspy/_symbols/equation.py +1407 -1298
- gamspy/_symbols/implicits/__init__.py +11 -11
- gamspy/_symbols/implicits/implicit_equation.py +186 -186
- gamspy/_symbols/implicits/implicit_parameter.py +272 -272
- gamspy/_symbols/implicits/implicit_set.py +124 -124
- gamspy/_symbols/implicits/implicit_symbol.py +315 -315
- gamspy/_symbols/implicits/implicit_variable.py +255 -255
- gamspy/_symbols/parameter.py +648 -609
- gamspy/_symbols/set.py +985 -923
- gamspy/_symbols/symbol.py +395 -386
- gamspy/_symbols/universe_alias.py +182 -182
- gamspy/_symbols/variable.py +1101 -1017
- gamspy/_types.py +7 -7
- gamspy/_validation.py +735 -735
- gamspy/_workspace.py +72 -72
- gamspy/exceptions.py +128 -128
- gamspy/formulations/__init__.py +46 -46
- gamspy/formulations/ml/__init__.py +11 -11
- gamspy/formulations/ml/decision_tree_struct.py +80 -80
- gamspy/formulations/ml/gradient_boosting.py +203 -203
- gamspy/formulations/ml/random_forest.py +187 -187
- gamspy/formulations/ml/regression_tree.py +533 -533
- gamspy/formulations/nn/__init__.py +19 -19
- gamspy/formulations/nn/avgpool2d.py +232 -232
- gamspy/formulations/nn/conv1d.py +533 -533
- gamspy/formulations/nn/conv2d.py +529 -529
- gamspy/formulations/nn/linear.py +341 -341
- gamspy/formulations/nn/maxpool2d.py +88 -88
- gamspy/formulations/nn/minpool2d.py +88 -88
- gamspy/formulations/nn/mpool2d.py +245 -245
- gamspy/formulations/nn/torch_sequential.py +278 -278
- gamspy/formulations/piecewise.py +682 -682
- gamspy/formulations/result.py +119 -119
- gamspy/formulations/shape.py +188 -188
- gamspy/formulations/utils.py +173 -173
- gamspy/math/__init__.py +215 -215
- gamspy/math/activation.py +783 -767
- gamspy/math/log_power.py +435 -435
- gamspy/math/matrix.py +534 -534
- gamspy/math/misc.py +1709 -1625
- gamspy/math/probability.py +170 -170
- gamspy/math/trigonometric.py +232 -232
- gamspy/utils.py +810 -791
- gamspy/version.py +5 -5
- {gamspy-1.18.3.dist-info → gamspy-1.19.0.dist-info}/METADATA +90 -121
- gamspy-1.19.0.dist-info/RECORD +90 -0
- {gamspy-1.18.3.dist-info → gamspy-1.19.0.dist-info}/WHEEL +1 -1
- {gamspy-1.18.3.dist-info → gamspy-1.19.0.dist-info}/licenses/LICENSE +22 -22
- gamspy-1.18.3.dist-info/RECORD +0 -90
- {gamspy-1.18.3.dist-info → gamspy-1.19.0.dist-info}/entry_points.txt +0 -0
- {gamspy-1.18.3.dist-info → gamspy-1.19.0.dist-info}/top_level.txt +0 -0
gamspy/_algebra/condition.py
CHANGED
|
@@ -1,194 +1,290 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
4
|
-
|
|
5
|
-
import gamspy._algebra.domain as domain
|
|
6
|
-
import gamspy._algebra.expression as expression
|
|
7
|
-
import gamspy._algebra.operable as operable
|
|
8
|
-
import gamspy._symbols as syms
|
|
9
|
-
import gamspy._symbols.implicits as implicits
|
|
10
|
-
import gamspy.utils as utils
|
|
11
|
-
from gamspy._symbols.implicits.implicit_symbol import ImplicitSymbol
|
|
12
|
-
from gamspy._symbols.symbol import Symbol
|
|
13
|
-
|
|
14
|
-
if TYPE_CHECKING:
|
|
15
|
-
import pandas as pd
|
|
16
|
-
|
|
17
|
-
from gamspy import Alias, Parameter, Set, Variable
|
|
18
|
-
from gamspy._algebra.domain import Domain
|
|
19
|
-
from gamspy._algebra.expression import Expression
|
|
20
|
-
from gamspy._algebra.number import Number
|
|
21
|
-
from gamspy._algebra.operation import Card, Operation, Ord
|
|
22
|
-
from gamspy._symbols.implicits import (
|
|
23
|
-
ImplicitParameter,
|
|
24
|
-
ImplicitSet,
|
|
25
|
-
)
|
|
26
|
-
from gamspy.math import MathOp
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class Condition(operable.Operable):
|
|
30
|
-
"""
|
|
31
|
-
Condition class allows conditioning on GAMSPy constructs such as Symbols and Expressions.
|
|
32
|
-
|
|
33
|
-
Parameters
|
|
34
|
-
----------
|
|
35
|
-
symbol: ImplicitSymbol | Expression
|
|
36
|
-
Reference to the symbol to be conditioned.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if isinstance(self.conditioning_on,
|
|
111
|
-
self.conditioning_on.
|
|
112
|
-
|
|
113
|
-
self.conditioning_on.container.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
import gamspy._algebra.domain as domain
|
|
6
|
+
import gamspy._algebra.expression as expression
|
|
7
|
+
import gamspy._algebra.operable as operable
|
|
8
|
+
import gamspy._symbols as syms
|
|
9
|
+
import gamspy._symbols.implicits as implicits
|
|
10
|
+
import gamspy.utils as utils
|
|
11
|
+
from gamspy._symbols.implicits.implicit_symbol import ImplicitSymbol
|
|
12
|
+
from gamspy._symbols.symbol import Symbol
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
import pandas as pd
|
|
16
|
+
|
|
17
|
+
from gamspy import Alias, Parameter, Set, Variable
|
|
18
|
+
from gamspy._algebra.domain import Domain
|
|
19
|
+
from gamspy._algebra.expression import Expression
|
|
20
|
+
from gamspy._algebra.number import Number
|
|
21
|
+
from gamspy._algebra.operation import Card, Operation, Ord
|
|
22
|
+
from gamspy._symbols.implicits import (
|
|
23
|
+
ImplicitParameter,
|
|
24
|
+
ImplicitSet,
|
|
25
|
+
)
|
|
26
|
+
from gamspy.math import MathOp
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Condition(operable.Operable):
|
|
30
|
+
"""
|
|
31
|
+
Condition class allows conditioning on GAMSPy constructs such as Symbols and Expressions.
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
symbol: ImplicitSymbol | Expression
|
|
36
|
+
Reference to the symbol to be conditioned.
|
|
37
|
+
|
|
38
|
+
Examples
|
|
39
|
+
--------
|
|
40
|
+
>>> import gamspy as gp
|
|
41
|
+
>>> m = gp.Container()
|
|
42
|
+
>>> i = gp.Set(m, "i", records=["i1", "i2", "i3"])
|
|
43
|
+
>>> a = gp.Parameter(m, "a", domain=i, records=[("i1", 10), ("i2", 20), ("i3", 30)])
|
|
44
|
+
>>> # Conditional assignment: Set values to 1 where they exceed 15
|
|
45
|
+
>>> a[i].where[a[i] > 15] = 1
|
|
46
|
+
>>> a.records.values.tolist()
|
|
47
|
+
[['i1', 10.0], ['i2', 1.0], ['i3', 1.0]]
|
|
48
|
+
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
def __init__(
|
|
52
|
+
self,
|
|
53
|
+
conditioning_on: ImplicitSymbol
|
|
54
|
+
| Set
|
|
55
|
+
| Alias
|
|
56
|
+
| Parameter
|
|
57
|
+
| Variable
|
|
58
|
+
| Expression
|
|
59
|
+
| Operation
|
|
60
|
+
| Domain
|
|
61
|
+
| Number
|
|
62
|
+
| Card
|
|
63
|
+
| Ord
|
|
64
|
+
| MathOp,
|
|
65
|
+
condition: Operation
|
|
66
|
+
| Expression
|
|
67
|
+
| ImplicitParameter
|
|
68
|
+
| ImplicitSet
|
|
69
|
+
| int
|
|
70
|
+
| None = None,
|
|
71
|
+
):
|
|
72
|
+
self.conditioning_on = conditioning_on
|
|
73
|
+
self.condition = condition
|
|
74
|
+
self._where = None
|
|
75
|
+
self.container = None
|
|
76
|
+
if hasattr(conditioning_on, "container"):
|
|
77
|
+
self.container = conditioning_on.container
|
|
78
|
+
|
|
79
|
+
self.domain = None
|
|
80
|
+
if hasattr(conditioning_on, "domain"):
|
|
81
|
+
self.domain = conditioning_on.domain
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def where(self):
|
|
85
|
+
return Condition(self)
|
|
86
|
+
|
|
87
|
+
def __getitem__(
|
|
88
|
+
self,
|
|
89
|
+
condition: Operation | Expression | ImplicitParameter | ImplicitSet,
|
|
90
|
+
) -> Condition:
|
|
91
|
+
if isinstance(condition, expression.Expression):
|
|
92
|
+
condition._fix_equalities()
|
|
93
|
+
|
|
94
|
+
return Condition(self.conditioning_on, condition)
|
|
95
|
+
|
|
96
|
+
def __setitem__(self, condition, rhs):
|
|
97
|
+
# conditioning_on.where[condition] = rhs
|
|
98
|
+
eq_types = (syms.Equation, implicits.ImplicitEquation)
|
|
99
|
+
if isinstance(rhs, bool):
|
|
100
|
+
rhs = "yes" if rhs is True else "no"
|
|
101
|
+
|
|
102
|
+
op_type = ".." if isinstance(self.conditioning_on, eq_types) else "="
|
|
103
|
+
|
|
104
|
+
if isinstance(condition, expression.Expression):
|
|
105
|
+
condition._fix_equalities()
|
|
106
|
+
|
|
107
|
+
lhs = Condition(self.conditioning_on, condition)
|
|
108
|
+
statement = expression.Expression(lhs, op_type, rhs)
|
|
109
|
+
|
|
110
|
+
if isinstance(self.conditioning_on, ImplicitSymbol):
|
|
111
|
+
statement._validate_definition(utils._unpack(self.conditioning_on.domain))
|
|
112
|
+
|
|
113
|
+
self.conditioning_on.container._add_statement(statement)
|
|
114
|
+
|
|
115
|
+
if isinstance(self.conditioning_on, ImplicitSymbol):
|
|
116
|
+
self.conditioning_on.parent._assignment = statement
|
|
117
|
+
self.conditioning_on.parent._winner = "gams"
|
|
118
|
+
elif isinstance(self.conditioning_on, Symbol):
|
|
119
|
+
self.conditioning_on._assignment = statement
|
|
120
|
+
self.conditioning_on._winner = "gams"
|
|
121
|
+
|
|
122
|
+
if isinstance(self.conditioning_on, implicits.ImplicitEquation):
|
|
123
|
+
self.conditioning_on.parent._definition = statement
|
|
124
|
+
|
|
125
|
+
self.conditioning_on.container._synch_with_gams(gams_to_gamspy=True)
|
|
126
|
+
|
|
127
|
+
def __repr__(self) -> str:
|
|
128
|
+
return f"Condition(conditioning_on={self.conditioning_on}, condition={self.condition})"
|
|
129
|
+
|
|
130
|
+
@property
|
|
131
|
+
def dimension(self) -> int:
|
|
132
|
+
"""
|
|
133
|
+
The dimension of the records of the condition.
|
|
134
|
+
|
|
135
|
+
Returns
|
|
136
|
+
-------
|
|
137
|
+
int
|
|
138
|
+
Dimensionality
|
|
139
|
+
|
|
140
|
+
Examples
|
|
141
|
+
--------
|
|
142
|
+
>>> import gamspy as gp
|
|
143
|
+
>>> m = gp.Container()
|
|
144
|
+
>>> i = gp.Set(m, "i", records=["i1", "i2", "i3"])
|
|
145
|
+
>>> a = gp.Parameter(m, "a", domain=i, records=[("i1", 10), ("i2", 20), ("i3", 5)])
|
|
146
|
+
>>> condition = a[i].where[a[i] > 9]
|
|
147
|
+
>>> condition.dimension
|
|
148
|
+
1
|
|
149
|
+
|
|
150
|
+
"""
|
|
151
|
+
if self.domain is None:
|
|
152
|
+
return 0
|
|
153
|
+
|
|
154
|
+
return len(self.domain)
|
|
155
|
+
|
|
156
|
+
@property
|
|
157
|
+
def records(self) -> pd.DataFrame | None:
|
|
158
|
+
"""
|
|
159
|
+
The records of the condition.
|
|
160
|
+
|
|
161
|
+
Returns
|
|
162
|
+
-------
|
|
163
|
+
pd.DataFrame | None
|
|
164
|
+
|
|
165
|
+
Examples
|
|
166
|
+
--------
|
|
167
|
+
>>> import gamspy as gp
|
|
168
|
+
>>> m = gp.Container()
|
|
169
|
+
>>> i = gp.Set(m, "i", records=["i1", "i2", "i3"])
|
|
170
|
+
>>> a = gp.Parameter(m, "a", domain=i, records=[("i1", 10), ("i2", 20), ("i3", 5)])
|
|
171
|
+
>>> condition = a[i].where[a[i] > 9]
|
|
172
|
+
>>> condition.records.values.tolist()
|
|
173
|
+
[['i1', 10.0], ['i2', 20.0]]
|
|
174
|
+
|
|
175
|
+
"""
|
|
176
|
+
assert self.container is not None
|
|
177
|
+
assert self.domain is not None
|
|
178
|
+
if isinstance(
|
|
179
|
+
self.conditioning_on,
|
|
180
|
+
(syms.Set, syms.Alias, implicits.ImplicitSet),
|
|
181
|
+
):
|
|
182
|
+
temp_name = "c" + utils._get_unique_name()
|
|
183
|
+
temp_sym = syms.Set._constructor_bypass(
|
|
184
|
+
self.container,
|
|
185
|
+
temp_name,
|
|
186
|
+
self.domain, # type: ignore
|
|
187
|
+
)
|
|
188
|
+
temp_sym[...] = self
|
|
189
|
+
del self.container.data[temp_name]
|
|
190
|
+
elif isinstance(self.conditioning_on, domain.Domain):
|
|
191
|
+
temp_name = "c" + utils._get_unique_name()
|
|
192
|
+
temp_sym = syms.Set._constructor_bypass(
|
|
193
|
+
self.container,
|
|
194
|
+
temp_name,
|
|
195
|
+
self.domain, # type: ignore
|
|
196
|
+
)
|
|
197
|
+
temp_sym[...].where[self.condition] = True
|
|
198
|
+
del self.container.data[temp_name]
|
|
199
|
+
else:
|
|
200
|
+
temp_name = "c" + utils._get_unique_name()
|
|
201
|
+
temp_sym = syms.Parameter._constructor_bypass(
|
|
202
|
+
self.container,
|
|
203
|
+
temp_name,
|
|
204
|
+
self.domain, # type: ignore
|
|
205
|
+
)
|
|
206
|
+
temp_sym[...] = self
|
|
207
|
+
del self.container.data[temp_name]
|
|
208
|
+
|
|
209
|
+
return temp_sym.records
|
|
210
|
+
|
|
211
|
+
def gamsRepr(self) -> str:
|
|
212
|
+
"""
|
|
213
|
+
Representation of this condition in GAMS.
|
|
214
|
+
|
|
215
|
+
Returns
|
|
216
|
+
-------
|
|
217
|
+
str
|
|
218
|
+
|
|
219
|
+
Examples
|
|
220
|
+
--------
|
|
221
|
+
>>> import gamspy as gp
|
|
222
|
+
>>> m = gp.Container()
|
|
223
|
+
>>> i = gp.Set(m, "i", records=["i1", "i2"])
|
|
224
|
+
>>> a = gp.Parameter(m, "a", domain=i)
|
|
225
|
+
>>> condition = a[i].where[a[i] > 5]
|
|
226
|
+
>>> condition.gamsRepr()
|
|
227
|
+
'a(i) $ (a(i) > 5)'
|
|
228
|
+
|
|
229
|
+
"""
|
|
230
|
+
condition_str = (
|
|
231
|
+
self.condition.gamsRepr() # type: ignore
|
|
232
|
+
if hasattr(self.condition, "gamsRepr")
|
|
233
|
+
else str(self.condition)
|
|
234
|
+
)
|
|
235
|
+
conditioning_on_str = self.conditioning_on.gamsRepr()
|
|
236
|
+
|
|
237
|
+
if isinstance(self.condition, bool):
|
|
238
|
+
condition_str = str(int(self.condition))
|
|
239
|
+
|
|
240
|
+
if isinstance(self.conditioning_on, expression.Expression):
|
|
241
|
+
conditioning_on_str = f"({conditioning_on_str})"
|
|
242
|
+
|
|
243
|
+
return f"{conditioning_on_str} $ ({condition_str})" # type: ignore
|
|
244
|
+
|
|
245
|
+
def getDeclaration(self) -> str:
|
|
246
|
+
"""
|
|
247
|
+
Declaration of this condition in GAMS.
|
|
248
|
+
|
|
249
|
+
Returns
|
|
250
|
+
-------
|
|
251
|
+
str
|
|
252
|
+
|
|
253
|
+
Examples
|
|
254
|
+
--------
|
|
255
|
+
>>> import gamspy as gp
|
|
256
|
+
>>> m = gp.Container()
|
|
257
|
+
>>> i = gp.Set(m, "i", records=["i1", "i2"])
|
|
258
|
+
>>> a = gp.Parameter(m, "a", domain=i)
|
|
259
|
+
>>> condition = a[i].where[a[i] > 5]
|
|
260
|
+
>>> condition.getDeclaration()
|
|
261
|
+
'a(i) $ (a(i) > 5)'
|
|
262
|
+
|
|
263
|
+
"""
|
|
264
|
+
return self.gamsRepr()
|
|
265
|
+
|
|
266
|
+
def latexRepr(self) -> str:
|
|
267
|
+
"""
|
|
268
|
+
Representation of this condition in Latex.
|
|
269
|
+
|
|
270
|
+
Returns
|
|
271
|
+
-------
|
|
272
|
+
str
|
|
273
|
+
|
|
274
|
+
Examples
|
|
275
|
+
--------
|
|
276
|
+
>>> import gamspy as gp
|
|
277
|
+
>>> m = gp.Container()
|
|
278
|
+
>>> i = gp.Set(m, "i", records=["i1", "i2"])
|
|
279
|
+
>>> a = gp.Parameter(m, "a", domain=i)
|
|
280
|
+
>>> condition = a[i].where[a[i] > 2]
|
|
281
|
+
>>> condition.latexRepr()
|
|
282
|
+
'a_{i} ~ | ~ a_{i} > 2'
|
|
283
|
+
|
|
284
|
+
"""
|
|
285
|
+
condition_str = (
|
|
286
|
+
self.condition.latexRepr() # type: ignore
|
|
287
|
+
if hasattr(self.condition, "latexRepr")
|
|
288
|
+
else str(self.condition)
|
|
289
|
+
)
|
|
290
|
+
return f"{self.conditioning_on.latexRepr()} ~ | ~ {condition_str}" # type: ignore
|