1 / 9

How to get started with GAMS

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

mervin
Download Presentation

How to get started with GAMS

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How to get started with GAMS MS&E 348 – Lecture 1/20/04

  2. 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

  3. Some GAMS References • www.gams.com • 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) Seattle New York Chicago San Diego Topeka

  4. Structure of a GAMS model Output Input file_name.lst file_name.gms Sets Echo Print Data Reference Maps Variables Equation Listings Equations Status Reports Model specification Results Solve statement

  5. Program Listing 1/3 * Instance of the transportation problem * From R. Rosenthal's GAMS Tutorial 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 /;

  6. 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; variables x(i,j) shipment quantities in cases z total transportation costs in 1000s of dollars; positive variable x;

  7. Program Listing 3/3 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; display x.l, x.m;

  8. Implementation • 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 becomes • a$(b > 1.5) = 2; • This operator is very useful to handle exceptions

  9. 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!

More Related