GAMS

GAMS Language

A clear and reliable language for building optimization models, choosing the right solver, and turning decision problems into results.

The GAMS Language helps you express complex optimization problems in a compact, readable way, connect them to data, and solve them efficiently across different solvers and deployment environments within the GAMS ecosystem.

Use Case Optimization modeling for complex decision problems
Strengths Concise syntax, performance, reliability

Core Capabilities of the GAMS Language

GAMS is designed for optimization models where scale, structure, and dependable execution matter from prototype to production.


Declarative Algebraic Modeling

Describe the decision problem clearly and let optimization algorithms find the best solution.

  • Readable structure: Sets, data, variables, and constraints stay close to the problem you want to solve.
  • Indexed formulations: Compact statements expand automatically to large model instances.
  • Data independence: Run the same model logic on new scenarios without rewriting the formulation.

Production-Ready at Industrial Scale

Efficiently generate, solve, and secure large-scale optimization workflows built for enterprise demands.

  • Solver independence: Switch between commercial and open-source solvers without changing the model formulation.
  • Seamless Scalability: Move effortlessly from small test cases to massive industrial applications using the exact same core concepts.
  • Enterprise Security: Keep proprietary models and sensitive data structured and secure within controlled, reliable execution environments.
GAMS Studio Screenshot

Foundation of the GAMS Ecosystem

Model once in GAMS, or in Python, connect the same optimization logic to analysis, apps, and managed execution.

GAMSPy

Use familiar GAMS modeling concepts directly in Python workflows.

GAMS MIRO

Turn models into interactive decision-support applications.

GAMS Engine

Run optimization workloads centrally on-premise or in the cloud.

From Algebra to Application

GAMS models are written in an algebraic form that mirrors the underlying mathematics, making them easier to read, review, and maintain as they grow.

  • Formulate the optimization problem with sets, parameters, variables, and equations
  • Connect model logic to scenario inputs without changing the formulation
  • Generate the full model instance, solve it, and inspect results in one workflow

Model Anatomy

Sets and Data

Define the structure of the model and provide input data through sets, parameters, and tables.

Variables

Represent the decisions the optimizer can make, including various continuous and discrete variable types.

Equations

Declare objective functions and constraints in compact indexed algebraic form.

Solve Statement

Select the model type, solver, optimization direction, and objective variable.

Why Choose the GAMS Language?

GAMS helps teams move from a clear model description to reliable optimization results, with strong solver support and long-term stability.


Concise Model Development

  • Express complex optimization problems with compact, readable model statements
  • Keep data and model formulation clearly separated
  • Make model logic easier to review, share, and maintain across teams

Solver Flexibility

  • Select and tune solvers without changing the model structure
  • Use state-of-the-art commercial and open-source solvers through one modeling workflow
  • Support LP, MIP, NLP, MINLP, MCP, stochastic optimization models and many more

Reliable Long-Term Use

  • Scale from small test cases to demanding operational applications
  • Preserve model behavior with stable, backward-compatible language concepts
  • Support business-critical optimization workflows in controlled environments

Learn the Language by Example

The transportation model shows how a compact algebraic formulation turns sets, data, variables, and equations into a solvable optimization model.


Annotated Example

Transportation Model

A canonical linear program that shows how GAMS combines model structure, input data, decisions, and constraints in one readable formulation.

Model Code

  
    

Sets
      i   canning plants   / Seattle, San-Diego /
      j   markets          / New-York, Chicago, Topeka / ;

Parameters
      a(i)  capacity of plant i in cases
          /    Seattle     350
               San-Diego   600  /
      b(j)  demand at market j in cases
          /    New-York    325
               Chicago     300
               Topeka      275  / ;

Table  d(i,j)  distance in thousands of miles
                 New-York       Chicago      Topeka
     Seattle          2.5            1.7          1.8
     San-Diego        2.5            1.8          1.4  ;

Scalar f  freight in dollars per case per thousand miles  /90/ ;

Parameter
      c(i,j)  transport cost in thousands of dollars per case ;
c(i,j) = f * d(i,j) / 1000 ;

Variables
      x(i,j)  shipment quantities in cases
      z       total transportation costs in thousands of dollars ;

Positive variables x ;

Equations
      cost          define objective function
      supply(i)   observe supply limit at plant i
      demand(j)   satisfy demand at market j ;
cost ..          z  =e=  sum((i,j), c(i,j)*x(i,j)) ;
supply(i) ..   sum(j, x(i,j))  =l=  a(i) ;
demand(j) ..   sum(i, x(i,j))  =g=  b(j) ;

Model transport /all/ ;

Solve transport using LP minimizing z ;


  

What this model demonstrates

  • Sets define the model structure through plants and markets.
  • Parameters and tables capture capacities, demand, and distances independently of model logic.
  • Decision variables represent shipment quantities between each origin and destination pair.
  • Equations express costs, supply limits, and demand requirements in indexed algebraic form.
