├── .gitignore ├── .gitlab-ci.yml ├── .gitlab └── merge_request_templates │ └── Default.md ├── .pre-commit-config.yaml ├── .readthedocs.yaml ├── .secrets.baseline ├── CHANGELOG.rst ├── LICENSE ├── README.md ├── README_PYPI.md ├── changelog ├── 561.improvement.rst ├── 637.doc.rst ├── 637.feature.rst ├── 645.improvement.rst ├── README.rst └── _template.rst ├── ci ├── .cli.yml ├── .docs.yml ├── .performance.yml ├── .precommit-check.yml ├── .test-dac.yml ├── .test-deg.yml ├── .test-lag.yml ├── .test-leg.yml ├── .test-wei.yml ├── .update-website.yml └── .upload.yml ├── conftest.py ├── docs ├── Makefile ├── README.md ├── _static │ ├── api_reference.svg │ ├── big_picture.jpg │ ├── cnn_data.pth │ ├── custom.css │ ├── examples.svg │ ├── ffn_data.pth │ ├── gams.ico │ ├── gams.svg │ ├── gamspy_logo.png │ ├── gamspy_logo_dark.png │ ├── logo.png │ ├── miro.png │ ├── quick_start.svg │ ├── set_tree.png │ ├── switcher.json │ ├── user_guide.svg │ └── whatis.png ├── _templates │ └── custom-module-template.rst ├── cli │ ├── index.rst │ ├── install.rst │ ├── list.rst │ ├── probe.rst │ ├── retrieve.rst │ ├── run.rst │ ├── show.rst │ └── uninstall.rst ├── conf.py ├── index.rst ├── make.bat ├── reference │ ├── gamspy.Card.rst │ ├── gamspy.ConvertOptions.rst │ ├── gamspy.Expression.rst │ ├── gamspy.FreezeOptions.rst │ ├── gamspy.Options.rst │ ├── gamspy.Ord.rst │ ├── gamspy.Problem.rst │ ├── gamspy.Product.rst │ ├── gamspy.Sand.rst │ ├── gamspy.Sense.rst │ ├── gamspy.Smax.rst │ ├── gamspy.Smin.rst │ ├── gamspy.Sor.rst │ ├── gamspy.SpecialValues.rst │ ├── gamspy.Sum.rst │ ├── gamspy._algebra.domain.rst │ ├── gamspy._algebra.number.rst │ ├── gamspy._container.rst │ ├── gamspy._engine.rst │ ├── gamspy._model.rst │ ├── gamspy._neos.rst │ ├── gamspy._symbols.alias.rst │ ├── gamspy._symbols.equation.rst │ ├── gamspy._symbols.parameter.rst │ ├── gamspy._symbols.set.rst │ ├── gamspy._symbols.universe_alias.rst │ ├── gamspy._symbols.variable.rst │ ├── gamspy.exceptions.rst │ ├── gamspy.formulations.rst │ ├── gamspy.math.rst │ ├── gamspy.rst │ ├── gamspy.utils.rst │ └── index.rst ├── release │ ├── index.rst │ ├── release_0.10.0.rst │ ├── release_0.10.1.rst │ ├── release_0.10.2.rst │ ├── release_0.10.3.rst │ ├── release_0.10.4.rst │ ├── release_0.10.5.rst │ ├── release_0.11.0.rst │ ├── release_0.11.1.rst │ ├── release_0.11.10.rst │ ├── release_0.11.2.rst │ ├── release_0.11.3.rst │ ├── release_0.11.4.rst │ ├── release_0.11.5.rst │ ├── release_0.11.6.rst │ ├── release_0.11.7.rst │ ├── release_0.11.8.rst │ ├── release_0.11.9.rst │ ├── release_0.12.0.rst │ ├── release_0.12.1.rst │ ├── release_0.12.2.rst │ ├── release_0.12.3.rst │ ├── release_0.12.4.rst │ ├── release_0.12.5.rst │ ├── release_0.12.6.rst │ ├── release_0.12.7.rst │ ├── release_0.13.0.rst │ ├── release_0.13.1.rst │ ├── release_0.13.2.rst │ ├── release_0.13.3.rst │ ├── release_0.13.4.rst │ ├── release_0.13.5.rst │ ├── release_0.13.6.rst │ ├── release_0.13.7.rst │ ├── release_0.14.0.rst │ ├── release_0.14.1.rst │ ├── release_0.14.2.rst │ ├── release_0.14.3.rst │ ├── release_0.14.4.rst │ ├── release_0.14.5.rst │ ├── release_0.14.6.rst │ ├── release_0.14.7.rst │ ├── release_1.0.0.rst │ ├── release_1.0.0rc1.rst │ ├── release_1.0.1.rst │ ├── release_1.0.2.rst │ ├── release_1.0.3.rst │ ├── release_1.0.4.rst │ ├── release_1.1.0.rst │ ├── release_1.10.0.rst │ ├── release_1.11.0.rst │ ├── release_1.11.1.rst │ ├── release_1.2.0.rst │ ├── release_1.3.0.rst │ ├── release_1.3.1.rst │ ├── release_1.4.0.rst │ ├── release_1.5.0.rst │ ├── release_1.5.1.rst │ ├── release_1.6.0.rst │ ├── release_1.7.0.rst │ ├── release_1.8.0.rst │ └── release_1.9.0.rst └── user │ ├── _data │ └── reformer.csv │ ├── advanced │ ├── advanced.rst │ ├── debugging.rst │ ├── external_equations.rst │ ├── extrinsic_functions.rst │ ├── formulations.rst │ ├── miro.rst │ ├── model_instance.rst │ └── special_features.rst │ ├── basics │ ├── alias.rst │ ├── assignments.rst │ ├── basics.rst │ ├── card_ord.rst │ ├── container.rst │ ├── equation.rst │ ├── expression_and_indexing.rst │ ├── lag_lead.rst │ ├── model.rst │ ├── number.rst │ ├── parameter.rst │ ├── set.rst │ └── variable.rst │ ├── developer_guide.rst │ ├── examples.rst │ ├── faq.rst │ ├── gamspy_for_gams_users.rst │ ├── images │ ├── conv1d.gif │ ├── logistic_regression.png │ ├── logistic_regression_2.png │ ├── loss_per_iter.png │ ├── mnist.png │ ├── network.png │ ├── noisy_image.png │ ├── noisy_image_2.png │ ├── pooling.png │ ├── pwl.png │ ├── pwl_excluded.png │ ├── pwl_unbounded.png │ ├── reformer.png │ └── synchronization.png │ ├── index.rst │ ├── installation.rst │ ├── ml │ ├── embed_nn.rst │ ├── examples.rst │ ├── formulations.rst │ ├── introduction.rst │ ├── logistic.rst │ ├── ml.rst │ ├── nn.rst │ ├── ols.rst │ └── thermal_reformer.rst │ ├── notebooks │ ├── blend.ipynb │ ├── blend_colab.ipynb │ ├── clsp.ipynb │ ├── clsp_colab.ipynb │ ├── latex_pdf.png │ ├── mcf.ipynb │ ├── mcf_colab.ipynb │ ├── millco.ipynb │ ├── millco_colab.ipynb │ ├── network.png │ ├── nurses.ipynb │ ├── nurses_colab.ipynb │ ├── nurses_data.xlsx │ ├── pickstock.ipynb │ ├── pickstock_colab.ipynb │ ├── trnsport.ipynb │ └── trnsport_colab.ipynb │ └── whatisgamspy.rst ├── pyproject.toml ├── scripts ├── performance │ ├── IJKLM │ │ ├── IJKLM.gms │ │ ├── data_generation.py │ │ ├── help.py │ │ ├── run_gams.py │ │ └── run_gamspy.py │ ├── lp │ │ └── main.py │ ├── main_IJKLM.py │ ├── memory_check.py │ ├── performance.py │ ├── qcp │ │ └── main.py │ └── read.py └── update_version.py ├── src └── gamspy │ ├── __init__.py │ ├── __main__.py │ ├── _algebra │ ├── __init__.py │ ├── condition.py │ ├── domain.py │ ├── expression.py │ ├── number.py │ ├── operable.py │ └── operation.py │ ├── _backend │ ├── __init__.py │ ├── backend.py │ ├── engine.py │ ├── local.py │ └── neos.py │ ├── _cli │ ├── __init__.py │ ├── cli.py │ ├── install.py │ ├── list.py │ ├── probe.py │ ├── retrieve.py │ ├── run.py │ ├── show.py │ ├── uninstall.py │ └── util.py │ ├── _config.py │ ├── _container.py │ ├── _convert.py │ ├── _database.py │ ├── _extrinsic.py │ ├── _miro.py │ ├── _model.py │ ├── _model_instance.py │ ├── _options.py │ ├── _serialization.py │ ├── _symbols │ ├── __init__.py │ ├── alias.py │ ├── equation.py │ ├── implicits │ │ ├── __init__.py │ │ ├── implicit_equation.py │ │ ├── implicit_parameter.py │ │ ├── implicit_set.py │ │ ├── implicit_symbol.py │ │ └── implicit_variable.py │ ├── parameter.py │ ├── set.py │ ├── symbol.py │ ├── universe_alias.py │ └── variable.py │ ├── _types.py │ ├── _validation.py │ ├── _workspace.py │ ├── exceptions.py │ ├── formulations │ ├── __init__.py │ ├── nn │ │ ├── __init__.py │ │ ├── avgpool2d.py │ │ ├── conv1d.py │ │ ├── conv2d.py │ │ ├── linear.py │ │ ├── maxpool2d.py │ │ ├── minpool2d.py │ │ ├── mpool2d.py │ │ └── utils.py │ ├── piecewise.py │ └── shape.py │ ├── math │ ├── __init__.py │ ├── activation.py │ ├── log_power.py │ ├── matrix.py │ ├── misc.py │ ├── probability.py │ └── trigonometric.py │ ├── py.typed │ ├── utils.py │ └── version.py └── tests ├── integration ├── dice2.py ├── external_module │ ├── CMakeLists.txt │ ├── build │ │ ├── libsimple_ext_module.dll │ │ ├── libsimple_ext_module.dylib │ │ ├── libsimple_ext_module.so │ │ └── libsimple_ext_module_arm64.dylib │ ├── example.py │ ├── geheader.h │ └── mylib.cpp ├── gms_references │ ├── ECD.gms │ ├── attr.gms │ ├── master.gms │ ├── math.gms │ ├── qp6.gms │ ├── skip.gms │ ├── square.gms │ ├── transport.gms │ └── war.gms ├── miro_models │ ├── _miro3_gdxin_.gdx │ ├── _miro4_gdxin_.gdx │ ├── _miro5_gdxin_.gdx │ ├── _miro5_gdxout_.gdx │ ├── conf_miro │ │ ├── miro.json │ │ └── miro_io.json │ ├── conf_miro2 │ │ ├── miro2.json │ │ └── miro2_io.json │ ├── conf_miro3 │ │ └── miro3_io.json │ ├── conf_miro4 │ │ └── miro4_io.json │ ├── conf_miro5 │ │ └── miro5_io.json │ ├── conf_miro7 │ │ └── miro7_io.json │ ├── conf_miro8 │ │ └── miro8_io.json │ ├── miro.py │ ├── miro10.py │ ├── miro2.py │ ├── miro3.py │ ├── miro4.py │ ├── miro5.py │ ├── miro6.py │ ├── miro7.py │ ├── miro8.py │ └── miro9.py ├── models │ ├── BondIndex.gdx │ ├── BondIndex.py │ ├── BoundaryLP.py │ ├── CVaR.py │ ├── Corporate.gdx │ ├── Corporate.py │ ├── DED-PB.py │ ├── DED.py │ ├── DEDESSwind.py │ ├── DedicationMip.py │ ├── DedicationNoBorrow.py │ ├── EDsensitivity.py │ ├── EmergencyCentreAllocation.py │ ├── EnergyHub.py │ ├── EnvironmentalED.py │ ├── Horizon.py │ ├── Immunization.py │ ├── InternationalMeanVar.gdx │ ├── InternationalMeanVar.py │ ├── MAD.py │ ├── MOED.py │ ├── MeanVarMip.gdx │ ├── MeanVarMip.py │ ├── MultiperiodACOPF24bus.py │ ├── OPF2bus.py │ ├── OPF5bus.py │ ├── PMU-OBI.py │ ├── PMU-cost.py │ ├── PMU.py │ ├── ParetoOptimalFront.py │ ├── PutCall.py │ ├── RampSenDED.py │ ├── Regret.gdx │ ├── Regret.py │ ├── SelectiveHedging.gdx │ ├── SelectiveHedging.py │ ├── Sharpe.gdx │ ├── Sharpe.py │ ├── SimpleLP.py │ ├── SimpleMIP.py │ ├── StochDedicationBL.gdx │ ├── StochDedicationBL.py │ ├── TEP.py │ ├── ThreeStageSPDA.py │ ├── TransportationOn-Off.py │ ├── WaterEnergy.py │ ├── WorldIndices.gdx │ ├── acopf.gdx │ ├── acopf.py │ ├── aircraft.py │ ├── batchreactor.py │ ├── benz.py │ ├── blend.py │ ├── carseq.py │ ├── cesam2.py │ ├── chain.py │ ├── chenery.gdx │ ├── chenery.py │ ├── circuit.py │ ├── clsp.py │ ├── coex.py │ ├── control3.py │ ├── cpa.py │ ├── cpack.py │ ├── cta.py │ ├── cta.xlsx │ ├── cutstock.py │ ├── dice.py │ ├── diffusion2.py │ ├── dyncge.py │ ├── edc2.py │ ├── f1_l-d_kp_10_269 │ ├── fdesign.py │ ├── fiat.py │ ├── flowshop.py │ ├── flywheel.py │ ├── food.py │ ├── fuel.py │ ├── gapmin.py │ ├── hansmcp.gdx │ ├── hansmcp.py │ ├── hansmge.gdx │ ├── hansmge.py │ ├── heatex3.py │ ├── hhd.py │ ├── inscribedsquare.py │ ├── invmat.py │ ├── iobalance.py │ ├── knapsack.py │ ├── korcns.py │ ├── linear.py │ ├── lop.gdx │ ├── lop.py │ ├── macro.py │ ├── mcf.py │ ├── mexss.py │ ├── minlphi.py │ ├── minlphix.py │ ├── multiclass_softmax.py │ ├── nurses.py │ ├── nurses_data.xlsx │ ├── partssupply.py │ ├── phase.py │ ├── piecewiseLinear.py │ ├── poutil.py │ ├── process.py │ ├── prodmix.py │ ├── protein.py │ ├── ps10_s_mn.py │ ├── qdemo7.gdx │ ├── qdemo7.py │ ├── qp6.gdx │ ├── qp6.py │ ├── ramsey.py │ ├── rcpsp.py │ ├── rcpsp.sm │ ├── refrigeration.py │ ├── reservoir.py │ ├── reshop.py │ ├── riversys.py │ ├── robustlp.py │ ├── rotdk.py │ ├── sat.py │ ├── sgolfer.py │ ├── spatequ.gdx │ ├── spatequ.py │ ├── spbenders1.py │ ├── speed.py │ ├── springchain.py │ ├── sq.draft │ ├── surface.py │ ├── syscomp.py │ ├── tanksize.gdx │ ├── tanksize.py │ ├── tforss.gdx │ ├── tforss.py │ ├── thai.gdx │ ├── thai.py │ ├── timesteps.py │ ├── traffic.gdx │ ├── traffic.py │ ├── trnsport.py │ ├── trnspwl.py │ ├── trussm.py │ ├── tsp4.gdx │ ├── tsp4.py │ ├── weapons.py │ └── whouse.py ├── test_cli.py ├── test_engine.py ├── test_external_module.py ├── test_gamspy_to_gams.py ├── test_gamspy_to_latex.py ├── test_miro.py ├── test_model_instance.py ├── test_models.py ├── test_neos.py ├── test_solve.py └── tex_references │ ├── ECD.tex │ ├── master.tex │ ├── qp6.tex │ ├── skip.tex │ ├── square.tex │ ├── transport.tex │ ├── transport2.tex │ └── war.tex ├── test_gamspy.py └── unit ├── libtricclib64.so ├── libtricclib64arm.dylib ├── libtricclib64x86.dylib ├── test_alias.py ├── test_condition.py ├── test_container.py ├── test_domain.py ├── test_equation.py ├── test_expression.py ├── test_extrinsic.py ├── test_formulation.py ├── test_magics.py ├── test_math.py ├── test_matrix.py ├── test_model.py ├── test_nn_formulation.py ├── test_operation.py ├── test_options.py ├── test_parameter.py ├── test_set.py ├── test_special_values.py ├── test_utils.py ├── test_variable.py └── tricclib64.dll /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | .vscode 3 | dist 4 | default* 5 | *.egg-info 6 | .coverage 7 | build 8 | __pycache__ 9 | test.gms 10 | test.gdx 11 | *.lst 12 | test.py 13 | /test 14 | gams-transfer-python 15 | 225* 16 | docs/_build 17 | _gams_py_* 18 | tests/integration/*.txt 19 | tests/integration/models/results.xlsx 20 | tests/integration/miro_models/*out_.gdx 21 | **/.ipynb_checkpoints 22 | /_* 23 | miro.log 24 | trace.txt 25 | data 26 | results 27 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | default: 2 | tags: 3 | - linux 4 | 5 | stages: 6 | - precommit 7 | - cli 8 | - test 9 | - engine 10 | - neos 11 | - docs 12 | - performance 13 | - website 14 | - upload 15 | 16 | variables: 17 | MACHINES_CONTAINER_REG: 18 | value: registry.gams.com/devel/machines 19 | description: "URL to the container registry of the machines repository" 20 | PF_GITLAB_WEBSITE_TOKEN: 21 | value: $GITLAB_WEBSITE_TOKEN 22 | description: "Token for updating gams.com" 23 | PF_CUSTOM_BRANCH: 24 | value: $CUSTOM_BRANCH 25 | description: "Name of custom branch or 0 if published distribution with version as specified should be taken" 26 | PF_BUILDS_WWW_PATH: 27 | value: $BUILDS_WWW_PATH 28 | description: "URL path prefix for builds server" 29 | PF_BUILDS_SSH_PORT: 30 | value: $BUILDS_SSH_PORT 31 | description: "Port used for SSH connection to builds server" 32 | PF_BUILDS_SSH_SERVER: 33 | value: $BUILDS_SSH_SERVER 34 | description: "URL of the build server" 35 | PF_BUILDS_SSH_USER: 36 | value: $BUILDS_SSH_USER 37 | description: "Username used for SSH connection to builds server" 38 | PF_GAMS_LICENSE: 39 | value: $GAMS_LICENSE 40 | description: "GAMS license string used for testing" 41 | PF_PYPI_USERNAME: 42 | value: $PYPI_USERNAME 43 | description: "Username for PyPI" 44 | PF_PYPI_PASSWORD: 45 | value: $PYPI_PASSWORD 46 | description: "Password for PyPI" 47 | 48 | 49 | include: ['ci/.precommit-check.yml', 50 | 'ci/.cli.yml', 51 | 'ci/.test-leg.yml', 52 | 'ci/.test-lag.yml', 53 | 'ci/.test-dac.yml', 54 | 'ci/.test-deg.yml', 55 | 'ci/.test-wei.yml', 56 | 'ci/.update-website.yml', 57 | 'ci/.upload.yml', 58 | 'ci/.docs.yml', 59 | 'ci/.performance.yml'] 60 | -------------------------------------------------------------------------------- /.gitlab/merge_request_templates/Default.md: -------------------------------------------------------------------------------- 1 | # Brief description of the changes 2 | ....description.... 3 | 4 | Closes #???? 5 | 6 | # Author checklist 7 | - [ ] Documentation 8 | - [ ] Changelog update 9 | - [ ] New Test(s) 10 | - [ ] Release notes (Only if it's a release branch) 11 | 12 | 13 | # Assignee checklist 14 | - [ ] Code 15 | - [ ] Information security (if applicable) 16 | - [ ] Documentation 17 | - [ ] Changelog update 18 | - [ ] New Test(s) 19 | - [ ] Release notes (Only if it's a release branch) 20 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v5.0.0 4 | hooks: 5 | - id: end-of-file-fixer 6 | exclude: ^(tests\/integration\/miro_models|docs|tests\/integration\/tex_references) 7 | - id: check-added-large-files 8 | args: ['--maxkb=50000'] 9 | - id: check-ast 10 | - id: check-case-conflict 11 | - repo: https://github.com/pre-commit/mirrors-mypy 12 | rev: 'v1.15.0' 13 | hooks: 14 | - id: mypy 15 | files: '^src\/gamspy\/(.*?)$' 16 | - repo: https://github.com/Yelp/detect-secrets 17 | rev: v1.5.0 18 | hooks: 19 | - id: detect-secrets 20 | args: ['--baseline', '.secrets.baseline'] 21 | - repo: https://github.com/astral-sh/ruff-pre-commit 22 | rev: v0.9.4 23 | hooks: 24 | # Run the linter. 25 | - id: ruff 26 | args: [ --fix ] 27 | # Run the formatter. 28 | - id: ruff-format 29 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | 3 | build: 4 | os: "ubuntu-22.04" 5 | tools: 6 | python: "3.10" 7 | 8 | python: 9 | install: 10 | # Install our python package before building the docs 11 | - method: pip 12 | path: .[doc] 13 | 14 | sphinx: 15 | configuration: docs/conf.py 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GAMSpy - General Algebraic Modeling in Python 2 | 3 | Copyright (c) 2024 GAMS Development Corp. 4 | Copyright (c) 2024 GAMS Software GmbH 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. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 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). 50 | -------------------------------------------------------------------------------- /README_PYPI.md: -------------------------------------------------------------------------------- 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). 48 | -------------------------------------------------------------------------------- /changelog/561.improvement.rst: -------------------------------------------------------------------------------- 1 | Allow args and kwargs for gamspy scripts for miro applications. 2 | -------------------------------------------------------------------------------- /changelog/637.doc.rst: -------------------------------------------------------------------------------- 1 | Add docs for Conv1d formulation. 2 | -------------------------------------------------------------------------------- /changelog/637.feature.rst: -------------------------------------------------------------------------------- 1 | Add Conv1d formulation. 2 | -------------------------------------------------------------------------------- /changelog/645.improvement.rst: -------------------------------------------------------------------------------- 1 | Accept os.PathLike objects as load from argument of Container. 2 | -------------------------------------------------------------------------------- /changelog/README.rst: -------------------------------------------------------------------------------- 1 | This directory contains "newsfragments" which are short files that contain a small **ReST**-formatted 2 | text that will be added to the next ``CHANGELOG``. 3 | 4 | The ``CHANGELOG`` will be read by **users** and **developers**. 5 | 6 | Each file should be named like ``..rst``, where 7 | ```` is an issue number, and ```` is one of: 8 | 9 | * ``feature``: new user facing features, like new command-line options and new behavior. 10 | * ``improvement``: improvement of an existing functionality. 11 | * ``bugfix``: fixes a bug. 12 | * ``doc``: documentation changes. 13 | * ``deprecation``: feature deprecation. 14 | * ``dependency``: changes in dependencies (version update etc.). 15 | * ``cicd``: ci/cd related changes. 16 | * ``misc``: changes that are hard to assign to any of the above 17 | categories. 18 | 19 | So for example: ``123.feature.rst``, ``456.bugfix.rst``. 20 | 21 | .. tip:: 22 | 23 | See :file:`pyproject.toml` for all available categories 24 | (``tool.towncrier.type``). 25 | 26 | If your PR fixes an issue, use that number here. If there is no issue, 27 | then after you submit the PR and get the PR number you can add a 28 | changelog using that instead. 29 | 30 | If you are not sure what issue type to use, don't hesitate to ask in your PR. 31 | 32 | ``towncrier`` preserves multiple paragraphs and formatting (code blocks, lists, and so on), but for entries 33 | other than ``features`` it is usually better to stick to a single paragraph to keep it concise. 34 | -------------------------------------------------------------------------------- /changelog/_template.rst: -------------------------------------------------------------------------------- 1 | {% for section in sections %} 2 | {% set underline = "=" %} 3 | {% if section %} 4 | {{section}} 5 | {{ underline * section|length }}{% set underline = "~" %} 6 | 7 | {% endif %} 8 | {% if sections[section] %} 9 | {% for category, val in definitions.items() if category in sections[section] %} 10 | 11 | {{ definitions[category]['name'] }} 12 | {{ underline * definitions[category]['name']|length }} 13 | 14 | {% if definitions[category]['showcontent'] %} 15 | {% for text, values in sections[section][category]|dictsort(by='value') %} 16 | {% set issue_joiner = joiner(', ') %} 17 | - {% for value in values|sort %}{{ issue_joiner() }}{{ value }}{% endfor %}: {{ text }} 18 | 19 | {% endfor %} 20 | {% else %} 21 | - {{ sections[section][category]['']|sort|join(', ') }} 22 | 23 | {% endif %} 24 | {% if sections[section][category]|length == 0 %} 25 | 26 | No significant changes. 27 | 28 | 29 | {% else %} 30 | {% endif %} 31 | {% endfor %} 32 | {% else %} 33 | 34 | No significant changes. 35 | 36 | 37 | {% endif %} 38 | {% endfor %} 39 | -------------------------------------------------------------------------------- /ci/.docs.yml: -------------------------------------------------------------------------------- 1 | leg-build-docs: 2 | stage: docs 3 | when: manual 4 | needs: [] 5 | tags: [linux] 6 | image: python:3.10 7 | script: 8 | - python -m pip install uv && uv venv .docs_venv && source .docs_venv/bin/activate 9 | - uv pip install .[test,doc] 10 | - python -m pytest --nbmake docs/user/notebooks/*.ipynb 11 | - ipython kernel install --name "python3" --user 12 | - wget https://github.com/jgm/pandoc/releases/download/3.1.8/pandoc-3.1.8-linux-amd64.tar.gz && tar xvzf pandoc-3.1.8-linux-amd64.tar.gz --strip-components 1 13 | - PATH=$(pwd)/bin/:$PATH 14 | - cd docs && make linkcheck && make html 15 | -------------------------------------------------------------------------------- /ci/.performance.yml: -------------------------------------------------------------------------------- 1 | leg-performance: 2 | stage: performance 3 | needs: [] 4 | tags: [puma] 5 | image: python:3.12 6 | when: manual 7 | script: 8 | - curl --silent https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o Miniconda3-latest-Linux-x86_64.sh 9 | - sh Miniconda3-latest-Linux-x86_64.sh -b -p anaconda3 10 | - source anaconda3/bin/activate 11 | - conda create -y -n performance python=3.12 12 | - conda activate performance 13 | - conda install -c conda-forge cyipopt 14 | - python -m pip install psutil pyoptinterface 15 | - python -m pip install .[dev,test] --force-reinstall 16 | - python -m pip install highsbox llvmlite tccbox 17 | - gamspy install license $NETWORK_LICENSE 18 | - echo $GAMS_LICENSE > $(gamspy show base)/gamslice.txt 19 | - gamspy install solver mpsge scip reshop highs 20 | - python scripts/performance/lp/main.py 21 | - python scripts/performance/qcp/main.py 22 | - $(gamspy show base)/gamsgetkey $LOCAL_LICENSE > $(gamspy show base)/ci_license.txt 23 | - python scripts/performance/performance.py 24 | - python scripts/performance/read.py 25 | - python scripts/performance/main_IJKLM.py 26 | - python scripts/performance/memory_check.py 27 | artifacts: 28 | name: performance_stats 29 | expire_in: 2 hours 30 | paths: 31 | - stats.csv 32 | -------------------------------------------------------------------------------- /ci/.precommit-check.yml: -------------------------------------------------------------------------------- 1 | leg-precommit: 2 | stage: precommit 3 | when: on_success 4 | tags: [linux] 5 | image: python:3.13 6 | script: 7 | - python -m pip install uv && uv venv .precommit_venv && source .precommit_venv/bin/activate 8 | - uv export --no-emit-project --format requirements-txt > requirements.txt && uvx pip-audit -v -r requirements.txt --disable-pip && rm requirements.txt 9 | - uv pip install pre-commit 10 | - pre-commit run --all-files 11 | -------------------------------------------------------------------------------- /ci/.update-website.yml: -------------------------------------------------------------------------------- 1 | leg-update-website: 2 | stage: website 3 | needs: [] 4 | tags: [puma] 5 | image: 6 | name: $MACHINES_CONTAINER_REG/leg/builder-full:latest 7 | entrypoint: [""] 8 | before_script: 9 | - git config --global user.email "puma@noreply.gams.com" 10 | - git config --global user.name "Gitlab Runner (puma)" 11 | script: 12 | - git clone https://engine_ci:${PF_GITLAB_WEBSITE_TOKEN}@git.gams.com/smann/new.gams.com.git --branch master --single-branch website 13 | - export GAMSPY_VERSION=$(grep "version" pyproject.toml -m 1 | cut -d "=" -f2) 14 | - export GAMSPY_RELEASE_DATE=\"$(date --rfc-3339=date)\" 15 | - cd website && sed -i -e 's/^\( *gamspy_release *= *\).*/\1'"${GAMSPY_VERSION}"'/' ./config.toml && sed -i -e 's/^\( *gamspy_release_date *= *\).*/\1'"${GAMSPY_RELEASE_DATE}"'/' ./config.toml && git add config.toml && git commit -m "Update gamspy version" && git push origin master 16 | rules: 17 | - if: $CI_COMMIT_BRANCH != "master" 18 | when: never 19 | - when: manual 20 | -------------------------------------------------------------------------------- /ci/.upload.yml: -------------------------------------------------------------------------------- 1 | leg-upload-wheel: 2 | stage: upload 3 | needs: [] 4 | tags: [puma] 5 | image: python:3.12 6 | script: 7 | - python -m pip install uv && uv venv .upload_venv 8 | - source .upload_venv/bin/activate && uv pip install pip 9 | - uv pip install wheel build twine pip-audit licensecheck 10 | - pip-audit -v 11 | - if [ "$?" == "0" ]; then echo "Audit passed!"; else exit 1; fi 12 | - licensecheck --ignore-packages gamspy-base --zero --requirements-paths pyproject.toml 13 | - python -m build && twine upload dist/* -u $PF_PYPI_USERNAME -p $PF_PYPI_PASSWORD 14 | rules: 15 | - if: $CI_COMMIT_BRANCH != "master" 16 | when: never 17 | - when: manual 18 | -------------------------------------------------------------------------------- /conftest.py: -------------------------------------------------------------------------------- 1 | from pytest import Function 2 | 3 | 4 | def pytest_collection_modifyitems(items: list[Function]) -> None: 5 | """ 6 | Enforces the order of tests. GAMSPy currently has the following marks: 7 | 8 | - "unit: unit tests" 9 | - "integration: integration tests" 10 | - "cli: cli tests" 11 | - "doc: doctests" 12 | - "engine: engine tests" 13 | - "neos: neos tests" 14 | - "model_library: run all model library" 15 | 16 | We want to run the unit tests first and model_library tests last. 17 | """ 18 | all_markers = [] 19 | for item in items: 20 | markers = [marker.name for marker in item.iter_markers()] 21 | all_markers.append(markers) 22 | 23 | # Run unit tests first 24 | new_items: list[Function] = [] 25 | model_library = None 26 | for item, markers in zip(items, all_markers): 27 | if "model_library" in markers: 28 | model_library = item 29 | continue 30 | 31 | if "unit" in markers: 32 | new_items.insert(0, item) 33 | else: 34 | new_items.append(item) 35 | 36 | # Run model library last since takes a lot of time 37 | if model_library is not None: 38 | new_items.append(model_library) 39 | 40 | items[:] = new_items 41 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # GAMSPy Documentation 2 | 3 | This folder contains the documentation of GAMSPy. 4 | 5 | ## Install Dependencies 6 | 7 | ```sh 8 | pip install -r requirements.txt ----extra-index-url https://test.pypi.org/simple/ 9 | ``` 10 | 11 | ## Build 12 | 13 | ```sh 14 | make clean 15 | make html 16 | ``` 17 | 18 | ## Generate Docs 19 | 20 | ```sh 21 | sphinx-apidoc src/gamspy/ --separate -o bla --private 22 | ``` -------------------------------------------------------------------------------- /docs/_static/api_reference.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 15 | 17 | 21 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /docs/_static/big_picture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/_static/big_picture.jpg -------------------------------------------------------------------------------- /docs/_static/cnn_data.pth: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/_static/cnn_data.pth -------------------------------------------------------------------------------- /docs/_static/custom.css: -------------------------------------------------------------------------------- 1 | .jp-RenderedHTMLCommon table, div.rendered_html table { 2 | table-layout: unset; 3 | } 4 | 5 | #module-gamspy .class { 6 | border-top: 2px solid black; 7 | } 8 | 9 | .navbar-icon-links img.icon-link-image { 10 | height: 1.25em; 11 | } 12 | 13 | .icon-link-table { 14 | width: 14px; 15 | height: auto; 16 | margin-left: 15px; 17 | vertical-align: middle; 18 | } 19 | 20 | .admonition-information { 21 | background-color: #e0f7fa; /* Light blue background */ 22 | border-left: 3px solid #007acc; /* Blue border on the left */ 23 | padding: 10px; 24 | margin: 10px 0; 25 | } 26 | .admonition-information .admonition-title { 27 | color: #007acc; /* Blue title text */ 28 | font-weight: bold; 29 | } 30 | 31 | .sd-card .sd-card-img-top { 32 | height: 60px; 33 | width: 60px; 34 | margin-left: auto; 35 | margin-right: auto; 36 | margin-top: 10px; 37 | } 38 | 39 | html[data-theme=dark] .sd-card img[src*='.svg'] { 40 | filter: invert(0.82) brightness(0.8) contrast(1.2); 41 | } 42 | 43 | .sphinx-tabs-panel { 44 | background: none; 45 | } 46 | 47 | .sphinx-tabs-tab[aria-selected="true"] { 48 | background: none; 49 | } 50 | -------------------------------------------------------------------------------- /docs/_static/examples.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /docs/_static/ffn_data.pth: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/_static/ffn_data.pth -------------------------------------------------------------------------------- /docs/_static/gams.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/_static/gams.ico -------------------------------------------------------------------------------- /docs/_static/gams.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/_static/gamspy_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/_static/gamspy_logo.png -------------------------------------------------------------------------------- /docs/_static/gamspy_logo_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/_static/gamspy_logo_dark.png -------------------------------------------------------------------------------- /docs/_static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/_static/logo.png -------------------------------------------------------------------------------- /docs/_static/miro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/_static/miro.png -------------------------------------------------------------------------------- /docs/_static/quick_start.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /docs/_static/set_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/_static/set_tree.png -------------------------------------------------------------------------------- /docs/_static/user_guide.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /docs/_static/whatis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/_static/whatis.png -------------------------------------------------------------------------------- /docs/_templates/custom-module-template.rst: -------------------------------------------------------------------------------- 1 | {{ fullname | escape | underline}} 2 | 3 | .. automodule:: {{ fullname }} 4 | 5 | {% block attributes %} 6 | {% if attributes %} 7 | .. rubric:: {{ _('Module Attributes') }} 8 | 9 | .. autosummary:: 10 | :toctree: 11 | {% for item in attributes %} 12 | {{ item }} 13 | {%- endfor %} 14 | {% endif %} 15 | {% endblock %} 16 | 17 | {% block functions %} 18 | {% if functions %} 19 | .. rubric:: {{ _('Functions') }} 20 | 21 | .. autosummary:: 22 | :toctree: 23 | {% for item in functions %} 24 | {{ item }} 25 | {%- endfor %} 26 | {% endif %} 27 | {% endblock %} 28 | 29 | {% block classes %} 30 | {% if classes %} 31 | .. rubric:: {{ _('Classes') }} 32 | 33 | .. autosummary:: 34 | :toctree: 35 | :template: custom-class-template.rst 36 | {% for item in classes %} 37 | {{ item }} 38 | {%- endfor %} 39 | {% endif %} 40 | {% endblock %} 41 | 42 | {% block exceptions %} 43 | {% if exceptions %} 44 | .. rubric:: {{ _('Exceptions') }} 45 | 46 | .. autosummary:: 47 | :toctree: 48 | {% for item in exceptions %} 49 | {{ item }} 50 | {%- endfor %} 51 | {% endif %} 52 | {% endblock %} 53 | 54 | {% block modules %} 55 | {% if modules %} 56 | .. rubric:: Modules 57 | 58 | .. autosummary:: 59 | :toctree: 60 | :template: custom-module-template.rst 61 | :recursive: 62 | {% for item in modules %} 63 | {{ item }} 64 | {%- endfor %} 65 | {% endif %} 66 | {% endblock %} -------------------------------------------------------------------------------- /docs/cli/index.rst: -------------------------------------------------------------------------------- 1 | :html_theme.sidebar_secondary.remove: 2 | 3 | .. _cli: 4 | 5 | gamspy 6 | ====== 7 | 8 | GAMSPy comes with a command-line interface (CLI) to allow users to 9 | easily install solvers, licenses and much more. Autocompletion can be 10 | installed for the current shell with `--install-completion`. 11 | 12 | .. list-table:: 13 | :widths: 20 20 20 40 14 | :header-rows: 1 15 | 16 | * - Option 17 | - Short 18 | - Default 19 | - Description 20 | * - -\-help 21 | - -h 22 | - 23 | - Shows the help message 24 | * - -\-version 25 | - -v 26 | - 27 | - Shows the version of GAMSPy, GAMS and gamspy_base 28 | * - -\-install-completion 29 | - 30 | - 31 | - Install completion for the current shell. 32 | * - -\-show-completion 33 | - 34 | - 35 | - Show completion for the current shell, to copy it or customize the installation. 36 | 37 | Example 38 | ------- 39 | 40 | Show help message:: 41 | 42 | $ gamspy --help 43 | Usage: gamspy [OPTIONS] COMMAND [ARGS]... 44 | 45 | GAMSPy CLI 46 | 47 | Options: 48 | -h, --help Show this message and exit. 49 | -v, --version Shows the version of GAMSPy, GAMS and gamspy_base 50 | 51 | Commands: 52 | install To install licenses and solvers. 53 | list To list solvers. 54 | probe To probe node information for license retrieval. 55 | retrieve To retrieve a license with another node's information. 56 | run To run your model with GAMS MIRO. 57 | show To show your license and gamspy_base directory. 58 | uninstall To uninstall licenses and solvers. 59 | 60 | Show version information:: 61 | 62 | $ gamspy --version 63 | GAMSPy version: 1.4.0 64 | GAMS version: 48.5.0 65 | gamspy_base version: 48.5.0 66 | 67 | List of Commands 68 | ---------------- 69 | 70 | .. toctree:: 71 | :maxdepth: 1 72 | 73 | install 74 | list 75 | probe 76 | retrieve 77 | run 78 | show 79 | uninstall -------------------------------------------------------------------------------- /docs/cli/probe.rst: -------------------------------------------------------------------------------- 1 | gamspy probe 2 | ============ 3 | 4 | Probes the node (computer) to get information about the node for fingerprinting the license. 5 | 6 | Usage 7 | ~~~~~ 8 | 9 | :: 10 | 11 | gamspy probe [OPTIONS] 12 | 13 | .. list-table:: 14 | :widths: 20 20 20 40 15 | :header-rows: 1 16 | 17 | * - Option 18 | - Short 19 | - Default 20 | - Description 21 | * - -\-json-out 22 | - -j 23 | - None 24 | - Output path to dump probed information. 25 | 26 | Example 27 | ~~~~~~~ 28 | 29 | :: 30 | 31 | $ gamspy probe -j info.json 32 | { 33 | "cpu_id": "27197016915918185882701231384169", 34 | "device_id": "18113801", 35 | "docker_mac_address": "", 36 | "hostname": "my_computer", 37 | "logical_cpu_cores": 8, 38 | "mac_addresses": [ 39 | "00:15:5d:02:2f:76" 40 | ], 41 | "machine_id": "535bd6adab9ab283e853050532b042a9", 42 | "operating_system": "Linux", 43 | "physical_cpu_cores": 4, 44 | "running_in_docker": false, 45 | "running_in_kubernetes": false, 46 | "total_memory": 16, 47 | "username": "joe" 48 | } 49 | 50 | .. note:: 51 | The probed information is always written to standard output. The ``-j`` option will write the information to a JSON file. -------------------------------------------------------------------------------- /docs/cli/retrieve.rst: -------------------------------------------------------------------------------- 1 | .. _gamspy_retrieve: 2 | 3 | gamspy retrieve 4 | ============== 5 | 6 | Retrieves a license with another node's information. 7 | 8 | Retrieve License 9 | -------------- 10 | 11 | Retrieves a license using an access code and node information from a JSON file. 12 | 13 | Usage 14 | ~~~~~ 15 | 16 | :: 17 | 18 | gamspy retrieve license [OPTIONS] 19 | 20 | .. list-table:: 21 | :widths: 20 20 20 40 22 | :header-rows: 1 23 | 24 | * - Option 25 | - Short 26 | - Default 27 | - Description 28 | * - -\-input 29 | - -i 30 | - None 31 | - Input JSON file path to retrieve the license based on the node information. 32 | * - -\-output 33 | - -o 34 | - None 35 | - Output path for the license file. 36 | 37 | Examples 38 | ~~~~~~~~ 39 | 40 | Retrieve a license with node information:: 41 | 42 | $ gamspy retrieve license 876e5812-1222-4aba-819d-e1e91b7e2f52 --input node_info.json 43 | 44 | Retrieve and save the license to a file:: 45 | 46 | $ gamspy retrieve license 876e5812-1222-4aba-819d-e1e91b7e2f52 --input node_info.json --output license.txt 47 | 48 | .. note:: 49 | The input JSON file should contain the node information required for license retrieval. -------------------------------------------------------------------------------- /docs/cli/run.rst: -------------------------------------------------------------------------------- 1 | gamspy run 2 | ========= 3 | 4 | Runs GAMSPy models with GAMS MIRO. 5 | 6 | Run with MIRO 7 | ------------ 8 | 9 | Runs a GAMSPy model with GAMS MIRO application. 10 | 11 | Usage 12 | ~~~~~ 13 | 14 | :: 15 | 16 | gamspy run miro [OPTIONS] 17 | 18 | .. list-table:: 19 | :widths: 20 20 20 40 20 | :header-rows: 1 21 | 22 | * - Option 23 | - Short 24 | - Default 25 | - Description 26 | * - -\-model 27 | - -g 28 | - None 29 | - Path to the GAMSPy model. 30 | * - -\-mode 31 | - -m 32 | - base 33 | - Execution mode of MIRO (config, base, or deploy). 34 | * - -\-path 35 | - -p 36 | - None 37 | - Path to the MIRO executable (.exe on Windows, .app on macOS or .AppImage on Linux). 38 | * - -\-skip-execution 39 | - 40 | - False 41 | - Whether to skip model execution. 42 | 43 | Examples 44 | ~~~~~~~~ 45 | 46 | Run a model with MIRO:: 47 | 48 | $ gamspy run miro --model transport.py 49 | 50 | Run a model with MIRO in configuration mode:: 51 | 52 | $ gamspy run miro --model transport.py --mode config 53 | 54 | Run a model with MIRO using a specific MIRO executable:: 55 | 56 | $ gamspy run miro --model transport.py --path /path/to/miro.exe 57 | 58 | Run a model with MIRO skipping model execution:: 59 | 60 | $ gamspy run miro --model transport.py --skip-execution -------------------------------------------------------------------------------- /docs/cli/show.rst: -------------------------------------------------------------------------------- 1 | gamspy show 2 | ========== 3 | 4 | Shows information about your GAMSPy installation. 5 | 6 | Show License 7 | ----------- 8 | 9 | Shows the content of the current license. 10 | 11 | Usage 12 | ~~~~~ 13 | 14 | :: 15 | 16 | gamspy show license 17 | 18 | Example:: 19 | 20 | $ gamspy show license 21 | License found at: /home/user/.gamspy/gamspy_license.txt 22 | 23 | License Content 24 | =============== 25 | [License content will be displayed here] 26 | 27 | Show Base Directory 28 | ----------------- 29 | 30 | Shows the path of the gamspy_base installation directory. 31 | 32 | Usage 33 | ~~~~~ 34 | 35 | :: 36 | 37 | gamspy show base 38 | 39 | Example:: 40 | 41 | $ gamspy show base 42 | /home/user/miniconda3/envs/gamspy/lib/python3.9/site-packages/gamspy_base 43 | -------------------------------------------------------------------------------- /docs/cli/uninstall.rst: -------------------------------------------------------------------------------- 1 | gamspy uninstall 2 | =============== 3 | 4 | Uninstalls solvers or the current license from the GAMSPy installation. 5 | 6 | Uninstall License 7 | --------------- 8 | 9 | Uninstalls the current license. 10 | 11 | Usage 12 | ~~~~~ 13 | 14 | :: 15 | 16 | gamspy uninstall license 17 | 18 | Example:: 19 | 20 | $ gamspy uninstall license 21 | 22 | Uninstall Solver 23 | -------------- 24 | 25 | Uninstalls one or more solvers from the GAMSPy installation. 26 | 27 | Usage 28 | ~~~~~ 29 | 30 | :: 31 | 32 | gamspy uninstall solver [solver_name(s)] [OPTIONS] 33 | 34 | .. list-table:: 35 | :widths: 20 20 20 40 36 | :header-rows: 1 37 | 38 | * - Option 39 | - Short 40 | - Default 41 | - Description 42 | * - -\-skip-pip-install 43 | - -s 44 | - False 45 | - If you already have the solver uninstalled, skip pip uninstall and update gamspy installed solver list. 46 | * - -\-uninstall-all-solvers 47 | - 48 | - False 49 | - Uninstalls all add-on solvers. 50 | * - -\-use-uv 51 | - 52 | - False 53 | - Use uv instead of pip to uninstall solvers. 54 | 55 | Examples 56 | ~~~~~~~~ 57 | 58 | Uninstall specific solvers:: 59 | 60 | $ gamspy uninstall solver mosek conopt 61 | 62 | Uninstall all add-on solvers:: 63 | 64 | $ gamspy uninstall solver --uninstall-all-solvers 65 | 66 | Skip pip uninstallation:: 67 | 68 | $ gamspy uninstall solver mosek -s 69 | 70 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | %SPHINXBUILD% >NUL 2>NUL 14 | if errorlevel 9009 ( 15 | echo. 16 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 17 | echo.installed, then set the SPHINXBUILD environment variable to point 18 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 19 | echo.may add the Sphinx directory to PATH. 20 | echo. 21 | echo.If you don't have Sphinx installed, grab it from 22 | echo.https://www.sphinx-doc.org/ 23 | exit /b 1 24 | ) 25 | 26 | if "%1" == "" goto help 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs/reference/gamspy.Card.rst: -------------------------------------------------------------------------------- 1 | Card 2 | ==== 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy Card (gamspy.Card) 6 | :keywords: Reference, Card, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. autoclass:: gamspy.Card 9 | :members: 10 | :undoc-members: 11 | :show-inheritance: -------------------------------------------------------------------------------- /docs/reference/gamspy.ConvertOptions.rst: -------------------------------------------------------------------------------- 1 | ConvertOptions 2 | ============== 3 | 4 | .. autoclass:: gamspy.ConvertOptions 5 | :members: 6 | :exclude-members: AmplNLBin,AmplNlInitDual,AmplNlInitPrimal,GDXHessian,GDXNames,GDXQuadratic,GDXUELs,GmsInsert,HeaderTimeStamp,IntervalEval,ObjVar,PermuteEqus,PermuteVars,QExtractAlg,Reform,SkipNRows,Width,copy, model_construct, model_computed_fields, model_copy, model_dump, model_dump_json, model_json_schema, model_parametrized_name, model_post_init, model_rebuild, model_validate, model_validate_json, model_validate_strings,construct, dict, from_orm, json, parse_file, parse_obj, parse_raw, schema, schema_json, update_forward_refs, validate, model_config 7 | :undoc-members: -------------------------------------------------------------------------------- /docs/reference/gamspy.Expression.rst: -------------------------------------------------------------------------------- 1 | Expression 2 | ========== 3 | 4 | .. autoclass:: gamspy.Expression 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/reference/gamspy.FreezeOptions.rst: -------------------------------------------------------------------------------- 1 | FreezeOptions 2 | ============= 3 | 4 | .. autoclass:: gamspy.FreezeOptions 5 | :members: no_match_limit, debug, update_type 6 | :undoc-members: -------------------------------------------------------------------------------- /docs/reference/gamspy.Options.rst: -------------------------------------------------------------------------------- 1 | Options 2 | ======= 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy Options (gamspy.Options) 6 | :keywords: Reference, Options, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. autoclass:: gamspy.Options 9 | :members: 10 | :exclude-members: bypass_solver, cutoff, default_point, enable_scaling, enable_prior, infeasibility_tolerance, try_partial_integer_solution, examine_linearity, min_improvement_threshold, miro_protect, generate_name_dict, loadpoint, monitor_process_tree_memory, memory_tick_interval, profile_file, reference_file, copy, model_construct, model_computed_fields, model_copy, model_dump, model_dump_json, model_json_schema, model_parametrized_name, model_post_init, model_rebuild, model_validate, model_validate_json, model_validate_strings, cns,dnlp,emp,lp,mcp,minlp,mip,miqcp,mpec,nlp,qcp,rminlp,rmip,rmiqcp,rmpec,allow_suffix_in_equation,allow_suffix_in_limited_variables,basis_detection_threshold,compile_error_limit,domain_violation_limit,hold_fixed_variables,iteration_limit,keep_temporary_files,listing_file,log_file,variable_listing_limit,equation_listing_limit,node_limit,absolute_optimality_gap,relative_optimality_gap,profile,profile_tolerance,time_limit,savepoint,seed,report_solution,show_os_memory,solve_link_type,merge_strategy,step_summary,suppress_compiler_listing,report_solver_status,threads,write_listing_file,zero_rounding_threshold,report_underflowinherited_method1, inherited_method2, construct, dict, from_orm, json, parse_file, parse_obj, parse_raw, schema, schema_json, update_forward_refs, validate, redirect_log_to_stdout, report_underflow, model_config, model_fields 11 | :undoc-members: -------------------------------------------------------------------------------- /docs/reference/gamspy.Ord.rst: -------------------------------------------------------------------------------- 1 | Ord 2 | === 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy Ord (gamspy.Ord) 6 | :keywords: Reference, Ord, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. autoclass:: gamspy.Ord 9 | :members: 10 | :undoc-members: 11 | :show-inheritance: -------------------------------------------------------------------------------- /docs/reference/gamspy.Problem.rst: -------------------------------------------------------------------------------- 1 | Problem 2 | ======= 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy Problem types (gamspy.Problem) 6 | :keywords: Reference, Problem, solve, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. autoclass:: gamspy.Problem 9 | :members: LP,NLP,QCP,DNLP,MIP,RMIP,MINLP,RMINLP,MIQCP,RMIQCP,MCP,CNS,MPEC,RMPEC,EMP,MPSGE 10 | :undoc-members: 11 | :show-inheritance: -------------------------------------------------------------------------------- /docs/reference/gamspy.Product.rst: -------------------------------------------------------------------------------- 1 | Product 2 | ======= 3 | 4 | .. autoclass:: gamspy.Product 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | :inherited-members: -------------------------------------------------------------------------------- /docs/reference/gamspy.Sand.rst: -------------------------------------------------------------------------------- 1 | Sand 2 | ==== 3 | 4 | .. autoclass:: gamspy.Sand 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | :inherited-members: -------------------------------------------------------------------------------- /docs/reference/gamspy.Sense.rst: -------------------------------------------------------------------------------- 1 | Sense 2 | ===== 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy Sense types (gamspy.Sense) 6 | :keywords: Reference, Sense, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. autoclass:: gamspy.Sense 9 | :members: MIN,MAX,FEASIBILITY 10 | :undoc-members: 11 | :show-inheritance: -------------------------------------------------------------------------------- /docs/reference/gamspy.Smax.rst: -------------------------------------------------------------------------------- 1 | Smax 2 | ==== 3 | 4 | .. autoclass:: gamspy.Smax 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | :inherited-members: -------------------------------------------------------------------------------- /docs/reference/gamspy.Smin.rst: -------------------------------------------------------------------------------- 1 | Smin 2 | ==== 3 | 4 | .. autoclass:: gamspy.Smin 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | :inherited-members: -------------------------------------------------------------------------------- /docs/reference/gamspy.Sor.rst: -------------------------------------------------------------------------------- 1 | Sor 2 | === 3 | 4 | .. autoclass:: gamspy.Sor 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | :inherited-members: -------------------------------------------------------------------------------- /docs/reference/gamspy.SpecialValues.rst: -------------------------------------------------------------------------------- 1 | SpecialValues 2 | ============= 3 | 4 | .. autoclass:: gamspy.SpecialValues 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: -------------------------------------------------------------------------------- /docs/reference/gamspy.Sum.rst: -------------------------------------------------------------------------------- 1 | Sum 2 | === 3 | 4 | .. meta:: 5 | :description: Documentation of GAMSPy Sum (gamspy.Sum) operation. 6 | :keywords: Sum, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. autoclass:: gamspy.Sum 9 | :members: 10 | :undoc-members: 11 | :show-inheritance: 12 | :inherited-members: -------------------------------------------------------------------------------- /docs/reference/gamspy._algebra.domain.rst: -------------------------------------------------------------------------------- 1 | Domain 2 | ====== 3 | 4 | .. autoclass:: gamspy.Domain 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/reference/gamspy._algebra.number.rst: -------------------------------------------------------------------------------- 1 | Number 2 | ====== 3 | 4 | .. autoclass:: gamspy.Number 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/reference/gamspy._container.rst: -------------------------------------------------------------------------------- 1 | Container 2 | ========= 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy Container (gamspy.Container) 6 | :keywords: Reference, Container, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. autoclass:: gamspy.Container 9 | :members: read, write, generateGamsString, loadRecordsFromGdx, addAlias, addEquation, addModel, addParameter, addSet, addUniverseAlias, addVariable, addGamsCode, close, getSymbols, getSets, getAliases, getParameters, getVariables, getEquations, copy, describeSets, describeAliases, describeParameters, describeVariables, describeEquations, importExtrinsicLibrary, gamsJobName, gdxInputPath, gdxOutputPath, hasSymbols, in_miro, isValid, summary, system_directory, working_directory 10 | :undoc-members: 11 | :show-inheritance: 12 | -------------------------------------------------------------------------------- /docs/reference/gamspy._engine.rst: -------------------------------------------------------------------------------- 1 | EngineClient 2 | ============ 3 | 4 | .. autoclass:: gamspy.EngineClient 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | 9 | .. autoclass:: gamspy._backend.engine.Job 10 | :members: 11 | :undoc-members: 12 | :show-inheritance: 13 | 14 | .. autoclass:: gamspy._backend.engine.Auth 15 | :members: 16 | :undoc-members: 17 | :show-inheritance: -------------------------------------------------------------------------------- /docs/reference/gamspy._model.rst: -------------------------------------------------------------------------------- 1 | Model 2 | ===== 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy Model (gamspy.Model) 6 | :keywords: Reference, Model, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. autoclass:: gamspy.Model 9 | :members: 10 | :undoc-members: 11 | :show-inheritance: 12 | 13 | .. autoclass:: gamspy.ModelStatus 14 | :members: 15 | :undoc-members: 16 | :show-inheritance: 17 | 18 | .. autoclass:: gamspy.SolveStatus 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | .. autoclass:: gamspy.FileFormat 24 | :members: 25 | :undoc-members: 26 | :show-inheritance: -------------------------------------------------------------------------------- /docs/reference/gamspy._neos.rst: -------------------------------------------------------------------------------- 1 | NeosClient 2 | ========== 3 | 4 | .. autoclass:: gamspy.NeosClient 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/reference/gamspy._symbols.alias.rst: -------------------------------------------------------------------------------- 1 | Alias 2 | ===== 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy Alias (gamspy.Alias) 6 | :keywords: Reference, Alias, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. autoclass:: gamspy.Alias 9 | :members: alias_with,container,description,dimension,domain,domain_labels,domain_names,domain_type,equals,first,gamsRepr,getDeclaration,getSparsity,isValid,is_singleton,lag,last,lead,len,modified,name,number_records,off,ord,pivot,pos,records,rev,sameAs,setRecords,summary,tlen,toList,tval,uel,val,where 10 | :undoc-members: 11 | :show-inheritance: -------------------------------------------------------------------------------- /docs/reference/gamspy._symbols.equation.rst: -------------------------------------------------------------------------------- 1 | Equation 2 | ======== 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy Equation (gamspy.Equation) and GAMSPy EquationType (gamspy.EquationType) 6 | :keywords: Reference, Equation, EquationType, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. autoclass:: gamspy.Equation 9 | :members: synchronize,computeInfeasibilities,container,countEps,countNA,countNegInf,countPosInf,countUndef,default_records,description,dimension,domain,domain_forwarding,domain_labels,domain_names,domain_type,dropDefaults,dropEps,dropMissing,dropNA,dropUndef,equals,findEps,findNA,findNegInf,findPosInf,findSpecialValues,findUndef,gamsRepr,generateRecords,getEquationListing,getDeclaration,getDefinition,getMaxAbsValue,getMaxValue,getMeanValue,getMinValue,getSparsity,infeas,isValid,is_scalar,l,lo,m,modified,name,number_records,pivot,range,records,scale,setRecords,shape,slack,slacklo,slackup,stage,summary,toDense,toDict,toList,toSparseCoo,toValue,type,up,where,whereMax,whereMaxAbs,whereMin,latexRepr 10 | :undoc-members: 11 | :show-inheritance: 12 | 13 | .. autoclass:: gamspy.EquationType 14 | :members: 15 | :undoc-members: 16 | :show-inheritance: 17 | -------------------------------------------------------------------------------- /docs/reference/gamspy._symbols.parameter.rst: -------------------------------------------------------------------------------- 1 | Parameter 2 | ========= 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy Parameter (gamspy.Parameter) 6 | :keywords: Reference, Parameter, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. autoclass:: gamspy.Parameter 9 | :members: synchronize,container,countEps,countNA,countNegInf,countPosInf,countUndef,description,dimension,domain,domain_forwarding,domain_labels,domain_names,domain_type,dropDefaults,dropEps,dropMissing,dropNA,dropUndef,dropZeros,equals,findEps,findNA,findNegInf,findPosInf,findSpecialValues,findUndef,gamsRepr,generateRecords,getDeclaration,getAssignment,getMaxAbsValue,getMaxValue,getMeanValue,getMinValue,getSparsity,isValid,is_scalar,modified,name,number_records,pivot,records,setRecords,shape,summary,toDense,toDict,toList,toSparseCoo,toValue,where,whereMax,whereMaxAbs,whereMin 10 | :undoc-members: 11 | :show-inheritance: 12 | -------------------------------------------------------------------------------- /docs/reference/gamspy._symbols.set.rst: -------------------------------------------------------------------------------- 1 | Set 2 | === 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy Set (gamspy.Set) 6 | :keywords: Reference, Set, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. autoclass:: gamspy.Set 9 | :members: synchronize,container,description,dimension,domain,domain_forwarding,domain_labels,domain_names,domain_type,equals,first,gamsRepr,generateRecords,getDeclaration,getAssignment,getSparsity,isValid,is_singleton,lag,last,lead,len,modified,name,number_records,off,ord,pivot,pos,records,rev,sameAs,setRecords,summary,tlen,toList,tval,uel,val,where, 10 | :undoc-members: 11 | :show-inheritance: 12 | -------------------------------------------------------------------------------- /docs/reference/gamspy._symbols.universe_alias.rst: -------------------------------------------------------------------------------- 1 | Universe Alias 2 | ============== 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy UniverseAlias (gamspy.UniverseAlias) 6 | :keywords: Reference, UniverseAlias, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. autoclass:: gamspy.UniverseAlias 9 | :inherited-members: 10 | :members: 11 | :undoc-members: 12 | :show-inheritance: 13 | -------------------------------------------------------------------------------- /docs/reference/gamspy._symbols.variable.rst: -------------------------------------------------------------------------------- 1 | Variable 2 | ======== 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy Variable (gamspy.Variable) and GAMSPy VariableType (gamspy.VariableType) 6 | :keywords: Reference, Variable, VariableType, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. autoclass:: gamspy.Variable 9 | :members: synchronize,computeInfeasibilities,container,countEps,countNA,countNegInf,countPosInf,countUndef,default_records,description,dimension,domain,domain_forwarding,domain_labels,domain_names,domain_type,dropDefaults,dropEps,dropMissing,dropNA,dropUndef,equals,findEps,findNA,findNegInf,findPosInf,findSpecialValues,findUndef,fx,gamsRepr,generateRecords,getVariableListing,getDeclaration,getAssignment,getMaxAbsValue,getMaxValue,getMeanValue,getMinValue,getSparsity,isValid,is_scalar,l,lo,m,modified,name,number_records,pivot,prior,records,scale,setRecords,shape,stage,summary,toDense,toDict,toList,toSparseCoo,toValue,type,up,where,whereMax,whereMaxAbs,whereMin 10 | :undoc-members: 11 | :show-inheritance: 12 | 13 | .. autoclass:: gamspy.VariableType 14 | :members: BINARY,INTEGER,POSITIVE,NEGATIVE,FREE,SOS1,SOS2,SEMICONT,SEMIINT 15 | :undoc-members: 16 | :show-inheritance: 17 | -------------------------------------------------------------------------------- /docs/reference/gamspy.exceptions.rst: -------------------------------------------------------------------------------- 1 | exceptions 2 | ========== 3 | 4 | .. automodule:: gamspy.exceptions 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: -------------------------------------------------------------------------------- /docs/reference/gamspy.formulations.rst: -------------------------------------------------------------------------------- 1 | formulations 2 | ============ 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy Formulations module (gamspy.formulations) 6 | :keywords: Reference, math, GAMSPy, gamspy, GAMS, gams, mathematical modeling, formulations, performance 7 | 8 | .. automodule:: gamspy.formulations 9 | :members: 10 | :undoc-members: 11 | :show-inheritance: 12 | :special-members: __call__ 13 | -------------------------------------------------------------------------------- /docs/reference/gamspy.math.rst: -------------------------------------------------------------------------------- 1 | math 2 | ==== 3 | 4 | .. meta:: 5 | :description: Reference page for GAMSPy Math module (gamspy.math) 6 | :keywords: Reference, math, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. automodule:: gamspy.math 9 | :members: 10 | :undoc-members: 11 | :show-inheritance: 12 | -------------------------------------------------------------------------------- /docs/reference/gamspy.rst: -------------------------------------------------------------------------------- 1 | gamspy 2 | ====== 3 | 4 | .. meta:: 5 | :description: GAMSPy Reference 6 | :keywords: Reference, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | 11 | gamspy._container 12 | gamspy._symbols.set 13 | gamspy._symbols.alias 14 | gamspy._symbols.universe_alias 15 | gamspy._symbols.parameter 16 | gamspy._symbols.variable 17 | gamspy._symbols.equation 18 | gamspy._model 19 | gamspy.Problem 20 | gamspy.Sense 21 | gamspy.Options 22 | gamspy.FreezeOptions 23 | gamspy.ConvertOptions 24 | gamspy.Expression 25 | gamspy._algebra.domain 26 | gamspy._algebra.number 27 | gamspy.Sum 28 | gamspy.Product 29 | gamspy.Smax 30 | gamspy.Smin 31 | gamspy.Sand 32 | gamspy.Sor 33 | gamspy.Ord 34 | gamspy.Card 35 | gamspy._engine 36 | gamspy._neos 37 | gamspy.math 38 | gamspy.formulations 39 | gamspy.utils 40 | gamspy.SpecialValues 41 | gamspy.exceptions 42 | 43 | .. autofunction:: gamspy.set_options 44 | .. autofunction:: gamspy.get_option 45 | .. autofunction:: gamspy.serialize 46 | .. autofunction:: gamspy.deserialize -------------------------------------------------------------------------------- /docs/reference/gamspy.utils.rst: -------------------------------------------------------------------------------- 1 | utils 2 | ======================== 3 | 4 | .. automodule:: gamspy.utils 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: -------------------------------------------------------------------------------- /docs/reference/index.rst: -------------------------------------------------------------------------------- 1 | .. _reference: 2 | 3 | API Reference 4 | ============= 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | gamspy -------------------------------------------------------------------------------- /docs/release/index.rst: -------------------------------------------------------------------------------- 1 | .. _release: 2 | 3 | ############# 4 | Release Notes 5 | ############# 6 | 7 | .. toctree:: 8 | :maxdepth: 1 9 | 10 | release_1.11.0 11 | release_1.10.0 12 | release_1.9.0 13 | release_1.8.0 14 | release_1.7.0 15 | release_1.6.0 16 | release_1.5.1 17 | release_1.5.0 18 | release_1.4.0 19 | release_1.3.1 20 | release_1.3.0 21 | release_1.2.0 22 | release_1.1.0 23 | release_1.0.4 24 | release_1.0.3 25 | release_1.0.2 26 | release_1.0.1 27 | release_1.0.0 28 | release_1.0.0rc1 29 | release_0.14.7 30 | release_0.14.6 31 | release_0.14.5 32 | release_0.14.4 33 | release_0.14.3 34 | release_0.14.2 35 | release_0.14.1 36 | release_0.14.0 37 | release_0.13.7 38 | release_0.13.6 39 | release_0.13.5 40 | release_0.13.4 41 | release_0.13.3 42 | release_0.13.2 43 | release_0.13.1 44 | release_0.13.0 45 | release_0.12.7 46 | release_0.12.6 47 | release_0.12.5 48 | release_0.12.4 49 | release_0.12.3 50 | release_0.12.2 51 | release_0.12.1 52 | release_0.12.0 53 | release_0.11.10 54 | release_0.11.9 55 | release_0.11.8 56 | release_0.11.7 57 | release_0.11.6 58 | release_0.11.5 59 | release_0.11.4 60 | release_0.11.3 61 | release_0.11.2 62 | release_0.11.1 63 | release_0.11.0 64 | release_0.10.5 65 | release_0.10.4 66 | release_0.10.3 67 | release_0.10.2 68 | release_0.10.1 69 | release_0.10.0 70 | release_0.10.0 71 | -------------------------------------------------------------------------------- /docs/release/release_0.10.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.10.0 2 | ============= 3 | 4 | Initial release. -------------------------------------------------------------------------------- /docs/release/release_0.10.1.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.10.1 2 | ============= 3 | 4 | - General 5 | 6 | - Fix ellipsis syntax bug for variable and equation attributes 7 | - Introduce Pydantic as a dependency for options and engine configuration validation 8 | 9 | - Documentation 10 | 11 | - Change reference API structure so that each class has its own page 12 | 13 | - Testing 14 | 15 | - Simplify reinstall.py script 16 | - Add tests for options 17 | - Update tests for symbol creation -------------------------------------------------------------------------------- /docs/release/release_0.10.2.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.10.2 2 | ============= 3 | 4 | - General 5 | 6 | - Read and write only dirty symbols instead of all symbols to improve performance. 7 | - Make gdx file names thread safe by using uuid. 8 | 9 | - Documentation 10 | 11 | - Fix api reference for inherited members. 12 | - Make execution modes and debugging section of container documentation a separate page. 13 | 14 | - Testing 15 | 16 | - Add a new test for sending extra files to GAMS Engine. 17 | - Add scripts/atomic_conda_env.py to avoid race condition for parallel builds in the pipeline. -------------------------------------------------------------------------------- /docs/release/release_0.10.3.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.10.3 2 | ============= 3 | 4 | - General 5 | 6 | - Allow creating log file in working directory. 7 | - Forbid extra arguments for pydantic models (Options, EngineConfig) 8 | 9 | - Documentation 10 | 11 | - Update model options table 12 | - Update jupyter notebook examples 13 | 14 | - Testing 15 | 16 | - Adapt tests to new Options class instead of using dictionary. -------------------------------------------------------------------------------- /docs/release/release_0.10.4.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.10.4 2 | ============= 3 | 4 | - General 5 | 6 | - Fix not equals overload of Ord and Card operations (bug fix) 7 | - Refactor generation of GAMS string 8 | 9 | - Documentation 10 | 11 | - Move doc dependencies to pyproject.toml -------------------------------------------------------------------------------- /docs/release/release_0.10.5.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.10.5 2 | ============= 3 | 4 | - General 5 | 6 | - Fix the issue of not setting options that are set to 0 (bug fix) 7 | 8 | - Testing 9 | 10 | - Remove duplicated equations in models for MCP models. -------------------------------------------------------------------------------- /docs/release/release_0.11.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.11.0 2 | ============= 3 | 4 | - General 5 | 6 | - Generate expression representation as soon as it is created to avoid tall recursions. 7 | - Find variables in equations by iteratively traversing instead of doing recursion. 8 | - Fix domain for the equations that were specified in the constructor of the equation. 9 | - Check if the container of domain symbols of a symbol match with the symbol's container. 10 | - Check if the container is valid before running the model. 11 | 12 | - Documentation 13 | - Add documentation for NEOS backend. 14 | 15 | - Testing 16 | 17 | - Add NEOS Server as a backend to solve models. 18 | - Add tests for NEOS backend. 19 | - Add tests for equations that were defined in the constructor. 20 | - Add tests for checking the containers of domain symbols. 21 | -------------------------------------------------------------------------------- /docs/release/release_0.11.1.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.11.1 2 | ============= 3 | 4 | - General 5 | 6 | - Fix missing atttributes of Alias such as .first, .last etc. 7 | - Fix global option bug 8 | - Display summary on Jupyter Notebook. 9 | 10 | - Testing 11 | 12 | - Add tests for Alias attributes. -------------------------------------------------------------------------------- /docs/release/release_0.11.10.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.11.10 2 | ============== 3 | 4 | - General 5 | 6 | - Adapt debugging level to GAMS 46 debugging levels. 7 | - Users have to upgrade their gamspy_base version. Command to upgrade: `gamspy update` or `pip install gamspy_base --upgrade`. 8 | - Adapt getInstalledSolvers to renaming of SCENSOLVER 9 | 10 | - Testing 11 | 12 | - Add test for GAMS Engine extra model files with incorrect relative path. 13 | - Update the results of model instance tests (CONOPT3 -> CONOPT4). 14 | -------------------------------------------------------------------------------- /docs/release/release_0.11.2.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.11.2 2 | ============= 3 | 4 | - General 5 | 6 | - Fix the bug in writing only modified symbols. 7 | - Return summary dataframe for all synchronous backends. 8 | - Fix the bug in using set, alias attributes in conditions. 9 | 10 | - Documentation 11 | 12 | - Re-run notebooks to reflect the changes in solve summary. 13 | 14 | - Testing 15 | 16 | - Add tests for the returned summary dataframe from solve. 17 | - Add tests for solve with trace options. -------------------------------------------------------------------------------- /docs/release/release_0.11.3.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.11.3 2 | ============= 3 | 4 | - General 5 | 6 | - Fix setRecords bug 7 | - Run after an equation is defined 8 | 9 | - Testing 10 | 11 | - Fix incorrect order of setRecords in gapmin model 12 | - Fix domain violation in the unit tests revealed by the execution of equation definitions in immediate mode. 13 | - Use gams_math.sqr instead of custom sqr function in tests. 14 | -------------------------------------------------------------------------------- /docs/release/release_0.11.4.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.11.4 2 | ============= 3 | 4 | - General 5 | 6 | - Expose GTP special values via gp.SpecialValues 7 | - Fix NEOS bug when the previous workfile comes from another backend. 8 | - Optimize read function of Container by assigning the symbols attributes directly while casting. 9 | - Remove autogenerated variable and equation from Container after each solve. 10 | - Recover dirty and modified states if the write is invoked by the user. 11 | - Do not expose cast_to_gamspy to user. 12 | - Abstract backends to allow easier extension. 13 | - Add compress, mode, eps_to_zero arguments to write 14 | - Add load_records, mode, and encoding arguments to read 15 | 16 | - Documentation 17 | 18 | - Fix Variable attribute assignments in user guide. 19 | - Add more examples in docstrings. 20 | - Add docs for collecting the results of non-blocking NEOS Server solves. 21 | 22 | - Testing 23 | 24 | - Test the special value usage in assignments for Parameter, ImplicitParameter and Operation (Sum, Smax, Smin, Product). 25 | - Add hansmpsge model to the model library. 26 | - Add tests for the new arguments of write 27 | - Add tests for the new arguments of read 28 | -------------------------------------------------------------------------------- /docs/release/release_0.11.5.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.11.5 2 | ============= 3 | 4 | - General 5 | 6 | - Verify dimensionality of the symbol and the given indices to provide better error messages. 7 | - Allow Model object to also accept tuple of equations. 8 | - List available and installed solvers in alphabetically sorted order. 9 | - Fix adding autogenerated equations twice. 10 | - Generate unique names for the autogenerated variables and equations. 11 | - Add __str__ and __repr__ to Model. 12 | - Allow literals in sameAs operation. 13 | - Make Number operable. 14 | - Add more data validation functions. 15 | - Clear autogenerated symbols from the container if there is an exception. 16 | - Fix Alias bug while preparing the modified symbols list. 17 | 18 | - Testing 19 | 20 | - Add tests to check if incompatible dimensionality throws exception. 21 | - Test validation errors. 22 | - Allow providing system directory for the tests via environment variable. 23 | 24 | - Documentation 25 | 26 | - Add documentation for `matches` argument of Model. 27 | -------------------------------------------------------------------------------- /docs/release/release_0.11.6.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.11.6 2 | ============= 3 | 4 | - General 5 | 6 | - Support slices for indexing. 7 | - Fix unary operator for expressions 8 | - Fixes SpecialValues bug in expressions. 9 | - Fix the bug for nonbinding equations. 10 | - Fix discovery of variables in math operations. 11 | - Fix literal while checking for domain validation. 12 | 13 | - Testing 14 | 15 | - Add tests for slicing and ellipsis. 16 | - Add tests for unary operator applied to expressions. 17 | - Add tests to verify the correctness of SpecialValues in expressions. 18 | - Add more tests for nonbinding equations. 19 | 20 | - Documentation 21 | 22 | - Document indexing with slices and ellipsis. -------------------------------------------------------------------------------- /docs/release/release_0.11.7.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.11.7 2 | ============= 3 | 4 | - General 5 | 6 | - Allow variable/equation attribute assignment without any index. 7 | - Run GAMS on symbol declaration and setRecords. 8 | - Add debugging_level argument to Container. 9 | - Performance improvements (~25-30%). 10 | 11 | - Testing 12 | 13 | - Test scalar variable/equation assignment without any index. 14 | - Test uel order. 15 | 16 | - Documentation 17 | 18 | - Document assigning to scalar variable/equation. 19 | - Update documentation of frozen solve (model instance in GAMS). 20 | - Add documentation for debugging levels. 21 | -------------------------------------------------------------------------------- /docs/release/release_0.11.8.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.11.8 2 | ============= 3 | 4 | - General 5 | 6 | - Allow assigning VariableType enum or EquationType enum as an attribute after object creation for Equation and Variable. 7 | - Fix running twice on symbol declaration with records 8 | - Return better error messages for incorrectly provided solver, options, and output arguments. 9 | - Fix missing uels_on_axes argument in setRecords. 10 | - Start using pylint to improve code quality. 11 | 12 | - Testing 13 | 14 | - Add tests for assigning type to Variable and Equation after creation. 15 | - Add models information at the top of each model's docstring. 16 | - Add tests for setRecords with uels on axes. 17 | 18 | - Documentation 19 | 20 | - Add docs for translating GAMS Macros to GAMSPy. -------------------------------------------------------------------------------- /docs/release/release_0.11.9.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.11.9 2 | ============= 3 | 4 | - General 5 | 6 | - Fix relative path issue of GAMS Engine backend. 7 | - Use $loadDC instead of $load to better catch domain violations. 8 | - Bypass constructor while creating a Container copy. 9 | - Do not execute_unload in case there is no dirty symbols to unload. 10 | - Update the behavior of `gamspy install/uninstall license`. 11 | - Implement GAMS Engine Client and consolidate NeosClient and EngineClient into one argument in solve. 12 | - Fix finding variables to mark in power and sameAs operations. 13 | 14 | - Testing 15 | 16 | - Add test for GAMS Engine extra model files with incorrect relative path. 17 | - Add tests for new GAMS Engine Client. 18 | - Add a test to catch domain violation. 19 | - Remove declaration of objective variables and functions and add the equations into Python variables. 20 | - Add a new test to verify the license installation/uninstallation behavior. 21 | - Add a test to find variables in power operation. 22 | 23 | - Documentation 24 | 25 | - Add a note in model documentation to warn about relative path requirement of GAMS Engine. 26 | - Add documentation for solving models asynchronously with GAMS Engine. 27 | - Modify model library table generation script to add more information and better table styling. -------------------------------------------------------------------------------- /docs/release/release_0.12.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.12.0 2 | ============= 3 | 4 | - General 5 | 6 | - Implement GAMS MIRO integration. 7 | - Update minimum gamsapi and gamspy_base version to 46.1.0. 8 | 9 | - Testing 10 | 11 | - Add tests for GAMS MIRO. 12 | 13 | - Documentation 14 | 15 | - Add documentation of GAMS MIRO integration. 16 | -------------------------------------------------------------------------------- /docs/release/release_0.12.1.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.12.1 2 | ============= 3 | 4 | - General 5 | 6 | - Fix dataframe column names of GAMS MIRO input tables. 7 | - Catch solve status errors and throw necessary exceptions. 8 | - __pow__ returns sqrt instead of rPower if the exponent is 0.5. 9 | - Deprecate delayed_execution mode. 10 | - Replace pylint, flake8 and black with ruff. 11 | - Implement /api/auth -> post, /api/auth/login -> post and /api/auth/logout -> post for GAMS Engine. 12 | - Allow dumping log file to arbitrary path. 13 | - Allow dumping listing file to arbitrary path. 14 | - Allow dumping gdx file to arbitrary path. 15 | - Disallow equation definitions without any equality sign. 16 | - Add calculate_infeasibilities function for variables, equations and models. 17 | - Add 'gamspy show license', and 'gamspy show base' commands. 18 | 19 | - Testing 20 | 21 | - Replace PandasExcelReader and PandasExcelWriter with new ExcelReader and ExcelWriter from GAMS Connect correspondingly. 22 | - Add a new model (Nurses) to the model library and the Notebook examples. 23 | - Add an AC optimal power flow (ACOPF) model to the model library. 24 | - Add a test to verify the generated string for power where the exponent is 0.5. 25 | - Add tests for /api/auth. 26 | - Add a test for creating log file with arbitrary name. 27 | - Add a test for creating lst file with arbitrary name. 28 | - Add a test for creating gdx file with arbitrary name. 29 | - Add tests for infeasibility calculations. 30 | 31 | - Documentation 32 | 33 | - Remove FAQ about Google Colab (it is resolved) and add FAQ about Windows Defender. 34 | - Remove documentation for delayed execution mode. 35 | - Add an example for providing solver options. 36 | - Document CLI for gamspy show commands. 37 | -------------------------------------------------------------------------------- /docs/release/release_0.12.2.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.12.2 2 | ============= 3 | 4 | - General 5 | 6 | - Add infeasibility_tolerance as a model attribute. 7 | - Make urllib3 a true dependency instead of an optional one. 8 | - Do not suppress compiler listing by default. 9 | - Improve the performance of model attribute loading. 10 | - Fix license path for model instance. 11 | 12 | - Documentation 13 | 14 | - Add documentation about solver specific infeasibility options. 15 | -------------------------------------------------------------------------------- /docs/release/release_0.12.3.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.12.3 2 | ============= 3 | 4 | - General 5 | 6 | - Set log and listing file option relative to os.cwd instead of workspace.working_directory. 7 | - Simplify expression generation and fix incorrect expression data. 8 | - Add logoption=4. 9 | - Add show_raw option to the generateGamsString function. 10 | 11 | - Testing 12 | 13 | - Test relative path for listing file and log file creation options. 14 | - Update log option tests. 15 | - Add new tests for generateGamsString. 16 | 17 | - Documentation 18 | 19 | - Remove the remnants of .definition and .assignment syntax from documentation. 20 | - Fix the example in gamspy for gams users. 21 | - Add notes about the equivalent operation in GAMS to .where syntax in GAMSPy. 22 | - Update the documentation for debugging with generateGamsString. -------------------------------------------------------------------------------- /docs/release/release_0.12.4.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.12.4 2 | ============= 3 | 4 | - General 5 | 6 | - Add checks on model name. 7 | - Adjust when to throw an exception and when to throw a warning for different SolveStatus values. 8 | - Make autogenerated model attribute symbol names independent of the model name. 9 | - Do not allow expressions and symbols to be used as truth values. 10 | - Add deprecation message for getStatement and expose getDeclaration and getDefinition. 11 | - Override __repr__ and __str__ of Container. 12 | - Synchronize gamspy_base and gamsapi versions. 13 | 14 | - Testing 15 | 16 | - Test invalid model names. 17 | - Add tests for expressions and symbols that are used as truth values. 18 | - Add tests for __repr__ and __str__ of Container. 19 | -------------------------------------------------------------------------------- /docs/release/release_0.12.5.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.12.5 2 | ============= 3 | 4 | - General 5 | 6 | - Do not pick the default solver if the given solver is not compatible with the problem type. 7 | - Add extrinsic function support. 8 | - Expose addGamsCode to user. 9 | - Refactor the underlying implementation of options. 10 | - Show better error messages. 11 | - Fix number of arguments that log_gamma takes. 12 | - Rename getStatement to getDeclaration. 13 | 14 | - Testing 15 | 16 | - Add tests for extrinsic functions. 17 | - Test whether the given solver is capable of solving the problem type. 18 | - Add an addGamsCode test for each problem type. 19 | - Test Jupyter Notebooks in docs automatically. 20 | - update log option tests. 21 | 22 | - Documentation 23 | 24 | - Remove unnecessary GTP functions from documentation 25 | - Add a doctest for addGamsCode. 26 | - Update the documentation on generating log files. 27 | -------------------------------------------------------------------------------- /docs/release/release_0.12.6.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.12.6 2 | ============= 3 | 4 | - General 5 | 6 | - Do not open gdx file in case there is nothing to load. 7 | - Fix solver capability check bug. 8 | - Enable explicit expert synchronization for symbols. 9 | - Fix dist function in math package. 10 | 11 | Testing 12 | 13 | - Adapt generateGamsString tests to new the gdx load logic. 14 | - Add test for the solver capability bug. 15 | - Test explicit expert synchronization for symbols. 16 | -------------------------------------------------------------------------------- /docs/release/release_0.12.7.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.12.7 2 | ============= 3 | 4 | - General 5 | 6 | - Fix equation/variable listing bug. 7 | - Exclude autogen statements in generateGamsString raw. 8 | - Upgrade gamspy_base and gamsapi versions to 47.1.0. 9 | - Fix parameter equality bug in equations. 10 | - Set upper bound of numpy version below 2 until gamsapi supports it. 11 | 12 | - Documentation 13 | 14 | - Fix the alignment of code section in debugging page. 15 | 16 | - Testing 17 | 18 | - Add test to verify the correctness of parameter equality in equations. 19 | -------------------------------------------------------------------------------- /docs/release/release_0.13.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.13.0 2 | ============= 3 | 4 | - General 5 | 6 | - Communicate with GAMS executable via socket instead of spawning a new job every time. 7 | 8 | - Documentation 9 | 10 | - Adjust debugging page according to the new .gms generation rules. 11 | - Update installation page to adjust to the new licensing scheme. 12 | - Add a note about the new licensing scheme (GAMS license != GAMSPy license). 13 | 14 | - Testing 15 | 16 | - Add new tests to verify correct license installation and listing solvers. 17 | -------------------------------------------------------------------------------- /docs/release/release_0.13.1.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.13.1 2 | ============= 3 | 4 | - General 5 | 6 | - Support output redirection for NEOS backend. 7 | - Support GAMSPy to GAMS automatic conversion. 8 | - Add support for the old way of installing a license. 9 | 10 | - Documentation 11 | 12 | - Update model documentation to show how to redirect NEOS output to a file. 13 | 14 | - Testing 15 | 16 | - Add a new model (knapsack) to the model library. -------------------------------------------------------------------------------- /docs/release/release_0.13.2.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.13.2 2 | ============= 3 | 4 | - General 5 | 6 | - Set the records of objective value in model instance solves. 7 | - Allow using an environment variable to set the GAMS system directory (given environment variable will override the system directory even if the user provides a system directory argument to Container). 8 | - Use gdxSymbols commandline option instead of manually marking symbols dirty. 9 | - Add memory_tick_interval, monitor_process_tree_memory, and profile_file options. 10 | - Change the way to generate a GAMS model from a GAMSPy model. 11 | - Remove import_symbols argument for addGamsCode since it is not needed anymore. 12 | 13 | - Documentation 14 | 15 | - Redirect model library page to gamspy-examples Github repo. 16 | - Update toGams docs. 17 | - Update doctest of addGamsCode. 18 | 19 | - Testing 20 | 21 | - Add model instance tests that check the objective value. 22 | - Update system directory test to adjust to the environment variable support. 23 | - Add tests for profiling options. 24 | -------------------------------------------------------------------------------- /docs/release/release_0.13.3.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.13.3 2 | ============= 3 | 4 | - General 5 | 6 | - Change default solvers to 'CONOPT', 'CONVERT', 'CPLEX', 'GUSS', 'IPOPT', 'IPOPTH', 'KESTREL', 'NLPEC', 'PATH', and 'SHOT'. 7 | - Fix the version of gamspy_base when "gamspy update" command is being executed. 8 | - Fix the order issue for Alias in toGams function. 9 | - Add exponential backoff for GAMS Engine logout API. 10 | - Add symbol validation for Ord operation. 11 | 12 | - Testing 13 | 14 | - Update model library tests according to the new default solvers. 15 | - Add a test to verify that modifiable symbols cannot be in conditions for model instance runs. 16 | - Add new tests for symbol validation. 17 | -------------------------------------------------------------------------------- /docs/release/release_0.13.4.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.13.4 2 | ============= 3 | 4 | - General 5 | 6 | - Fix hanging issue on Windows for GAMS Engine backend. 7 | - Refactor toGams converter. 8 | - Fix solver options file path bug. 9 | 10 | - Testing 11 | 12 | - Add more tests for GAMS MIRO. -------------------------------------------------------------------------------- /docs/release/release_0.13.5.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.13.5 2 | ============= 3 | 4 | - General 5 | 6 | - Make trace file name dynamic to avoid race condition on parallel runs. 7 | - Fix log options for GAMS Engine backend. 8 | - Initial support for GAMSPy to Latex. 9 | - Generate solver options file under container working directory instead of current directory. 10 | - Fix implicit set issues for toGams function. 11 | 12 | - Documentation 13 | 14 | - Add links to the api reference for symbols and functions mentioned in the documentation. 15 | - Minor documentation corrections. 16 | 17 | - Testing 18 | 19 | - Logout from GAMS Engine only on Python 3.12 to avoid unauthorized calls on parallel jobs. 20 | - Add tests to verify the behaviour of different logoption values. 21 | - Add tests for GAMSPy to Latex. 22 | -------------------------------------------------------------------------------- /docs/release/release_0.13.6.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.13.6 2 | ============= 3 | 4 | - General 5 | 6 | - Make all file read and writes with utf-8 encoding. 7 | - Fix model instance record columns. 8 | - Allow all iterables for equations argument of model. 9 | - Fix the bug in socket connection messages. 10 | 11 | - Testing 12 | 13 | - Add a test to verify the columns of symbols in model instance solves. 14 | - Test set difference for model equations argument. 15 | -------------------------------------------------------------------------------- /docs/release/release_0.13.7.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.13.7 2 | ============= 3 | 4 | - General 5 | 6 | - Support .where syntax for Card and Ord. 7 | - Return condition on where operations on the right instead of expression. 8 | - Support custom streams for output redirection. 9 | - Catch set is already under control errors early. 10 | 11 | - Documentation 12 | 13 | - Fix docstring of the Card operation. 14 | - Add warning about non-professional licenses in addGamsCode docstring. 15 | - Add an example to show how to redirect output to a custom stream. 16 | 17 | - Testing 18 | 19 | - Add tests for .where syntax for Card and Ord. 20 | - Add tests to catch set is already under control errors. 21 | - Add a test which redirects output to a custom stream. 22 | -------------------------------------------------------------------------------- /docs/release/release_0.14.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.14.0 2 | ============= 3 | 4 | - General 5 | 6 | - Introduce matrix multiplication operator `@`. 7 | - Add most common activation functions for machine learning. 8 | - Improve domain checking. 9 | - Write division with frac in toLatex function. 10 | - Allow specifying port for the communication with GAMS license server with --port argument of GAMSPy CLI. 11 | 12 | - Documentation 13 | 14 | - Add GAMSPy and Machine Learning section. 15 | - Add ML examples. 16 | - Give more information about the restrictions of frozen solve. 17 | 18 | - Testing 19 | 20 | - Add tests for different cases of matrix multiplication. 21 | - Add tests for activation functions. 22 | - Add tests for domain checking. 23 | -------------------------------------------------------------------------------- /docs/release/release_0.14.1.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.14.1 2 | ------------- 3 | - General 4 | 5 | - Add SOS1 ReLU implementation. 6 | - Add __repr__ to all GAMSPy language constructs for better debugging. 7 | - Give a warning in case the domain is not initialized by the time there is an attribute assigment. 8 | - Allow indexing on alias symbols. 9 | - Add reference_file option. 10 | - Add selective loading for solve statements. 11 | - Change default port to communicate with license server to 443. 12 | - Fix installing licenses from a path. 13 | 14 | - Documentation 15 | 16 | - Add API docs for SOS1 ReLU implementation. 17 | - Explain the working directory - debugging level relationship. 18 | 19 | - Testing 20 | 21 | - Add tests for SOS1 ReLU implementation. 22 | - Shorten attribute assignments in model library (variable.l[...] = ... -> variable.l = ...). 23 | - Add tests for indexing on alias symbols. 24 | - Test selective loading for solve statements. 25 | - Add new install license tests. 26 | - Add a new model (coex) to the model library. 27 | -------------------------------------------------------------------------------- /docs/release/release_0.14.2.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.14.2 2 | ------------- 3 | - General 4 | 5 | - Add generate_name_dict option. 6 | - Disable solution report by default. 7 | - Fix the order of equations in toGams utility. 8 | - Allow options in toGams. 9 | - Add loadpoint option to start from a solution. 10 | -------------------------------------------------------------------------------- /docs/release/release_0.14.3.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.14.3 2 | ------------- 3 | - General 4 | 5 | - Add getEquationListing function to be able to inspect generated equations. 6 | - Add infeasibility threshold filter for equation listings. 7 | - Add getVariableListing function to be able to inspect generated variables. 8 | 9 | - Testing 10 | 11 | - Add tests for getEquationListing function. 12 | - Add tests for getVariableListing function. 13 | - Test infeasibility threshold. 14 | 15 | - Documentation 16 | 17 | - Add docs for getEquationListing. 18 | - Add docs for getVariableListing. 19 | -------------------------------------------------------------------------------- /docs/release/release_0.14.4.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.14.4 2 | ------------- 3 | - General 4 | 5 | - Add container.in_miro flag to selectively load data. 6 | - Parse error message after verifying the return code for engine backend. 7 | - Fix the behaviour of Model if it's declared twice with objective function. 8 | - Update the error message of license error. 9 | - Fix output stream validation. 10 | - Fix exception on solve in case listing file is specified. 11 | - Add external equations support. 12 | - Do not raise exception in case GAMS Engine returns 308 on get_logs call. 13 | 14 | - Testing 15 | 16 | - Add test for container.in_miro flag. 17 | - Add tests to simulate Jupyter Notebook behaviour. 18 | - Remove system_directory for tests. 19 | - Add a test which specifies the listing file and fails because the license does not allow to run the model. 20 | - Add tests for external equations support. 21 | - Add traffic model to the model library. 22 | 23 | - Documentation 24 | 25 | - Document in_miro flag. 26 | - Add docstring for setBaseEqual. 27 | - Add section "External Equations" under Advanced documentation. 28 | - Add section "Extrinsic Functions" under Advanced documentation. 29 | -------------------------------------------------------------------------------- /docs/release/release_0.14.5.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.14.5 2 | ------------- 3 | - General 4 | 5 | - Retry login with exponential backoff in GAMS Engine backend. 6 | - Allow to set all model attributes that can be set before solve in GAMS. 7 | - Fix equation listing, variable listing parsing when listing file is specified. 8 | 9 | - Testing 10 | 11 | - Use contextmanager to create atomic conda environments. 12 | - Add tests for model attribute options. 13 | 14 | - Documentation 15 | 16 | - Fix links in the api reference. 17 | - Add an example that shows how to embed NN to an optimization problem. 18 | -------------------------------------------------------------------------------- /docs/release/release_0.14.6.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.14.6 2 | ------------- 3 | - General 4 | 5 | - Fix GAMS Engine get_logs return values according to the status code. 6 | - Allow explicit port definition via environment variable to communicate with GAMS. 7 | - Replace GamsWorkspace with GAMSPy workspace implementation. 8 | - Remove unnecessary validation for system_directory. 9 | - Better formatting for gamspy list solvers and gamspy list solvers -a. 10 | - Change the structure installing licenses on offline machines. 11 | - Fix UniverseAlias bug. 12 | - Check standard locations for GAMS MIRO. 13 | - Simplify toLatex output. 14 | - Make name optional for addX syntax of adding symbols. 15 | - Add __mod__ overload for all operables. 16 | - Fix domain forwarding issue when trying to forward records to the same set. 17 | - Do not convert eps to zero by default. 18 | - Add Sand and Sor operations. 19 | - Ensure that external equations contain == operation. 20 | 21 | - Testing 22 | 23 | - Use the Container that is created in the setup phase instead of creating a new one. 24 | - Remove unnecessary init files in tests. 25 | - Add a test for invalid port. 26 | - Explicitly close the Container for jobs executed by ProcessPoolExecutor. 27 | - Add a test for long running jobs with network license. 28 | - Add tests for gamspy probe and gamspy retrieve license. 29 | - Add test to use UniverseAlias object as domain. 30 | - Add tests to verify that symbol creation with no name is possible. 31 | 32 | - Documentation 33 | 34 | - Add what is gamspy page to docs. 35 | - Update indexing docs. 36 | - Add a link to model library on the landing page. 37 | - Encourage the use of the Discourse platform instead of sending direct emails to gamspy@gams.com. 38 | - Add instructions on how to install a license on an offline machine. 39 | - Update what is gamspy page model example. 40 | - Change the order of symbol declaration and data specification in the quick start guide. 41 | - Add equation listing, variable listing, and interoperabiltiy sections to quick start guide. 42 | - Add gamspy.exceptions to the api reference. 43 | - Change the order of indexing, lag-lead operations, ord-card operations and number. 44 | - Add gamspy.NeosClient to the api reference. 45 | - Add model attributes to docstring. 46 | -------------------------------------------------------------------------------- /docs/release/release_0.14.7.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 0.14.7 2 | ------------- 3 | - General 4 | 5 | - Include variable infeasibilities in model.computeInfeasibilities(). 6 | - Remove cone equation type. 7 | - Fix empty space issue in paths. 8 | 9 | - Documentation 10 | 11 | - Add gamspy probe and gamspy retrieve to the cli reference page. 12 | - Fix typo in miro docs. 13 | -------------------------------------------------------------------------------- /docs/release/release_1.0.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.0.0 2 | ------------ 3 | 4 | Release Date: 02.09.2024 5 | 6 | Highlights 7 | ========== 8 | 9 | - Flexibility to solve your model with three possible backends: your local machine, GAMS Engine, and NEOS Server. 10 | - Integration with GAMS MIRO. 11 | - Matrix operations for machine learning. 12 | - Interoperability with GAMS (via toGams) and LaTeX (via toLatex). 13 | - Commandline interface (gamspy cli) to install/uninstall licenses and add on solvers. 14 | - 114 models and 6 notebooks on our gamspy-examples repository. 15 | - Frozen solve support (aka ModelInstance) 16 | - External equation support. 17 | - Extrinsic function support. -------------------------------------------------------------------------------- /docs/release/release_1.0.0rc1.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.0.0rc1 2 | --------------- 3 | - General 4 | 5 | - Fix starting from a loadpoint for GAMS Engine backend. 6 | - Fix solver options issue for GAMS Engine backend. 7 | - Fix solver options issue for NEOS backend. 8 | - Support external equation for GAMS Engine backend. 9 | - Change the behaviour of expert synch mode. 10 | - Update quick start guide with latex to pdf output. 11 | - Fix quote issue in paths. 12 | - Activation functions now return added equations as well. 13 | - skip_intrinsic option added for log_softmax. 14 | - Allow installing/uninstalling multiple solvers at once. 15 | - Make miro_protect an option. 16 | - Show a better help message on gamspy -h command. 17 | - Fix missing links in api reference. 18 | - Set default problem type as MIP instead of LP. 19 | - Allow UniverseAlias in assignments. 20 | 21 | - Documentation 22 | 23 | - Add a warning about the manipulation of records via .records. 24 | - Fix model attribute return type. 25 | -------------------------------------------------------------------------------- /docs/release/release_1.0.1.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.0.1 2 | ------------ 3 | 4 | Release Date: 13.09.2024 5 | 6 | - General 7 | 8 | - Fix frozen solve with non-scalar symbols. 9 | - Fix the definition update problem while redefining an equation with definition argument. 10 | - Introduce default directories to keep license information on upgrade. 11 | - Add --existing-solvers and --install-all-solvers options for gamspy install solver. 12 | - Add --uninstall-all-solvers option for gamspy uninstall solver. 13 | - Show license path on gamspy show license command. 14 | - Simplify the implementation of the copy container operation. 15 | - Add Conv2d formulation for convenience 16 | - Map GAMSPy problem types to NEOS problem types before sending the job. 17 | - Upgrade gamspy_base and gamsapi versions to 47.6.0. 18 | 19 | - Testing 20 | 21 | - Add test for the frozen solve with non-scalar symbols. 22 | - Add a test to verify the behaviour of equation redefinition with definition argument. 23 | - Test the usage of a license that is in one of the default paths. 24 | - Fix the issue related to reading equation records from a gdx file. 25 | - Add tests to verify the records after reading them from a gdx file. 26 | - Add tests for installing/uninstalling solvers. 27 | - Add tests to verify correctness of Conv2d formulation 28 | - Add a test to verify GAMSPy -> NEOS mapping. 29 | - Add an execution error test. 30 | 31 | - Documentation 32 | 33 | - Update the documentation of install/uninstall command line arguments. 34 | - Add a section for NN formulations -------------------------------------------------------------------------------- /docs/release/release_1.0.2.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.0.2 2 | ------------ 3 | 4 | Release Date: 01.10.2024 5 | 6 | - General 7 | 8 | - Validate whether the solver is installed only for local backend. 9 | - Change the default value of sense to Sense.FEASIBILITY. 10 | - Support output in Container constructor. 11 | - Fix debugging_level bug. 12 | - Add additional checks for the validity of the license. 13 | - Allow generateGamsString function only if the debugging level is set to "keep". 14 | - Fix socket communication issue on license error. 15 | - Distinguish GamspyException from FatalError. The user might catch GamspyException and continue but FatalError should never be caught. 16 | - Fix singleton assignment bug. 17 | - Allow an alternative syntax for variable/equation attributes (e.g. b[t].stage = 30). 18 | - Add support for MaxPool2d/MinPool2d/AvgPool2d. 19 | - Add support for flatten_dims for flattening n domains into 1 domain. 20 | - Show class members groupwise in the table of contents (first methods, then properties). 21 | - Use the new license server endpoint to verify the license type. 22 | - Don't do extra unnecessary GAMSPy to GAMS synch after addGamsCode. 23 | - Fix incorrect domain information of symbols created by addGamsCode 24 | - Fix network license issue on NEOS Server. 25 | - Replace non-utf8 bytes of stdout. 26 | 27 | - Testing 28 | 29 | - Remove license uninstall test to avoid crashing parallel tests on the same machine. 30 | - Add tests for the generated solve strings for different type of problems. 31 | - Add a test for Container output argument. 32 | - Add tests for debugging_level. 33 | - Add tests to verify the validity of the license. 34 | - Add memory check script for the performance CI step. 35 | - Add tests for the alternative syntax for variable/equation attributes. 36 | - Add tests for pooling layers and flatten_dims 37 | 38 | - Documentation 39 | 40 | - Fix broken links in the documentation. 41 | - Add a ci step to check doc links. 42 | - Improve the wording of debugging document. 43 | - Add pooling and flatten_dims docs. 44 | -------------------------------------------------------------------------------- /docs/release/release_1.0.3.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.0.3 2 | ------------ 3 | 4 | Release Date: 08.10.2024 5 | 6 | - General 7 | 8 | - Fix solver installation bug in case of a solver installation before the license installation. 9 | - Fix the validation bug on multiple operations in a row. 10 | - Fix set attribute comparison bug. 11 | 12 | - Testing 13 | 14 | - Remove leftover files after running all tests. 15 | -------------------------------------------------------------------------------- /docs/release/release_1.0.4.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.0.4 2 | ------------ 3 | 4 | Release Date: 17.10.2024 5 | 6 | - General 7 | 8 | - Do not create a GDX file when it's not necessary. 9 | - Do not carry solver options from the previous solve to the new solve. 10 | - Fix toGams bug of MathOp symbols. 11 | - Use symbol< syntax of GAMS to handle domain forwarding. 12 | - Add "same" and "valid" options for Conv2d padding. 13 | - Update dependencies. gamspy_base -> 48.1.1 and gamsapi -> 48.1.0. 14 | - Make minimum supported Python version 3.9 and add support for Python 3.13. 15 | 16 | - Documentation 17 | 18 | - Fix documented type of model.solve_status. 19 | - Add num_equations attribute to the model page of user guide. 20 | - Add synchronization docs to reference api. 21 | 22 | - Testing 23 | 24 | - Add one to one comparison tests with reference files in toGams tests. 25 | - Add tests for "same" and "valid" padding options of Conv2d. 26 | -------------------------------------------------------------------------------- /docs/release/release_1.1.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.1.0 2 | ------------ 3 | 4 | Release Date: 30.10.2024 5 | 6 | - General 7 | 8 | - Allow printing the records of variable/equation attributes with a print(variable.attribute[domain].records) syntax. 9 | - Allow printing the records of a subset of a parameter with print(parameter['literal'].records) syntax. 10 | - Allow printing the records of a subset of a set with print(set['literal'].records) syntax. 11 | - Update variable/equation attribute domains on addGamsCode call. 12 | - Show log file instead of listing file on solve statements with NEOS backend. 13 | - Add Linear layer formulation 14 | - Fix minor bug of domain conflict in batched matrix multiplication 15 | - Improve the error messages of the thrown exceptions in case the user provide a model option at Container creation time. 16 | - Do not allow models with the same name to override each other. 17 | - Upgrade gamspy_base and gamsapi versions to 48.2.0. 18 | 19 | - Testing 20 | 21 | - Fix race conditions in the pipeline. 22 | - Remove redundant setRecords in gapmin.py example. 23 | - Add sq.py model to the test model suite. 24 | - Update hansmge model. 25 | - Fix lower bound in reshop model. 26 | - Add tests for the Linear layer 27 | - Add a script to measure the overhead of GAMSPy and Python in general for each model in the model library. 28 | 29 | - Documentation 30 | 31 | - Add documentation for the Linear layer 32 | -------------------------------------------------------------------------------- /docs/release/release_1.10.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.10.0 (2025-04-30) 2 | ========================== 3 | 4 | New features 5 | ============ 6 | 7 | - #599: Allow renaming on ``container.loadRecordsFromGdx`` function call. 8 | 9 | - #601: Allow users to disable all validation via ``gp.set_options({"VALIDATION": 0})``. 10 | 11 | 12 | Improvements in existing functionality 13 | ====================================== 14 | 15 | - #594: Add GAMSPyJacobian file format for the convert function. 16 | 17 | - #612: Raise a validation error in case an automatically named symbol is used in an equation of an EMP model. Use base64 auto-generated names instead of plain uuid.uuid4 names. 18 | 19 | - #613: Improve the error message of undefined scalar equations. 20 | 21 | - #615: Remove duplicate conopt entries in gamspy list solvers cli command and add utils.getInstallableSolvers function. 22 | 23 | - #617: Cast the type of objective value, num equations, num variables, and solver time in the summary dataframe. 24 | 25 | - #623: Improve the error message in case the user does not have an internet connection or the PyPI server are down. 26 | 27 | - #624: Allow .records call on implicit variables and equations. 28 | 29 | 30 | Bug fixes 31 | ========= 32 | 33 | - #625: Overload __eq__ and __ne__ magic functions of the Number class to ensure the order is correct in expressions. 34 | 35 | - #626: Fix the bug in the filtering of a single record in non-level attributes of a variable (lo, up, marginal, scale). 36 | 37 | - #629: Allow record filtering over eq.range, eq.slacklo, eq.slackup, eq.slack, and eq.infeas attributes. 38 | 39 | 40 | Improved documentation 41 | ====================== 42 | 43 | - #602: Use towncrier to automate changelog creation and avoid marge conflicts in the changelog file. 44 | 45 | 46 | -------------------------------------------------------------------------------- /docs/release/release_1.11.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.11.0 (2025-05-16) 2 | ========================== 3 | 4 | New features 5 | ============ 6 | 7 | - #607: Allow evaluation of expression on the fly without requiring an explicit assignment statement to a parameter. 8 | 9 | 10 | Bug fixes 11 | ========= 12 | 13 | - #608: Fix literal bug in latex representation of implicit symbols. 14 | 15 | - #633: Incrementally build model declaration to avoid input line length limitation (80000 characters). 16 | 17 | - #638: Fix the bug that occurs when "gamspy probe -h" runs. 18 | 19 | 20 | Improved documentation 21 | ====================== 22 | 23 | - #614: Add developer guide to the documentation. 24 | 25 | 26 | CI/CD changes 27 | ============= 28 | 29 | - #631: Add tests for Linux arm64. Add a new marker called "requires_license" to separate tests that require a license to run. 30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/release/release_1.11.1.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.11.1 (2025-06-03) 2 | ========================== 3 | 4 | Improvements in existing functionality 5 | ====================================== 6 | 7 | - #611: Allow users to create GAMSPy options from a dictionary of GAMS options. 8 | 9 | - #640: Add "append_to_log_file" option to allow appending to the log file. 10 | 11 | 12 | Bug fixes 13 | ========= 14 | 15 | - #641: Fix the overload of the unary magic function. 16 | 17 | - #643: Escape underscores in latex representation to support symbol names with underscores. 18 | 19 | 20 | -------------------------------------------------------------------------------- /docs/release/release_1.2.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.2.0 2 | ------------ 3 | 4 | Release Date: 19.11.2024 5 | 6 | - General 7 | 8 | - Fix non-zero return code issue in case there is an error in the script. In case the return code is non-zero, GAMSPy will not launch GAMS MIRO. 9 | - Fix the behaviour of CTRL+C. 10 | - Allow alternative `set +/- n` syntax for lead and lag operations. 11 | - Upgrade gamspy_base and gamsapi dependencies. 12 | - Expose the filename and the line number of the solve to the listing file. 13 | - Improve the performance of `load_from` argument of Container. 14 | 15 | - Testing 16 | 17 | - Add a new performance test which compares the performance of GAMS Transfer read and GAMSPy read. 18 | 19 | - Documentation 20 | 21 | - Add a favicon. 22 | -------------------------------------------------------------------------------- /docs/release/release_1.3.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.3.0 2 | ------------ 3 | 4 | Release Date: 29.11.2024 5 | 6 | - General 7 | 8 | - Change the way to show limited variables in latex file. 9 | - Overload __rpower__ for operables. 10 | - Support __neg__ overload for Card and Ord operations. 11 | - Fix the bug in new lag/lead syntax. 12 | - Add a verification step for working directory path length. 13 | - Add `map_value` function to the math library. 14 | - Allow conditioning on conditions. 15 | - Upgrade gamspy_base and gamsapi dependencies. 16 | 17 | - Documentation 18 | 19 | - Add a section for limited variables. 20 | - Add an example that shows how to read from another Container. 21 | -------------------------------------------------------------------------------- /docs/release/release_1.3.1.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.3.1 2 | ------------ 3 | 4 | Release Date: 03.12.2024 5 | 6 | - General 7 | 8 | - Fix the bug in equality type traversal. Use post-traversal instead of in-order traversal. 9 | -------------------------------------------------------------------------------- /docs/release/release_1.4.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.4.0 2 | ------------ 3 | 4 | Release Date: 20.12.2024 5 | 6 | - General 7 | 8 | - Resolve static code analysis issues to improve code quality. 9 | - Return the value as a float if the given domain sets are all literals. 10 | - Add an automation script to update pyproject.toml, switcher, version test, and the release notes. 11 | - Allow propagating bounds of the output in the Linear class. 12 | 13 | - Testing 14 | 15 | - Set COVERAGE_CORE to sysmon to make use of the new sys.monitoring package in Python. 16 | 17 | - Documentation 18 | 19 | - Add an example demonstrating how to solve the Minimum Cost Multi-Commodity Flow Problem using Column Generation in GAMSPy. 20 | - Remove non-negative variable type from the docs. 21 | - Add plausible.js for analytics. 22 | - Minor update in embedding nn documentation. 23 | -------------------------------------------------------------------------------- /docs/release/release_1.5.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.5.0 2 | ------------ 3 | 4 | Release Date: 10.01.2025 5 | 6 | - General 7 | 8 | - Fix implicit parameter validation bug. 9 | - Allow the usage of Container as a context manager. 10 | - Allow propagating bounds to the output variable in `flatten_dims` method. 11 | - Add piecewise linear function formulations. 12 | - Migrate GAMSPy CLI to Typer. 13 | - Threads can now create a container since we register the signal only to the main thread. 14 | - Fix solver options bug in frozen solve. 15 | - Synchronize after read. 16 | - Upgrade gamspy_base and gamsapi dependencies. 17 | 18 | - Testing 19 | 20 | - Lower the number of dices in the interrupt test and put a time limit to the solve. 21 | - Add tests for piecewise linear functions. 22 | 23 | - Documentation 24 | 25 | - Install dependencies in the first cell of the example transportation notebook. 26 | - Add Formulations page to list piecewise linear functions and nn formulations. 27 | -------------------------------------------------------------------------------- /docs/release/release_1.5.1.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.5.1 2 | ------------ 3 | 4 | Release Date: 31.01.2025 5 | 6 | - General 7 | 8 | - Fix the bugs in dynamic set assignments. 9 | - Rewrite parts of GAMS Control API. 10 | - Fix debugging level bug of NEOS backend. 11 | - Fix license issue of big models that are solved with frozen solve. 12 | - Allow loadRecordsFromGdx to domain forward. 13 | - Enhance bound propagation for `MaxPool2d` and `MinPool2d` classes. 14 | 15 | - Testing 16 | 17 | - Add bound propagation tests for `MaxPool2d` and `MinPool2d` classes. 18 | 19 | - Documentation 20 | 21 | - Update embedding Neural Network documentation. -------------------------------------------------------------------------------- /docs/release/release_1.6.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.6.0 2 | ------------ 3 | 4 | Release Date: 23.02.2025 5 | 6 | - General 7 | 8 | - Upgrade pre-commit dependencies. 9 | - Enhance bound propagation for `AvgPool2d` class. 10 | - Allow adding debug options to Options objects. 11 | - Allow starting from a GAMS restart file. 12 | - Allow registering metadata to symbols via `symbol._metadata` attribute. 13 | - Fix solver option format of HIGHS, SHOT, SOPLEX and SCIP. 14 | - Allow dumping gams state on `.toGams` call. 15 | - Allow indexing into symbols with integers. 16 | - Add `bypass_solver`, `cutoff`, and `default_point` options. 17 | - Replace conda, pip and virtualenv with uv in ci pipelines. 18 | - Provide ssl context explicitly for NEOS backend. 19 | - Add configurable options via set_options and get_option. 20 | - Fix bug in an edge case of the vector-matrix multiplication. 21 | 22 | - Testing 23 | 24 | - Add an lp and a qcp benchmark for performance comparison. 25 | 26 | - Documentation 27 | 28 | - Add CNNs to embedding Neural Network documentation. 29 | -------------------------------------------------------------------------------- /docs/release/release_1.7.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.7.0 2 | ------------ 3 | 4 | Release Date: 06.03.2025 5 | 6 | - General 7 | 8 | - Allow container serialization/deserialization. 9 | - Support an alternative syntax for operations. For example, x.sum() is equivalent to Sum(x.domain, x[x.domain]). 10 | - Fix a bug when starting from a GAMS restart file. 11 | - Allow propagating bounds of the output in `Conv2D` class. 12 | - Introduce `name_prefix` option to NN formulations for ease of debugging. 13 | 14 | - Documentation 15 | 16 | - Add a section in FAQ about the compatibiltiy issues of the Python interpreter from the Microsoft Store. 17 | - Fix minor issue in embedding Neural Network documentation. 18 | 19 | - Testing 20 | 21 | - Enforce the order of tests. Run unit tests first, and model library tests last. 22 | - Use spawn method for multiprocessing to avoid possible deadlocks with fork method. 23 | -------------------------------------------------------------------------------- /docs/release/release_1.8.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.8.0 2 | ------------ 3 | 4 | Release Date: 16.03.2025 5 | 6 | - General 7 | 8 | - Improve the performance of frozen solves. 9 | - Add support for new equation, variable matching syntax for MCP models. 10 | - Ignore empty and newlines in the existing solvers file. 11 | - Use finalizers instead of __del__. 12 | - Cache solver capabilities, default solvers and installed solvers to speed up solver validation. 13 | - Fix the bug in the case of multiple frozen models in one container. 14 | - Perform pip audit check in the pipeline instead of pre-commit. 15 | 16 | - Documentation 17 | 18 | - Add `Examples` section under `Machine Learning` documentation. 19 | - Add a Thermal Reformer example demonstrating neural network surrogate modeling. 20 | 21 | - Testing 22 | 23 | - Fix the issue of mac jobs deleting each others environments. 24 | -------------------------------------------------------------------------------- /docs/release/release_1.9.0.rst: -------------------------------------------------------------------------------- 1 | GAMSPy 1.9.0 2 | ------------ 3 | 4 | Release Date: 09.04.2025 5 | 6 | - General 7 | 8 | - Validate solver options for most of the solvers. It can be disable through VALIDATE_SOLVER_OPTIONS option. 9 | - get the value of objective estimation and the number of nodes used after frozen solves 10 | - Add description argument for model objects. 11 | - Make GAMSPy symbols non-iterable. 12 | - Inherit output argument from the container in solve function if the output argument is not specified. 13 | - Start the renaming process (deprecation) of model_instance_options to freeze_options. GAMSPy 1.9.0 will throw a warning. GAMSPy 1.10.0 will throw an exception, and GAMSPy 1.11.0 will remove model_instance_options altogether. 14 | - Fix sense=feasibility bug of frozen models. 15 | - Rename ModelInstanceOptions to FreezeOptions and add a warning for the usage of ModelInstanceOptions. 16 | - Add model.convert function to allow converting a GAMSPy model instance to different file formats. 17 | - Fix sense=feasibility bug of frozen models. 18 | - Fix static code analysis errors. 19 | - Do not validate equation definitions in case the container was restarted from a save file (.g00 file). 20 | - Propagate the output option of the container to `model.freeze`. 21 | - Raise warning in case the frozen solve is interrupted. 22 | - Improve the performance of symbol declarations without any records and declaration of 0 dimensional symbols with records. 23 | 24 | - Documentation 25 | 26 | - Add additional instructions to deploy a GAMSPy/GAMS MIRO model. 27 | - Fix name mismatch between the argument name and the docstring of loadRecordsFromGdx function. 28 | 29 | - Testing 30 | 31 | - Run all pre-commit hooks instead of running selectively. 32 | -------------------------------------------------------------------------------- /docs/user/advanced/advanced.rst: -------------------------------------------------------------------------------- 1 | ******** 2 | Advanced 3 | ******** 4 | 5 | .. meta:: 6 | :description: GAMSPy Advanced User Guide 7 | :keywords: Advanced, User, Guide, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 8 | 9 | These documents clarify concepts, design decisions, and technical 10 | constraints in GAMSPy. This is a great place to understand the 11 | fundamental GAMSPy ideas and philosophy. 12 | 13 | .. toctree:: 14 | :maxdepth: 1 15 | 16 | ./debugging 17 | ./special_features 18 | ./miro 19 | ./model_instance 20 | ./external_equations 21 | ./extrinsic_functions 22 | ./formulations 23 | -------------------------------------------------------------------------------- /docs/user/basics/basics.rst: -------------------------------------------------------------------------------- 1 | ****** 2 | Basics 3 | ****** 4 | 5 | .. meta:: 6 | :description: GAMSPy User Guide 7 | :keywords: User, Guide, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 8 | 9 | These documents clarify concepts, design decisions, and technical 10 | constraints in GAMSPy. This is a great place to understand the 11 | fundamental GAMSPy ideas and philosophy. 12 | 13 | .. toctree:: 14 | :maxdepth: 1 15 | 16 | ./container 17 | ./set 18 | ./alias 19 | ./parameter 20 | ./variable 21 | ./equation 22 | ./model 23 | ./expression_and_indexing 24 | ./assignments 25 | ./card_ord 26 | ./lag_lead.rst 27 | ./number 28 | -------------------------------------------------------------------------------- /docs/user/basics/number.rst: -------------------------------------------------------------------------------- 1 | .. _number: 2 | 3 | ****** 4 | Number 5 | ****** 6 | 7 | A :meth:`gamspy.Number` object is needed for assigning records to a symbol conditionally. For example: 8 | 9 | .. code-block:: python 10 | 11 | import gamspy as gp 12 | 13 | m = gp.Container() 14 | k = gp.Set(m, "k", records=["1964-i","1964-ii","1964-iii","1964-iv"]) 15 | ki = gp.Set(m, domain=k, description="initial period") 16 | ki[k] = gp.Number(1).where[gp.Ord(k) == 1] 17 | 18 | The code snippet above would assign only `1964-i` to `ki` since only the order of `1964-i` is equal to 1. 19 | -------------------------------------------------------------------------------- /docs/user/images/conv1d.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/images/conv1d.gif -------------------------------------------------------------------------------- /docs/user/images/logistic_regression.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/images/logistic_regression.png -------------------------------------------------------------------------------- /docs/user/images/logistic_regression_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/images/logistic_regression_2.png -------------------------------------------------------------------------------- /docs/user/images/loss_per_iter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/images/loss_per_iter.png -------------------------------------------------------------------------------- /docs/user/images/mnist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/images/mnist.png -------------------------------------------------------------------------------- /docs/user/images/network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/images/network.png -------------------------------------------------------------------------------- /docs/user/images/noisy_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/images/noisy_image.png -------------------------------------------------------------------------------- /docs/user/images/noisy_image_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/images/noisy_image_2.png -------------------------------------------------------------------------------- /docs/user/images/pooling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/images/pooling.png -------------------------------------------------------------------------------- /docs/user/images/pwl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/images/pwl.png -------------------------------------------------------------------------------- /docs/user/images/pwl_excluded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/images/pwl_excluded.png -------------------------------------------------------------------------------- /docs/user/images/pwl_unbounded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/images/pwl_unbounded.png -------------------------------------------------------------------------------- /docs/user/images/reformer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/images/reformer.png -------------------------------------------------------------------------------- /docs/user/images/synchronization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/images/synchronization.png -------------------------------------------------------------------------------- /docs/user/index.rst: -------------------------------------------------------------------------------- 1 | .. _user: 2 | 3 | ########## 4 | User Guide 5 | ########## 6 | 7 | .. todolist:: 8 | 9 | This guide is an overview and explains the important features; 10 | details are found in :ref:`reference`. 11 | 12 | .. toctree:: 13 | :caption: Getting Started 14 | :maxdepth: 1 15 | 16 | whatisgamspy 17 | installation 18 | notebooks/trnsport 19 | examples 20 | Model Library 21 | 22 | .. toctree:: 23 | :caption: Fundamentals and Usage 24 | :maxdepth: 2 25 | 26 | basics/basics 27 | advanced/advanced 28 | 29 | .. toctree:: 30 | :caption: Extras 31 | :maxdepth: 1 32 | 33 | faq 34 | gamspy_for_gams_users 35 | developer_guide 36 | 37 | .. toctree:: 38 | :caption: Machine Learning 39 | :maxdepth: 2 40 | 41 | ml/ml 42 | ml/examples -------------------------------------------------------------------------------- /docs/user/ml/examples.rst: -------------------------------------------------------------------------------- 1 | *************************** 2 | Examples 3 | *************************** 4 | 5 | .. meta:: 6 | :description: Machine learning and Optimization examples in GAMSPy 7 | :keywords: Machine Learning, Optimization, Examples, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 8 | 9 | This section contains various examples demonstrating the use of GAMSPy in the context of neural network optimization to tackle a wide range of challenges. 10 | 11 | .. toctree:: 12 | :maxdepth: 1 13 | 14 | ./ols 15 | ./logistic 16 | ./nn 17 | ./thermal_reformer 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/user/ml/ml.rst: -------------------------------------------------------------------------------- 1 | *************************** 2 | GAMSPy and Machine Learning 3 | *************************** 4 | 5 | .. meta:: 6 | :description: GAMSPy User Guide 7 | :keywords: Machine Learning, User, Guide, GAMSPy, gamspy, GAMS, gams, mathematical modeling, sparsity, performance 8 | 9 | GAMSPy heralds a new era of possibilities, bridging the gap between machine learning 10 | and optimization that was previously difficult to cross using GAMS alone. Here's why 11 | GAMSPy is the ultimate choice: 12 | 13 | * Easy to understand, easy to write 14 | 15 | * ``eq1[...] = y == tanh(a @ W + b)`` 16 | 17 | * Versatility in Solver Selection 18 | 19 | * ``regression.solve(solver="your_favourite_solver")`` 20 | 21 | * It provides a robust algebraic language that allows you to experiment with how a neural network is implemented. 22 | 23 | * Built-in flexibility: 24 | 25 | * You are not limited to inference; you can also train your neural network. 26 | 27 | * You can build the architecture from scratch using GAMSPy 28 | 29 | * Development speed of Python combined with model generation speed of the GAMS execution engine 30 | 31 | * Equations and variables are generated in GAMS, not in Python, giving GAMSPy a speed advantage. 32 | 33 | 34 | We are continually developing our ML-related features. If you have specific 35 | needs or require additional information, please use our `Discourse platform `_. 36 | 37 | .. toctree:: 38 | :maxdepth: 1 39 | 40 | ./introduction 41 | ./formulations 42 | ./embed_nn 43 | -------------------------------------------------------------------------------- /docs/user/notebooks/latex_pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/notebooks/latex_pdf.png -------------------------------------------------------------------------------- /docs/user/notebooks/network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/notebooks/network.png -------------------------------------------------------------------------------- /docs/user/notebooks/nurses_data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/docs/user/notebooks/nurses_data.xlsx -------------------------------------------------------------------------------- /scripts/performance/IJKLM/IJKLM.gms: -------------------------------------------------------------------------------- 1 | $eval start jnow 2 | option limrow=0, limcol=0, solprint=off, reslim=0; 3 | 4 | set i,j,k,l,m, IJK(i,j,k), JKL(j,k,l), KLM(k,l,m); 5 | Variable z, x(i,j,k,l,m); 6 | Equations obj, ei; 7 | 8 | obj.. z =e= 1; 9 | ei(i).. sum((IJK(i,j,k),JKL(j,k,l),KLM(k,l,m)), x(i,j,k,l,m)) =g= 0; 10 | 11 | model mi /obj, ei/; 12 | 13 | $if not set GDXdata $set GDXdata 'scripts/performance/IJKLM/data/data.gdx' 14 | $gdxLoad '%GDXdata%' i,j,k,l,m 15 | 16 | $if not set R $set R 1 17 | $if not set N $set N 1 18 | 19 | Set r /1*%R%/, n /1*%N%/; Parameter t(r); Scalar fix, startn; 20 | 21 | fix = jnow - %start%; 22 | loop (r, 23 | startn = jnow; 24 | loop (n, 25 | execute_load '%GDXdata%', IJK,JKL,KLM; 26 | $$if not set solve mi.JustScrDir = 1 27 | solve mi minimizing z using lp; 28 | ); 29 | t(r) = ((fix + jnow - startn) * 24 * 3600) / card(n); 30 | ); 31 | 32 | execute_unload 'scripts/performance/IJKLM/results/result.gdx', t; 33 | -------------------------------------------------------------------------------- /scripts/performance/IJKLM/data_generation.py: -------------------------------------------------------------------------------- 1 | from collections import defaultdict 2 | 3 | import numpy as np 4 | import pandas as pd 5 | 6 | 7 | ########## Data ########## 8 | def create_fixed_data(m): 9 | J = [f"j{x}" for x in range(1, m + 1)] 10 | K = [f"k{x}" for x in range(1, m + 1)] 11 | L = [f"l{x}" for x in range(1, m + 1)] 12 | M = [f"m{x}" for x in range(1, m + 1)] 13 | 14 | jkl = pd.DataFrame( 15 | np.random.binomial(1, 0.05, size=(len(J) * len(K) * len(L))), 16 | index=pd.MultiIndex.from_product([J, K, L], names=["j", "k", "l"]), 17 | columns=["value"], 18 | ).reset_index() 19 | klm = pd.DataFrame( 20 | np.random.binomial(1, 0.05, size=(len(K) * len(L) * len(M))), 21 | index=pd.MultiIndex.from_product([K, L, M], names=["k", "l", "m"]), 22 | columns=["value"], 23 | ).reset_index() 24 | 25 | return J, K, L, M, jkl, klm 26 | 27 | 28 | def create_variable_data(n, j, k): 29 | i = [f"i{x}" for x in range(1, n + 1)] 30 | 31 | ijk = pd.DataFrame( 32 | np.random.binomial(1, 0.05, size=(len(i) * len(j) * len(k))), 33 | index=pd.MultiIndex.from_product([i, j, k], names=["i", "j", "k"]), 34 | columns=["value"], 35 | ).reset_index() 36 | 37 | return i, ijk 38 | 39 | 40 | def fixed_data_to_tuples(JKL, KLM): 41 | jkl = [ 42 | tuple(x) 43 | for x in JKL.loc[JKL["value"] == 1][["j", "k", "l"]].to_dict("split")[ 44 | "data" 45 | ] 46 | ] 47 | klm = [ 48 | tuple(x) 49 | for x in KLM.loc[KLM["value"] == 1][["k", "l", "m"]].to_dict("split")[ 50 | "data" 51 | ] 52 | ] 53 | return jkl, klm 54 | 55 | 56 | def variable_data_to_tuples(IJK): 57 | ijk = [ 58 | tuple(x) 59 | for x in IJK.loc[IJK["value"] == 1][["i", "j", "k"]].to_dict("split")[ 60 | "data" 61 | ] 62 | ] 63 | return ijk 64 | 65 | 66 | def fixed_data_to_dicts(JKL, KLM): 67 | JKL_dict = defaultdict(list) 68 | KLM_dict = defaultdict(list) 69 | for j, k, l in JKL: 70 | JKL_dict[j, k].append(l) 71 | for k, l, m in KLM: 72 | KLM_dict[k, l].append(m) 73 | return JKL_dict, KLM_dict 74 | -------------------------------------------------------------------------------- /scripts/performance/IJKLM/help.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | 4 | import pandas as pd 5 | 6 | 7 | def incremental_range(start, stop, step, inc): 8 | value = start 9 | while value < stop: 10 | yield value 11 | value += step 12 | step += inc 13 | 14 | 15 | def create_data_frame(): 16 | return pd.DataFrame( 17 | { 18 | "I": [], 19 | "Language": [], 20 | "MeanTime": [], 21 | "MedianTime": [], 22 | "MinTime": [], 23 | } 24 | ) 25 | 26 | 27 | def create_directories(model): 28 | for d in ["data", "results"]: 29 | if not os.path.exists(os.path.join(model, d)): 30 | os.makedirs(os.path.join(model, d)) 31 | 32 | 33 | def save_to_json(symbol, name, i, model): 34 | file = os.path.join(model, "data", f"data_{name}{i}.json") 35 | with open(file, "w") as f: 36 | json.dump(list(symbol), f) 37 | 38 | 39 | def save_to_json_d(d, name, i, model): 40 | file = os.path.join(model, "data", f"data_{name}{i}.json") 41 | df = pd.DataFrame( 42 | [(i, m, d[i, m]) for i, m in d], columns=["i", "m", "value"] 43 | ) 44 | df.to_json(file, orient="values") 45 | 46 | 47 | def below_time_limit(df, limit): 48 | return (df["MinTime"].max() < limit) or (df.empty) 49 | 50 | 51 | def process_results(r, res_df): 52 | return pd.concat([res_df, r]) 53 | 54 | 55 | def print_log_message(language, n, df): 56 | # define a standardized log 57 | log = "{language:<19} done {n:>6} in {time:>}s" 58 | print( 59 | log.format( 60 | language=language, 61 | n=n, 62 | time=round(df["MinTime"].mean(), 2), 63 | ) 64 | ) 65 | 66 | 67 | def save_results(df, model): 68 | file = os.path.join(model, "results", "experiment_results_solve.csv") 69 | df.pivot(index="I", columns="Language", values="MinTime").to_csv(file) 70 | -------------------------------------------------------------------------------- /scripts/performance/IJKLM/run_gams.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | 4 | import gams.transfer as gt 5 | import gamspy_base 6 | import numpy as np 7 | import pandas as pd 8 | 9 | import gamspy as gp 10 | 11 | 12 | ########## GAMS ########## 13 | def data_to_gdx(I, J, K, L, M, ijk, jkl, klm): 14 | c = gt.Container(system_directory=gamspy_base.directory) 15 | 16 | # create sets 17 | i = c.addSet("i", records=I) 18 | j = c.addSet("j", records=J) 19 | k = c.addSet("k", records=K) 20 | l = c.addSet("l", records=L) 21 | m = c.addSet("m", records=M) 22 | 23 | c.addSet("IJK", [i, j, k], records=ijk[ijk["value"] == 1]) 24 | c.addSet("JKL", [j, k, l], records=jkl[jkl["value"] == 1]) 25 | c.addSet("KLM", [k, l, m], records=klm[klm["value"] == 1]) 26 | 27 | # create parameter 28 | c.addParameter("time") 29 | 30 | # create variables 31 | c.addVariable("z") 32 | c.addVariable("x", domain=[i, j, k, l, m]) 33 | 34 | c.write(os.path.join(os.path.dirname(__file__), "data", "data.gdx")) 35 | 36 | 37 | def run_gams(N, repeats, number): 38 | process = subprocess.run( 39 | [ 40 | os.path.join(gamspy_base.directory, "gams"), 41 | os.path.join(os.path.dirname(__file__), "IJKLM.gms"), 42 | f"--R={repeats}", 43 | f"--N={number}", 44 | ], 45 | stdout=subprocess.DEVNULL, 46 | stderr=subprocess.DEVNULL, 47 | ) 48 | assert process.returncode == 0 49 | 50 | c = gp.Container() 51 | c.read(os.path.join(os.path.dirname(__file__), "results", "result.gdx")) 52 | r = c["t"].records["value"] 53 | c.close() 54 | 55 | result = pd.DataFrame( 56 | { 57 | "I": [N], 58 | "Language": ["GAMS"], 59 | "MinTime": [np.min(r)], 60 | "MeanTime": [np.mean(r)], 61 | "MedianTime": [np.median(r)], 62 | } 63 | ) 64 | 65 | return result 66 | -------------------------------------------------------------------------------- /scripts/performance/memory_check.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import os 4 | import sys 5 | 6 | import psutil 7 | 8 | from gamspy import ( 9 | Container, 10 | Equation, 11 | Model, 12 | Number, 13 | Parameter, 14 | Set, 15 | Sum, 16 | Variable, 17 | ) 18 | from gamspy.math import uniform 19 | 20 | process = psutil.Process(os.getpid()) 21 | 22 | m = Container() 23 | 24 | density = 0.002 25 | i = Set(m, records=range(1000)) 26 | j = Set(m, records=range(1000)) 27 | arc = Set(m, domain=[i, j]) 28 | p = Parameter(m, domain=[i, j]) 29 | v = Variable(m, domain=[i, j]) 30 | e = Equation(m, domain=[i, j]) 31 | e[i, j] = v[i, j] <= p[i, j] 32 | model = Model( 33 | m, 34 | equations=[e], 35 | objective=Sum((i, j), v[i, j] * p[i, j]), 36 | problem="lp", 37 | sense="max", 38 | ) 39 | 40 | # Warmup iterations 41 | for _ in range(10): 42 | arc[...] = Number(1).where[(uniform(0, 1) < density)] 43 | p[arc] = uniform(0, 1) 44 | model.solve() 45 | p[...] = 0 46 | 47 | memory_usages: list[float] = [] 48 | for _ in range(100): 49 | mem_tracking_overhead = sys.getsizeof(memory_usages) / float(2**20) 50 | 51 | arc[...] = Number(1).where[(uniform(0, 1) < density)] 52 | p[arc] = uniform(0, 1) 53 | model.solve() 54 | p[...] = 0 55 | 56 | # Append usages 57 | memory_usage = process.memory_info().rss / float(2**20) 58 | memory_usages.append(memory_usage - mem_tracking_overhead) 59 | 60 | print(memory_usage) 61 | 62 | print(memory_usages[-1] / memory_usages[0]) 63 | -------------------------------------------------------------------------------- /scripts/performance/read.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import os 3 | import timeit 4 | 5 | import gams.transfer as gt 6 | import gamspy_base 7 | 8 | import gamspy as gp 9 | 10 | 11 | def get_args() -> argparse.Namespace: 12 | parser = argparse.ArgumentParser() 13 | parser.add_argument("-N", "--num-iters", default=500) 14 | return parser.parse_args() 15 | 16 | 17 | def write_gdx(N: int, m: gt.Container): 18 | for idx in range(N): 19 | m.addSet(f"set{idx}", records=[f"i{i}" for i in range(N)]) 20 | 21 | for idx in range(N): 22 | param = m.addParameter(f"parameter{idx}", domain=m[f"set{idx}"]) 23 | param.generateRecords() 24 | 25 | for idx in range(N): 26 | var = m.addVariable(f"variable{idx}", domain=m[f"set{idx}"]) 27 | var.generateRecords() 28 | 29 | m.write("in.gdx") 30 | 31 | 32 | def run_gtp(): # read from a gdx file 33 | _ = gt.Container( 34 | system_directory=gamspy_base.directory, load_from="in.gdx" 35 | ) 36 | 37 | 38 | def run_gp(): # read from a gdx file 39 | _ = gp.Container(load_from="in.gdx") 40 | 41 | 42 | def run_gtp2(m: gt.Container): # read from a Container 43 | _ = gt.Container(system_directory=gamspy_base.directory, load_from=m) 44 | 45 | 46 | def run_gp2(m: gt.Container): # read from a Container 47 | _ = gp.Container(load_from=m) 48 | 49 | 50 | def main(): 51 | args = get_args() 52 | N = args.num_iters 53 | R = 10 54 | NUM = 1 55 | 56 | m = gt.Container(system_directory=gamspy_base.directory) 57 | write_gdx(N, m) 58 | 59 | setup = {"func": run_gtp} 60 | r = timeit.repeat("func()", repeat=R, number=NUM, globals=setup) 61 | gt_time = sum(r) / len(r) 62 | 63 | setup = {"func": run_gp} 64 | r = timeit.repeat("func()", repeat=R, number=NUM, globals=setup) 65 | gp_time = sum(r) / len(r) 66 | 67 | print(f"{gt_time=}, {gp_time=}, ratio: {gp_time / gt_time: .2f}") 68 | 69 | setup = {"m": m, "func": run_gtp2} 70 | r = timeit.repeat("func(m)", repeat=R, number=NUM, globals=setup) 71 | gt_time = sum(r) / len(r) 72 | 73 | setup = {"m": m, "func": run_gp2} 74 | r = timeit.repeat("func(m)", repeat=R, number=NUM, globals=setup) 75 | gp_time = sum(r) / len(r) 76 | 77 | print(f"{gt_time=}, {gp_time=}, ratio: {gp_time / gt_time: .2f}") 78 | 79 | os.remove("in.gdx") 80 | 81 | 82 | if __name__ == "__main__": 83 | main() 84 | -------------------------------------------------------------------------------- /src/gamspy/__init__.py: -------------------------------------------------------------------------------- 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._config import _set_default_options, get_option, set_options 24 | from gamspy._container import Container 25 | from gamspy._model import ( 26 | FileFormat, 27 | Model, 28 | ModelStatus, 29 | Problem, 30 | Sense, 31 | SolveStatus, 32 | ) 33 | from gamspy._options import ( 34 | ConvertOptions, 35 | FreezeOptions, 36 | ModelInstanceOptions, 37 | Options, 38 | ) 39 | from gamspy._serialization import deserialize, serialize 40 | from gamspy._symbols import ( 41 | Alias, 42 | Equation, 43 | EquationType, 44 | Parameter, 45 | Set, 46 | UniverseAlias, 47 | Variable, 48 | VariableType, 49 | ) 50 | 51 | from .version import __version__ 52 | 53 | _ctx_managers: dict[tuple[int, int], Container] = dict() 54 | _set_default_options() 55 | 56 | __all__ = [ 57 | "Container", 58 | "Set", 59 | "Alias", 60 | "UniverseAlias", 61 | "Parameter", 62 | "Variable", 63 | "Equation", 64 | "Model", 65 | "Problem", 66 | "Sense", 67 | "VariableType", 68 | "EquationType", 69 | "ModelStatus", 70 | "SolveStatus", 71 | "Sum", 72 | "Product", 73 | "Smax", 74 | "Smin", 75 | "Sand", 76 | "Sor", 77 | "Domain", 78 | "Number", 79 | "Ord", 80 | "Card", 81 | "Options", 82 | "FreezeOptions", 83 | "ModelInstanceOptions", 84 | "ConvertOptions", 85 | "FileFormat", 86 | "Expression", 87 | "EngineClient", 88 | "NeosClient", 89 | "math", 90 | "formulations", 91 | "utils", 92 | "SpecialValues", 93 | "__version__", 94 | "get_option", 95 | "set_options", 96 | "serialize", 97 | "deserialize", 98 | ] 99 | -------------------------------------------------------------------------------- /src/gamspy/__main__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from gamspy._cli.cli import main 4 | 5 | if __name__ == "__main__": 6 | main() 7 | -------------------------------------------------------------------------------- /src/gamspy/_algebra/__init__.py: -------------------------------------------------------------------------------- 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 14 | -------------------------------------------------------------------------------- /src/gamspy/_algebra/number.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import gamspy._algebra.condition as condition 4 | import gamspy._algebra.operable as operable 5 | from gamspy._algebra import expression 6 | 7 | 8 | class Number(operable.Operable): 9 | """ 10 | Needed for conditions on numbers. 11 | 12 | Parameters 13 | ---------- 14 | value : int | float 15 | 16 | Examples 17 | -------- 18 | >>> import gamspy as gp 19 | >>> m = gp.Container() 20 | >>> k = gp.Set(m, "k", records=["1964-i","1964-ii","1964-iii","1964-iv"]) 21 | >>> ki = gp.Set(m, name="ki", domain=[k], description="initial period") 22 | >>> ki[k] = gp.Number(1).where[gp.Ord(k) == 1] 23 | 24 | """ 25 | 26 | def __init__(self, value: int | float): 27 | if not isinstance(value, (int, float)): 28 | raise TypeError( 29 | f"Number should be of type int or float but given value has type `{type(value)}`" 30 | ) 31 | 32 | self._value = value 33 | self.where = condition.Condition(self) 34 | self.domain: list = [] 35 | 36 | def __eq__(self, other): 37 | return expression.Expression(self, "=e=", other) 38 | 39 | def __ne__(self, other): 40 | return expression.Expression(self, "ne", other) 41 | 42 | def __repr__(self) -> str: 43 | return f"Number(value={self._value})" 44 | 45 | def gamsRepr(self) -> str: 46 | """ 47 | Representation of this Number in GAMS language. 48 | 49 | Returns 50 | ------- 51 | str 52 | 53 | Examples 54 | -------- 55 | >>> import gamspy as gp 56 | >>> gp.Number(2.0).gamsRepr() 57 | '2.0' 58 | 59 | """ 60 | return f"{self._value}" 61 | 62 | def latexRepr(self) -> str: 63 | """ 64 | Representation of this Number in Latex. 65 | 66 | Returns 67 | ------- 68 | str 69 | """ 70 | return f"{self._value}" 71 | -------------------------------------------------------------------------------- /src/gamspy/_backend/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/src/gamspy/_backend/__init__.py -------------------------------------------------------------------------------- /src/gamspy/_cli/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | -------------------------------------------------------------------------------- /src/gamspy/_cli/cli.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import os 4 | import subprocess 5 | from typing import Optional 6 | 7 | import typer 8 | 9 | from gamspy.exceptions import ValidationError 10 | import gamspy.utils as utils 11 | 12 | from . import install, list, retrieve, run, show, uninstall, probe 13 | 14 | app = typer.Typer( 15 | rich_markup_mode="rich", 16 | context_settings={"help_option_names": ["-h", "--help"]}, 17 | ) 18 | app.add_typer(install.app, name="install") 19 | app.add_typer(list.app, name="list") 20 | app.add_typer(probe.app, name="probe") 21 | app.add_typer(retrieve.app, name="retrieve") 22 | app.add_typer(run.app, name="run") 23 | app.add_typer(show.app, name="show") 24 | app.add_typer(uninstall.app, name="uninstall") 25 | 26 | 27 | def version_callback(value: bool): 28 | if value: 29 | import gams 30 | 31 | import gamspy 32 | 33 | print(f"GAMSPy version: {gamspy.__version__}") 34 | print(f"GAMS version: {gams.__version__}") 35 | 36 | try: 37 | import gamspy_base 38 | 39 | print(f"gamspy_base version: {gamspy_base.__version__}") 40 | except ModuleNotFoundError: 41 | ... 42 | 43 | raise typer.Exit() 44 | 45 | 46 | @app.callback() 47 | def callback( 48 | version: Optional[bool] = typer.Option( 49 | None, 50 | "-v", 51 | "--version", 52 | help="Shows the version of gamspy, gamsapi, and gamspy_base.", 53 | callback=version_callback, 54 | ), 55 | ) -> None: 56 | """ 57 | GAMSPy CLI - The [bold]gamspy[/bold] command line app. 😎 58 | 59 | Install solvers and licenses, run MIRO apps, and more. 60 | 61 | Read more in the docs: [link=https://gamspy.readthedocs.io/en/latest/cli/index.html]https://gamspy.readthedocs.io/en/latest/cli/index.html[/link]. 62 | """ 63 | ... 64 | 65 | def main(): 66 | """ 67 | Entry point for gamspy command line application. 68 | """ 69 | app() 70 | -------------------------------------------------------------------------------- /src/gamspy/_cli/probe.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import os 4 | import subprocess 5 | from typing import Optional 6 | 7 | import typer 8 | 9 | from gamspy.exceptions import ValidationError 10 | import gamspy.utils as utils 11 | 12 | app = typer.Typer( 13 | rich_markup_mode="rich", 14 | short_help="To probe a node's information.", 15 | help="[bold][yellow]Examples[/yellow][/bold]: gamspy probe -j ", 16 | context_settings={"help_option_names": ["-h", "--help"]}, 17 | ) 18 | 19 | def _probe(json_out: Optional[str]) -> None: 20 | gamspy_base_dir = utils._get_gamspy_base_directory() 21 | process = subprocess.run( 22 | [os.path.join(gamspy_base_dir, "gamsprobe")], 23 | text=True, 24 | capture_output=True, 25 | ) 26 | 27 | if process.returncode: 28 | raise ValidationError(process.stderr) 29 | 30 | print(process.stdout) 31 | 32 | if json_out: 33 | with open(json_out, "w") as file: 34 | file.write(process.stdout) 35 | 36 | raise typer.Exit() 37 | 38 | @app.callback() 39 | def callback( 40 | json_out: Optional[str] = typer.Option( 41 | None, 42 | "--json-out", "-j", 43 | help="Output path for the JSON file.", 44 | callback=_probe 45 | ), 46 | ) -> None: 47 | ... 48 | 49 | if __name__ == "__main__": 50 | app() 51 | -------------------------------------------------------------------------------- /src/gamspy/_cli/retrieve.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import os 4 | import subprocess 5 | 6 | import typer 7 | 8 | import gamspy.utils as utils 9 | from gamspy.exceptions import ValidationError 10 | 11 | app = typer.Typer( 12 | rich_markup_mode="rich", 13 | short_help="To retrieve a license with another node's information.", 14 | help="[bold][yellow]Examples[/yellow][/bold]: gamspy retrieve license [--input .json] [--output .json]", 15 | context_settings={"help_option_names": ["-h", "--help"]}, 16 | ) 17 | 18 | 19 | @app.command( 20 | short_help="Retrives the license with the given node information.", 21 | help="[bold][yellow]Examples[/yellow][/bold]: gamspy retrieve license [--input .json] [--output .json]" 22 | ) 23 | def license( 24 | access_code: str = typer.Argument( 25 | ..., 26 | help="Access code of the license." 27 | ), 28 | input: str = typer.Option( 29 | None, 30 | "--input", 31 | "-i", 32 | help="Input json file path to retrieve the license based on the node information." 33 | ), 34 | output: str = typer.Option( 35 | None, 36 | "--output", 37 | "-o", 38 | help="Output path for the license file." 39 | ), 40 | ) -> None: 41 | if input is None or not os.path.isfile(input): 42 | raise ValidationError( 43 | f"Given path `{input}` is not a json file. Please use `gamspy retrieve license -i `" 44 | ) 45 | 46 | if access_code is None: 47 | raise ValidationError( 48 | f"Given licence id `{access_code}` is not valid!" 49 | ) 50 | 51 | gamspy_base_dir = utils._get_gamspy_base_directory() 52 | process = subprocess.run( 53 | [ 54 | os.path.join(gamspy_base_dir, "gamsgetkey"), 55 | access_code, 56 | "-i", 57 | input, 58 | ], 59 | text=True, 60 | capture_output=True, 61 | ) 62 | 63 | if process.returncode: 64 | raise ValidationError(process.stderr) 65 | 66 | print(process.stdout) 67 | if output: 68 | with open(output, "w") as file: 69 | file.write(process.stdout) 70 | 71 | 72 | if __name__ == "__main__": 73 | app() 74 | -------------------------------------------------------------------------------- /src/gamspy/_cli/show.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import typer 4 | 5 | import gamspy.utils as utils 6 | from gamspy.exceptions import ValidationError 7 | 8 | app = typer.Typer( 9 | rich_markup_mode="rich", 10 | short_help="To show your license and gamspy_base directory.", 11 | help="[bold][yellow]Examples[/yellow][/bold]: gamspy show license | gamspy show base", 12 | context_settings={"help_option_names": ["-h", "--help"]}, 13 | ) 14 | 15 | 16 | @app.command(short_help="Shows the license content.") 17 | def license(): 18 | try: 19 | import gamspy_base 20 | except ModuleNotFoundError as e: 21 | raise ValidationError( 22 | "You must install gamspy_base to use this command!" 23 | ) from e 24 | 25 | license_path = utils._get_license_path(gamspy_base.directory) 26 | print(f"License found at: {license_path}\n") 27 | print("License Content") 28 | print("=" * 15) 29 | with open(license_path, encoding="utf-8") as license_file: 30 | print(license_file.read().strip()) 31 | 32 | 33 | @app.command(short_help="Shows the path of gamspy_base.") 34 | def base(): 35 | try: 36 | import gamspy_base 37 | except ModuleNotFoundError as e: 38 | raise ValidationError( 39 | "You must install gamspy_base to use this command!" 40 | ) from e 41 | 42 | print(gamspy_base.directory) 43 | 44 | 45 | if __name__ == "__main__": 46 | app() 47 | -------------------------------------------------------------------------------- /src/gamspy/_symbols/__init__.py: -------------------------------------------------------------------------------- 1 | from gamspy._symbols.alias import Alias 2 | from gamspy._symbols.equation import Equation, EquationType 3 | from gamspy._symbols.parameter import Parameter 4 | from gamspy._symbols.set import Set 5 | from gamspy._symbols.universe_alias import UniverseAlias 6 | from gamspy._symbols.variable import Variable, VariableType 7 | 8 | __all__ = [ 9 | "Alias", 10 | "Equation", 11 | "EquationType", 12 | "Parameter", 13 | "Set", 14 | "UniverseAlias", 15 | "Variable", 16 | "VariableType", 17 | ] 18 | -------------------------------------------------------------------------------- /src/gamspy/_symbols/implicits/__init__.py: -------------------------------------------------------------------------------- 1 | from gamspy._symbols.implicits.implicit_equation import ImplicitEquation 2 | from gamspy._symbols.implicits.implicit_parameter import ImplicitParameter 3 | from gamspy._symbols.implicits.implicit_set import ImplicitSet 4 | from gamspy._symbols.implicits.implicit_variable import ImplicitVariable 5 | 6 | __all__ = [ 7 | "ImplicitEquation", 8 | "ImplicitParameter", 9 | "ImplicitSet", 10 | "ImplicitVariable", 11 | ] 12 | -------------------------------------------------------------------------------- /src/gamspy/_types.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Union 4 | 5 | from typing_extensions import TypeAlias 6 | 7 | from gamspy._algebra.operable import Operable 8 | 9 | OperableType: TypeAlias = Union[Operable, int, float] 10 | EllipsisType: TypeAlias = type(...) # type: ignore 11 | -------------------------------------------------------------------------------- /src/gamspy/_workspace.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import os 4 | import shutil 5 | import tempfile 6 | import weakref 7 | 8 | from gamspy.exceptions import ValidationError 9 | 10 | DEBUGGING_LEVELS = ("delete", "keep_on_error", "keep") 11 | 12 | 13 | def validate_arguments( 14 | working_directory: str | None, 15 | debugging_level: str, 16 | ): 17 | # Validate working_directory 18 | if working_directory == "": 19 | raise ValidationError("`working_directory` cannot be an empty string.") 20 | 21 | # Validate debug_level 22 | if ( 23 | not isinstance(debugging_level, str) 24 | or debugging_level not in DEBUGGING_LEVELS 25 | ): 26 | raise ValidationError( 27 | f"debugging level must be one of {DEBUGGING_LEVELS}" 28 | ) 29 | 30 | 31 | class Workspace: 32 | def __init__( 33 | self, debugging_level: str, working_directory: str | None = None 34 | ): 35 | validate_arguments(working_directory, debugging_level) 36 | 37 | self.debugging_level = debugging_level 38 | self.using_tmp_working_dir = False 39 | self._errors: list[str] = [] 40 | 41 | if working_directory is None: 42 | self.using_tmp_working_dir = True 43 | self.working_directory = tempfile.mkdtemp() 44 | else: 45 | self.working_directory = os.path.abspath(working_directory) 46 | os.makedirs(self.working_directory, exist_ok=True) 47 | 48 | weakref.finalize( 49 | self, 50 | self.cleanup, 51 | self.using_tmp_working_dir, 52 | self.debugging_level, 53 | self.working_directory, 54 | self._errors, 55 | ) 56 | 57 | @staticmethod 58 | def cleanup( 59 | using_tmp_working_dir: bool, 60 | debugging_level: str, 61 | working_directory: str, 62 | errors: list[str], 63 | ): 64 | if using_tmp_working_dir: 65 | try: # in case working directory has already been deleted. 66 | if debugging_level == "delete": 67 | shutil.rmtree(working_directory) 68 | 69 | if debugging_level == "keep_on_error" and len(errors) == 0: 70 | shutil.rmtree(working_directory) 71 | except (FileNotFoundError, PermissionError): 72 | ... 73 | -------------------------------------------------------------------------------- /src/gamspy/formulations/__init__.py: -------------------------------------------------------------------------------- 1 | import gamspy.formulations.nn as nn 2 | import gamspy.formulations.piecewise as piecewise 3 | from gamspy.formulations.nn import ( 4 | AvgPool2d, 5 | Conv1d, 6 | Conv2d, 7 | Linear, 8 | MaxPool2d, 9 | MinPool2d, 10 | ) 11 | from gamspy.formulations.piecewise import ( 12 | pwl_convexity_formulation, 13 | pwl_interval_formulation, 14 | ) 15 | from gamspy.formulations.shape import flatten_dims 16 | 17 | __all__ = [ 18 | "nn", 19 | "piecewise", 20 | "Conv1d", 21 | "Conv2d", 22 | "MaxPool2d", 23 | "MinPool2d", 24 | "AvgPool2d", 25 | "Linear", 26 | "flatten_dims", 27 | "pwl_convexity_formulation", 28 | "pwl_interval_formulation", 29 | ] 30 | -------------------------------------------------------------------------------- /src/gamspy/formulations/nn/__init__.py: -------------------------------------------------------------------------------- 1 | from gamspy.formulations.nn.avgpool2d import AvgPool2d 2 | from gamspy.formulations.nn.conv1d import Conv1d 3 | from gamspy.formulations.nn.conv2d import Conv2d 4 | from gamspy.formulations.nn.linear import Linear 5 | from gamspy.formulations.nn.maxpool2d import MaxPool2d 6 | from gamspy.formulations.nn.minpool2d import MinPool2d 7 | from gamspy.formulations.nn.mpool2d import _MPool2d 8 | 9 | __all__ = [ 10 | "Conv1d", 11 | "Conv2d", 12 | "_MPool2d", 13 | "MaxPool2d", 14 | "MinPool2d", 15 | "AvgPool2d", 16 | "Linear", 17 | ] 18 | -------------------------------------------------------------------------------- /src/gamspy/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/src/gamspy/py.typed -------------------------------------------------------------------------------- /src/gamspy/version.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from importlib import metadata 4 | 5 | __version__ = metadata.version("gamspy") 6 | -------------------------------------------------------------------------------- /tests/integration/external_module/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0 FATAL_ERROR) 2 | project(SimpleExternalModule) 3 | 4 | 5 | add_library(simple_ext_module SHARED mylib.cpp) 6 | 7 | target_compile_definitions(simple_ext_module PRIVATE CONST_DERIV=1) 8 | target_compile_definitions(simple_ext_module PRIVATE HV_PRODUCT=1) 9 | target_include_directories(simple_ext_module PRIVATE ".") 10 | 11 | set_property(TARGET simple_ext_module PROPERTY CXX_STANDARD 17) 12 | set_property(TARGET simple_ext_module PROPERTY POSITION_INDEPENDENT_CODE ON) 13 | -------------------------------------------------------------------------------- /tests/integration/external_module/build/libsimple_ext_module.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/external_module/build/libsimple_ext_module.dll -------------------------------------------------------------------------------- /tests/integration/external_module/build/libsimple_ext_module.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/external_module/build/libsimple_ext_module.dylib -------------------------------------------------------------------------------- /tests/integration/external_module/build/libsimple_ext_module.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/external_module/build/libsimple_ext_module.so -------------------------------------------------------------------------------- /tests/integration/external_module/build/libsimple_ext_module_arm64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/external_module/build/libsimple_ext_module_arm64.dylib -------------------------------------------------------------------------------- /tests/integration/external_module/example.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import math 4 | import sys 5 | 6 | import gamspy as gp 7 | 8 | m = gp.Container() 9 | y1 = gp.Variable(m, "y1") 10 | y2 = gp.Variable(m, "y2") 11 | x1 = gp.Variable(m, "x1") 12 | x2 = gp.Variable(m, "x2") 13 | 14 | eq1 = gp.Equation(m, "eq1", type="external") 15 | eq2 = gp.Equation(m, "eq2", type="external") 16 | 17 | eq1[...] = 1 * x1 + 3 * y1 == 1 18 | eq2[...] = 2 * x2 + 4 * y2 == 2 19 | 20 | model = gp.Model( 21 | container=m, 22 | name="sincos", 23 | equations=m.getEquations(), 24 | problem="NLP", 25 | sense="min", 26 | objective=y1 + y2, 27 | external_module="libsimple_ext_module", 28 | ) 29 | 30 | model.solve(output=sys.stdout, solver="conopt") 31 | 32 | assert math.isclose(y1.toDense(), -1) 33 | assert math.isclose(y2.toDense(), -1) 34 | -------------------------------------------------------------------------------- /tests/integration/gms_references/ECD.gms: -------------------------------------------------------------------------------- 1 | Set gen(*); 2 | Parameter load / 998.0 /; 3 | Parameter data(gen,*); 4 | free Variable P(gen); 5 | Equation eq2; 6 | free Variable ECD_objective_variable; 7 | Equation ECD_objective; 8 | Model ECD / eq2,ECD_objective /; 9 | $onMultiR 10 | $gdxLoadAll /home/muhammet/Documents/gams_workspace/gamspy/tmp/to_gams/ECD_data.gdx 11 | $offMulti 12 | eq2 .. sum(gen,P(gen)) =g= load; 13 | ECD_objective .. sum(gen,((((data(gen,"a") * P(gen)) * P(gen)) + (data(gen,"b") * P(gen))) + data(gen,"c"))) =e= ECD_objective_variable; 14 | solve ECD using QCP MIN ECD_objective_variable; 15 | -------------------------------------------------------------------------------- /tests/integration/gms_references/attr.gms: -------------------------------------------------------------------------------- 1 | Set s(*); 2 | positive Variable x(s) / /; 3 | Equation eq(s) / /; 4 | free Variable attr_objective_variable / /; 5 | Equation attr_objective / /; 6 | Model attr / eq,attr_objective /; 7 | $onMultiR 8 | $gdxLoadAll /home/muhammet/Documents/gams_workspace/gamspy/tmp/to_gams/attr_data.gdx 9 | $offMulti 10 | eq(s) $ ( not s.first) .. x(s) =g= 1; 11 | attr_objective .. sum(s,x(s)) =e= attr_objective_variable; 12 | solve attr using LP MIN attr_objective_variable; 13 | -------------------------------------------------------------------------------- /tests/integration/gms_references/master.gms: -------------------------------------------------------------------------------- 1 | Set i(*) "widths"; 2 | Set p(*) "possible patterns"; 3 | Set pp(p) "dynamic subset of p"; 4 | Parameter d(i) "demand"; 5 | Parameter aip(i,p) "number of width i in pattern growing in p"; 6 | integer Variable xp(p) "patterns used"; 7 | free Variable z "objective variable"; 8 | Equation numpat "number of patterns used"; 9 | Equation demand(i) "meet demand"; 10 | Model master / numpat,demand /; 11 | $onMultiR 12 | $gdxLoadAll /home/muhammet/Documents/gams_workspace/gamspy/tmp/to_gams/master_data.gdx 13 | $offMulti 14 | numpat .. z =e= sum(pp,xp(pp)); 15 | demand(i) .. sum(pp,(aip(i,pp) * xp(pp))) =g= d(i); 16 | solve master using RMIP MIN z; 17 | -------------------------------------------------------------------------------- /tests/integration/gms_references/math.gms: -------------------------------------------------------------------------------- 1 | Set S(*); 2 | Parameter p(S); 3 | positive Variable x(S) / /; 4 | Equation e(S) / /; 5 | free Variable math_objective_variable / /; 6 | Equation math_objective / /; 7 | Model math / e,math_objective /; 8 | $onMultiR 9 | $gdxLoadAll /home/muhammet/Documents/gams_workspace/gamspy/tmp/to_gams/math_data.gdx 10 | $offMulti 11 | e(S) .. power((p(S) * x(S)),2) =l= 4; 12 | math_objective .. sum(S,x(S)) =e= math_objective_variable; 13 | solve math using QCP MIN math_objective_variable; 14 | -------------------------------------------------------------------------------- /tests/integration/gms_references/qp6.gms: -------------------------------------------------------------------------------- 1 | Set days(*) "100 days from 95-11-27 to 96-04-29"; 2 | Set stocks(*) "170 selected stocks"; 3 | Set d(days) "selected days"; 4 | Set s(stocks) "selected stocks"; 5 | Parameter mean(stocks) "mean of daily return"; 6 | Parameter dev(stocks,days) "deviations"; 7 | Parameter totmean "total mean return" / -0.08019310344827588 /; 8 | positive Variable x(stocks) "investments"; 9 | free Variable w(days) "intermediate variables"; 10 | Equation budget; 11 | Equation retcon "returns constraint"; 12 | Equation wdef(days); 13 | Equation d_x(stocks); 14 | Equation d_w(days); 15 | free Variable m_budget; 16 | free Variable m_wdef(days); 17 | positive Variable m_retcon; 18 | Model qp6 / d_x.x,d_w.w,retcon.m_retcon,budget.m_budget,wdef.m_wdef /; 19 | $onMultiR 20 | $gdxLoadAll /home/muhammet/Documents/gams_workspace/gamspy/tmp/to_gams/qp6_data.gdx 21 | $offMulti 22 | d_x(s) .. sum(d,(m_wdef(d) * dev(s,d))) =g= ((m_retcon * mean(s)) + m_budget); 23 | d_w(d) .. ((2 * w(d)) / (card(d) - 1)) =e= m_wdef(d); 24 | retcon .. sum(s,(mean(s) * x(s))) =g= (totmean * 1.25); 25 | budget .. sum(s,x(s)) =e= 1.0; 26 | wdef(d) .. w(d) =e= sum(s,(x(s) * dev(s,d))); 27 | solve qp6 using MCP; 28 | -------------------------------------------------------------------------------- /tests/integration/gms_references/square.gms: -------------------------------------------------------------------------------- 1 | Set i(*) "corner points of square"; 2 | free Variable t(i) "position of square corner points on curve"; 3 | free Variable x "x-coordinate of lower-left corner of square (=fx(t('1')))"; 4 | free Variable y "y-coordinate of lower-left corner of square (=fy(t('1')))"; 5 | positive Variable a "horizontal distance between lower-left and lower-right corner of square"; 6 | positive Variable b "vertical distance between lower-left and lower-right corner of square"; 7 | Equation e1x "define x-coordinate of lower-left corner"; 8 | Equation e1y "define y-coordinate of lower-left corner"; 9 | Equation e2x "define x-coordinate of lower-right corner"; 10 | Equation e2y "define y-coordinate of lower-right corner"; 11 | Equation e3x "define x-coordinate of upper-left corner"; 12 | Equation e3y "define y-coordinate of upper-left corner"; 13 | Equation e4x "define x-coordinate of upper-right corner"; 14 | Equation e4y "define y-coordinate of upper-right corner"; 15 | free Variable square_objective_variable; 16 | Equation square_objective; 17 | Model square / e1x,e1y,e2x,e2y,e3x,e3y,e4x,e4y,square_objective /; 18 | $onMultiR 19 | $gdxLoadAll /home/muhammet/Documents/gams_workspace/gamspy/tmp/to_gams/square_data.gdx 20 | $offMulti 21 | e1x .. (sin(t("1")) * cos((t("1") - (t("1") * t("1"))))) =e= x; 22 | e1y .. (t("1") * sin(t("1"))) =e= y; 23 | e2x .. (sin(t("2")) * cos((t("2") - (t("2") * t("2"))))) =e= (x + a); 24 | e2y .. (t("2") * sin(t("2"))) =e= (y + b); 25 | e3x .. (sin(t("3")) * cos((t("3") - (t("3") * t("3"))))) =e= (x - b); 26 | e3y .. (t("3") * sin(t("3"))) =e= (y + a); 27 | e4x .. (sin(t("4")) * cos((t("4") - (t("4") * t("4"))))) =e= ((x + a) - b); 28 | e4y .. (t("4") * sin(t("4"))) =e= ((y + a) + b); 29 | square_objective .. (power(a,2) + power(b,2)) =e= square_objective_variable; 30 | solve square using DNLP MAX square_objective_variable; 31 | -------------------------------------------------------------------------------- /tests/integration/gms_references/transport.gms: -------------------------------------------------------------------------------- 1 | Set i(*) "canning plants"; 2 | Set j(*) "markets"; 3 | Parameter a(i) "capacity of plant i in cases"; 4 | Parameter b(j) "demand at market j in cases"; 5 | Parameter c(i,j) "transport cost in thousands of dollars per case"; 6 | positive Variable x(i,j) "shipment quantities in cases" / /; 7 | Equation supply(i) "observe supply limit at plant i" / /; 8 | Equation demand(j) "satisfy demand at market j" / /; 9 | free Variable transport_objective_variable / /; 10 | Equation transport_objective / /; 11 | Model transport / supply,demand,transport_objective /; 12 | $onMultiR 13 | $gdxLoadAll /home/muhammet/Documents/gams_workspace/gamspy/tmp/to_gams/transport_data.gdx 14 | $offMulti 15 | supply(i) .. sum(j,x(i,j)) =l= a(i); 16 | demand(j) .. sum(i,x(i,j)) =g= b(j); 17 | transport_objective .. sum((i,j),(c(i,j) * x(i,j))) =e= transport_objective_variable; 18 | transport.dictfile = 0; 19 | solve transport using LP MIN transport_objective_variable; 20 | -------------------------------------------------------------------------------- /tests/integration/gms_references/war.gms: -------------------------------------------------------------------------------- 1 | Set w(*) "weapons"; 2 | Set t(*) "targets"; 3 | Parameter td(w,t) "target data"; 4 | Parameter wa(w) "weapons availability"; 5 | Parameter tm(t) "minimum number of weapons per target"; 6 | Parameter mv(t) "military value of target"; 7 | positive Variable x(w,t) "weapons assignment"; 8 | Equation maxw(w) "weapons balance"; 9 | Equation minw(t) "minimum number of weapons required per target"; 10 | free Variable war_objective_variable; 11 | Equation war_objective; 12 | Model war / maxw,minw,war_objective /; 13 | $onMultiR 14 | $gdxLoadAll /home/muhammet/Documents/gams_workspace/gamspy/tmp/to_gams/war_data.gdx 15 | $offMulti 16 | maxw(w) .. sum(t $ td(w,t),x(w,t)) =l= wa(w); 17 | minw(t) $ tm(t) .. sum(w $ td(w,t),x(w,t)) =g= tm(t); 18 | war_objective .. sum(t,(mv(t) * (1 - prod(w $ td(w,t),rPower((1 - td(w,t)),x(w,t)))))) =e= war_objective_variable; 19 | solve war using NLP MAX war_objective_variable; 20 | -------------------------------------------------------------------------------- /tests/integration/miro_models/_miro3_gdxin_.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/miro_models/_miro3_gdxin_.gdx -------------------------------------------------------------------------------- /tests/integration/miro_models/_miro4_gdxin_.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/miro_models/_miro4_gdxin_.gdx -------------------------------------------------------------------------------- /tests/integration/miro_models/_miro5_gdxin_.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/miro_models/_miro5_gdxin_.gdx -------------------------------------------------------------------------------- /tests/integration/miro_models/_miro5_gdxout_.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/miro_models/_miro5_gdxout_.gdx -------------------------------------------------------------------------------- /tests/integration/miro_models/conf_miro/miro.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /tests/integration/miro_models/conf_miro2/miro2.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /tests/integration/miro_models/conf_miro3/miro3_io.json: -------------------------------------------------------------------------------- 1 | { 2 | "modelTitle": "GAMSPy App", 3 | "inputSymbols": { 4 | "initial_state": { 5 | "alias": "initial_state", 6 | "symtype": "parameter", 7 | "headers": { 8 | "row": { 9 | "type": "string", 10 | "alias": "row" 11 | }, 12 | "col1": { 13 | "type": "numeric", 14 | "alias": "col1" 15 | }, 16 | "col2": { 17 | "type": "numeric", 18 | "alias": "col2" 19 | }, 20 | "col3": { 21 | "type": "numeric", 22 | "alias": "col3" 23 | }, 24 | "col4": { 25 | "type": "numeric", 26 | "alias": "col4" 27 | }, 28 | "col5": { 29 | "type": "numeric", 30 | "alias": "col5" 31 | }, 32 | "col6": { 33 | "type": "numeric", 34 | "alias": "col6" 35 | }, 36 | "col7": { 37 | "type": "numeric", 38 | "alias": "col7" 39 | }, 40 | "col8": { 41 | "type": "numeric", 42 | "alias": "col8" 43 | }, 44 | "col9": { 45 | "type": "numeric", 46 | "alias": "col9" 47 | } 48 | } 49 | } 50 | }, 51 | "outputSymbols": {} 52 | } -------------------------------------------------------------------------------- /tests/integration/miro_models/conf_miro4/miro4_io.json: -------------------------------------------------------------------------------- 1 | { 2 | "modelTitle": "GAMSPy App", 3 | "inputSymbols": { 4 | "p": { 5 | "alias": "p", 6 | "symtype": "parameter", 7 | "headers": { 8 | "i": { 9 | "type": "string", 10 | "alias": "i" 11 | }, 12 | "value": { 13 | "type": "numeric", 14 | "alias": "value" 15 | } 16 | } 17 | } 18 | }, 19 | "outputSymbols": {} 20 | } -------------------------------------------------------------------------------- /tests/integration/miro_models/conf_miro5/miro5_io.json: -------------------------------------------------------------------------------- 1 | { 2 | "modelTitle": "GAMSPy App", 3 | "inputSymbols": { 4 | "_scalars": { 5 | "alias": "Input Scalars", 6 | "symnames": [ 7 | "f" 8 | ], 9 | "symtext": [ 10 | "freight in dollars per case per thousand miles" 11 | ], 12 | "symtypes": [ 13 | "parameter" 14 | ], 15 | "headers": { 16 | "scalar": { 17 | "type": "string", 18 | "alias": "Scalar Name" 19 | }, 20 | "description": { 21 | "type": "string", 22 | "alias": "Scalar Description" 23 | }, 24 | "value": { 25 | "type": "string", 26 | "alias": "Scalar Value" 27 | } 28 | } 29 | } 30 | }, 31 | "outputSymbols": { 32 | "_scalarsve_out": { 33 | "alias": "Output Variable/Equation Scalars", 34 | "symnames": [ 35 | "z" 36 | ], 37 | "symtext": [ 38 | "total transportation costs in thousands of dollars" 39 | ], 40 | "symtypes": [ 41 | "variable" 42 | ], 43 | "headers": { 44 | "scalar": { 45 | "type": "string", 46 | "alias": "Scalar Name" 47 | }, 48 | "description": { 49 | "type": "string", 50 | "alias": "Scalar Description" 51 | }, 52 | "level": { 53 | "type": "numeric", 54 | "alias": "Level" 55 | }, 56 | "marginal": { 57 | "type": "numeric", 58 | "alias": "Marginal" 59 | }, 60 | "lower": { 61 | "type": "numeric", 62 | "alias": "Lower" 63 | }, 64 | "upper": { 65 | "type": "numeric", 66 | "alias": "Upper" 67 | }, 68 | "scale": { 69 | "type": "numeric", 70 | "alias": "Scale" 71 | } 72 | } 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /tests/integration/miro_models/conf_miro7/miro7_io.json: -------------------------------------------------------------------------------- 1 | { 2 | "modelTitle": "GAMSPy App", 3 | "inputSymbols": { 4 | "letters": { 5 | "alias": "letters", 6 | "symtype": "set", 7 | "headers": { 8 | "uni": { 9 | "type": "string", 10 | "alias": "uni" 11 | }, 12 | "element_text": { 13 | "type": "string", 14 | "alias": "element_text" 15 | } 16 | } 17 | } 18 | }, 19 | "outputSymbols": {} 20 | } -------------------------------------------------------------------------------- /tests/integration/miro_models/conf_miro8/miro8_io.json: -------------------------------------------------------------------------------- 1 | { 2 | "modelTitle": "GAMSPy App", 3 | "inputSymbols": { 4 | "pick_letter": { 5 | "alias": "pick_letter", 6 | "symtype": "set", 7 | "headers": { 8 | "letters": { 9 | "type": "string", 10 | "alias": "letters" 11 | }, 12 | "element_text": { 13 | "type": "string", 14 | "alias": "element_text" 15 | } 16 | } 17 | } 18 | }, 19 | "outputSymbols": {} 20 | } -------------------------------------------------------------------------------- /tests/integration/miro_models/miro10.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | 3 | parser = argparse.ArgumentParser(description="Delete files safely.") 4 | 5 | # Get the kwarg option 6 | parser.add_argument("--my-kwarg") 7 | 8 | # Get the positional args 9 | parser.add_argument("files", nargs="*", help="Files to delete") 10 | 11 | args = parser.parse_args() 12 | 13 | assert args.my_kwarg == "bla" 14 | assert args.files == ["a", "b", "c", "d"] 15 | -------------------------------------------------------------------------------- /tests/integration/miro_models/miro3.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from gamspy import ( 4 | Container, 5 | Parameter, 6 | Set, 7 | ) 8 | 9 | 10 | def main(): 11 | m = Container() 12 | 13 | # Set 14 | col = Set(m, "col", records=[("col" + str(i), i) for i in range(1, 10)]) 15 | row = Set(m, "row", records=[("row" + str(i), i) for i in range(1, 10)]) 16 | initial_state_data = np.array( 17 | [ 18 | [0, 0, 0, 0, 8, 6, 0, 0, 0], 19 | [0, 7, 0, 9, 0, 2, 0, 0, 0], 20 | [6, 9, 0, 0, 0, 0, 2, 0, 8], 21 | [8, 0, 0, 0, 9, 0, 7, 0, 2], 22 | [4, 0, 0, 0, 0, 0, 0, 0, 3], 23 | [2, 0, 9, 0, 1, 0, 0, 0, 4], 24 | [5, 0, 3, 0, 0, 0, 0, 7, 6], 25 | [0, 0, 0, 5, 0, 8, 0, 2, 0], 26 | [0, 0, 0, 3, 7, 0, 0, 0, 0], 27 | ], 28 | ) 29 | 30 | initial_state = Parameter( 31 | m, 32 | "initial_state", 33 | domain=[row, col], 34 | is_miro_input=True, 35 | is_miro_table=True, 36 | records=initial_state_data, 37 | ) 38 | assert initial_state.records.columns.tolist() == ["row", "col", "value"] 39 | 40 | 41 | if __name__ == "__main__": 42 | main() 43 | -------------------------------------------------------------------------------- /tests/integration/miro_models/miro4.py: -------------------------------------------------------------------------------- 1 | from gamspy import ( 2 | Container, 3 | Parameter, 4 | Set, 5 | ) 6 | 7 | 8 | def main(): 9 | m = Container() 10 | i = Set(m, name="i") 11 | p = Parameter( 12 | m, 13 | name="p", 14 | domain=i, 15 | records=[("i2", 2)], 16 | domain_forwarding=True, 17 | is_miro_input=True, 18 | ) 19 | 20 | assert i.records.values.tolist() == [["i1", ""]] 21 | assert p.records.values.tolist() == [["i1", 1.0]] 22 | 23 | 24 | if __name__ == "__main__": 25 | main() 26 | -------------------------------------------------------------------------------- /tests/integration/miro_models/miro6.py: -------------------------------------------------------------------------------- 1 | from gamspy import ( 2 | Container, 3 | Parameter, 4 | ) 5 | 6 | 7 | def main(): 8 | m = Container() 9 | 10 | f = Parameter( 11 | m, 12 | name="f", 13 | description="supply of commodity at plant i (in cases)", 14 | records=5 if not m.in_miro else None, 15 | is_miro_input=True, 16 | ) 17 | 18 | if m.in_miro: 19 | assert f.toValue() == 120 20 | else: 21 | assert f.toValue() == 5 22 | 23 | 24 | if __name__ == "__main__": 25 | main() 26 | -------------------------------------------------------------------------------- /tests/integration/miro_models/miro7.py: -------------------------------------------------------------------------------- 1 | import gamspy as gp 2 | 3 | m = gp.Container() 4 | i = gp.Set(m, name="i", records=range(10)) 5 | j = gp.Alias(m, name="j", alias_with=i) 6 | 7 | letters = gp.Set( 8 | m, 9 | name="letters", 10 | records=[x for x in "abcdefghijklmnopqrstuvwxyz"], 11 | is_miro_input=True, 12 | ) 13 | -------------------------------------------------------------------------------- /tests/integration/miro_models/miro8.py: -------------------------------------------------------------------------------- 1 | import gamspy as gp 2 | 3 | m = gp.Container() 4 | i = gp.Set(m, name="i", records=range(10)) 5 | j = gp.Alias(m, name="j", alias_with=i) 6 | 7 | letters = gp.Set( 8 | m, 9 | name="letters", 10 | records=[x for x in "abcdefghijklmnopqrstuvwxyz"], 11 | ) 12 | 13 | pick_letter = gp.Set( 14 | m, name="pick_letter", domain=[letters], is_miro_input=True 15 | ) 16 | -------------------------------------------------------------------------------- /tests/integration/miro_models/miro9.py: -------------------------------------------------------------------------------- 1 | import gamspy as gp 2 | 3 | c = gp.Container() 4 | 5 | par = gp.Parameter( 6 | c, "test", domain=["*"], is_miro_input=True, is_miro_table=True 7 | ) 8 | -------------------------------------------------------------------------------- /tests/integration/models/BondIndex.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/BondIndex.gdx -------------------------------------------------------------------------------- /tests/integration/models/Corporate.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/Corporate.gdx -------------------------------------------------------------------------------- /tests/integration/models/InternationalMeanVar.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/InternationalMeanVar.gdx -------------------------------------------------------------------------------- /tests/integration/models/MeanVarMip.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/MeanVarMip.gdx -------------------------------------------------------------------------------- /tests/integration/models/Regret.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/Regret.gdx -------------------------------------------------------------------------------- /tests/integration/models/SelectiveHedging.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/SelectiveHedging.gdx -------------------------------------------------------------------------------- /tests/integration/models/Sharpe.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/Sharpe.gdx -------------------------------------------------------------------------------- /tests/integration/models/SimpleLP.py: -------------------------------------------------------------------------------- 1 | """ 2 | ## GAMSSOURCE: https://www.gams.com/latest/psoptlib_ml/libhtml/psoptlib_SimpleLP.html 3 | ## LICENSETYPE: Demo 4 | ## MODELTYPE: LP 5 | 6 | 7 | Simple linear programming model 8 | 9 | For more details please refer to Chapter 2 (Gcode2.1), of the following book: 10 | Soroudi, Alireza. Power System Optimization Modeling in GAMS. Springer, 2017. 11 | -------------------------------------------------------------------------------- 12 | Model type: LP 13 | -------------------------------------------------------------------------------- 14 | Contributed by 15 | Dr. Alireza Soroudi 16 | IEEE Senior Member 17 | email: alireza.soroudi@gmail.com 18 | We do request that publications derived from the use of the developed GAMS code 19 | explicitly acknowledge that fact by citing 20 | Soroudi, Alireza. Power System Optimization Modeling in GAMS. Springer, 2017. 21 | DOI: doi.org/10.1007/978-3-319-62350-4 22 | """ 23 | 24 | from __future__ import annotations 25 | 26 | from gamspy import Container, Equation, Model, Variable 27 | 28 | 29 | def main(): 30 | m = Container() 31 | 32 | # VARIABLES # 33 | x1 = Variable(m, name="x1") 34 | x2 = Variable(m, name="x2") 35 | x3 = Variable(m, name="x3") 36 | 37 | # EQUATIONS # 38 | eq1 = Equation(m, name="eq1", type="regular") 39 | eq2 = Equation(m, name="eq2", type="regular") 40 | eq3 = Equation(m, name="eq3", type="regular") 41 | 42 | eq1[...] = x1 + 2 * x2 >= 3 43 | eq2[...] = x3 + x2 >= 5 44 | eq3[...] = x1 + x3 == 4 45 | eq4 = x1 + 3 * x2 + 3 * x3 # Objective Function 46 | 47 | LP1 = Model( 48 | m, 49 | name="LP1", 50 | equations=m.getEquations(), 51 | problem="lp", 52 | sense="min", 53 | objective=eq4, 54 | ) 55 | LP1.solve() 56 | 57 | print("Objective Function Value: ", round(LP1.objective_value, 4), "\n") 58 | print("x1: ", round(x1.toValue(), 4)) 59 | print("x2: ", round(x2.toValue(), 4)) 60 | print("x3: ", round(x3.toValue(), 4)) 61 | 62 | 63 | if __name__ == "__main__": 64 | main() 65 | -------------------------------------------------------------------------------- /tests/integration/models/SimpleMIP.py: -------------------------------------------------------------------------------- 1 | """ 2 | ## GAMSSOURCE: https://www.gams.com/latest/psoptlib_ml/libhtml/psoptlib_SimpleMIP.html 3 | ## LICENSETYPE: Demo 4 | ## MODELTYPE: MIP 5 | 6 | 7 | Simple Mixed Integer Linear Programming model 8 | 9 | For more details please refer to Chapter 2 (Gcode2.3), of the following book: 10 | Soroudi, Alireza. Power System Optimization Modeling in GAMS. Springer, 2017. 11 | -------------------------------------------------------------------------------- 12 | Model type: MIP 13 | -------------------------------------------------------------------------------- 14 | Contributed by 15 | Dr. Alireza Soroudi 16 | IEEE Senior Member 17 | email: alireza.soroudi@gmail.com 18 | We do request that publications derived from the use of the developed GAMS code 19 | explicitly acknowledge that fact by citing 20 | Soroudi, Alireza. Power System Optimization Modeling in GAMS. Springer, 2017. 21 | DOI: doi.org/10.1007/978-3-319-62350-4 22 | """ 23 | 24 | from __future__ import annotations 25 | 26 | from gamspy import Container, Equation, Model, Variable 27 | 28 | 29 | def main(): 30 | m = Container() 31 | 32 | # VARIABLES # 33 | x = Variable(m, name="x", type="free") 34 | y = Variable(m, name="y", type="binary") 35 | 36 | # EQUATIONS # 37 | eq1 = Equation(m, name="eq1", type="regular") 38 | eq2 = Equation(m, name="eq2", type="regular") 39 | 40 | eq1[...] = -3 * x + 2 * y >= 1 41 | eq2[...] = -8 * x + 10 * y <= 10 42 | eq3 = x + y # Objective Function 43 | 44 | MIP1 = Model( 45 | m, 46 | name="MIP1", 47 | equations=m.getEquations(), 48 | problem="mip", 49 | sense="max", 50 | objective=eq3, 51 | ) 52 | 53 | x.up = 0.3 54 | MIP1.solve() 55 | 56 | print("Objective Function Value: ", round(MIP1.objective_value, 4)) 57 | print("y: ", round(y.toValue(), 4)) 58 | print("x: ", round(x.toValue(), 4)) 59 | 60 | 61 | if __name__ == "__main__": 62 | main() 63 | -------------------------------------------------------------------------------- /tests/integration/models/StochDedicationBL.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/StochDedicationBL.gdx -------------------------------------------------------------------------------- /tests/integration/models/WorldIndices.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/WorldIndices.gdx -------------------------------------------------------------------------------- /tests/integration/models/acopf.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/acopf.gdx -------------------------------------------------------------------------------- /tests/integration/models/chenery.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/chenery.gdx -------------------------------------------------------------------------------- /tests/integration/models/cta.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/cta.xlsx -------------------------------------------------------------------------------- /tests/integration/models/f1_l-d_kp_10_269: -------------------------------------------------------------------------------- 1 | 10 269 2 | 55 95 3 | 10 4 4 | 47 60 5 | 5 32 6 | 4 23 7 | 50 72 8 | 8 80 9 | 61 62 10 | 85 65 11 | 87 46 12 | -------------------------------------------------------------------------------- /tests/integration/models/flywheel.py: -------------------------------------------------------------------------------- 1 | """ 2 | ## LICENSETYPE: Demo 3 | ## MODELTYPE: NLP 4 | 5 | 6 | Design of a disc flywheel 7 | 8 | Schittkowski, K., More test examples for nonlinear programming codes. 9 | Lecture Notes in Economics and Mathematical Systems, Vol.282, Springer-Verlag, 10 | Berlin, 1987. (Problem 346, page 167) 11 | """ 12 | 13 | from __future__ import annotations 14 | 15 | from gamspy import Container, Equation, Model, Variable 16 | 17 | 18 | def main(): 19 | m = Container() 20 | 21 | # VARIABLES # 22 | x1 = Variable(m, name="x1") 23 | x2 = Variable(m, name="x2") 24 | x3 = Variable(m, name="x3") 25 | 26 | # EQUATIONS # 27 | e1 = Equation(m, name="e1", type="regular") 28 | e2 = Equation(m, name="e2", type="regular") 29 | 30 | # Objective function: 31 | obj = -0.0201 * (x1**4) * x2 * (x3**2) / 10000000 32 | 33 | # Constraints: 34 | e1[...] = 675 - (x1**2) * x2 >= 0 35 | e2[...] = 0.419 - (x1**2) * (x3**2) / 10000000 >= 0 36 | 37 | # Bounds on variables: 38 | x1.lo = 0 39 | x1.up = 36 40 | x2.lo = 0 41 | x2.up = 5 42 | x3.lo = 0 43 | x3.up = 125 44 | 45 | # Initial point: 46 | x1.l = 22.3 47 | x2.l = 0.5 48 | x3.l = 125 49 | 50 | flywheel = Model( 51 | m, 52 | name="flywheel", 53 | equations=m.getEquations(), 54 | problem="nlp", 55 | sense="MIN", 56 | objective=obj, 57 | ) 58 | 59 | flywheel.solve() 60 | 61 | print("Objective Function Value: ", round(flywheel.objective_value, 4)) 62 | print("x1: ", round(x1.toValue(), 3)) 63 | print("x2: ", round(x2.toValue(), 3)) 64 | print("x3: ", round(x3.toValue(), 3)) 65 | 66 | # End flywheel 67 | 68 | 69 | if __name__ == "__main__": 70 | main() 71 | -------------------------------------------------------------------------------- /tests/integration/models/hansmcp.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/hansmcp.gdx -------------------------------------------------------------------------------- /tests/integration/models/hansmge.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/hansmge.gdx -------------------------------------------------------------------------------- /tests/integration/models/hansmge.py: -------------------------------------------------------------------------------- 1 | """ 2 | ## GAMSSOURCE: https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_hansmge.html 3 | ## LICENSETYPE: Demo 4 | ## MODELTYPE: MCP 5 | ## DATAFILES: hansmge.gdx 6 | ## KEYWORDS: mixed complementarity problem, general equilibrium model, activity analysis, social accounting matrix, European regional policy 7 | 8 | 9 | Hansen's Activity Analysis Example - MPSGE. 10 | 11 | Scarf, H, and Hansen, T, The Computation of Economic Equilibria. 12 | Yale University Press, 1973. 13 | """ 14 | 15 | from __future__ import annotations 16 | 17 | from math import isclose 18 | from pathlib import Path 19 | 20 | from gamspy import Container, Model, Sum 21 | 22 | 23 | def main(): 24 | m = Container( 25 | load_from=str(Path(__file__).parent.absolute()) + "/hansmge.gdx", 26 | ) 27 | c, n, h, s, e, d, esub, data = ( 28 | m[sym] for sym in ["c", "n", "h", "s", "e", "d", "esub", "data"] 29 | ) 30 | m.addGamsCode(""" 31 | $onText 32 | $MODEL:HANSEN 33 | 34 | $SECTORS: 35 | Y(S) 36 | 37 | $COMMODITIES: 38 | P(C) 39 | 40 | $CONSUMERS: 41 | HH(H) 42 | 43 | $PROD:Y(S) 44 | O:P(C) Q:DATA("OUTPUT",C,S) 45 | I:P(C) Q:DATA("INPUT" ,C,S) 46 | 47 | $DEMAND:HH(H) s:ESUB(H) 48 | D:P(C) Q:D(C,H) 49 | E:P(C) Q:E(C,H) 50 | $offText 51 | 52 | $sysInclude mpsgeset HANSEN 53 | """) 54 | dummy01, y, p, hh = (m[sym] for sym in ["dummy01", "y", "p", "hh"]) 55 | dummy01[:] = Sum(s, y[s]) + Sum(c, p[c]) + Sum(h, hh[h]) == 0 56 | hansen = Model(m, name="hansen", equations=m.getEquations(), problem="mcp") 57 | p.fx[c].where[c.ord == 1] = 1 58 | m.addGamsCode("$include HANSEN.GEN") 59 | hansen.solve() 60 | 61 | demands = m["HH"].toList() 62 | assert isclose(demands[0][1], 5.1549, rel_tol=1e-4) 63 | assert isclose(demands[1][1], 2.8275, rel_tol=1e-4) 64 | assert isclose(demands[2][1], 0.5876, rel_tol=1e-4) 65 | assert isclose(demands[3][1], 8.5600, rel_tol=1e-4) 66 | 67 | 68 | if __name__ == "__main__": 69 | main() 70 | -------------------------------------------------------------------------------- /tests/integration/models/lop.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/lop.gdx -------------------------------------------------------------------------------- /tests/integration/models/nurses_data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/nurses_data.xlsx -------------------------------------------------------------------------------- /tests/integration/models/qdemo7.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/qdemo7.gdx -------------------------------------------------------------------------------- /tests/integration/models/qp6.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/qp6.gdx -------------------------------------------------------------------------------- /tests/integration/models/reshop.py: -------------------------------------------------------------------------------- 1 | """ 2 | ## LICENSETYPE: Demo 3 | ## MODELTYPE: EMP 4 | ## KEYWORDS: Extended Mathematical Programming, EMP, RESHOP 5 | 6 | """ 7 | 8 | import gamspy.math as gpm 9 | from gamspy import Container, Equation, Model, Set, Variable 10 | 11 | 12 | def ReSHOPAnnotation(m, s): 13 | return m.addGamsCode("EmbeddedCode ReSHOP:\n" + s + "\nendEmbeddedCode") 14 | 15 | 16 | def main(): 17 | m = Container(debugging_level="keep") 18 | t = Set(m, name="m", records=[0, 1]) 19 | a = Set(m, name="a", records=["a0", "a1"]) 20 | beta = 7 21 | alpha = 6 22 | 23 | x = Variable(m, name="x", domain=[a, t]) 24 | obj = Variable(m, name="obj", domain=[a]) 25 | 26 | oterms = a.toList() 27 | cterms = a.toList() 28 | 29 | # Agent 0 30 | oterms[0] = (beta / 2 * gpm.sqr(x["a0", "0"]) - alpha * x["a0", "0"]) + ( 31 | 1 / 2 * gpm.sqr(x["a0", "1"]) 32 | + 3 * x["a0", "1"] * x["a1", "1"] 33 | - 4 * x["a0", "1"] 34 | ) 35 | cterms[0] = x["a0", "1"] - x["a0", "0"] 36 | 37 | # Agent 1 38 | oterms[1] = x["a1", "0"] + ( 39 | 1 / 2 * gpm.sqr(x["a1", "1"]) 40 | + x["a0", "1"] * x["a1", "1"] 41 | - 3 * x["a1", "1"] 42 | ) 43 | cterms[1] = x["a1", "1"] 44 | 45 | defobj = Equation(m, name="defobj", domain=a) 46 | defobj[a] = obj[a] == sum( 47 | o.where[a.sameAs(f"a{i}")] for i, o in enumerate(oterms) 48 | ) 49 | 50 | cons = Equation(m, name="cons", domain=a) 51 | cons[a] = ( 52 | sum(c.where[a.sameAs(f"a{i}")] for i, c in enumerate(cterms)) >= 0 53 | ) 54 | 55 | x.lo["a0", "0"] = 0 56 | x.fx["a1", "0"] = 0 57 | 58 | nash = Model(m, name="nash", equations=[defobj, cons], problem="emp") 59 | 60 | ReSHOPAnnotation( 61 | m, 62 | """ 63 | n(a): min obj(a) x(a,'*') defobj(a) cons(a) 64 | root: Nash(n(a)) 65 | """, 66 | ) 67 | 68 | nash.solve(solver="reshop") 69 | assert x.toList() == [ 70 | ("a0", "0", 0.8571428571428571), 71 | ("a0", "1", 2.5), 72 | ("a1", "0", 0.0), 73 | ("a1", "1", 0.5), 74 | ] 75 | 76 | 77 | if __name__ == "__main__": 78 | main() 79 | -------------------------------------------------------------------------------- /tests/integration/models/sat.py: -------------------------------------------------------------------------------- 1 | import string 2 | 3 | import numpy as np 4 | 5 | import gamspy as gp 6 | 7 | 8 | def main(): 9 | m = gp.Container() 10 | c = gp.Set(m, "c", description="conjunctions", records=range(5)) 11 | d = gp.Set(m, "d", description="disjunctions", records=range(2)) 12 | j = gp.Set(m, "j", records=list(string.ascii_uppercase[:5])) 13 | 14 | # CNF Representation of (D | E) & (A | ~D) & (B | ~C | ~D) & (~B | ~E) & (C | ~D) 15 | # using numerical data -1|0|1 16 | cnf_data = gp.Parameter( 17 | m, 18 | domain=[c, j], 19 | records=np.array( 20 | [ # A B C D E 21 | [0, 0, 0, 1, 1], 22 | [1, 0, 0, -1, 0], 23 | [0, 1, -1, -1, 0], 24 | [0, -1, 0, 0, -1], 25 | [0, 0, 1, -1, 0], 26 | ] 27 | ), 28 | ) 29 | 30 | # via sympy's to_dnf (with simplify=True): (E & ~B & ~D) | (A & B & C & D & ~E) 31 | dnf_data = gp.Parameter( 32 | m, 33 | domain=[d, j], 34 | records=np.array( 35 | [ # A B C D E 36 | [0, -1, 0, -1, 1], 37 | [1, 1, 1, 1, -1], 38 | ] 39 | ), 40 | ) 41 | 42 | x = gp.Variable(m, domain=j, type="binary") 43 | 44 | xc = gp.Variable(m, domain=c, type="binary") 45 | def_conjunction = gp.Equation(m, domain=c) 46 | def_conjunction[c] = xc[c] == gp.Sor( 47 | j.where[cnf_data[c, j] > 0], x[j] 48 | ) | gp.Sor(j.where[cnf_data[c, j] < 0], ~x[j]) 49 | 50 | xd = gp.Variable(m, domain=d, type="binary") 51 | def_disjunction = gp.Equation(m, domain=d) 52 | def_disjunction[d] = xd[d] == gp.Sand( 53 | j.where[dnf_data[d, j] > 0], x[j] 54 | ) | gp.Sand(j.where[dnf_data[d, j] < 0], ~x[j]) 55 | 56 | cnf = gp.Model( 57 | m, 58 | equations=[def_conjunction], 59 | objective=gp.Sand(c, xc[c]), 60 | problem="minlp", 61 | sense="max", 62 | ) 63 | cnf.solve(solver="scip") 64 | 65 | dnf = gp.Model( 66 | m, 67 | equations=[def_conjunction], 68 | objective=gp.Sand(c, xc[c]), 69 | problem="minlp", 70 | sense="max", 71 | ) 72 | dnf.solve(solver="scip") 73 | 74 | assert cnf.objective_value == dnf.objective_value 75 | 76 | 77 | if __name__ == "__main__": 78 | main() 79 | -------------------------------------------------------------------------------- /tests/integration/models/spatequ.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/spatequ.gdx -------------------------------------------------------------------------------- /tests/integration/models/surface.py: -------------------------------------------------------------------------------- 1 | """ 2 | ## GAMSSOURCE: https://www.gams.com/latest/noalib_ml/libhtml/noalib_surface.html 3 | ## LICENSETYPE: Demo 4 | ## MODELTYPE: NLP 5 | 6 | 7 | Minimal surface problem 8 | 9 | Find a function f that minimizes the array of its graph subject to some 10 | constraints on the boundary of the domain of f. 11 | 12 | Boyd, S., Vandenberghe, L., Convex Optimization, Cambridge University Press, 13 | Cambridge, 2004. 14 | """ 15 | 16 | from __future__ import annotations 17 | 18 | import gamspy.math as gams_math 19 | from gamspy import ( 20 | Card, 21 | Container, 22 | Domain, 23 | Model, 24 | Ord, 25 | Parameter, 26 | Set, 27 | Sum, 28 | Variable, 29 | ) 30 | from gamspy.math import sqr 31 | 32 | 33 | def main(): 34 | m = Container() 35 | 36 | # SETS # 37 | X = Set(m, name="X", records=[f"I{i}" for i in range(1, 22)]) 38 | Y = Set(m, name="Y", records=[f"J{j}" for j in range(1, 22)]) 39 | inside = Set(m, name="inside", domain=[X, Y]) 40 | 41 | # Exclude i1 and i21 from inside 42 | inside[X, Y].where[~((Ord(X) == 1) & (Ord(X) == Card(X)))] = True 43 | 44 | # display inside 45 | 46 | # SCALAR # 47 | K = Parameter(m, name="K", records=10) 48 | 49 | # VARIABLES # 50 | f = Variable(m, name="f", domain=[X, Y], type="positive") 51 | 52 | # Bounds on variables, initial conditions, fixing conditions: 53 | f.up[X, Y] = 1 54 | f.l[X, Y] = 1.0 55 | f.fx[X, Y].where[(Ord(X) == 1) | (Ord(X) == Card(X))] = 1 56 | 57 | # EQUATION # 58 | objfun = (1 / sqr(K)) * Sum( 59 | Domain(X, Y).where[inside[X, Y]], 60 | gams_math.sqrt( 61 | sqr((f[X + 1, Y] - f[X, Y]) / K) 62 | + sqr((f[X, Y + 1] - f[X, Y]) / K) 63 | + 1 64 | ), 65 | ) 66 | 67 | surface = Model( 68 | m, 69 | name="surface", 70 | equations=m.getEquations(), 71 | problem="nlp", 72 | sense="MIN", 73 | objective=objfun, 74 | ) 75 | surface.solve() 76 | 77 | print("Objective Function Value: ", round(surface.objective_value, 4)) 78 | print("f(X,Y): \n", f.pivot()) 79 | 80 | # End surface 81 | 82 | 83 | if __name__ == "__main__": 84 | main() 85 | -------------------------------------------------------------------------------- /tests/integration/models/tanksize.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/tanksize.gdx -------------------------------------------------------------------------------- /tests/integration/models/tforss.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/tforss.gdx -------------------------------------------------------------------------------- /tests/integration/models/thai.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/thai.gdx -------------------------------------------------------------------------------- /tests/integration/models/traffic.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/traffic.gdx -------------------------------------------------------------------------------- /tests/integration/models/tsp4.gdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/integration/models/tsp4.gdx -------------------------------------------------------------------------------- /tests/integration/test_models.py: -------------------------------------------------------------------------------- 1 | import glob 2 | import os 3 | import subprocess 4 | import sys 5 | from pathlib import Path 6 | 7 | import pytest 8 | 9 | pytestmark = pytest.mark.model_library 10 | 11 | 12 | @pytest.fixture 13 | def teardown(): 14 | # Act and assert 15 | yield 16 | 17 | # Cleanup 18 | files = glob.glob("*.csv") 19 | for file in files: 20 | if os.path.isfile(file): 21 | os.remove(file) 22 | 23 | files = glob.glob("*.xlsx") 24 | for file in files: 25 | if os.path.isfile(file): 26 | os.remove(file) 27 | 28 | mpsge_file_path = os.path.join(os.getcwd(), "HANSEN.GEN") 29 | if os.path.exists(mpsge_file_path): 30 | os.remove(mpsge_file_path) 31 | 32 | solution_file = os.path.join(os.getcwd(), "solution.txt") 33 | if os.path.exists(solution_file): 34 | os.remove(solution_file) 35 | 36 | 37 | def test_full_models(teardown): 38 | paths = glob.glob( 39 | os.path.join(str(Path(__file__).parent), "models", "*.py") 40 | ) 41 | 42 | for idx, path in enumerate(paths): 43 | print(f"[{idx + 1}/{len(paths)}] {path.split(os.sep)[-1]}", flush=True) 44 | process = subprocess.run( 45 | [sys.executable, "-B", "-Wd", path], capture_output=True, text=True 46 | ) 47 | print(process.stderr) 48 | assert process.returncode == 0, process.stderr 49 | -------------------------------------------------------------------------------- /tests/integration/tex_references/ECD.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt]{article} 2 | \usepackage{geometry} 3 | \usepackage[american]{babel} 4 | \usepackage{amsmath} 5 | \usepackage{amssymb} 6 | \usepackage[hidelinks]{hyperref} 7 | \usepackage{tabularx} 8 | \usepackage{ltablex} 9 | \keepXColumns 10 | 11 | \begin{document} 12 | \section*{Symbols} 13 | 14 | 15 | \subsection*{Sets} 16 | \begin{tabularx}{\textwidth}{| l | l | X |} 17 | \hline 18 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 19 | \hline 20 | \endhead 21 | 22 | gen & * & \\ 23 | \hline 24 | \end{tabularx} 25 | \subsection*{Parameters} 26 | \begin{tabularx}{\textwidth}{| l | l | X |} 27 | \hline 28 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 29 | \hline 30 | \endhead 31 | 32 | load & & \\ 33 | data & gen,* & \\ 34 | \hline 35 | \end{tabularx} 36 | \subsection*{Variables} 37 | \begin{tabularx}{\textwidth}{| l | l | X |} 38 | \hline 39 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 40 | \hline 41 | \endhead 42 | 43 | P & gen & \\ 44 | \hline 45 | \end{tabularx} 46 | \subsection*{Equations} 47 | \begin{tabularx}{\textwidth}{| l | l | X |} 48 | \hline 49 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 50 | \hline 51 | \endhead 52 | 53 | eq2 & & \\ 54 | \hline 55 | \end{tabularx} 56 | \subsection*{Model Definition} 57 | \textbf{min} $\sum_\text{gen} ((((data_{gen,\textquotesingle a \textquotesingle} \cdot P_{gen}) \cdot P_{gen}) + (data_{gen,\textquotesingle b \textquotesingle} \cdot P_{gen})) + data_{gen,\textquotesingle c \textquotesingle})$\\ 58 | \textbf{s.t.} 59 | \subsubsection*{$eq2$} 60 | $ 61 | \sum_\text{gen} P_{gen} \geq load 62 | $ 63 | \vspace{5pt} 64 | \hrule 65 | \bigskip 66 | \end{document} -------------------------------------------------------------------------------- /tests/integration/tex_references/master.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt]{article} 2 | \usepackage{geometry} 3 | \usepackage[american]{babel} 4 | \usepackage{amsmath} 5 | \usepackage{amssymb} 6 | \usepackage[hidelinks]{hyperref} 7 | \usepackage{tabularx} 8 | \usepackage{ltablex} 9 | \keepXColumns 10 | 11 | \begin{document} 12 | \section*{Symbols} 13 | 14 | 15 | \subsection*{Sets} 16 | \begin{tabularx}{\textwidth}{| l | l | X |} 17 | \hline 18 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 19 | \hline 20 | \endhead 21 | 22 | i & * & widths\\ 23 | p & * & possible patterns\\ 24 | pp & p & dynamic subset of p\\ 25 | \hline 26 | \end{tabularx} 27 | \subsection*{Parameters} 28 | \begin{tabularx}{\textwidth}{| l | l | X |} 29 | \hline 30 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 31 | \hline 32 | \endhead 33 | 34 | d & i & demand\\ 35 | aip & i,p & number of width i in pattern growing in p\\ 36 | \hline 37 | \end{tabularx} 38 | \subsection*{Variables} 39 | \begin{tabularx}{\textwidth}{| l | l | X |} 40 | \hline 41 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 42 | \hline 43 | \endhead 44 | 45 | xp & p & patterns used\\ 46 | z & & objective variable\\ 47 | \hline 48 | \end{tabularx} 49 | \subsection*{Equations} 50 | \begin{tabularx}{\textwidth}{| l | l | X |} 51 | \hline 52 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 53 | \hline 54 | \endhead 55 | 56 | numpat & & number of patterns used\\ 57 | demand & i & meet demand\\ 58 | \hline 59 | \end{tabularx} 60 | \subsection*{Model Definition} 61 | \textbf{min} $z$\\ 62 | \textbf{s.t.} 63 | \subsubsection*{$numpat$} 64 | $ 65 | z = \sum_\text{pp} xp_{pp} 66 | $ 67 | \vspace{5pt} 68 | \hrule 69 | \subsubsection*{$demand_{i}$} 70 | $ 71 | \sum_\text{pp} (aip_{i,pp} \cdot xp_{pp}) \geq d_{i}\hfill \forall i 72 | $ 73 | \vspace{5pt} 74 | \hrule 75 | \bigskip 76 | $xp\in \mathbb{Z}_{+} \forall p\\$ 77 | \end{document} -------------------------------------------------------------------------------- /tests/integration/tex_references/qp6.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt]{article} 2 | \usepackage{geometry} 3 | \usepackage[american]{babel} 4 | \usepackage{amsmath} 5 | \usepackage{amssymb} 6 | \usepackage[hidelinks]{hyperref} 7 | \usepackage{tabularx} 8 | \usepackage{ltablex} 9 | \keepXColumns 10 | 11 | \begin{document} 12 | \section*{Symbols} 13 | 14 | 15 | \subsection*{Sets} 16 | \begin{tabularx}{\textwidth}{| l | l | X |} 17 | \hline 18 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 19 | \hline 20 | \endhead 21 | 22 | days & days & 100 days from 95-11-27 to 96-04-29\\ 23 | stocks & stocks & 170 selected stocks\\ 24 | d & days & selected days\\ 25 | s & stocks & selected stocks\\ 26 | \hline 27 | \end{tabularx} 28 | \subsection*{Parameters} 29 | \begin{tabularx}{\textwidth}{| l | l | X |} 30 | \hline 31 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 32 | \hline 33 | \endhead 34 | 35 | mean & stocks & mean of daily return\\ 36 | dev & stocks,days & deviations\\ 37 | totmean & & total mean return\\ 38 | \hline 39 | \end{tabularx} 40 | \subsection*{Variables} 41 | \begin{tabularx}{\textwidth}{| l | l | X |} 42 | \hline 43 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 44 | \hline 45 | \endhead 46 | 47 | x & stocks & investments\\ 48 | w & days & intermediate variables\\ 49 | m\_budget & & \\ 50 | m\_wdef & days & \\ 51 | m\_retcon & & \\ 52 | \hline 53 | \end{tabularx} 54 | \subsection*{Equations} 55 | \begin{tabularx}{\textwidth}{| l | l | X |} 56 | \hline 57 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 58 | \hline 59 | \endhead 60 | 61 | budget & & \\ 62 | retcon & & returns constraint\\ 63 | wdef & days & \\ 64 | d\_x & stocks & \\ 65 | d\_w & days & \\ 66 | \hline 67 | \end{tabularx} 68 | \subsection*{Model Definition} 69 | 70 | \bigskip 71 | $x\geq 0 ~ \forall stocks\\$ 72 | $m\_retcon\geq 0 ~ \forall \\$ 73 | \end{document} -------------------------------------------------------------------------------- /tests/integration/tex_references/transport.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt]{article} 2 | \usepackage{geometry} 3 | \usepackage[american]{babel} 4 | \usepackage{amsmath} 5 | \usepackage{amssymb} 6 | \usepackage[hidelinks]{hyperref} 7 | \usepackage{tabularx} 8 | \usepackage{ltablex} 9 | \keepXColumns 10 | 11 | \begin{document} 12 | \section*{Symbols} 13 | 14 | 15 | \subsection*{Sets} 16 | \begin{tabularx}{\textwidth}{| l | l | X |} 17 | \hline 18 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 19 | \hline 20 | \endhead 21 | 22 | i & * & canning plants\\ 23 | j & * & markets\\ 24 | \hline 25 | \end{tabularx} 26 | \subsection*{Parameters} 27 | \begin{tabularx}{\textwidth}{| l | l | X |} 28 | \hline 29 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 30 | \hline 31 | \endhead 32 | 33 | a & i & capacity of plant i in cases\\ 34 | b & j & demand at market j in cases\\ 35 | c & i,j & transport cost in thousands of dollars per case\\ 36 | \hline 37 | \end{tabularx} 38 | \subsection*{Variables} 39 | \begin{tabularx}{\textwidth}{| l | l | X |} 40 | \hline 41 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 42 | \hline 43 | \endhead 44 | 45 | x & i,j & shipment quantities in cases\\ 46 | \hline 47 | \end{tabularx} 48 | \subsection*{Equations} 49 | \begin{tabularx}{\textwidth}{| l | l | X |} 50 | \hline 51 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 52 | \hline 53 | \endhead 54 | 55 | supply & i & observe supply limit at plant i\\ 56 | demand & j & satisfy demand at market j\\ 57 | \hline 58 | \end{tabularx} 59 | \subsection*{Model Definition} 60 | \textbf{min} $\sum_\text{i,j} (c_{i,j} \cdot x_{i,j})$\\ 61 | \textbf{s.t.} 62 | \subsubsection*{$supply_{i}$} 63 | $ 64 | \sum_\text{j} x_{i,j} \leq a_{i}\hfill \forall i 65 | $ 66 | \vspace{5pt} 67 | \hrule 68 | \subsubsection*{$demand_{j}$} 69 | $ 70 | \sum_\text{i} x_{i,j} \geq b_{j}\hfill \forall j 71 | $ 72 | \vspace{5pt} 73 | \hrule 74 | \bigskip 75 | $x\geq 0 ~ \forall i,j\\$ 76 | \end{document} -------------------------------------------------------------------------------- /tests/integration/tex_references/transport2.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt]{article} 2 | \usepackage{geometry} 3 | \usepackage[american]{babel} 4 | \usepackage{amsmath} 5 | \usepackage{amssymb} 6 | \usepackage[hidelinks]{hyperref} 7 | \usepackage{tabularx} 8 | \usepackage{ltablex} 9 | \keepXColumns 10 | 11 | \begin{document} 12 | \section*{Symbols} 13 | 14 | 15 | \subsection*{Sets} 16 | \begin{tabularx}{\textwidth}{| l | l | X |} 17 | \hline 18 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 19 | \hline 20 | \endhead 21 | 22 | i & * & canning plants\\ 23 | j & * & markets\\ 24 | freeLinks & i,j & \\ 25 | \hline 26 | \end{tabularx} 27 | \subsection*{Parameters} 28 | \begin{tabularx}{\textwidth}{| l | l | X |} 29 | \hline 30 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 31 | \hline 32 | \endhead 33 | 34 | a & i & capacity of plant i in cases\\ 35 | b & j & demand at market j in cases\\ 36 | c & i,j & transport cost in thousands of dollars per case\\ 37 | \hline 38 | \end{tabularx} 39 | \subsection*{Variables} 40 | \begin{tabularx}{\textwidth}{| l | l | X |} 41 | \hline 42 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 43 | \hline 44 | \endhead 45 | 46 | x & freeLinks & shipment quantities in cases\\ 47 | \hline 48 | \end{tabularx} 49 | \subsection*{Equations} 50 | \begin{tabularx}{\textwidth}{| l | l | X |} 51 | \hline 52 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 53 | \hline 54 | \endhead 55 | 56 | supply & i & observe supply limit at plant i\\ 57 | demand & j & satisfy demand at market j\\ 58 | \hline 59 | \end{tabularx} 60 | \subsection*{Model Definition} 61 | \textbf{min} $\sum_\text{i,j} (c_{i,j} \cdot x_{i,j})$\\ 62 | \textbf{s.t.} 63 | \subsubsection*{$supply_{i}$} 64 | $ 65 | \sum_\text{j} x_{i,j} \leq a_{i}\hfill \forall i 66 | $ 67 | \vspace{5pt} 68 | \hrule 69 | \subsubsection*{$demand_{j}$} 70 | $ 71 | \sum_\text{i} x_{i,j} \geq b_{j}\hfill \forall j 72 | $ 73 | \vspace{5pt} 74 | \hrule 75 | \bigskip 76 | $x\geq 0 ~ \forall i,j\\$ 77 | \end{document} -------------------------------------------------------------------------------- /tests/integration/tex_references/war.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt]{article} 2 | \usepackage{geometry} 3 | \usepackage[american]{babel} 4 | \usepackage{amsmath} 5 | \usepackage{amssymb} 6 | \usepackage[hidelinks]{hyperref} 7 | \usepackage{tabularx} 8 | \usepackage{ltablex} 9 | \keepXColumns 10 | 11 | \begin{document} 12 | \section*{Symbols} 13 | 14 | 15 | \subsection*{Sets} 16 | \begin{tabularx}{\textwidth}{| l | l | X |} 17 | \hline 18 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 19 | \hline 20 | \endhead 21 | 22 | w & * & weapons\\ 23 | t & * & targets\\ 24 | \hline 25 | \end{tabularx} 26 | \subsection*{Parameters} 27 | \begin{tabularx}{\textwidth}{| l | l | X |} 28 | \hline 29 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 30 | \hline 31 | \endhead 32 | 33 | td & w,t & target data\\ 34 | wa & w & weapons availability\\ 35 | tm & t & minimum number of weapons per target\\ 36 | mv & t & military value of target\\ 37 | \hline 38 | \end{tabularx} 39 | \subsection*{Variables} 40 | \begin{tabularx}{\textwidth}{| l | l | X |} 41 | \hline 42 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 43 | \hline 44 | \endhead 45 | 46 | x & w,t & weapons assignment\\ 47 | \hline 48 | \end{tabularx} 49 | \subsection*{Equations} 50 | \begin{tabularx}{\textwidth}{| l | l | X |} 51 | \hline 52 | \textbf{Name} & \textbf{Domains} & \textbf{Description}\\ 53 | \hline 54 | \endhead 55 | 56 | maxw & w & weapons balance\\ 57 | minw & t & minimum number of weapons required per target\\ 58 | \hline 59 | \end{tabularx} 60 | \subsection*{Model Definition} 61 | \textbf{max} $\sum_\text{t} (mv_{t} \cdot (1 - \prod_\text{w ~ | ~ td_{w,t}} rPower((1 - td(w,t)),x(w,t))))$\\ 62 | \textbf{s.t.} 63 | \subsubsection*{$maxw_{w}$} 64 | $ 65 | \sum_\text{t ~ | ~ td_{w,t}} x_{w,t} \leq wa_{w}\hfill \forall w 66 | $ 67 | \vspace{5pt} 68 | \hrule 69 | \subsubsection*{$minw_{t}$} 70 | $ 71 | \sum_\text{w ~ | ~ td_{w,t}} x_{w,t} \geq tm_{t}\hfill \forall t ~ | ~ tm_{t} 72 | $ 73 | \vspace{5pt} 74 | \hrule 75 | \bigskip 76 | $x\geq 0 ~ \forall w,t\\$ 77 | \end{document} -------------------------------------------------------------------------------- /tests/unit/libtricclib64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/unit/libtricclib64.so -------------------------------------------------------------------------------- /tests/unit/libtricclib64arm.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/unit/libtricclib64arm.dylib -------------------------------------------------------------------------------- /tests/unit/libtricclib64x86.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/unit/libtricclib64x86.dylib -------------------------------------------------------------------------------- /tests/unit/tricclib64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAMS-dev/gamspy/5e018df202eb798cbd607056e75ecc491ffcc1fd/tests/unit/tricclib64.dll --------------------------------------------------------------------------------