gams user guide

950
McCarl GAMS User Guide Version 24.4 Bruce A. McCarl Regents Professor of Agricultural Economics Texas A&M University  Alex M eeraus Paul van der E ijk Mi chael Bussiec k Steven Dirkse Pete Steacy Franz Nelissen GAMS Development Corporation

Upload: daniel-zamudio

Post on 05-Jul-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

Texas A&M University
Steven Dirkse Pete Steacy
8/16/2019 Gams User Guide
................................................................................................................................... 32   Introduction
................................................................................................................................... 41  Basic models
.......................................................................................................................................................... 5Solving for an economic equilibrium
.......................................................................................................................................................... 6Solving a nonlinear equation system
................................................................................................................................... 72  Dissecting the simple models
.......................................................................................................................................................... 7Variables ......................................................................................................................................................... 8What is the new Z var iable in the optimization problem?
.......................................................................................................................................................... 9Equations
.......................................................................................................................................................... 14What are the .L items
................................................................................................................................... 143  Running the job
.......................................................................................................................................................... 15Comm and line approach
.......................................................................................................................................................... 18Generation listing
......................................................................................................................................................... 18Equation listing
......................................................................................................................................................... 19Variable listing
......................................................................................................................................................... 21Model statistics
.......................................................................................................................................................... 21Execution output
.......................................................................................................................................................... 27Revised e quilibrium example
.......................................................................................................................................................... 29Sets
......................................................................................................................................... 33 Algebra and model .. specifications
.......................................................................................................................................................... 34Output differences
......................................................................................................................................................... 34Equation listing
......................................................................................................................................................... 35Variable list
................................................................................................................................... 399  Adding complexity
......................................................................................................................................................... 40Conditionally add a term in sum or other set operation
......................................................................................................................................................... 40Conditionally define an equation
.......................................................................................................................................................... 40Displaying data
.......................................................................................................................................................... 44Use of algebraic modeling
.......................................................................................................................................................... 47Adding report writing
.......................................................................................................................................................... 47Self-docume nting nature
.......................................................................................................................................................... 49Model library and widespread professional use
.......................................................................................................................................................... 49Use by Others
.......................................................................................................................................................... 49Ease of use w ith NLP, MIP, CGE and other pr oblem forms
.......................................................................................................................................................... 49Interface with other packages
................................................................................................................................... 501 Sets
.......................................................................................................................................................... 50Set declaration
.......................................................................................................................................................... 52Singleton Sets
.......................................................................................................................................................... 57Multi dimensional sets
......................................................................................................................................... 60Using subsets
......................................................................................................................................... 60Using conditionals
.......................................................................................................................................................... 63Universal Set: * as a set identifier
.......................................................................................................................................................... 64Using set attributes
.......................................................................................................................................................... 66Using another nam e or an alias
.......................................................................................................................................................... 67Element order and capitalization in output
.......................................................................................................................................................... 67Functions specifically referencing se ts
......................................................................................................................................................... 67Ord
......................................................................................................................................................... 70Leads and Lags: + / -
......................................................................................................................................................... 71Element Position
.......................................................................................................................................................... 71Set Arithmetic
.......................................................................................................................................................... 78Variables
......................................................................................................................................................... 78Variable Declaration......................................................................................................................................................... 80Variable attributes
.......................................................................................................................................................... 82Equation
......................................................................................................................................................... 94 Actions on executing solve
......................................................................................................................................................... 95Programs w ith multiple solve statements ......................................................................................................................................... 96Multiple solve management - merge replace
......................................................................................................................................................... 97Choosing a solver 
.......................................................................................................................................................... 97Model Types
8/16/2019 Gams User Guide
......................................................................................................................................................... 102Relaxed mixed integer nonlinear program (RMINLP)
......................................................................................................................................................... 103Mixed integer quadratically constrained program (MIQCP)
......................................................................................................................................................... 103Relaxed mixed integer quad. constrain program (RMIQCP)
......................................................................................................................................................... 104Constrained nonlinear systems (CNS)
......................................................................................................................................................... 106Relaxed mathematical program w ith equilibrium constraints (RMPEC)
......................................................................................................................................................... 106Extended Mathematical Programs (EMP)
......................................................................................................................................................... 108General notes on solver vers ions
......................................................................................................................................................... 108 Available solvers
.......................................................................................................................................................... 135Output overview and navigation
.......................................................................................................................................................... 138Compilation phase output
......................................................................................................................................... 139Compilation phase error messages
......................................................................................................................................................... 149Model generation error listing
......................................................................................................................................... 157Including slacks in the output
......................................................................................................................................................... 157Ranging analys is
......................................................................................................................................................... 162Final execution summary
......................................................................................................................................................... 163New pages
.......................................................................................................................................................... 164Managing output volume
......................................................................................................................................................... 164Eliminate model listing
.......................................................................................................................................................... 165Adding slack variables to the output
.......................................................................................................................................................... 166Sending messages to the LOG file
................................................................................................................................... 1666   Writing Models and Good Modeling Practices
.......................................................................................................................................................... 166Formatting models - my recommendations
......................................................................................................................................... 168Basic point
......................................................................................................................................................... 170Entering raw versus calculated data
......................................................................................................................................................... 170 Avoiding use of * in input data set specification
......................................................................................................................................................... 171Making sets w ork for you
......................................................................................................................................................... 171Making subsets w ork for you
......................................................................................................................................................... 172Formatting the typing of files to improve model readability
......................................................................................................................................................... 174Other possible conventions
................................................................................................................................... 1751  Licenses on IDE
................................................................................................................................... 1752   Licenses outside of IDE—Windows and Unix/Linux
Chapter V Running Jobs with GAMS and the GAMS IDE   176
................................................................................................................................... 1761   Basic approaches to GAMS usage
................................................................................................................................... 1762   Running GAMS from the command line
................................................................................................................................... 1773  IDE concept and usage
.......................................................................................................................................................... 178Steps to us ing IDE
......................................................................................................................................................... 178Create a project ......................................................................................................................................... 178Defining a project name and location.
......................................................................................................................................... 179Creating or opening an existing GMS file
......................................................................................................................................................... 180Preparing file for execution
......................................................................................................................................................... 181Select default IDE functions
......................................................................................................................................... 182Make IDE the default GMS f ile processor 
......................................................................................................................................................... 182Run GAMS by clicking the run button
......................................................................................................................................................... 184Open and navigate around the output
......................................................................................................................................... 185Using the process w indow
8/16/2019 Gams User Guide
................................................................................................................................... 189Finding the Active Location
.......................................................................................................................................................... 191Fixing compilation errors
......................................................................................................................................... 194Search menu and find in files
......................................................................................................................................................... 195Matching parentheses
......................................................................................................................................................... 198Help on the IDE
......................................................................................................................................................... 202 Adding your ow n documentation
......................................................................................................................................................... 203 Accessing documentation outside the IDE
.......................................................................................................................................................... 203Unraveling complex files: Refreader
.......................................................................................................................................................... 213When is it not worth us ing?
.......................................................................................................................................................... 213Employing command line paramete rs
.......................................................................................................................................................... 214A difficulty you w ill have using IDE
.......................................................................................................................................................... 214Installation
......................................................................................................................................................... 215On Window s machines make IDE icon
......................................................................................................................................................... 215On Linux/Unix run Gamsinst
......................................................................................................................................................... 217Unpacking sof tw are on Window s machines
Chapter VI Fixing Compilation Errors   217
................................................................................................................................... 2171   Don’t bark up the wrong tree
................................................................................................................................... 2172  Finding errors: ****
................................................................................................................................... 2183  Finding errors: $
................................................................................................................................... 2195   Improperly placed semi colons - error A
................................................................................................................................... 2206  Error message proliferation
................................................................................................................................... 2218  Other common errors
.......................................................................................................................................................... 222Excess or insufficient s em i colons - e rror B
.......................................................................................................................................................... 222Spelling mistakes - error C
8/16/2019 Gams User Guide
.......................................................................................................................................................... 225Neglecting to deal with sets - err or G
.......................................................................................................................................................... 225Mismatched parentheses - error H
.......................................................................................................................................................... 227Entering imprope r nonlinear expressions - e rror J
.......................................................................................................................................................... 228Using undefined data - error K
.......................................................................................................................................................... 229Improper refer ences to individual set elem ents - e rror L
.......................................................................................................................................................... 230No variable, parameter , or equation definition - error M
.......................................................................................................................................................... 230Duplicate names - er ror N
.......................................................................................................................................................... 231Referencing item with w rong set - error O
.......................................................................................................................................................... 231ORD on an unordere d se t - e rror P
Chapter VII More Language Basics   232
................................................................................................................................... 2331   Rules for Item Names, Element Names and Explanatory Text
.......................................................................................................................................................... 233Item name rules
.......................................................................................................................................................... 238In line comments
.......................................................................................................................................................... 240Hidden comments
......................................................................................................................................................... 243= replacement or .. statements
......................................................................................................................................................... 243Sum , Smax, Smin, Prod
......................................................................................................................................... 246Multiple sets
......................................................................................................................................................... 248Sets
......................................................................................................................................................... 248Data
......................................................................................................................................................... 252Mixing logical expressions, sets and numbers
......................................................................................................................................................... 253Functions
................................................................................................................................... 267String manipulation functions: Ord, Ordascii, Ordebcdic
................................................................................................................................... 268String manipulation functions: Card
................................................................................................................................... 275Random Numbers from Functions
................................................................................................................................... 282Defining an Extrinsic Function
......................................................................................................................................... 284 Attributes of variables and equations
................................................................................................................................... 284L
................................................................................................................................... 285M
................................................................................................................................... 286Lo
................................................................................................................................... 286.range
................................................................................................................................... 287Up
................................................................................................................................... 287Fx
................................................................................................................................... 288Scale
................................................................................................................................... 289Prior 
.......................................................................................................................................................... 291Adding report writing
......................................................................................................................................................... 292 Adding a report
.......................................................................................................................................................... 294Using displays
......................................................................................................................................................... 294 Abort
......................................................................................................................................... 299Controlling item order ing
.......................................................................................................................................................... 300Reordering set orde r in output
.......................................................................................................................................................... 301Preprogramm ed table m aking utility: Gams 2tbl
.......................................................................................................................................................... 302Output to other programs
.......................................................................................................................................................... 307Item capitalization
.......................................................................................................................................................... 308Set elem ent order
.......................................................................................................................................................... 311Basic forms of conditionals
................................................................................................................................... 314Controlling indices in sums etc
................................................................................................................................... 315Suppressing model equations (left hand side)
................................................................................................................................... 316Conditionally displaying information
.......................................................................................................................................................... 318Forms of conditional / logical true false statem ents
......................................................................................................................................................... 318Numerical comparisons
......................................................................................................................................... 323Computation over a set
......................................................................................................................................... 324Element tex t comparison: Sameas and Diag
......................................................................................................................................... 325Subset or tuple membership
................................................................................................................................... 330Note of caution
................................................................................................................................... 3327  Control Structures
......................................................................................................................................................... 341 Alternative syntax ......................................................................................................................................... 341Endfor 
................................................................................................................................... 3431  Basic approaches
................................................................................................................................... 3432  Manual approach
......................................................................................................................................................... 347Percentage change cross scenario reports
.......................................................................................................................................................... 348Preser ving changed data
.......................................................................................................................................................... 352Adding a scenario
................................................................................................................................... 3551  Important parameters
.......................................................................................................................................................... 357Solver nam e choice
.......................................................................................................................................................... 358Option file prese nce
.......................................................................................................................................................... 362User defined options
.......................................................................................................................................................... 364-- // -/ /-- on comm and lines
.......................................................................................................................................................... 364Action: A
.......................................................................................................................................................... 365Appendexpand: Ae
.......................................................................................................................................................... 365Appendlog: Al
.......................................................................................................................................................... 365Appendout: Ao
.......................................................................................................................................................... 384Integer1 to Integer5
.......................................................................................................................................................... 409Warnings
................................................................................................................................... 4111  Save Restart Basics
.......................................................................................................................................................... 412Save: S
.......................................................................................................................................................... 412Restart: R
.......................................................................................................................................................... 413Xsave: Xs
................................................................................................................................... 4132   Use of save and restarts and their effect .......................................................................................................................................................... 413Save and res tart on comm and line
.......................................................................................................................................................... 414IDE usage
................................................................................................................................... 4153   Why use save and restart?
.......................................................................................................................................................... 415Increasing run efficiency
.......................................................................................................................................................... 417Fast re lated solutions
Chapter XI Customizing GAMS   417 ................................................................................................................................... 4181   What types of options are there?
................................................................................................................................... 4182   Possible command line parameters to customize
................................................................................................................................... 4193   How can these options be set?
.......................................................................................................................................................... 419To se t in comm and line via pf=
.......................................................................................................................................................... 420To set in Gmsprm xx.txt paramete r file
.......................................................................................................................................................... 421To set in IDE
8/16/2019 Gams User Guide
Chapter XII Finding and Fixing Errors or Performance Problems   438
................................................................................................................................... 4391  Fixing Execution Errors
.......................................................................................................................................................... 439GAMS limit e rrors
.......................................................................................................................................................... 442Execution er rors during mode l generation
.......................................................................................................................................................... 443Execution er rors during model solution
......................................................................................................................................................... 444Solver function evaluation errors
......................................................................................................................................... 445Repair 
......................................................................................................................................... 448No feasible continuous solution
......................................................................................................................................................... 449Solver specific limits .......................................................................................................................................................... 449Basing conditionals on num ber of err ors
.......................................................................................................................................................... 450Clearing error conditions
......................................................................................................................................................... 454Example of scaling
.......................................................................................................................................................... 458How do you know how much to scale?
.......................................................................................................................................................... 458A caution w hen s caling – runaway cases
.......................................................................................................................................................... 459User defined data scaling
.......................................................................................................................................................... 460Basics
.......................................................................................................................................................... 463Steps for working from small to large.
.......................................................................................................................................................... 463Making small parts of large mode ls
......................................................................................................................................................... 463Save and restart to isolate problem areas
......................................................................................................................................................... 464Strategic sub-setting
......................................................................................................................................................... 465Data reduction
......................................................................................................................................................... 467Profile
................................................................................................................................... 468Invoking profile
................................................................................................................................... 469In the IDE GAMS parameters box
................................................................................................................................... 469 As an internal option
................................................................................................................................... 469What should the number be
................................................................................................................................... 469Limiting profile output: Profiletol
.......................................................................................................................................................... 471Why programs can be slow and their repair
......................................................................................................................................................... 471Set addressing and references
......................................................................................................................................... 473Calculation statements
......................................................................................................................................... 475Equation term consideration limited using conditions
......................................................................................................................................... 475Variable specification - suppression
.......................................................................................................................................................... 476Trading mem ory for time
.......................................................................................................................................................... 477Other spee d ups
......................................................................................................................................................... 479Profile
................................................................................................................................... 481Invoking profile
................................................................................................................................... 481In the IDE GAMS parameters box
................................................................................................................................... 481 As an internal option
................................................................................................................................... 481What should the profile number be
................................................................................................................................... 482Limiting profile output: Profiletol
......................................................................................................................................................... 482Memory use dumps: Dmpsym
......................................................................................................................................................... 484Looking w ithin memory hogs to f ind offending term
......................................................................................................................................................... 484My code w on’t w ork - searching
.......................................................................................................................................................... 485Causes of excessive m em ory use and repair
......................................................................................................................................................... 486 Avoiding considering unnecessary cases
......................................................................................................................................... 486Calculation statements
......................................................................................................................................... 487Variable specification - suppression
......................................................................................................................................... 488Memory traps to w atch out for 
......................................................................................................................................................... 488Clearing memory of unnecessary items
.......................................................................................................................................................... 489Limiting memory use with HeapLimit
Chapter XIII More Language Features   489 ................................................................................................................................... 4891  Including External Files
.......................................................................................................................................................... 489Inclusion without arguments
.......................................................................................................................................................... 493Redefining the location of include files - Idir
.......................................................................................................................................................... 493Include with arguments
......................................................................................................................................................... 496$Libinclude
......................................................................................................................................... 497Ldir 
......................................................................................................................................................... 497$Sysinclude
......................................................................................................................................... 497Sdir 
.......................................................................................................................................................... 497Influence on LST file contents: $Oninclude and $Offinclude
.......................................................................................................................................................... 498Passing $ commands betw een code se gme nts: $Onglobal and $Offglobal
.......................................................................................................................................................... 498Special provision for CSV files
......................................................................................................................................................... 498$Ondelim and $Off delim
.......................................................................................................................................................... 501Categories of $ commands
......................................................................................................................................................... 502LST and other output file contents control
......................................................................................................................................................... 503Ways of including external files
......................................................................................................................................................... 504Contents dependent compilation
......................................................................................................................................................... 505GDX file read/w rite
......................................................................................................................................................... 505 Alter compiler procedures
......................................................................................................................................................... 506Restrict access to data
.......................................................................................................................................................... 508Detailed description of dollar com mands
......................................................................................................................................................... 509$$
......................................................................................................................................................... 520Ifthen, Iftheni, Ifthene, Else, Elseif, Elseifi, Elseife, Endif 
......................................................................................................................................................... 521Include
......................................................................................................................................................... 521Inlinecom
......................................................................................................................................................... 522Kill
......................................................................................................................................................... 522Label
......................................................................................................................................................... 523Libinclude
......................................................................................................................................................... 523Lines
......................................................................................................................................................... 523Load
......................................................................................................................................................... 524Loaddc
......................................................................................................................................................... 525Loaddcm
......................................................................................................................................................... 525Loaddcr 
......................................................................................................................................................... 525Loadm
......................................................................................................................................................... 526Loadr 
......................................................................................................................................................... 527Log
......................................................................................................................................................... 527Macro
......................................................................................................................................................... 527Maxcol
......................................................................................................................................................... 528Maxgoto
......................................................................................................................................................... 528Mincol
......................................................................................................................................................... 538Onrecurse and Off recurse
......................................................................................................................................................... 541Phantom
......................................................................................................................................................... 542Prefixpath
......................................................................................................................................................... 542Protect
......................................................................................................................................................... 542Purge
......................................................................................................................................................... 543Remark
......................................................................................................................................................... 551Options including debugging information in LST file
......................................................................................................................................................... 552Options influencing LST file contents
......................................................................................................................................................... 552Options inf luencing solver function
......................................................................................................................................................... 552Other options altering GAMS settings
......................................................................................................................................................... 553Options affecting data for items in memory
......................................................................................................................................................... 553Options that form projections of data items
.......................................................................................................................................................... 553Description of options
......................................................................................................................................................... 554Option itemname < or <= itemname2
Chapter XIV Advanced Language Features   567 ................................................................................................................................... 5671  Macros in GAMS
................................................................................................................................... 5712  Output via Put Commands
.......................................................................................................................................................... 571Basics of put
......................................................................................................................................................... 574File
......................................................................................................................................... 575Sending output to the SCREEN
......................................................................................................................................................... 576Put
................................................................................................................................... 577Quoted text
................................................................................................................................... 578Set elements
................................................................................................................................... 579Set element explanatory text via .te and .tf 
................................................................................................................................... 581Putting out set elements for parameters via .Tn
................................................................................................................................... 581Item explanatory text via .ts
................................................................................................................................... 582Numeric items
................................................................................................................................... 582Parameter values
.Tsolstat
................................................................................................................................... 586System attributes
................................................................................................................................... 592Other positioning parameters
................................................................................................................................... 596.Ap
................................................................................................................................... 599Puttl
................................................................................................................................... 600Puthd
................................................................................................................................... 601Putclear 
................................................................................................................................... 602Width and decimal formatting
................................................................................................................................... 603.Nd number of decimals
................................................................................................................................... 604.Nw number w idth
................................................................................................................................... 606.Tw explanatory and quoted text w idth
................................................................................................................................... 607Local formatting
................................................................................................................................... 609Justification
................................................................................................................................... 611nj number justification
................................................................................................................................... 614Local formatting
................................................................................................................................... 616.nr 
................................................................................................................................... 616.nz
......................................................................................................................................... 617Putclose
......................................................................................................................................... 618Putpage
.......................................................................................................................................................... 618Putting out a block of text: $onput, $offput, $onputs, $onputv
.......................................................................................................................................................... 619Making puts conditional
.......................................................................................................................................................... 621Errors that arise during puts
................................................................................................................................... 6223   Acronyms
.......................................................................................................................................................... 630Environment variables
......................................................................................................................................................... 632 Augmenting environment variables
......................................................................................................................................................... 633 Accessing environment variable status at any point in the code: $Show
.......................................................................................................................................................... 633$If and $Ifi conditionals
......................................................................................................................................................... 633$If and $If i
.......................................................................................................................................................... 639Forms of conditionals
......................................................................................................................................... 639Existence
......................................................................................................................................... 641Contents
......................................................................................................................................... 644Item type
......................................................................................................................................... 646Set dependency: Dimension
......................................................................................................................................................... 648Passed parameter existence
......................................................................................................................................................... 649Based on system characteristics
......................................................................................................................................................... 651Based on file or directory existence
......................................................................................................................................................... 651Based on put f ile status
.......................................................................................................................................................... 651Incorporating Goto: $Goto and $Label
.......................................................................................................................................................... 652Redefining expressions ......................................................................................................................................................... 653System attributes that can be included
......................................................................................................................................................... 654GAMS command line attributes that can be included
......................................................................................................................................... 654Based on user options and command line: -- // -/ /- User1-5
......................................................................................................................................................... 656Passed parameter inclusion
......................................................................................................................................................... 656Control variable inclusion
......................................................................................................................................................... 656$Call
......................................................................................................................................................... 657Execute
......................................................................................................................................................... 657Shellexecute
......................................................................................................................................................... 657$Setargs
......................................................................................................................................................... 657LST File: $Abort and $Error 
......................................................................................................................................................... 657LOG file: $Log
.......................................................................................................................................................... 658End the job: $Exit, $Abort, $Error, $Stop, $Terminate
.......................................................................................................................................................... 659Longer examples
......................................................................................................................................................... 660Changing form of data in model and their use
......................................................................................................................................................... 661Having batincludes that deal w ith different data types
......................................................................................................................................................... 663For more examples
Chapter XV Using GAMS Data Exchange or GDX Files   663
8/16/2019 Gams User Guide
................................................................................................................................... 6631   Creating a GDX file in GAMS
.......................................................................................................................................................... 664Comm and line GDX option - GDX dump of the w hole problem
.......................................................................................................................................................... 665GDX Point Solution file
......................................................................................................................................................... 666Execution time selected item GDX file creation
......................................................................................................................................................... 667Compile time selected item GDX file creation ................................................................................................................................... 6682   Inputting data from a GDX file into GAMS
.......................................................................................................................................................... 669Compile time im ports from GDX files
.......................................................................................................................................................... 671Execution time GDX imports
................................................................................................................................... 6754   Identifying contents of a GDX file
.......................................................................................................................................................... 675Identifying contents with $Load
.......................................................................................................................................................... 678Identifying contents with Gdxdump
................................................................................................................................... 6825  Merging GDX files
.......................................................................................................................................................... 684Spreadsheets
.......................................................................................................................................................... 685GEMPACK
.......................................................................................................................................................... 685Other
................................................................................................................................... 6868   Writing older GDX versions with GDXCONVERT
Chapter XVI Links to Other Programs Including Spreadsheets   687
................................................................................................................................... 6871  Executing an external program
.......................................................................................................................................................... 688$Call
.......................................................................................................................................................... 690Execute
.......................................................................................................................................................... 691Put_utility
................................................................................................................................... 6972   Passing data from GAMS to other programs
.......................................................................................................................................................... 697Put file data passage
.......................................................................................................................................................... 699Rutherford's CSV put: Gams2csv
.......................................................................................................................................................... 706Gdxrrw
.......................................................................................................................................................... 706Gdxview er links: Access , Excel pivot table, Excel, CSV, GAMS include, HTML, Text files , Plots, XML
.......................................................................................................................................................... 707Other programs and convers ions: Convert, DB2, FLM2GMS, GAMS2TBL, HTML, Latex, MPS, Oracle, XML
................................................................................................................................... 7083   Passing data from other programs to GAMS
.......................................................................................................................................................... 708Including data
......................................................................................................................................................... 711XLSDUMP
................................................................................................................................... 7154  API usage
................................................................................................................................... 7155   Other programs: DB2, Latex, GNETGEN, Gnuplot, Matlab, MPS, NETGEN, Oracle
................................................................................................................................... 7166   Customized data interchange links for spreadsheets
.......................................................................................................................................................... 716Xlexport, Xldump, Xlimport
......................................................................................................................................... 724Data specification
................................................................................................................................... 733Examples
................................................................................................................................... 733Loading columns of set elements
................................................................................................................................... 734Loading set elements only if they have data or text
................................................................................................................................... 734Writing set elements
................................................................................................................................... 735Loading by upper left hand corner 
................................................................................................................................... 735Loading sets from data tables
................................................................................................................................... 736Loading sets f rom lists w ith duplicates
................................................................................................................................... 736Dealing w ith a tuple
................................................................................................................................... 737Execution time set reads
................................................................................................................................... 738Parameter data: Par 
................................................................................................................................... 741Variable and equation data: Equ and Var 
......................................................................................................................................... 742Special options for reading from a spreadsheet: Skipempty= and Se=
......................................................................................................................................... 744Special options for w riting to a spreadsheet
................................................................................................................................... 744Is the w orkbook open or shared?
8/16/2019 Gams User Guide
................................................................................................................................... 748Epsout
................................................................................................................................... 748Naout
................................................................................................................................... 748Minfout
................................................................................................................................... 748Pinfout
................................................................................................................................... 748Undfout
................................................................................................................................... 748Zeroout
................................................................................................................................... 749Squeeze
................................................................................................................................... 749Resetout
......................................................................................................................................... 749Command line parameters in a file
......................................................................................................................................... 750Parameters in a spreadsheet
......................................................................................................................................................... 759Calling GAMS from GAMS
.......................................................................................................................................................... 763Building the external function evaluator
Chapter XVII Controlling GAMS from External Programs   763
................................................................................................................................... 7641   Calling GAMS from other programs
.......................................................................................................................................................... 764Excel spreadshe et in charge
......................................................................................................................................................... 765Excel part of implementation
......................................................................................................................................... 767Worksheets present
................................................................................................................................... 770Critical user defined items
......................................................................................................................................... 771Examining the macros
.......................................................................................................................................................... 776Excel Spawning Alternative
......................................................................................................................................................... 776 A Delphi example
......................................................................................................................................... 777Steps in application development
......................................................................................................................................... 778Passing data to GAMS
.......................................................................................................................................................... 780Web servers or program s in other languages in charge
................................................................................................................................... 7802   Transferring models to other systems
Chapter XVIII Utilities included in GAMS   781
................................................................................................................................... 7811  Posix utilities
................................................................................................................................... 7852  Matrix Utilities
................................................................................................................................... 7904  GDX Utilities
................................................................................................................................... 8051   Basics
.......................................................................................................................................................... 805Telling a solver to look for an options file: .Optfile
.......................................................................................................................................................... 805Option file name
................................................................................................................................... 8062  Option file contents
................................................................................................................................... 8105   Learning about options: Solver manuals
................................................................................................................................... 8106   Default settings for Optfile
8/16/2019 Gams User Guide
.......................................................................................................................................................... 829Default bounds
.......................................................................................................................................................... 830Ending w ith a gap – big default for Optcr (10%)
.......................................................................................................................................................... 830The nonending quest
................................................................................................................................... 8311   Terminology
.......................................................................................................................................................... 838Model setup output
................................................................................................................................... 8414  NLP and MCP variants
................................................................................................................................... 8415   Solvers
................................................................................................................................... 8411  Attribute addressing
.......................................................................................................................................................... 848Marginals
Chapter XXIV Application Help: Model Library, Web Sites, Documentation   851
................................................................................................................................... 8511  Libraries
.......................................................................................................................................................... 858Installation
.......................................................................................................................................................... 862User generated materials
.......................................................................................................................................................... 862Courses and workshops
Chapter XXVI Grid Computing   864
................................................................................................................................... 8651   Grid Computing language features
................................................................................................................................... 8692   grid_example
Chapter XXVIII Licensing   870
McCarl Expanded GAMS User Guide Version 24.5
by  
Texas A&M University
Steven Dirkse Pete Steacy
8/16/2019 Gams User Guide
© 2015 Prof. Bruce McCarl 
1.1 Forword
The General Algebraic Modeling System (GAMS) is a high-level modeling system for mathematical programming problems. This document is a guide to GAMS language elements. The coverage in this document is as complete as possible for developments up to GAMS release 24.4.3 GAMS generated information on subsequent releases can be found on Release Notes.
The guide is designed to provide a smart document with many hyperlinks. When you click on those they will move you to related places in the document or open up example GMS files.
The document is organized into the sections identified below; an index is also present. For those wishing a printable copy as of now it is typically on C:\GAMS\win64\GAMS24.5\docs\userguides\mccarl
\index.html or here.
Quick Start Tutorial
Model Types and Solvers
Writing Models and Good Modeling Practices
Running Jobs with GAMS and the GAMS IDE Fixing Com pilation Errors
Rules for Item Nam es, Element Names and Explanatory Text
Including Comments
Calculating Items
Rules for Item Capitalization and Ordering
Conditionals
GAMS Comm and Line Parameters
Saves and Restarts
Scaling GAMS Models
Speeding up GAMS
Including External Files
Links to Other Programs Including Spreadsheets
Controlling GAMS from External Program s Solver Option Files
 Advanced Bas is Usage
NLP and MCP Model Types
Model Attributes
 Application Help: Model Library, Web Sites , Documentation
Many have contributed to this document beyond the authors. Erwin Kalvelagen wrote visual Basic Macros used in forming the complete document. Armin Pruessner provided comments and aid in the GDX chapter. Tony Brooke, David Kenderick, Alex Meeraus and later