how to get started with gams n.
Skip this Video
Loading SlideShow in 5 Seconds..
How to get started with GAMS PowerPoint Presentation
Download Presentation
How to get started with GAMS

Loading in 2 Seconds...

play fullscreen
1 / 9

How to get started with GAMS - PowerPoint PPT Presentation

  • Uploaded on

How to get started with GAMS. MS&E 348 – Lecture 1/20/04. GAMS Basics. The General Algebraic Modeling System (GAMS) is a high-level modeling system for mathematical programming problems It consists of a language compiler and a stable of integrated high-performance solvers

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'How to get started with GAMS' - mervin

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
how to get started with gams

How to get started with GAMS

MS&E 348 – Lecture 1/20/04

gams basics
GAMS Basics
  • The General Algebraic Modeling System (GAMS) is a high-level modeling system for mathematical programming problems
  • It consists of a language compiler and a stable of integrated high-performance solvers
  • GAMS is tailored for complex, large scale modeling applications, and allows you to build large maintainable models that can be adapted quickly to new situations
some gams references
Some GAMS References
  • A User’s Guide by Brooke et al.
    • GAMS Tutorial by Rosenthal (ch. 2 of above)

Transportation Problem

Canning plants /

Capacity a(i)

Markets /

Demand b(j)

Transport cost c(i,j)


New York


San Diego


structure of a gams model
Structure of a GAMS model






Echo Print


Reference Maps


Equation Listings


Status Reports

Model specification


Solve statement

program listing 1 3
Program Listing 1/3

* Instance of the transportation problem

* From R. Rosenthal's GAMS Tutorial


i canning plants / seattle, san-diego /

j markets / new-york, chicago, topeka /;


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 /;

program listing 2 3
Program Listing 2/3

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 1000 miles / 90 /;

parameter c(i,j) transport cost in 1000s of dollars per case;

c(i,j) = f*d(i,j)/1000;


x(i,j) shipment quantities in cases

z total transportation costs in 1000s of dollars;

positive variable x;

program listing 3 3
Program Listing 3/3


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;

display x.l, x.m;

  • From Leland account
    • Type input file in standard text editor (emacs, etc.)
    • Run with following command:/usr/sweet/apps/gams-2.50/gams file_name.gms
  • Programming styles
    • Data -> Model -> Solution
    • Model -> Data -> Solution
  • General remarks
    • Distinguish between ‘declaration’ and ‘assignment’ or ‘definition’
    • An entity of the model cannot be referenced before it is declared to exist
  • Useful feature not discussed in the tutorial: the ‘dollar’ operator
    • This powerful feature of GAMS operates with a logical condition $(condition), which can be read as ‘such that condition is valid’
    • Example:
      • If (b > 1.5) then a = 2


      • a$(b > 1.5) = 2;
    • This operator is very useful to handle exceptions
other remarks
Other Remarks
  • Documentation is crucial. It is returned in the output file
  • Compiler options can be used

Example of line: $include file_name

  • Advantage of GAMS over Fortran or C: values can be assigned without ‘do loops’
  • Key idea is that the definition of the constraints is exactly the same regardless of the size of the problem: the user just enters equations algebraically and GAMS creates the specific equations appropriate for the model at hand
  • Don’t get confused by error messages!
  • Read the output file!
  • Equation listings are useful for checking the model
  • Don’t wait to get started!