A GAMS example

This toy problem is presented only to illustrate how GAMS lets you model in a natural way. GAMS can handle much larger and highly complex problems. Only a few of the basic features of GAMS can be highlighted here.

Algebraic Description

Here is a standard algebraic description of the problem, which is to minimize the cost of shipping goods from 2 plants to 3 markets, subject to supply and demand constraints.

Indices:

$i = $plants

$j = $markets

Given data:

$a_{i} = $supply of commodity of plant $i$ (cases)

$b_{j} = $demand for commodity at market $j$ (cases)

$d_{ij} = $distance between plant $i$ and market $j$ (thousand miles)

$c_{ij} = F \times d_{ij}$ shipping cost per unit shipment between plant $i$ and market $j$ (dollars per case per thousand miles)

Distances Markets
Plants New York Chicago Topeka Supply
Seattle 2.5 1.7 1.8 350
San Diego 2.5 1.8 1.4 600
Demand 325 300 275

$F=$ $ per thousand miles

Decision variables

$x_{ij}=$ amount of commodity to ship from plant $i$ to market $j$ (cases), where $x_{ij} > 0$, for all $i,j$.

Constraints

  • Observe supply limit at plant $i: \sum_{j}{x_{ij}} \le a_{i}$ for all $i$ cases
  • Satisfy demand at market $j: \sum_{i}{x_{ij}} \ge b_{j}$ for all $j$ cases

The GAMS Model

The same model modeled in GAMS. The use of concise algebraic descriptions makes the model highly compact, with a logical structure. Internal documentation, such as explanation of parameters and units of measurement makes the model easy to read.

  
    
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 ;