Skip to main content

plot


PyPI version Downloads Documentation Status

GAMSPy: Mathematical optimization in Python

GAMSPy is an open-source Python package for building and solving mathematical optimization models. Its algebraic, indexed API supports linear, mixed-integer, nonlinear, quadratically constrained, and complementarity models while fitting naturally into Python data and analytics workflows.

Installation

pip install gamspy

GAMSPy requires Python 3.11 or newer. Installation includes the local execution runtime and a set of default solvers, so you do not need to install GAMS separately to run the example below. The included demo license is sufficient for this small model.

Your first model

This production-mix model chooses how many desks and chairs to make to maximize profit within 40 available labor hours:

import gamspy as gp

m = gp.Container()

products = gp.Set(m, records=["desk", "chair"])
profit = gp.Parameter(
    m,
    domain=products,
    records=[("desk", 100), ("chair", 40)],
    description="profit per unit",
)
hours = gp.Parameter(
    m,
    domain=products,
    records=[("desk", 4), ("chair", 1)],
    description="labor hours per unit",
)
production = gp.Variable(
    m,
    domain=products,
    type="Positive",
    description="units to produce",
)

capacity = gp.Equation(m)
capacity[...] = gp.Sum(products, hours[products] * production[products]) <= 40

model = gp.Model(
    m,
    equations=[capacity],
    problem=gp.Problem.LP,
    sense=gp.Sense.MAX,
    objective=gp.Sum(products, profit[products] * production[products]),
)
model.solve()

print(f"Maximum profit: {model.objective_value:.0f}")
Maximum profit: 1600

The same workflow—define indexed data, variables, equations, and an objective, then solve—scales to larger and more complex models.

Why GAMSPy

  • Algebraic, indexed modeling: Express whole families of variables and constraints over sets instead of constructing each scalar expression with Python loops. Model definitions stay close to their mathematical notation.
  • Multiple problem classes: Build linear, mixed-integer, nonlinear, quadratically constrained, complementarity, and related model types with a consistent API.
  • Choice of solver: Use compatible installed solvers without rewriting the model. GAMSPy provides access to both open-source and commercial solvers, subject to their license terms.
  • Python workflows: Load model data from Python lists, NumPy arrays, or pandas objects, and work with results as pandas DataFrames.

Licensing and free use

The modeling package and the components used to execute and solve a model have different licensing considerations:

  • GAMSPy source code: The Python source in this repository is available under the MIT License.
  • Demo license: A time- and size-limited demo license is included with GAMSPy and can solve small models such as the example above. See the demo license limitations for current details.
  • Free personal license: Individuals can generate a free license for non-commercial learning, experimentation, hobby projects, and prototypes. It includes a selection of free and open-source solvers; see the free-license overview for the applicable terms.
  • Free academic GAMSPy license: Eligible students, teachers, researchers, and academic staff can obtain a free license for academic, non-commercial, non-production use. It includes selected commercial solvers without model-size limits. See the current included-solvers overview.
  • Commercial license: Commercial and production use requires an appropriate license. Contact sales@gams.com or use the GAMS contact form and select Licensing.

Sign up and generate a free personal or academic license at the GAMS Portal, then follow the GAMSPy license installation instructions.

Solver availability depends on both the installed solver package and the active license. Runtime and solver components may have terms separate from the MIT-licensed Python source.

Relationship to GAMS

GAMSPy builds on GAMS model-generation and execution technology. You write and manage the model in Python; GAMSPy translates its algebraic representation for the execution system and dispatches it to a compatible solver. No knowledge of the GAMS language is required, and the standard pip install gamspy installation provides the local runtime needed to get started.

GAMS and GAMSPy licenses are separate. An existing GAMS license is not automatically a GAMSPy license; see the installation and licensing guide for the available options and exceptions.

Learn more

Community and contributing

For usage questions, visit the GAMSPy documentation or the GAMS Forum. Report bugs and request features through the GitHub issue tracker. Contributions are welcome; see the contributing guide to get started.

Metadata

Release files for gamspy 1.29.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gamspy 1.29.0
File Size Uploaded
gamspy-1.29.0.tar.gz 341.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gamspy 1.29.0
File Interpreter ABI Platform
gamspy-1.29.0-py3-none-any.whl Python 3 none any Details

Total release size: 744.6 kB

Release files / gamspy-1.29.0.tar.gz

Download URL gamspy-1.29.0.tar.gz
Size 341.1 kB
Tags Source
SHA-256 checksum
How to use checksums
666d7db017608ae863182c41ee4f7f5331297a4318e9a9efa41573b106ae8cfc
BLAKE2b-256 checksum
How to use checksums
6e5680d4f250856b591b49512920196a5940b8e3ca3de0f5b6ddd2ee86712348
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / gamspy-1.29.0-py3-none-any.whl

Download URL gamspy-1.29.0-py3-none-any.whl
Size 403.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9230a27b17b216f06ac529ae3a8a29c8bc3c7db3f4e5e980351f560a5f2ff5b
BLAKE2b-256 checksum
How to use checksums
ae12715714873cd865781313b153581d7a9e057aab4b17238e91063bcdfe80b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

1.29.1

2 release files

This release

1.29.0 This release

2 release files

1.28.0

2 release files

1.27.0

2 release files

1.26.2

2 release files

1.26.1

2 release files

1.25.0

2 release files

1.24.2

2 release files

1.24.1

2 release files

1.24.0

2 release files

1.23.0

2 release files

1.20.0

2 release files

1.19.2

2 release files

1.19.1

2 release files

1.19.0

2 release files

1.18.4

2 release files

1.18.3

2 release files

1.17.2

2 release files

1.17.1

2 release files

1.17.0

2 release files

1.16.0

2 release files

0.12.3

1 release file

0.12.2

1 release file

0.12.1

1 release file

0.12.0

1 release file

0.11.10

1 release file

0.11.9

1 release file

0.11.8

1 release file

0.11.7

1 release file

0.11.6

1 release file

0.11.5

1 release file

0.11.4

1 release file

0.11.3

1 release file

0.11.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page