Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "How to get started with GAMS MS&E 348 – Lecture 1/20/04."— 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) Seattle San DiegoTopeka New York Chicago Canning plants / Capacity a(i) Markets / Demand b(j) Transport cost c(i,j) Transportation Problem

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

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!


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

Similar presentations


Ads by Google