Download presentation
Presentation is loading. Please wait.
1
GAMS/GAMSIDE AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl and improved upon by previous lab instructors. Special thanks to Yuquan “Wolfgang” Zhang 1
2
Overview 1.Introduction to GAMS/GAMSIDE 2.Formulation of a General Problem 3.Model Inspection & Error Message 4.Power of GAMS 5.Examining A Model for Flaws 6.Good Modeling Practices 2
3
Overview 7.GAMS Check: Pre/Post Solution Analysis 8.Comparative Analysis: Multiple Submissions and Loops 9.Conditionals 10.Output Improvement and Management 11.Topics 3
4
What is GAMS? Generalized Algebraic Modeling System Programming language for setting up and solving optimization models All-In-One Package that allows to Specify the structure of an optimization model Specify and calculate data that go into the model Solve that model Conduct report writing on a model Perform a comparative static analysis 4
5
Formulation of A Simple Problem Max St. 5
6
Steps 1. Variable specifications 2. Equation specification Declaration Algebraic structure specification 3. Model statement 4. Solve statement 6
7
7
8
Variable specifications 8
9
Variable Specification VariableUnrestricted variables Positive VariableNonnegative Binary Variable0 or 1 Integer Variable0, 1, 2, …, 9999 9
10
Variable Specification GAMS requires variables in each problem to be identified. In the example, we have variables utility (variable), and bread, meat, and wine (positive variables) max CX should become max Z, where Z=CX. Variable name can be up to 64 characters and can have explanatory text. 10
11
Equation specification Declaration Algebraic structure specification 11
12
Equation Specification Algebraic form involves use of a special syntax to tell the exact form of the equation SyntaxExplanation =E=Indicates an equality constraint =L=Indicates a less than or equal to constraint =G=Indicates a greater than or equal to constraint 12
13
Model Statement 13
14
Model Statement Identify models to be solved. 1. Name the model 2. Specify equations that will be included in the model in slashes / / 14
15
Solve Statement 15
16
Solve Statement Causes GAMS to apply a solver to the model and use the data defined SOLVE statementNotes SOLVE Consumption USING LP Maximizing Utility; LP Max SOLVE Consumption USING LP Minimizing Disutility ; LP Min SOLVE Consumption USING MIP Maximizing Utility; Mixed Integer Programming SOLVE Consumption USING NLP Maximizing Utility; Non-linear Programming 16
17
Semi-Colons ; Each command line must terminate with a ; Statements may be several lines long or may contain several elements Omission would lead to (many) Syntax Errors! 17
18
Solution Reports When GAMS is run the output is automatically place in the so called LST file – Example01.gms Example01.lst LST file contains a number of components 1.The echo print 2.Display of the list of symbols in the GAMS program - symlist 3.Display of some equations an variables – limrow/limcol 4.Report on model size and execution time 5.Model solution and solver characteristics 6.List of user generated display output 18
19
Solution Reports 19
20
20 GAMS Output Variables : values under lower and upper refer to bounds.
21
21 Equations : values under lower and upper are from RHS and relational type of equations. GAMS Output
22
Type.LO.UP.L =E=RHS AX=b =L=-INFRHSAXAX≤b =G=RHSINFAXAX≥b 22
23
GAMSIDE Project *.gpr: GAMS project file. *.gms: GAMS file where to write program codes. *.lst: GAMS output file generated AFTER the model runs. *.log: GAMS log file generated WHILE the model runs. 23
24
Hands On 1 Feeding Problem Create HandsOn1.gms with “* your name” on the first line of the code. Turn in an electronic copy of *.gms file and a hard copy of *.lst file (from solution report to the end). What if the corn price goes up to $6? Turn in a hard copy of *.lst file (from solution report to the end). 24
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.