gamspy 1.18.4__tar.gz → 1.19.1__tar.gz

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 (98) hide show
  1. {gamspy-1.18.4 → gamspy-1.19.1}/LICENSE +3 -3
  2. {gamspy-1.18.4/src/gamspy.egg-info → gamspy-1.19.1}/PKG-INFO +1 -32
  3. {gamspy-1.18.4 → gamspy-1.19.1}/pyproject.toml +39 -38
  4. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_algebra/condition.py +37 -0
  5. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_algebra/operation.py +140 -37
  6. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_backend/backend.py +3 -1
  7. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_backend/engine.py +10 -10
  8. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_backend/local.py +8 -8
  9. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_backend/neos.py +10 -10
  10. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_cli/install.py +0 -2
  11. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_container.py +94 -15
  12. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_convert.py +2 -2
  13. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_miro.py +6 -2
  14. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_model.py +134 -13
  15. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_model_instance.py +6 -6
  16. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_options.py +7 -5
  17. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_symbols/symbol.py +9 -0
  18. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_workspace.py +1 -1
  19. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/piecewise.py +2 -2
  20. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/math/activation.py +16 -0
  21. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/math/misc.py +84 -0
  22. {gamspy-1.18.4 → gamspy-1.19.1/src/gamspy.egg-info}/PKG-INFO +1 -32
  23. gamspy-1.19.1/src/gamspy.egg-info/requires.txt +9 -0
  24. {gamspy-1.18.4 → gamspy-1.19.1}/tests/test_gamspy.py +1 -1
  25. gamspy-1.18.4/src/gamspy.egg-info/requires.txt +0 -43
  26. {gamspy-1.18.4 → gamspy-1.19.1}/README.md +0 -0
  27. {gamspy-1.18.4 → gamspy-1.19.1}/README_PYPI.md +0 -0
  28. {gamspy-1.18.4 → gamspy-1.19.1}/setup.cfg +0 -0
  29. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/__init__.py +0 -0
  30. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/__main__.py +0 -0
  31. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_algebra/__init__.py +0 -0
  32. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_algebra/domain.py +0 -0
  33. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_algebra/expression.py +0 -0
  34. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_algebra/number.py +0 -0
  35. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_algebra/operable.py +0 -0
  36. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_backend/__init__.py +0 -0
  37. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_cli/__init__.py +0 -0
  38. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_cli/cli.py +0 -0
  39. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_cli/gdx.py +0 -0
  40. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_cli/list.py +0 -0
  41. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_cli/mps2gms.py +0 -0
  42. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_cli/probe.py +0 -0
  43. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_cli/retrieve.py +0 -0
  44. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_cli/run.py +0 -0
  45. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_cli/show.py +0 -0
  46. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_cli/uninstall.py +0 -0
  47. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_cli/util.py +0 -0
  48. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_communication.py +0 -0
  49. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_config.py +0 -0
  50. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_database.py +0 -0
  51. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_extrinsic.py +0 -0
  52. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_serialization.py +0 -0
  53. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_symbols/__init__.py +0 -0
  54. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_symbols/alias.py +0 -0
  55. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_symbols/equation.py +0 -0
  56. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_symbols/implicits/__init__.py +0 -0
  57. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_symbols/implicits/implicit_equation.py +0 -0
  58. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_symbols/implicits/implicit_parameter.py +0 -0
  59. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_symbols/implicits/implicit_set.py +0 -0
  60. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_symbols/implicits/implicit_symbol.py +0 -0
  61. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_symbols/implicits/implicit_variable.py +0 -0
  62. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_symbols/parameter.py +0 -0
  63. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_symbols/set.py +0 -0
  64. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_symbols/universe_alias.py +0 -0
  65. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_symbols/variable.py +0 -0
  66. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_types.py +0 -0
  67. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/_validation.py +0 -0
  68. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/exceptions.py +0 -0
  69. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/__init__.py +0 -0
  70. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/ml/__init__.py +0 -0
  71. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/ml/decision_tree_struct.py +0 -0
  72. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/ml/gradient_boosting.py +0 -0
  73. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/ml/random_forest.py +0 -0
  74. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/ml/regression_tree.py +0 -0
  75. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/nn/__init__.py +0 -0
  76. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/nn/avgpool2d.py +0 -0
  77. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/nn/conv1d.py +0 -0
  78. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/nn/conv2d.py +0 -0
  79. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/nn/linear.py +0 -0
  80. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/nn/maxpool2d.py +0 -0
  81. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/nn/minpool2d.py +0 -0
  82. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/nn/mpool2d.py +0 -0
  83. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/nn/torch_sequential.py +0 -0
  84. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/result.py +0 -0
  85. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/shape.py +0 -0
  86. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/formulations/utils.py +0 -0
  87. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/math/__init__.py +0 -0
  88. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/math/log_power.py +0 -0
  89. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/math/matrix.py +0 -0
  90. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/math/probability.py +0 -0
  91. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/math/trigonometric.py +0 -0
  92. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/py.typed +0 -0
  93. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/utils.py +0 -0
  94. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy/version.py +0 -0
  95. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy.egg-info/SOURCES.txt +0 -0
  96. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy.egg-info/dependency_links.txt +0 -0
  97. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy.egg-info/entry_points.txt +0 -0
  98. {gamspy-1.18.4 → gamspy-1.19.1}/src/gamspy.egg-info/top_level.txt +0 -0
