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:

  1. Generate a json file which contains the node information as follows:

    gamspy probe -o info.json
    
  2. 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
    
  3. 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

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:

  1. Python 3.8.x or newer

  2. 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.