
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.
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.
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 
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, SANDIEGO / J markets / NEWYORK, CHICAGO, TOPEKA / ; PARAMETERS A(I) capacity of plant i in cases / SEATTLE 350 SANDIEGO 600 / B(J) demand at market j in cases / NEWYORK 325 CHICAGO 300 TOPEKA 275 / ; TABLE D(I,J) distance in thousands of miles NEWYORK CHICAGO TOPEKA SEATTLE 2.5 1.7 1.8 SANDIEGO 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 VARIABLE 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 ;
SETS I canning plants / SEATTLE, SANDIEGO / J markets / NEWYORK, CHICAGO, TOPEKA / ;
GAMS lets you specify indices in a straightforward way: declare and name the set (here, I and J), and enumerate their elements.
PARAMETERS A(I) capacity of plant i in cases / SEATTLE 350 SANDIEGO 600 / B(J) demand at market j in cases / NEWYORK 325 CHICAGO 300 TOPEKA 275 / ;
Here data are entered as indexed parameters A(I) and B(J), and values simply are listed.
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 D(I,J) distance in thousands of miles NEWYORK CHICAGO TOPEKA SEATTLE 2.5 1.7 1.8 SANDIEGO 2.5 1.8 1.4 ;
Data can also be entered in convenient table form. GAMS lets you input data in their basic form  transformations are specified algebraically.
SCALAR F freight in dollars per case per thousand miles /90/ ;
A constant simply can be declared as a SCALAR, and its value specified.
PARAMETER C(I,J) transport cost in thousands of dollars per case ; C(I,J) = F * D(I,J) / 1000 ;
When data values are to be calculated, you first declare the parameter (i.e. give it a symbol and, optionally, index it), then give its algebraic formulation. GAMS will automatically make the calculations.
VARIABLES X(I,J) shipment quantities in cases Z total transportation costs in thousands of dollars ; POSITIVE VARIABLE X ;
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.
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) ;
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  as you can see in the output report below. An extensive set of tools enables you to model any expression that can be stated algebraically: arithmetic, indexing, functions and exceptionhandling log (e.g. ifthenelse and suchthat constructs).
=E= indicates 'equal to'
=L= indicates 'less than or equal to'
=G= indicates 'greater than or equal to'
MODEL TRANSPORT /ALL/ ;
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.
SOLVE TRANSPORT USING LP MINIMIZING Z ;
The solve statement (1) tells GAMS which model to solve, (2) selects the solver to use (in this case an LP solver), (3) indicaties the direction of the optimization, either MINIMIZING or MAXIMIZING , and (4) specifies the objective variable.
The full GAMS output report is much more extensive than the small excerpts shown here, and contains many aids for interpreting and diagnosing your model. Moreover, you can modify the output format to suit your particular purposes.
 COST =E= define objective function COST..  0.225*X(SEATTLE,NEWYORK)  0.153*X(SEATTLE,CHICAGO)  0.162*X(SEATTLE,TOPEKA)  0.225*X(SANDIEGO,NEWYORK)  0.162*X(SANDIEGO,CHICAGO)  0.126*X(SANDIEGO,TOPEKA) + Z =E= 0 ; (LHS = 0)  SUPPLY =L= observe supply limit at plant i SUPPLY(SEATTLE).. X(SEATTLE,NEWYORK) + X(SEATTLE,CHICAGO) + X(SEATTLE,TOPEKA) =L= 350 ; (LHS = 0) SUPPLY(SANDIEGO).. X(SANDIEGO,NEWYORK) + X(SANDIEGO,CHICAGO) + X(SANDIEGO,TOPEKA) =L= 600 ; (LHS = 0)  DEMAND =G= satisfy demand at market j DEMAND(NEWYORK).. X(SEATTLE,NEWYORK) + X(SANDIEGO,NEWYORK) =G= 325 ; (LHS = 0 ***) DEMAND(CHICAGO).. X(SEATTLE,CHICAGO) + X(SANDIEGO,CHICAGO) =G= 300 ; (LHS = 0 ***) DEMAND(TOPEKA).. X(SEATTLE,TOPEKA) + X(SANDIEGO,TOPEKA) =G= 275 ; (LHS = 0 ***)