@@ -1,7 +1,7 @@
1
- GAMSpy - General Algebraic Modeling in Python
1
+ GAMSPy - General Algebraic Modeling in Python
2
2
 
3
- Copyright (c) 2024 GAMS Development Corp. <support@gams.com>
4
- Copyright (c) 2024 GAMS Software GmbH <support@gams.com>
3
+ Copyright (c) 2026 GAMS Development Corp. <support@gams.com>
4
+ Copyright (c) 2026 GAMS Software GmbH <support@gams.com>
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gamspy
3
- Version: 1.18.4
3
+ Version: 1.19.1
4
4
  Summary: Python-based algebraic modeling interface to GAMS
5
5
  Author-email: GAMS Development Corporation <support@gams.com>
6
6
  Project-URL: homepage, https://gams.com/sales/gamspy_facts/
@@ -37,37 +37,6 @@ Requires-Dist: pandas<2.4,>=2.2.2
37
37
  Requires-Dist: pydantic>=2.0
38
38
  Requires-Dist: requests>=2.28.0
39
39
  Requires-Dist: typer>=0.16.0
40
- Provides-Extra: dev
41
- Requires-Dist: ruff>=0.13.0; extra == "dev"
42
- Requires-Dist: pre-commit>=3.5.0; extra == "dev"
43
- Requires-Dist: mypy>=1.18.1; extra == "dev"
44
- Requires-Dist: griffe>=1.14.0; extra == "dev"
45
- Provides-Extra: test
46
- Requires-Dist: coverage[toml]>=7.2.7; extra == "test"
47
- Requires-Dist: openpyxl>=3.1.2; extra == "test"
48
- Requires-Dist: cerberus>=1.3.5; extra == "test"
49
- Requires-Dist: python-dotenv>=1.0.0; extra == "test"
50
- Requires-Dist: pytest>=8.0.0; extra == "test"
51
- Requires-Dist: networkx>=3.2.1; extra == "test"
52
- Requires-Dist: scikit-learn>=1.6.1; extra == "test"
53
- Provides-Extra: doc
54
- Requires-Dist: sphinx>=7.1.2; extra == "doc"
55
- Requires-Dist: numpydoc>=1.5.0; extra == "doc"
56
- Requires-Dist: nbsphinx>=0.9.3; extra == "doc"
57
- Requires-Dist: sphinx_copybutton>=0.5.2; extra == "doc"
58
- Requires-Dist: sphinx-favicon>=1.0.1; extra == "doc"
59
- Requires-Dist: ipykernel; extra == "doc"
60
- Requires-Dist: matplotlib>=3.7.3; extra == "doc"
61
- Requires-Dist: sphinx_design>=0.5.0; extra == "doc"
62
- Requires-Dist: pydata_sphinx_theme>=0.14.1; extra == "doc"
63
- Requires-Dist: plotly>=5.22.0; extra == "doc"
64
- Requires-Dist: kaleido==0.2.1; extra == "doc"
65
- Requires-Dist: pytest>=8.2.1; extra == "doc"
66
- Requires-Dist: nbmake>=1.5.3; extra == "doc"
67
- Requires-Dist: openpyxl>=3.1.2; extra == "doc"
68
- Requires-Dist: sphinx-tabs>=3.4.7; extra == "doc"
69
- Requires-Dist: towncrier>=24.8.0; extra == "doc"
70
- Requires-Dist: geopandas>=1.1.1; extra == "doc"
71
40
  Provides-Extra: torch
