GAMSPy

GAMSPy

Mathematical optimization in Python, powered by the high-performance GAMS execution system.

GAMSPy bridges the expressive Python ecosystem and the robust GAMS system. Build algebraic optimization models, prepare and transform data, solve efficiently, and postprocess results in one intuitive Python workflow.

Use Case Python-based optimization pipelines
Strengths ML integration, solver access, scalable execution

Core Capabilities of GAMSPy

GAMSPy keeps optimization modeling close to Python while preserving the algebraic clarity, solver access, and performance of GAMS.


One Python Optimization Pipeline

Move from data preparation to model execution and result analysis in one environment.

Prepare Data

Use Python libraries such as NumPy, Pandas for data workflows.

Model and Solve

Implement mathematical models and solve them with the GAMS execution system, locally, on NEOS Server, or on GAMS Engine for centralized execution.

Analyze Results

Postprocess, visualize, export, and connect results to applications.

Algebraic Modeling in Python

Write optimization models directly in Python while keeping the structure readable and close to the mathematics.

  • Expressive notation: Create complex mathematical models without leaving Python.
  • Clear model structure: Preserve the separation of instance data and algebraic model logic.
  • Maintainable code: Build models that are easier to document, review, and reuse.

GAMS Performance Without Leaving Python

Offload the heavy lifting to the efficient GAMS backend and choose the solver that fits your model.

  • Solver independence: Switch solvers based on model type, licensing, and performance requirements.
  • No performance compromise: Use Python for orchestration while GAMS handles generation and execution.
  • Sparsity handling: Let GAMSPy handle sparse data cubes so you can focus on the formulation.

Why Choose GAMSPy?

GAMSPy helps teams move from prototype to production faster by reducing modeling friction, rework, and deployment overhead.


Shorter Time to Results

  • Prototype and iterate inside familiar Python workflows
  • Reduce handoffs between data preparation, modeling, and analysis
  • Get from idea to runnable optimization workflow with less glue code

Lower Maintenance Burden

  • Keep algebraic logic readable as models grow in scope and complexity
  • Make models easier to review, reuse, and hand over across teams
  • Avoid fragile custom orchestration around external modeling components

Easier Operationalization

  • Scale from local development to centralized execution with fewer changes
  • Connect models to GAMS MIRO and GAMS Engine for broader use
  • Share optimization workflows more easily with analysts, developers, and decision makers

Developer Features

Practical tools help teams document, share, reuse, and solve optimization models in modern Python workflows.


Extensive Model Library

Start from proven formulations and learn from runnable examples in the public model library.

  • Supply chain, transportation, and scheduling models
  • Energy, infrastructure, and process systems models
  • Finance, economics, and risk-oriented models
View examples

NEOS Server Integration

Solve optimization models remotely without local solver installations, useful for teaching, research, and quick experimentation.

  • Suitable for academic workflows
  • Experiment with different solvers remotely
Learn about NEOS

Deployment with Engine and MIRO

Move from model development to shared applications and centralized execution without leaving the broader GAMS ecosystem.

  • Deploy interactive apps with GAMS MIRO
  • Run and scale jobs with GAMS Engine
Explore deployment

Try GAMSPy in Colab

Open runnable notebooks directly in Google Colab and explore representative optimization models without local setup.


Transport Example

Manage supplies from plants to meet market demands for a single commodity.

Open Transport example in Colab

Nurses Example

Assign nurses to hospital shifts while respecting staffing constraints.

Open Nurses example in Colab

Capacitated Facility Location Example

Decide which facilities to open and how to assign customer demand while respecting capacity constraints.

Open capacitated facility location example in Colab

Advanced Machine Learning Workflows

For advanced use cases, GAMSPy can bring trained machine learning models directly into optimization workflows instead of treating them as external black boxes.


Bridge ML Models and Mathematical Optimization

GAMSPy offers a set of machine learning capabilities for teams that want to combine prediction models with algebraic decision models in one Python environment.

This includes neural network formulations, classic machine learning formulations, and workflows for embedding pretrained models so solvers can reason over them as part of the optimization problem.

Explore ML documentation

Neural Network Formulations

Use documented formulations for layers, activations, convolution, pooling, and related matrix operations to express neural networks inside GAMSPy models.

Embed Trained Models

Bring pretrained PyTorch networks into optimization models so outputs, constraints, and decisions can be handled in one solver-driven workflow.

Classic ML Formulations

Integrate tree-based models such as regression trees, random forests, and gradient boosting directly into optimization formulations.

Verification and Surrogate Use Cases

Support advanced applications such as robustness verification, adversarial input generation, and surrogate modeling within larger optimization pipelines.

Resources

Start with the documentation, browse examples, or join the forum for GAMSPy questions and support.


Documentation

Read the GAMSPy documentation and follow the installation and getting-started guides.

Open docs

Example Repository

Browse runnable examples and practical model references for learning, testing, and benchmarking.

View GitHub

Community Forum

Use the GAMSPy section of the GAMS forum for questions, support, and workflow discussions.

Visit forum

Talk to us about GAMSPy

Contact our team if you would like to discuss licensing, solver options, deployment with GAMS Engine, or how GAMSPy fits into your Python optimization workflow.