The equation listing shows the individual constraints that have been generated from the blocks specified in the GAMS input. In GAMS one can write down indexed equation blocks in a very compact form, that will generate a large amount of single equations. In our example we have specified three blocks of equations that generated six single equations.
 X shipment quantities in cases X(SEATTLE,NEWYORK) (.LO, .L, .UP = 0, 0, +INF) 0.225 COST 1 SUPPLY(SEATTLE) 1 DEMAND(NEWYORK) X(SEATTLE,CHICAGO) (.LO, .L, .UP = 0, 0, +INF) 0.153 COST 1 SUPPLY(SEATTLE) 1 DEMAND(CHICAGO) X(SEATTLE,TOPEKA) (.LO, .L, .UP = 0, 0, +INF) 0.162 COST 1 SUPPLY(SEATTLE) 1 DEMAND(TOPEKA) REMAINING 3 ENTRIES SKIPPED  Z total transportation costs in thousands of dollars Z (.LO, .L, .UP = INF, 0, +INF) 1 COST
The column listing gives information on the individual variables that were generated. The variable X(I,J) expands to six single variables. When many variables are generated for one block the default listing shows only the first three (this can be changed by the user).
MODEL STATISTICS BLOCKS OF EQUATIONS 3 SINGLE EQUATIONS 6 BLOCKS OF VARIABLES 2 SINGLE VARIABLES 7 NON ZERO ELEMENTS 19 GENERATION TIME = 0.017 SECONDS EXECUTION TIME = 0.033 SECONDS VERID AXU25085 S O L V E S U M M A R Y MODEL TRANSPORT OBJECTIVE Z TYPE LP DIRECTION MINIMIZE SOLVER BDMLP FROM LINE 47 **** SOLVER STATUS 1 NORMAL COMPLETION **** MODEL STATUS 1 OPTIMAL **** OBJECTIVE VALUE 153.6750 RESOURCE USAGE, LIMIT 0.184 1000.000 ITERATION COUNT, LIMIT 4 1000 B D M L P 1.1  AXP/OSF 1.1.045017 A. Brooke, A. Drud, and A. Meeraus, Analytic Support Unit, Development Research Department, World Bank, Washington, D.C. 20433, U.S.A. EXIT  OPTIMAL SOLUTION FOUND.
The solve statement will generate the model (creation of single equations and variables corresponding to the specified model). First some statistics about the generated model are printed: number of equations, variables and nonzero elements.
In the solve summary we see that BDMLP is called to solve this model. BDMLP found an optimal solution to this problem in 4 iterations and 0.184 seconds. The messages following the solve summary are coming from the solver.
LOWER LEVEL UPPER MARGINAL  EQU COST . . . 1.000 COST define objective function  EQU SUPPLY observe supply limit at plant i LOWER LEVEL UPPER MARGINAL SEATTLE INF 350.000 350.000 EPS SANDIEGO INF 550.000 600.000 .  EQU DEMAND satisfy demand at market j LOWER LEVEL UPPER MARGINAL NEWYORK 325.000 325.000 +INF 0.225 CHICAGO 300.000 300.000 +INF 0.153 TOPEKA 275.000 275.000 +INF 0.126  VAR X shipment quantities in cases LOWER LEVEL UPPER MARGINAL SEATTLE .NEWYORK . 50.000 +INF . SEATTLE .CHICAGO . 300.000 +INF . SEATTLE .TOPEKA . . +INF 0.036 SANDIEGO.NEWYORK . 275.000 +INF . SANDIEGO.CHICAGO . . +INF 0.009 SANDIEGO.TOPEKA . 275.000 +INF . LOWER LEVEL UPPER MARGINAL  VAR Z INF 153.675 +INF . Z total transportation costs in thousands of dollars **** REPORT SUMMARY : 0 NONOPT 0 INFEASIBLE 0 UNBOUNDED
The solution is printed here. The marginals correspond to the duals for the equations and to the reduced costs for the variables.
GAMS provides many more facilities to tailor the output to your needs and to generate managementstyle reports. In order to use the advanced report writing facilities of GAMS you don't need to learn yet another language. In GAMS both data manipulation, model specification and report writing is done in one single environment.
Dantzig G. B., Linear Programming and Extensions, Princeton University Press, Princeton, New Jersey, 1963, Chapter 33.