72
41
  Requires-Dist: torch>=2.7.0; extra == "torch"
73
42
  Dynamic: license-file
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gamspy"
7
- version = "1.18.4"
7
+ version = "1.19.1"
8
8
  authors = [
9
9
  { name = "GAMS Development Corporation", email = "support@gams.com" },
10
10
  ]
@@ -52,43 +52,6 @@ changelog = "https://github.com/GAMS-dev/gamspy/blob/develop/CHANGELOG.md"
52
52
 
53
53
 
54
54
  [project.optional-dependencies]
55
- dev = [
56
- "ruff >= 0.13.0",
57
- "pre-commit >= 3.5.0",
58
- "mypy >= 1.18.1",
59
- "griffe >= 1.14.0",
60
- ]
61
-
62
- test = [
63
- "coverage[toml] >= 7.2.7",
64
- "openpyxl >= 3.1.2",
65
- "cerberus >= 1.3.5",
66
- "python-dotenv >= 1.0.0",
67
- "pytest >= 8.0.0",
68
- "networkx >= 3.2.1",
69
- "scikit-learn >= 1.6.1",
70
- ]
71
-
72
- doc = [
73
- "sphinx>=7.1.2",
74
- "numpydoc>=1.5.0",
75
- "nbsphinx>=0.9.3",
76
- "sphinx_copybutton>=0.5.2",
77
- "sphinx-favicon>=1.0.1",
78
- "ipykernel",
79
- "matplotlib>=3.7.3",
80
- "sphinx_design>=0.5.0",
81
- "pydata_sphinx_theme>=0.14.1",
82
- "plotly>=5.22.0",
83
- "kaleido==0.2.1",
84
- "pytest>=8.2.1",
85
- "nbmake>=1.5.3",
86
- "openpyxl>=3.1.2",
87
- "sphinx-tabs>=3.4.7",
88
- "towncrier>= 24.8.0",
89
- "geopandas >= 1.1.1",
90
- ]
91
-
92
55
  torch = [
93
56
  "torch>=2.7.0"
94
57
  ]
@@ -103,6 +66,44 @@ name = "pytorch-cpu"
103
66
  url = "https://download.pytorch.org/whl/cpu"
104
67
  explicit = true
105
68
 
69
+ [dependency-groups]
70
+ dev = [
71
+ "griffe>=1.15.0",
72
+ "mypy>=1.19.1",
73
+ "prek>=0.2.28",
74
+ "ruff>=0.14.11",
75
+ ]
76
+ doc = [
77
+ "geopandas>=1.1.2",
78
+ "ipykernel>=7.1.0",
79
+ "kaleido>=0.2.1",
80
+ "matplotlib>=3.10.8",
81
+ "nbmake>=1.5.5",
82
+ "nbsphinx>=0.9.8",
83
+ "numpydoc>=1.10.0",
84
+ "openpyxl>=3.1.5",
85
+ "plotly>=6.5.1",
86
+ "pydata-sphinx-theme>=0.16.1",
87
+ "pytest>=9.0.2",
88
+ "sphinx>=8.1.3",
89
+ "sphinx-copybutton>=0.5.2",
90
+ "sphinx-design>=0.6.1",
91
+ "sphinx-favicon>=1.0.1",
92
+ "sphinx-tabs>=3.4.7",
93
+ "towncrier>=25.8.0",
94
+ ]
95
+ test = [
96
+ "cerberus>=1.3.8",
97
+ "coverage[toml]>=7.13.1",
98
+ "networkx>=3.4.2",
99
+ "openpyxl>=3.1.5",
100
+ "pip>=25.3",
101
+ "pytest>=9.0.2",
102
+ "python-dotenv>=1.2.1",
103
+ "pyyaml>=6.0.3",
104
+ "scikit-learn>=1.7.2",
105
+ ]
106
+
106
107
  [project.scripts]
