gamspy 1.5.0__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 (81) hide show
  1. gamspy-1.5.0/LICENSE +22 -0
  2. gamspy-1.5.0/PKG-INFO +137 -0
  3. gamspy-1.5.0/README.md +49 -0
  4. gamspy-1.5.0/README_PYPI.md +47 -0
  5. gamspy-1.5.0/pyproject.toml +191 -0
  6. gamspy-1.5.0/setup.cfg +4 -0
  7. gamspy-1.5.0/src/gamspy/__init__.py +76 -0
  8. gamspy-1.5.0/src/gamspy/__main__.py +6 -0
  9. gamspy-1.5.0/src/gamspy/_algebra/__init__.py +13 -0
  10. gamspy-1.5.0/src/gamspy/_algebra/condition.py +128 -0
  11. gamspy-1.5.0/src/gamspy/_algebra/domain.py +94 -0
  12. gamspy-1.5.0/src/gamspy/_algebra/expression.py +508 -0
  13. gamspy-1.5.0/src/gamspy/_algebra/number.py +58 -0
  14. gamspy-1.5.0/src/gamspy/_algebra/operable.py +135 -0
  15. gamspy-1.5.0/src/gamspy/_algebra/operation.py +821 -0
  16. gamspy-1.5.0/src/gamspy/_backend/__init__.py +0 -0
  17. gamspy-1.5.0/src/gamspy/_backend/backend.py +279 -0
  18. gamspy-1.5.0/src/gamspy/_backend/engine.py +973 -0
  19. gamspy-1.5.0/src/gamspy/_backend/local.py +131 -0
  20. gamspy-1.5.0/src/gamspy/_backend/neos.py +562 -0
  21. gamspy-1.5.0/src/gamspy/_cli/__init__.py +1 -0
  22. gamspy-1.5.0/src/gamspy/_cli/cli.py +92 -0
  23. gamspy-1.5.0/src/gamspy/_cli/install.py +299 -0
  24. gamspy-1.5.0/src/gamspy/_cli/list.py +89 -0
  25. gamspy-1.5.0/src/gamspy/_cli/retrieve.py +73 -0
  26. gamspy-1.5.0/src/gamspy/_cli/run.py +148 -0
  27. gamspy-1.5.0/src/gamspy/_cli/show.py +46 -0
  28. gamspy-1.5.0/src/gamspy/_cli/uninstall.py +122 -0
  29. gamspy-1.5.0/src/gamspy/_cli/util.py +98 -0
  30. gamspy-1.5.0/src/gamspy/_container.py +1326 -0
  31. gamspy-1.5.0/src/gamspy/_convert.py +366 -0
  32. gamspy-1.5.0/src/gamspy/_extrinsic.py +122 -0
  33. gamspy-1.5.0/src/gamspy/_miro.py +346 -0
  34. gamspy-1.5.0/src/gamspy/_model.py +1243 -0
  35. gamspy-1.5.0/src/gamspy/_model_instance.py +413 -0
  36. gamspy-1.5.0/src/gamspy/_options.py +547 -0
  37. gamspy-1.5.0/src/gamspy/_symbols/__init__.py +17 -0
  38. gamspy-1.5.0/src/gamspy/_symbols/alias.py +251 -0
  39. gamspy-1.5.0/src/gamspy/_symbols/equation.py +1180 -0
  40. gamspy-1.5.0/src/gamspy/_symbols/implicits/__init__.py +11 -0
  41. gamspy-1.5.0/src/gamspy/_symbols/implicits/implicit_equation.py +160 -0
  42. gamspy-1.5.0/src/gamspy/_symbols/implicits/implicit_parameter.py +214 -0
  43. gamspy-1.5.0/src/gamspy/_symbols/implicits/implicit_set.py +82 -0
  44. gamspy-1.5.0/src/gamspy/_symbols/implicits/implicit_symbol.py +115 -0
  45. gamspy-1.5.0/src/gamspy/_symbols/implicits/implicit_variable.py +230 -0
  46. gamspy-1.5.0/src/gamspy/_symbols/parameter.py +545 -0
  47. gamspy-1.5.0/src/gamspy/_symbols/set.py +887 -0
  48. gamspy-1.5.0/src/gamspy/_symbols/symbol.py +115 -0
  49. gamspy-1.5.0/src/gamspy/_symbols/universe_alias.py +171 -0
  50. gamspy-1.5.0/src/gamspy/_symbols/variable.py +961 -0
  51. gamspy-1.5.0/src/gamspy/_types.py +11 -0
  52. gamspy-1.5.0/src/gamspy/_validation.py +528 -0
  53. gamspy-1.5.0/src/gamspy/_workspace.py +62 -0
  54. gamspy-1.5.0/src/gamspy/exceptions.py +130 -0
  55. gamspy-1.5.0/src/gamspy/formulations/__init__.py +27 -0
  56. gamspy-1.5.0/src/gamspy/formulations/nn/__init__.py +15 -0
  57. gamspy-1.5.0/src/gamspy/formulations/nn/avgpool2d.py +172 -0
  58. gamspy-1.5.0/src/gamspy/formulations/nn/conv2d.py +322 -0
  59. gamspy-1.5.0/src/gamspy/formulations/nn/linear.py +323 -0
  60. gamspy-1.5.0/src/gamspy/formulations/nn/maxpool2d.py +69 -0
  61. gamspy-1.5.0/src/gamspy/formulations/nn/minpool2d.py +69 -0
  62. gamspy-1.5.0/src/gamspy/formulations/nn/mpool2d.py +160 -0
  63. gamspy-1.5.0/src/gamspy/formulations/nn/utils.py +74 -0
  64. gamspy-1.5.0/src/gamspy/formulations/piecewise.py +705 -0
  65. gamspy-1.5.0/src/gamspy/formulations/shape.py +193 -0
  66. gamspy-1.5.0/src/gamspy/math/__init__.py +207 -0
  67. gamspy-1.5.0/src/gamspy/math/activation.py +454 -0
  68. gamspy-1.5.0/src/gamspy/math/log_power.py +441 -0
  69. gamspy-1.5.0/src/gamspy/math/matrix.py +545 -0
  70. gamspy-1.5.0/src/gamspy/math/misc.py +1577 -0
  71. gamspy-1.5.0/src/gamspy/math/probability.py +183 -0
  72. gamspy-1.5.0/src/gamspy/math/trigonometric.py +233 -0
  73. gamspy-1.5.0/src/gamspy/utils.py +666 -0
  74. gamspy-1.5.0/src/gamspy/version.py +5 -0
  75. gamspy-1.5.0/src/gamspy.egg-info/PKG-INFO +137 -0
  76. gamspy-1.5.0/src/gamspy.egg-info/SOURCES.txt +79 -0
  77. gamspy-1.5.0/src/gamspy.egg-info/dependency_links.txt +1 -0
  78. gamspy-1.5.0/src/gamspy.egg-info/entry_points.txt +2 -0
  79. gamspy-1.5.0/src/gamspy.egg-info/requires.txt +36 -0
  80. gamspy-1.5.0/src/gamspy.egg-info/top_level.txt +1 -0
  81. gamspy-1.5.0/tests/test_gamspy.py +59 -0