Inputs

Capacities, market demand, distances, freight rate

Decisions

Shipment quantities between plants and markets

Objective

Minimize total transportation cost

Why this is useful

The same modeling pattern scales from teaching examples to large operational models without changing the underlying language concepts.

Walk Through the Model

Open the sections below to see how each part of the transportation model maps to a specific GAMS language concept.

Sets

Sets are the basic building blocks of a GAMS model, corresponding exactly to the indices in the algebraic representations of models. The Transportation example above contains just one Set statement:

  
    
Sets
       i   canning plants   / Seattle, San-Diego /
       j   markets          / New-York, Chicago, Topeka / ;

  

The effect of this statement is probably self-evident. We declared two sets and gave them the names $i$ and $j$. We also assigned members to the sets as follows:

$i =$ {Seattle, San-Diego}

$j =$ {New-York, Chicago, Topeka}.

Note the use of forward slashes ("/") for surrounding the list of set members. In mathematical notation this would be done with curly braces instead.

Parameters

Parameters are one way of entering data in GAMS. In this case, the parameters $a$ and $b$ are defined over the sets $i$ and $j$.

  
    
Parameters
       a(i)  capacity of plant i in cases
         /    Seattle     350
              San-Diego   600  /
       b(j)  demand at market j in cases
         /    New-York    325
              Chicago     300
              Topeka      275  / ;

  

GAMS lets you place explanatory text (shown in lower case) throughout your model as you develop it. Your comments are automatically incorporated into the output report at the appropriate places.

Table

Data can also be entered in convenient table form. GAMS lets you input data in their basic form - transformations are specified algebraically.

  
    
Table  d(i,j)  distance in thousands of miles
                  New-York       Chicago      Topeka
    Seattle          2.5           1.7          1.8
    San-Diego        2.5           1.8          1.4  ;

  

Scalar

Constants can simply be declared as scalars:

  
    
Scalar f  freight in dollars per case per thousand miles  /90/ ;

  

Data Manipulation

When data values are to be calculated, you first declare the parameter, give it a symbol and optionally index it, then give its algebraic formulation. GAMS will automatically make the calculations.

  
    
Parameter
       c(i,j)  transport cost in thousands of dollars per case ;
c(i,j) = f * d(i,j) / 1000 ;

  

Variables

Decision variables are expressed algebraically, with their indices specified. From this general form, GAMS generates each instance of the variable in the domain. Variables are specified as to type: FREE, POSITIVE, NEGATIVE, BINARY, or INTEGER. The default is FREE. The objective variable, z here, is simply declared without an index.

  
    
Variables
     x(i,j)  shipment quantities in cases
     z       total transportation costs in thousands of dollars ;
Positive variables x ;

  

Equations

Objective function and constraint equations are first declared by giving them names. Then their general algebraic formulae are described. GAMS now has enough information from data entered above and from the algebraic relationships specified in the equations to automatically generate each individual constraint statement. An extensive set of tools enables you to model any expression that can be stated algebraically: arithmetic, indexing, functions and exception-handling logic.

=E= indicates equal to
=L= indicates less than or equal to
=G= indicates greater than or equal to

  
    
Equations
     cost        define objective function
     supply(i)   observe supply limit at plant i
     demand(j)   satisfy demand at market j ;
cost ..        z  =e=  sum((i,j), c(i,j)*x(i,j)) ;
supply(i) ..   sum(j, x(i,j))  =l=  a(i) ;
demand(j) ..   sum(i, x(i,j))  =g=  b(j) ;

  

Model statement

The model is given a unique name, here TRANSPORT, and the modeler specifies which equations should be included in this particular formulation. In this case we specified ALL which indicates that all equations are part of the model. This would be equivalent to MODEL TRANSPORT /COST, SUPPLY, DEMAND/. This equation selection enables you to formulate different models within a single GAMS input file, based on the same or different given data.

  
    
Model transport /all/ ;

  

Solve statement

The solve statement tells GAMS which model to solve, selects the solver to use, indicates the direction of the optimization, either MINIMIZING or MAXIMIZING, and specifies the objective variable.

  
    
Solve transport using LP minimizing z ;

  

Resources

Start with the documentation, explore model examples, or download GAMS to try the language locally.


User's Guide

Learn the language fundamentals, data handling, model structure, execution, and reporting workflows.

Open docs

Solver Overview

Compare supported solvers, model types, and platform availability for GAMS optimization workflows.

View solvers

Model Library

Browse ready-to-run GAMS models across industries, mathematical structures, and application domains.

Explore models

Try GAMS

Download GAMS, request a license, and follow the first steps for running your own optimization models.

Get started

Talk to us about GAMS

Contact our team if you would like to discuss licensing, solver options, evaluation copies, or how GAMS fits into your optimization workflow.