107
108
  gamspy = "gamspy._cli.cli:main"
108
109
 
@@ -129,6 +129,25 @@ class Condition(operable.Operable):
129
129
 
130
130
  @property
131
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
+ """
132
151
  if self.domain is None:
133
152
  return 0
134
153
 
@@ -224,6 +243,24 @@ class Condition(operable.Operable):
224
243
  return f"{conditioning_on_str} $ ({condition_str})" # type: ignore
225
244
 
226
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
+ """
227
264
  return self.gamsRepr()
228
265
 
229
266
  def latexRepr(self) -> str:
@@ -2,6 +2,8 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING
4
4
 
5
+ from typing_extensions import override
6
+
5
7
  import gamspy._algebra.condition as condition
6
8
  import gamspy._algebra.domain as domain
7
9
  import gamspy._algebra.expression as expression
@@ -30,19 +32,45 @@ if TYPE_CHECKING:
30
32
 
31
33
 
32
34
  class Operation(operable.Operable):
33
- def __init__(
34
- self,
35
- domain: Set | Alias | ImplicitSet | Sequence[Set | Alias] | Domain | Condition,
36
- rhs: (
37
- Expression
38
- | Operation
35
+ """
36
+ Base class for different operations (Sum, Product etc.) over a domain.
37
+
38
+ Parameters
39
+ ----------
40
+ domain : Set | Alias | ImplicitSet | Sequence[Set | Alias], Domain, Condition
41
+ rhs : Operation
42
+ | Expression
39
43
  | MathOp
40
- | ImplicitSet
41
44
  | ImplicitVariable
42
45
  | ImplicitParameter
43
46
  | int
44
47
  | bool
45
- ),
48
+ | Variable
49
+ | Parameter
50
+
51
+ Examples
52
+ --------
53
+ >>> import gamspy as gp
54
+ >>> m = gp.Container()
55
+ >>> i = gp.Set(m, "i", records=['i1','i2', 'i3'])
56
+ >>> v = gp.Variable(m, "v")
57
+ >>> e = gp.Equation(m, "e", type="eq")
58
+ >>> d = gp.Parameter(m, "d", domain=[i], records=[("i1", 1), ("i2", 2), ("i3", 4)])
59
+ >>> e[...] = gp.Sum(i, d[i]) <= v
60
+
61
+ """
62
+
63
+ def __init__(
64
+ self,
65
+ domain: Set | Alias | ImplicitSet | Sequence[Set | Alias] | Domain | Condition,
66
+ rhs: Operation
67
+ | Expression
68
+ | MathOp
69
+ | ImplicitVariable
70
+ | ImplicitParameter
71
+ | ImplicitSet
72
+ | int
73
+ | bool,
46
74
  op_name: str,
47
75
  ):
48
76
  self.op_domain = utils._to_list(domain) # type: ignore
@@ -93,6 +121,18 @@ class Operation(operable.Operable):
93
121
  Returns
94
122
  -------
95
123
  pd.DataFrame | None
124
+
125
+ Examples
126
+ --------
127
+ >>> import numpy as np
128
+ >>> import gamspy as gp
129
+ >>> m = gp.Container()
130
+ >>> i = gp.Set(m, "i", records=["i1", "i2"])
131
+ >>> a = gp.Parameter(m, "a", domain=i, records=np.array([1,2]))
132
+ >>> gp.Sum(i, a[i]).records
133
+ value
134
+ 0 3.0
135
+
96
136
  """
97
137
  assert self.container is not None
98
138
  temp_name = "a" + utils._get_unique_name()
@@ -117,6 +157,17 @@ class Operation(operable.Operable):
117
157
  Returns
118
158
  -------
119
159
  float | None
160
+
161
+ Examples
162
+ --------
163
+ >>> import numpy as np
164
+ >>> import gamspy as gp
165
+ >>> m = gp.Container()
166
+ >>> i = gp.Set(m, "i", records=["i1", "i2"])
167
+ >>> a = gp.Parameter(m, "a", domain=i, records=np.array([1,2]))
168
+ >>> gp.Sum(i, a[i]).toValue()
169
+ np.float64(3.0)
170
+
120
171
  """
121
172
  records = self.records
122
173
  if records is not None:
@@ -131,6 +182,18 @@ class Operation(operable.Operable):
131
182
  Returns
132
183
  -------
133
184
  list | None
185
+
186
+ Examples
187
+ --------
188
+ >>> import numpy as np
189
+ >>> import gamspy as gp
190
+ >>> m = gp.Container()
191
+ >>> i = gp.Set(m, "i", records=["i1", "i2"])
192
+ >>> j = gp.Set(m, "j", records=["j1", "j2"])
193
+ >>> a = gp.Parameter(m, "a", domain=[i, j], records=np.array([(1,2), (3,4)]))
194
+ >>> gp.Sum(i, a[i, j]).toList()
195
+ [['j1', 4.0], ['j2', 6.0]]
196
+
134
197
  """
135
198
  records = self.records
136
199
  if records is not None:
@@ -195,6 +258,24 @@ class Operation(operable.Operable):
195
258
  return output
196
259
 
197
260
  def gamsRepr(self) -> str:
261
+ """
262
+ Representation of this operation in GAMS.
263
+
264
+ Returns
265
+ -------
266
+ str
267
+
268
+ Examples
269
+ --------
270
+ >>> import numpy as np
271
+ >>> import gamspy as gp
272
+ >>> m = gp.Container()
273
+ >>> i = gp.Set(m, "i", records=range(3))
274
+ >>> a = gp.Parameter(m, "a", domain=i, records=np.array([3,5,7]))
275
+ >>> print(gp.Sum(i, a[i]).gamsRepr())
276
+ sum(i,a(i))
277
+
278
+ """
198
279
  # Ex: sum((i,j), c(i,j) * x(i,j))
199
280
  output = f"{self._op_name}("
200
281
 
@@ -231,6 +312,16 @@ class Operation(operable.Operable):
231
312
  Returns
232
313
  -------
233
314
  str
315
+
316
+ Examples
317
+ --------
318
+ >>> import numpy as np
319
+ >>> import gamspy as gp
320
+ >>> m = gp.Container()
321
+ >>> i = gp.Set(m, "i", records=range(3))
322
+ >>> a = gp.Parameter(m, "a", domain=i, records=np.array([3,5,7]))
323
+ >>> print(gp.Sum(i, a[i]).latexRepr()) # doctest: +SKIP
324
+
234
325
  """
235
326
  op_map = {
236
327
  "sum": "sum",
@@ -274,8 +365,8 @@ class Sum(Operation):
274
365
  Parameters
275
366
  ----------
276
367
  domain : Set | Alias | ImplicitSet | Sequence[Set | Alias], Domain, Condition
277
- expression : (
278
- Expression
368
+ expression : Operation
369
+ | Expression
279
370
  | MathOp
280
371
  | ImplicitVariable
281
372
  | ImplicitParameter
@@ -283,8 +374,6 @@ class Sum(Operation):
283
374
  | bool
284
375
  | Variable
285
376
  | Parameter
286
- | Operation
287
- )
288
377
 
289
378
  Examples
290
379
  --------
@@ -315,6 +404,7 @@ class Sum(Operation):
315
404
  def __repr__(self) -> str:
316
405
  return f"Sum(domain={self.domain}, expression={self.rhs})"
317
406
 
407
+ @override
318
408
  def gamsRepr(self):
319
409
  """
320
410
  Representation of the Sum operation in GAMS language.
@@ -344,9 +434,9 @@ class Product(Operation):
344
434
 
345
435
  Parameters
346
436
  ----------
347
- domain : Set | Alias | Sequence[Set | Alias], Domain, Expression
348
- expression : (
349
- Expression
437
+ domain : Set | Alias | ImplicitSet | Sequence[Set | Alias], Domain, Condition
438
+ expression : Operation
439
+ | Expression
350
440
  | MathOp
351
441
  | ImplicitVariable
352
442
  | ImplicitParameter
@@ -354,8 +444,6 @@ class Product(Operation):
354
444
  | bool
355
445
  | Variable
356
446
  | Parameter
357
- | Operation
358
- )
359
447
 
360
448
  Examples
361
449
  --------
@@ -386,6 +474,7 @@ class Product(Operation):
386
474
  def __repr__(self) -> str:
387
475
  return f"Product(domain={self.domain}, expression={self.rhs})"
388
476
 
477
+ @override
389
478
  def gamsRepr(self):
390
479
  """
391
480
  Representation of the Product operation in GAMS language.
@@ -415,9 +504,9 @@ class Smin(Operation):
415
504
 
416
505
  Parameters
417
506
  ----------
418
- domain : Set | Alias | Sequence[Set | Alias], Domain, Expression
419
- expression : (
420
- Expression
507
+ domain : Set | Alias | ImplicitSet | Sequence[Set | Alias], Domain, Condition
508
+ expression : Operation
509
+ | Expression
421
510
  | MathOp
422
511
  | ImplicitVariable
423
512
  | ImplicitParameter
@@ -425,8 +514,6 @@ class Smin(Operation):
425
514
  | bool
426
515
  | Variable
427
516
  | Parameter
428
- | Operation
429
- )
430
517
 
431
518
  Examples
432
519
  --------
@@ -457,6 +544,7 @@ class Smin(Operation):
457
544
  def __repr__(self) -> str:
458
545
  return f"Smin(domain={self.domain}, expression={self.rhs})"
459
546
 
547
+ @override
460
548
  def gamsRepr(self):
461
549
  """
462
550
  Representation of the Smin operation in GAMS language.
@@ -486,9 +574,9 @@ class Smax(Operation):
486
574
 
487
575
  Parameters
488
576
  ----------
489
- domain : Set | Alias | Sequence[Set | Alias], Domain, Expression
490
- expression : (
491
- Expression
577
+ domain : Set | Alias | ImplicitSet | Sequence[Set | Alias], Domain, Condition
578
+ expression : Operation
579
+ | Expression
492
580
  | MathOp
493
581
  | ImplicitVariable
494
582
  | ImplicitParameter
@@ -496,8 +584,6 @@ class Smax(Operation):
496
584
  | bool
497
585
  | Variable
498
586
  | Parameter
499
- | Operation
500
- )
501
587
 
502
588
  Examples
503
589
  --------
@@ -528,6 +614,7 @@ class Smax(Operation):
528
614
  def __repr__(self) -> str:
529
615
  return f"Smax(domain={self.domain}, expression={self.rhs})"
530
616
 
617
+ @override
531
618
  def gamsRepr(self):
532
619
  """
533
620
  Representation of the Smax operation in GAMS language.
@@ -557,9 +644,9 @@ class Sand(Operation):
557
644
 
558
645
  Parameters
559
646
  ----------
560
- domain : Set | Alias | Sequence[Set | Alias], Domain, Expression
561
- expression : (
562
- Expression
647
+ domain : Set | Alias | ImplicitSet | Sequence[Set | Alias], Domain, Condition
648
+ expression : Operation
649
+ | Expression
563
650
  | MathOp
564
651
  | ImplicitVariable
565
652
  | ImplicitParameter
@@ -567,8 +654,6 @@ class Sand(Operation):
567
654
  | bool
568
655
  | Variable
569
656
  | Parameter
570
- | Operation
571
- )
572
657
 
573
658
  Examples
574
659
  --------
@@ -599,6 +684,7 @@ class Sand(Operation):
599
684
  def __repr__(self) -> str:
600
685
  return f"Sand(domain={self.domain}, expression={self.rhs})"
601
686
 
687
+ @override
602
688
  def gamsRepr(self):
603
689
  """
604
690
  Representation of the Sand operation in GAMS language.
@@ -627,9 +713,9 @@ class Sor(Operation):
627
713
 
628
714
  Parameters
629
715
  ----------
630
- domain : Set | Alias | Sequence[Set | Alias], Domain, Expression
631
- expression : (
632
- Expression
716
+ domain : Set | Alias | ImplicitSet | Sequence[Set | Alias], Domain, Condition
717
+ expression : Operation
718
+ | Expression
633
719
  | MathOp
634
720
  | ImplicitVariable
635
721
  | ImplicitParameter
@@ -637,8 +723,6 @@ class Sor(Operation):
637
723
  | bool
638
724
  | Variable
639
725
  | Parameter
640
- | Operation
641
- )
642
726
 
643
727
  Examples
644
728
  --------
@@ -669,6 +753,7 @@ class Sor(Operation):
669
753
  def __repr__(self) -> str:
670
754
  return f"Sor(domain={self.domain}, expression={self.rhs})"
671
755
 
756
+ @override
672
757
  def gamsRepr(self):
673
758
  """
674
759
  Representation of the Sor operation in GAMS language.
@@ -762,6 +847,15 @@ class Ord(operable.Operable):
762
847
  Returns
763
848
  -------
764
849
  str
850
+
851
+ Examples
852
+ --------
853
+ >>> import gamspy as gp
854
+ >>> m = gp.Container()
855
+ >>> i = gp.Set(m, "i")
856
+ >>> print(gp.Ord(i).latexRepr())
857
+ ord(i)
858
+
765
859
  """
766
860
  return f"ord({self._symbol._latex_name})"
767
861
 
@@ -841,5 +935,14 @@ class Card(operable.Operable):
841
935
  Returns
842
936
  -------
843
937
  str
938
+
939
+ Examples
940
+ --------
941
+ >>> import gamspy as gp
942
+ >>> m = gp.Container()
943
+ >>> i = gp.Set(m, "i")
944
+ >>> print(gp.Card(i).latexRepr())
945
+ card(i)
946
+
844
947
  """
845
948
  return f"card({self._symbol._latex_name})"
@@ -222,7 +222,9 @@ class Backend(ABC):
222
222
  symbols = filtered_names
223
223
 
224
224
  if len(symbols) != 0:
225
- self.container._load_records_from_gdx(self.container._gdx_out, symbols)
225
+ self.container._load_records_from_gdx(
226
+ self.container._gdx_out, symbols, create_if_not_declared=True
227
+ )
226
228
  self.make_unmodified(symbols)
227
229
 
228
230
  if relaxed_domain_mapping:
@@ -798,14 +798,14 @@ class GAMSEngine(backend.Backend):
798
798
  return summary
799
799
 
800
800
  def execute_gams(self, gams_string: str):
801
- extra_options = {
801
+ hidden_options = {
802
802
  "gdx": os.path.basename(self.container._gdx_out),
803
803
  "gdxSymbols": "newOrChanged",
804
804
  "trace": os.path.basename(self.trace_file),
805
805
  "restart": os.path.basename(self.restart_file),
806
806
  "input": os.path.basename(self.gms_file),
807
807
  }
808
- self.options._set_extra_options(extra_options)
808
+ self.options._set_hidden_options(hidden_options)
809
809
  self.options._export(self.pf_file, self.output)
810
810
 
811
811
  with open(self.gms_file, "w", encoding="utf-8") as file:
@@ -891,7 +891,7 @@ class GAMSEngine(backend.Backend):
891
891
  def _prepare_dummy_options(self) -> dict:
892
892
  scrdir = self.container._process_directory
893
893
 
894
- extra_options = {
894
+ hidden_options = {
895
895
  "gdx": self.container._gdx_out,
896
896
  "gdxSymbols": "newOrChanged",
897
897
  "trace": self.trace_file,
@@ -905,18 +905,18 @@ class GAMSEngine(backend.Backend):
905
905
  }
906
906
 
907
907
  if self.container._network_license:
908
- extra_options["netlicense"] = os.path.join(scrdir, "gamslice.dat")
908
+ hidden_options["netlicense"] = os.path.join(scrdir, "gamslice.dat")
909
909
 
910
- return extra_options
910
+ return hidden_options
911
911
 
912
912
  def _create_restart_file(self):
913
913
  with open(self.gms_file, "w", encoding="utf-8") as gams_file:
914
914
  gams_file.write("")
915
915
 
916
916
  options = Options()
917
- extra_options = self._prepare_dummy_options()
918
- options._set_extra_options(extra_options)
919
- options._extra_options["save"] = self.restart_file
917
+ hidden_options = self._prepare_dummy_options()
918
+ options._set_hidden_options(hidden_options)
919
+ options._hidden_options["save"] = self.restart_file
920
920
  options._export(self.pf_file)
921
921
 
922
922
  send_job(self.container._comm_pair_id, self.job_name, self.pf_file)
@@ -930,8 +930,8 @@ class GAMSEngine(backend.Backend):
930
930
  gams_file.write(f'execute_load "{self.container._gdx_out}", {dirty_str};')
931
931
 
932
932
  options = Options()
933
- extra_options = self._prepare_dummy_options()
934
- options._set_extra_options(extra_options)
933
+ hidden_options = self._prepare_dummy_options()
934
+ options._set_hidden_options(hidden_options)
935
935
  options._export(self.pf_file)
936
936
 
937
937
  send_job(self.container._comm_pair_id, self.job_name, self.pf_file)
@@ -38,10 +38,10 @@ class Local(backend.Backend):
38
38
  load_symbols,
39
39
  )
40
40
 
41
- def _prepare_extra_options(self, gams_to_gamspy: bool) -> dict:
41
+ def _prepare_hidden_options(self, gams_to_gamspy: bool) -> dict:
42
42
  scrdir = self.container._process_directory
43
43
 
44
- extra_options = {
44
+ hidden_options = {
45
45
  "trace": self.trace_file,
46
46
  "input": self.gms_file,
47
47
  "output": self.lst_file,
@@ -53,13 +53,13 @@ class Local(backend.Backend):
53
53
  }
54
54
 
55
55
  if gams_to_gamspy:
56
- extra_options["gdx"] = self.container._gdx_out
57
- extra_options["gdxSymbols"] = "newOrChanged"
56
+ hidden_options["gdx"] = self.container._gdx_out
57
+ hidden_options["gdxSymbols"] = "newOrChanged"
58
58
 
59
59
  if self.container._network_license:
60
- extra_options["netlicense"] = os.path.join(scrdir, "gamslice.dat")
60
+ hidden_options["netlicense"] = os.path.join(scrdir, "gamslice.dat")
61
61
 
62
- return extra_options
62
+ return hidden_options
63
63
 
64
64
  def is_async(self):
65
65
  return False
@@ -86,8 +86,8 @@ class Local(backend.Backend):
86
86
  gams_file.write(gams_string)
87
87
 
88
88
  # Write pf file
89
- extra_options = self._prepare_extra_options(gams_to_gamspy)
90
- self.options._set_extra_options(extra_options)
89
+ hidden_options = self._prepare_hidden_options(gams_to_gamspy)
90
+ self.options._set_hidden_options(hidden_options)
91
91
  self.options._export(self.pf_file, self.output)
92
92
 
93
93
  try: