Installation and Licensing#
Basic Installation#
You can run the following command to install GAMSPy from PyPI:
pip install gamspy
Licensing#
GAMSPy comes with a free demo license which lets you generate and solve small models. For more information about GAMS licenses and how to get a new license, check GAMS Licensing.
Installing or updating your license#
A GAMSPy license is a either an ASCII file of six lines or 36 character access code. In order to install your license, all you need to do is to run:
gamspy install license <path_to_ascii_file or access code>
For machines that are not connected to the internet and a license specified by an access code, you can probe the node’s data and get a license via a machine connected to the internet. Details about this can be found below and in gamspy retrieve.
Note
GAMS and GAMSPy licenses are different, which means one cannot use an existing GAMS license for GAMSPy. We provide GAMSPy licenses for free if you already have a maintained professional GAMS license. Contact sales@gams.com (with your GAMS license) to arrange for the delivery of a GAMSPy license.
Note
GAMSPy is free for academics. Please check GAMS Academic Program for details.
Uninstalling your license#
If you no longer wish to use your license, you can uninstall it with the following command:
gamspy uninstall license
The demo license originally shipped with GAMSPy is reinstated.
License installation for offline machines#
In order to use GAMSPy in a machine which does not have an internet connection (offline), the license installation process is as follows:
Generate a json file which contains the node information as follows:
gamspy probe -o info.json
Move info.json file to a machine which has an internet connection and run:
gamspy retrieve license <access code> -i info.json -o license.txt
Move license.txt to the machine that does not have an internet connection and run:
gamspy install license license.txt
Solvers#
GAMSPy comes with default solvers, and additional solvers can be installed on demand.
Listing solvers#
To list the installed solvers on your machine, you can run:
gamspy list solvers
Alternatively, if you want to list all available solvers, you can run the following:
gamspy list solvers --all
The same information can also be accessed programmatically via the utils module of GAMSPy:
import gamspy as gp
import gamspy_base
print(gp.utils.getInstalledSolvers(gamspy_base.directory))
print(gp.utils.getAvailableSolvers())
Note
All available solver packages can also be found on PyPI.
Installing/Uninstalling additional solvers#
The following command can be used to install additional solvers:
gamspy install solver <solver_name>
Similarly, a (non-default) solver can be uninstalled using:
gamspy uninstall solver <solver_name>
Note
To use a non-default solver to solve your model, remember to specify the solver argument
in the model.solve. For example,
your model definition
…
…
model.solve(solver=”xpress”)
Updating GAMSPy#
pip install gamspy implicitly upgrades the dependencies of GAMSPy (i.e. gamspy_base and gamsapi). If there is a new version of gamspy_base, you need to reinstall the additional solvers and your license after an upgrade:
pip install gamspy --upgrade
gamspy install license 876e5812-1222-4aba-819d-e1e91b7e2f52
gamspy install solver mosek conopt xpress
Additional steps when using solver link licenses#
Attempting to use a solver with a link license only you might need to perform additional steps to make your solver license known to GAMSPy. For example, a GAMS/Gurobi-Link license but without a properly set up Gurobi license will result in a licensing error with a message describing the problem. To make the GAMS/Gurobi-Link work you do not need to download or install the Gurobi software but only your Gurobi license.
You only need to set the GRB_LICENSE_FILE environment variable to the path of the Gurobi
license (gurobi.lic) that you generated using the grbgetkey program:
export GRB_LICENSE_FILE=/path/to/gurobi.lic
Similar instructions can be found in the GAMS Solver Manual for solvers that offer link licenses.
Building From Source#
If you are a macOS or Linux user (or using a subsystem like WSL on Windows) familiar with the command line, you can build GAMSPy locally by following the instructions below.
Prerequisites#
Building GAMSPy requires the following software to be installed:
Python 3.8.x or newer
The GAMSPy source code:
git clone git@github.com:GAMS-dev/gamspy.git
Installation#
You can install GAMSPy from source using the following command:
pip install .
Testing#
Tests are classified into three categories: unit tests, integration tests, and doc tests. The tests can be run with:
python tests/test_gamspy.py
Note
By default, only unit tests are run. To enable integration tests, the --integration argument should be provided.
Doctests can be enable with the --doc argument.