gamspy-1.5.0/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ GAMSpy - General Algebraic Modeling in Python
2
+
3
+ Copyright (c) 2024 GAMS Development Corp. <support@gams.com>
4
+ Copyright (c) 2024 GAMS Software GmbH <support@gams.com>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
gamspy-1.5.0/PKG-INFO ADDED
@@ -0,0 +1,137 @@
1
+ Metadata-Version: 2.2
2
+ Name: gamspy
3
+ Version: 1.5.0
4
+ Summary: Python-based algebraic modeling interface to GAMS
5
+ Author-email: GAMS Development Corporation <support@gams.com>
6
+ License: GAMSpy - General Algebraic Modeling in Python
7
+
8
+ Copyright (c) 2024 GAMS Development Corp. <support@gams.com>
9
+ Copyright (c) 2024 GAMS Software GmbH <support@gams.com>
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+ Project-URL: homepage, https://gams.com/sales/gamspy_facts/
30
+ Project-URL: documentation, https://gamspy.readthedocs.io/en/latest/user/index.html
31
+ Project-URL: repository, https://github.com/GAMS-dev/gamspy
32
+ Project-URL: changelog, https://github.com/GAMS-dev/gamspy/blob/develop/CHANGELOG.md
33
+ Keywords: Optimization,GAMS
34
+ Classifier: Development Status :: 5 - Production/Stable
35
+ Classifier: Environment :: Console
36
+ Classifier: Programming Language :: Python
37
+ Classifier: Topic :: Software Development
38
+ Classifier: Topic :: Scientific/Engineering
39
+ Classifier: Intended Audience :: Developers
40
+ Classifier: Intended Audience :: Science/Research
41
+ Classifier: License :: OSI Approved :: MIT License
42
+ Classifier: Programming Language :: Python
43
+ Classifier: Programming Language :: Python :: 3
44
+ Classifier: Programming Language :: Python :: 3 :: Only
45
+ Classifier: Programming Language :: Python :: 3.9
46
+ Classifier: Programming Language :: Python :: 3.10
47
+ Classifier: Programming Language :: Python :: 3.11
48
+ Classifier: Programming Language :: Python :: 3.12
49
+ Classifier: Programming Language :: Python :: 3.13
50
+ Classifier: Operating System :: POSIX
51
+ Classifier: Operating System :: Unix
52
+ Classifier: Operating System :: MacOS
53
+ Classifier: Operating System :: Microsoft :: Windows
54
+ Requires-Python: >=3.9
55
+ Description-Content-Type: text/markdown
56
+ License-File: LICENSE
57
+ Requires-Dist: gamsapi[control,transfer]==48.6.0
58
+ Requires-Dist: gamspy_base==48.6.0
59
+ Requires-Dist: pydantic>=2.0
60
+ Requires-Dist: certifi>=2022.09.14
61
+ Requires-Dist: urllib3>=2.0.7
62
+ Requires-Dist: typer>=0.15.1
63
+ Provides-Extra: dev
64
+ Requires-Dist: ruff>=0.5.6; extra == "dev"
65
+ Requires-Dist: pre-commit>=3.5.0; extra == "dev"
66
+ Requires-Dist: mypy>=1.11.1; extra == "dev"
67
+ Provides-Extra: test
68
+ Requires-Dist: coverage[toml]>=7.2.7; extra == "test"
69
+ Requires-Dist: openpyxl>=3.1.2; extra == "test"
70
+ Requires-Dist: cerberus>=1.3.5; extra == "test"
71
+ Requires-Dist: python-dotenv>=1.0.0; extra == "test"
72
+ Requires-Dist: pytest>=8.0.0; extra == "test"
73
+ Requires-Dist: networkx>=3.2.1; extra == "test"
74
+ Provides-Extra: doc
75
+ Requires-Dist: sphinx>=7.1.2; extra == "doc"
76
+ Requires-Dist: numpydoc>=1.5.0; extra == "doc"
77
+ Requires-Dist: nbsphinx>=0.9.3; extra == "doc"
78
+ Requires-Dist: sphinx_copybutton>=0.5.2; extra == "doc"
79
+ Requires-Dist: sphinx-favicon>=1.0.1; extra == "doc"
80
+ Requires-Dist: ipykernel; extra == "doc"
81
+ Requires-Dist: matplotlib>=3.7.3; extra == "doc"
82
+ Requires-Dist: sphinx_design>=0.5.0; extra == "doc"
83
+ Requires-Dist: pydata_sphinx_theme>=0.14.1; extra == "doc"
84
+ Requires-Dist: plotly>=5.22.0; extra == "doc"
85
+ Requires-Dist: kaleido==0.2.1; extra == "doc"
86
+ Requires-Dist: pytest>=8.2.1; extra == "doc"
87
+ Requires-Dist: nbmake>=1.5.3; extra == "doc"
88
+ Requires-Dist: openpyxl>=3.1.2; extra == "doc"
89
+ Requires-Dist: sphinx-tabs>=3.4.7; extra == "doc"
90
+
91
+ ![plot](https://github.com/GAMS-dev/gamspy/blob/develop/docs/_static/gamspy_logo.png?raw=true)
92
+
93
+ -----------------
94
+ [![PyPI version](https://img.shields.io/pypi/v/gamspy.svg?maxAge=3600)](https://gamspy.readthedocs.io/en/latest/)
95
+ [![Downloads](https://static.pepy.tech/badge/gamspy)](https://pepy.tech/project/gamspy)
96
+ [![Documentation Status](https://readthedocs.org/projects/gamspy/badge/?version=latest)](https://gamspy.readthedocs.io/en/latest/)
97
+
98
+ # GAMSPy: Algebraic Modeling Interface to GAMS
99
+
100
+ ## Installation
101
+
102
+ ```sh
103
+ pip install gamspy
104
+ ```
105
+
106
+ ## What is it?
107
+
108
+ **gamspy** is a mathematical optimization package that combines the power of the high performance GAMS execution system
109
+ and flexibility of the Python language. It includes all GAMS symbols (Set, Alias, Parameter, Variable, and
110
+ Equation) to compose mathematical models, a math package, and various utility functions.
111
+
112
+ ## Documentation
113
+ The official documentation is hosted on [GAMSPy Readthedocs](https://gamspy.readthedocs.io/en/latest/index.html).
114
+
115
+ ## Design Philosophy
116
+ GAMSPy makes extensive use of set based operations -- the absence of any explicit looping, indexing, etc., in native Python.
117
+ These things are taking place, of course, just “behind the scenes” in optimized, pre-compiled C code.
118
+
119
+ Set based approach has many advantages:
120
+
121
+ - Results in more concise Python code -- avoids inefficient and difficult to read for loops
122
+ - Closely resembles standard mathematical notation
123
+ - Easier to read
124
+ - Fewer lines of code generally means fewer bugs
125
+
126
+
127
+ ## Main Features
128
+ Here are just a few of the things that **gamspy** does well:
129
+
130
+ - Specify model algebra in Python natively
131
+ - Combines the flexibility of Python programming flow controls and the power of model specification in GAMS
132
+ - Test a variety of solvers on a model by changing only one line
133
+
134
+ ## Getting Help
135
+
136
+ For usage questions, the best place to go to is [GAMSPy Documentation](https://gamspy.readthedocs.io/en/latest/index.html).
137
+ General questions and discussions can also take place on the [GAMSPy Discourse Platform](https://forum.gams.com/c/gamspy-help).
gamspy-1.5.0/README.md ADDED
@@ -0,0 +1,49 @@
1
+ ![plot](https://github.com/GAMS-dev/gamspy/blob/develop/docs/_static/gamspy_logo.png?raw=true)
2
+
3
+ -----------------
4
+ [![PyPI version](https://img.shields.io/pypi/v/gamspy.svg?maxAge=3600)](https://gamspy.readthedocs.io/en/latest/)
5
+ [![Downloads](https://static.pepy.tech/badge/gamspy)](https://pepy.tech/project/gamspy)
6
+ [![Documentation Status](https://readthedocs.org/projects/gamspy/badge/?version=latest)](https://gamspy.readthedocs.io/en/latest/)
7
+
8
+ # GAMSPy: Algebraic Modeling Interface to GAMS
9
+
10
+ https://github.com/GAMS-dev/gamspy/assets/25618191/af91659c-408d-4f4c-a226-dc79e142a62f
11
+
12
+ ## Installation
13
+
14
+ ```sh
15
+ pip install gamspy
16
+ ```
17
+
18
+ ## What is it?
19
+
20
+ **GAMSPy** is a mathematical optimization package that combines the power of the high performance GAMS execution system
21
+ and flexibility of the Python language. It includes all GAMS symbols (Set, Alias, Parameter, Variable, and
22
+ Equation) to compose mathematical models, a math package, and various utility functions.
23
+
24
+ ## Documentation
25
+ The official documentation is hosted on [GAMSPy Readthedocs](https://gamspy.readthedocs.io/en/latest/index.html).
26
+
27
+ ## Design Philosophy
28
+ GAMSPy makes extensive use of set based operations -- the absence of any explicit looping, indexing, etc., in native Python.
29
+ These things are taking place, of course, just “behind the scenes” in optimized, pre-compiled C code.
30
+
31
+ Set based approach has many advantages:
32
+
33
+ - Results in more concise Python code -- avoids inefficient and difficult to read for loops
34
+ - Closely resembles standard mathematical notation
35
+ - Easier to read
36
+ - Fewer lines of code generally means fewer bugs
37
+
38
+
39
+ ## Main Features
40
+ Here are just a few of the things that **GAMSPy** does well:
41
+
42
+ - Specify model algebra in Python natively
43
+ - Combines the flexibility of Python programming flow controls and the power of model specification in GAMS
44
+ - Test a variety of solvers on a model by changing only one line
45
+
46
+ ## Getting Help
47
+
48
+ For usage questions, the best place to go to is [GAMSPy Documentation](https://gamspy.readthedocs.io/en/latest/index.html).
49
+ General questions and discussions can also take place on the [GAMSPy Discourse Platform](https://forum.gams.com).
@@ -0,0 +1,47 @@
1
+ ![plot](https://github.com/GAMS-dev/gamspy/blob/develop/docs/_static/gamspy_logo.png?raw=true)
2
+
3
+ -----------------
4
+ [![PyPI version](https://img.shields.io/pypi/v/gamspy.svg?maxAge=3600)](https://gamspy.readthedocs.io/en/latest/)
5
+ [![Downloads](https://static.pepy.tech/badge/gamspy)](https://pepy.tech/project/gamspy)
6
+ [![Documentation Status](https://readthedocs.org/projects/gamspy/badge/?version=latest)](https://gamspy.readthedocs.io/en/latest/)
7
+
8
+ # GAMSPy: Algebraic Modeling Interface to GAMS
9
+
10
+ ## Installation
11
+
12
+ ```sh
13
+ pip install gamspy
14
+ ```
15
+
16
+ ## What is it?
17
+
18
+ **gamspy** is a mathematical optimization package that combines the power of the high performance GAMS execution system
19
+ and flexibility of the Python language. It includes all GAMS symbols (Set, Alias, Parameter, Variable, and
20
+ Equation) to compose mathematical models, a math package, and various utility functions.
21
+
22
+ ## Documentation
23
+ The official documentation is hosted on [GAMSPy Readthedocs](https://gamspy.readthedocs.io/en/latest/index.html).
24
+
25
+ ## Design Philosophy
26
+ GAMSPy makes extensive use of set based operations -- the absence of any explicit looping, indexing, etc., in native Python.
27
+ These things are taking place, of course, just “behind the scenes” in optimized, pre-compiled C code.
28
+
29
+ Set based approach has many advantages:
30
+
31
+ - Results in more concise Python code -- avoids inefficient and difficult to read for loops
32
+ - Closely resembles standard mathematical notation
33
+ - Easier to read
34
+ - Fewer lines of code generally means fewer bugs
35
+
36
+
37
+ ## Main Features
38
+ Here are just a few of the things that **gamspy** does well:
39
+
40
+ - Specify model algebra in Python natively
41
+ - Combines the flexibility of Python programming flow controls and the power of model specification in GAMS
42
+ - Test a variety of solvers on a model by changing only one line
43
+
44
+ ## Getting Help
45
+
46
+ For usage questions, the best place to go to is [GAMSPy Documentation](https://gamspy.readthedocs.io/en/latest/index.html).
47
+ General questions and discussions can also take place on the [GAMSPy Discourse Platform](https://forum.gams.com/c/gamspy-help).
@@ -0,0 +1,191 @@
1
+ [build-system]
2
+ requires = ["setuptools"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "gamspy"
7
+ version = "1.5.0"
8
+ authors = [
9
+ { name = "GAMS Development Corporation", email = "support@gams.com" },
10
+ ]
11
+ readme = "README_PYPI.md"
12
+ description = "Python-based algebraic modeling interface to GAMS"
13
+ requires-python = ">=3.9"
14
+ license.file = "LICENSE"
15
+ keywords = ["Optimization", "GAMS"]
16
+ classifiers = [
17
+ "Development Status :: 5 - Production/Stable",
18
+ "Environment :: Console",
19
+ "Programming Language :: Python",
20
+ "Topic :: Software Development",
21
+ "Topic :: Scientific/Engineering",
22
+ "Intended Audience :: Developers",
23
+ "Intended Audience :: Science/Research",
24
+ "License :: OSI Approved :: MIT License",
25
+ "Programming Language :: Python",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3 :: Only",
28
+ "Programming Language :: Python :: 3.9",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ "Programming Language :: Python :: 3.13",
33
+ "Operating System :: POSIX",
34
+ "Operating System :: Unix",
35
+ "Operating System :: MacOS",
36
+ "Operating System :: Microsoft :: Windows",
37
+ ]
38
+ dependencies = [
39
+ "gamsapi[transfer,control] == 48.6.0",
40
+ "gamspy_base == 48.6.0",
41
+ "pydantic >= 2.0",
42
+ "certifi >= 2022.09.14",
43
+ "urllib3 >= 2.0.7",
44
+ "typer >= 0.15.1",
45
+ ]
46
+
47
+ [project.urls]
48
+ homepage = "https://gams.com/sales/gamspy_facts/"
49
+ documentation = "https://gamspy.readthedocs.io/en/latest/user/index.html"
50
+ repository = "https://github.com/GAMS-dev/gamspy"
51
+ changelog = "https://github.com/GAMS-dev/gamspy/blob/develop/CHANGELOG.md"
52
+
53
+
54
+ [project.optional-dependencies]
55
+ dev = [
56
+ "ruff >= 0.5.6",
57
+ "pre-commit >= 3.5.0",
58
+ "mypy >= 1.11.1",
59
+ ]
60
+
61
+ test = [
62
+ "coverage[toml] >= 7.2.7",
63
+ "openpyxl >= 3.1.2",
64
+ "cerberus >= 1.3.5",
65
+ "python-dotenv >= 1.0.0",
66
+ "pytest >= 8.0.0",
67
+ "networkx >= 3.2.1",
68
+ ]
69
+ doc = [
70
+ "sphinx>=7.1.2",
71
+ "numpydoc>=1.5.0",
72
+ "nbsphinx>=0.9.3",
73
+ "sphinx_copybutton>=0.5.2",
74
+ "sphinx-favicon>=1.0.1",
75
+ "ipykernel",
76
+ "matplotlib>=3.7.3",
77
+ "sphinx_design>=0.5.0",
78
+ "pydata_sphinx_theme>=0.14.1",
79
+ "plotly>=5.22.0",
80
+ "kaleido==0.2.1",
81
+ "pytest>=8.2.1",
82
+ "nbmake>=1.5.3",
83
+ "openpyxl>=3.1.2",
84
+ "sphinx-tabs>=3.4.7"
85
+ ]
86
+
87
+ [project.scripts]
88
+ gamspy = "gamspy._cli.cli:main"
89
+
90
+ [tool.mypy]
91
+ warn_unused_configs = true
92
+ follow_imports = "skip"
93
+ follow_imports_for_stubs = true
94
+
95
+ [tool.setuptools.packages.find]
96
+ where = ["src"]
97
+
98
+ [tool.coverage.run]
99
+ omit = ["*/_cli/*.py", "__main__.py", "*__init__.py", "*engine.py", "*neos.py"]
100
+
101
+ [tool.coverage.report]
102
+ exclude_also = ["pragma: no cover", "if TYPE_CHECKING:", "if typing.TYPE_CHECKING:", "def __repr__", "@property"]
103
+
104
+ [tool.ruff]
105
+ # Exclude a variety of commonly ignored directories.
106
+ exclude = [
107
+ ".bzr",
108
+ ".direnv",
109
+ ".eggs",
110
+ ".git",
111
+ ".git-rewrite",
112
+ ".hg",
113
+ ".ipynb_checkpoints",
114
+ ".mypy_cache",
115
+ ".nox",
116
+ ".pants.d",
117
+ ".pyenv",
118
+ ".pytest_cache",
119
+ ".pytype",
120
+ ".ruff_cache",
121
+ ".svn",
122
+ ".tox",
123
+ ".venv",
124
+ ".vscode",
125
+ "__pypackages__",
126
+ "_build",
127
+ "docs",
128
+ "buck-out",
129
+ "build",
130
+ "dist",
131
+ "node_modules",
132
+ "site-packages",
133
+ "venv",
134
+ "_cli",
135
+ "_options.py"
136
+ ]
137
+
138
+ # Same as PEP8.
139
+ line-length = 79
140
+ indent-width = 4
141
+
142
+ # Assume Python 9
143
+ target-version = "py39"
144
+
145
+ [tool.ruff.lint]
146
+ select = [
147
+ # pycodestyle
148
+ "E",
149
+ # Pyflakes
150
+ "F",
151
+ # pyupgrade
152
+ "UP",
153
+ # flake8-bugbear
154
+ "B",
155
+ # flake8-simplify
156
+ "SIM",
157
+ # isort
158
+ "I",
159
+ ]
160
+ ignore = ["E203", "E501", "E701", "E741", "E743", "W605", "SIM105", "B028", "B006"]
161
+
162
+ # Allow fix for all enabled rules (when `--fix`) is provided.
163
+ fixable = ["ALL"]
164
+ unfixable = []
165
+
166
+ # Allow unused variables when underscore-prefixed.
167
+ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
168
+
169
+ [tool.ruff.format]
170
+ # Like Black, use double quotes for strings.
171
+ quote-style = "double"
172
+
173
+ # Like Black, indent with spaces, rather than tabs.
174
+ indent-style = "space"
175
+
176
+ # Like Black, respect magic trailing commas.
177
+ skip-magic-trailing-comma = false
178
+
179
+ # Like Black, automatically detect the appropriate line ending.
180
+ line-ending = "auto"
181
+
182
+ [tool.pytest.ini_options]
183
+ markers = [
184
+ "unit: unit tests",
185
+ "integration: integration tests",
186
+ "cli: cli tests",
187
+ "doc: doctests",
188
+ "engine: engine tests",
189
+ "neos: neos tests",
190
+ "model_library: run all model library",
191
+ ]
gamspy-1.5.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,76 @@
1
+ from __future__ import annotations
2
+
3
+ from gams.transfer import SpecialValues
4
+
5
+ import gamspy.formulations as formulations
6
+ import gamspy.math as math
7
+ import gamspy.utils as utils
8
+ from gamspy._algebra import (
9
+ Card,
10
+ Domain,
11
+ Number,
12
+ Ord,
13
+ Product,
14
+ Sand,
15
+ Smax,
16
+ Smin,
17
+ Sor,
18
+ Sum,
19
+ )
20
+ from gamspy._algebra.expression import Expression
21
+ from gamspy._backend.engine import EngineClient
22
+ from gamspy._backend.neos import NeosClient
23
+ from gamspy._container import Container
24
+ from gamspy._model import Model, ModelStatus, Problem, Sense, SolveStatus
25
+ from gamspy._options import ModelInstanceOptions, Options
26
+ from gamspy._symbols import (
27
+ Alias,
28
+ Equation,
29
+ EquationType,
30
+ Parameter,
31
+ Set,
32
+ UniverseAlias,
33
+ Variable,
34
+ VariableType,
35
+ )
36
+
37
+ from .version import __version__
38
+
39
+ _ctx_managers: dict[tuple[int, int], Container] = dict()
40
+
41
+ __all__ = [
42
+ "Container",
43
+ "Set",
44
+ "Alias",
45
+ "UniverseAlias",
46
+ "Parameter",
47
+ "Variable",
48
+ "Equation",
49
+ "Model",
50
+ "Problem",
51
+ "Sense",
52
+ "VariableType",
53
+ "EquationType",
54
+ "ModelStatus",
55
+ "SolveStatus",
56
+ "Sum",
57
+ "Product",
58
+ "Smax",
59
+ "Smin",
60
+ "Sand",
61
+ "Sor",
62
+ "Domain",
63
+ "Number",
64
+ "Ord",
65
+ "Card",
66
+ "Options",
67
+ "ModelInstanceOptions",
68
+ "Expression",
69
+ "EngineClient",
70
+ "NeosClient",
71
+ "math",
72
+ "formulations",
73
+ "utils",
74
+ "SpecialValues",
75
+ "__version__",
76
+ ]
@@ -0,0 +1,6 @@
1
+ from __future__ import annotations
2
+
3
+ from gamspy._cli.cli import main
4
+
5
+ if __name__ == "__main__":
6
+ main()
@@ -0,0 +1,13 @@
1
+ # flake8: noqa
2
+ from __future__ import annotations
3
+
4
+ from gamspy._algebra.domain import Domain
5
+ from gamspy._algebra.number import Number
6
+ from gamspy._algebra.operation import Card
7
+ from gamspy._algebra.operation import Ord
8
+ from gamspy._algebra.operation import Product
9
+ from gamspy._algebra.operation import Smax
10
+ from gamspy._algebra.operation import Smin
11
+ from gamspy._algebra.operation import Sum
12
+ from gamspy._algebra.operation import Sand
13
+ from gamspy._algebra.operation import Sor
@@ -0,0 +1,128 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ import gamspy._algebra.expression as expression
6
+ import gamspy._algebra.operable as operable
7
+ import gamspy._symbols as syms
8
+ import gamspy._symbols.implicits as implicits
9
+ import gamspy.utils as utils
10
+ from gamspy._symbols.implicits.implicit_symbol import ImplicitSymbol
11
+
12
+ if TYPE_CHECKING:
13
+ from gamspy import Alias, Parameter, Set, Variable
14
+ from gamspy._algebra.domain import Domain
15
+ from gamspy._algebra.expression import Expression
16
+ from gamspy._algebra.number import Number
17
+ from gamspy._algebra.operation import Card, Operation, Ord
18
+ from gamspy._symbols.implicits import (
19
+ ImplicitParameter,
20
+ ImplicitSet,
21
+ )
22
+
23
+
24
+ class Condition(operable.Operable):
25
+ """
26
+ Condition class allows conditioning on GAMSPy constructs such as Symbols and Expressions.
27
+
28
+ Parameters
29
+ ----------
30
+ symbol: ImplicitSymbol | Expression
31
+ Reference to the symbol to be conditioned.
32
+ """
33
+
34
+ def __init__(
35
+ self,
36
+ conditioning_on: ImplicitSymbol
37
+ | Set
38
+ | Alias
39
+ | Parameter
40
+ | Variable
41
+ | Expression
42
+ | Operation
43
+ | Domain
44
+ | Number
45
+ | Card
46
+ | Ord,
47
+ condition: Expression
48
+ | ImplicitParameter
49
+ | ImplicitSet
50
+ | int
51
+ | None = None,
52
+ ):
53
+ self.conditioning_on = conditioning_on
54
+ self.condition = condition
55
+ self._where = None
56
+
57
+ @property
58
+ def where(self):
59
+ return Condition(self)
60
+
61
+ def __getitem__(
62
+ self, condition: Expression | ImplicitParameter | ImplicitSet
63
+ ) -> Condition:
64
+ if isinstance(condition, expression.Expression):
65
+ condition._fix_equalities()
66
+
67
+ return Condition(self.conditioning_on, condition)
68
+
69
+ def __setitem__(self, condition, rhs):
70
+ # conditioning_on.where[condition] = rhs
71
+ eq_types = (syms.Equation, implicits.ImplicitEquation)
72
+ if isinstance(rhs, bool):
73
+ rhs = "yes" if rhs is True else "no"
74
+
75
+ op_type = ".." if isinstance(self.conditioning_on, eq_types) else "="
76
+
77
+ if isinstance(condition, expression.Expression):
78
+ condition._fix_equalities()
79
+
80
+ lhs = Condition(self.conditioning_on, condition)
81
+ statement = expression.Expression(lhs, op_type, rhs)
82
+
83
+ if isinstance(self.conditioning_on, ImplicitSymbol):
84
+ statement._validate_definition(
85
+ utils._unpack(self.conditioning_on.domain)
86
+ )
87
+
88
+ self.conditioning_on.container._add_statement(statement)
89
+
90
+ if isinstance(self.conditioning_on, ImplicitSymbol):
91
+ self.conditioning_on.parent._assignment = statement
92
+
93
+ if isinstance(self.conditioning_on, implicits.ImplicitEquation):
94
+ self.conditioning_on.parent._definition = statement
95
+
96
+ self.conditioning_on.container._synch_with_gams(gams_to_gamspy=True)
97
+
98
+ def __neg__(self) -> Expression:
99
+ return expression.Expression(None, "-", self)
100
+
101
+ def __repr__(self) -> str:
102
+ return f"Condition(conditioning_on={self.conditioning_on}, condition={self.condition})"
103
+
104
+ def gamsRepr(self) -> str:
105
+ condition_str = (
106
+ self.condition.gamsRepr() # type: ignore
107
+ if hasattr(self.condition, "gamsRepr")
108
+ else str(self.condition)
109
+ )
110
+ return f"({self.conditioning_on.gamsRepr()} $ {condition_str})" # type: ignore
111
+
112
+ def getDeclaration(self) -> str:
113
+ return self.gamsRepr()
114
+
115
+ def latexRepr(self) -> str:
116
+ """
117
+ Representation of this condition in Latex.
118
+
119
+ Returns
120
+ -------
121
+ str
122
+ """
123
+ condition_str = (
124
+ self.condition.latexRepr() # type: ignore
125
+ if hasattr(self.condition, "latexRepr")
126
+ else str(self.condition)
127
+ )
128
+ return f"{self.conditioning_on.latexRepr()} ~ | ~ {condition_str}" # type: ignore