Unformatted text preview:

1 INTRODUCTION TO GAMS1 Daene C. McKinney CE385D Water Resources Planning and Management The University of Texas at Austin Table of Contents 1. Introduction ............................................................................................................................. 2 2. GAMS Installation .................................................................................................................. 2 3. GAMS Operation .................................................................................................................... 2 4. Examples ............................................................................................................................... 11 4.1. Algebraic Equation ........................................................................................................... 11 4.1.1. Background and GAMS Code ................................................................................... 11 4.1.2. What's Going On in the Model? ................................................................................ 12 4.2. Least Squares Parameter Estimation .............................................................................. 15 4.2.1. Background and GAMS Code ................................................................................ 15 4.2.2. What's Going On in the Model? ................................................................................ 16 5. A Brief Overview of the GAMS Language .......................................................................... 17 5.1. Model Structure ................................................................................................................ 17 5.2. Sets ................................................................................................................................. 18 5.3. Scalars, Parameters and Tables ...................................................................................... 20 5.4. Variables ......................................................................................................................... 21 5.5. Equations ........................................................................................................................ 22 5.6. Assembling a Model....................................................................................................... 23 5.7. Solving a Model ............................................................................................................. 24 5.8. Model Output ................................................................................................................. 24 5.9. IF-ELSE Operator .......................................................................................................... 26 References .................................................................................................................................. 27 1 This Introduction to GAMS Modeling benefited from research by Andrey G. Savitsky. The use and distribution of GAMS is made possible by the GAMS Development Corporation (www.gams.com) and it greatly appreciated.2 1. INTRODUCTION The General Algebraic Modeling System (GAMS) facilitates the creation of mathematical models, particularly optimization models, and allows the modeler to build models using the same logical structures as the mathematical equations that need to be solved. In this section, the river basin model described in Annex 3 will be described using the GAMS language to allow users to understand the model and to develop additional models. This section should be supplemented by the official GAMS Guide and Tutorials (Brooke et al., 2006), the monograph on optimization models for water and energy management (McKinney and Savitsky, 2006), and the GAMS website (www.gams.com). 2. GAMS INSTALLATION A. Run setup.exe: Run the file “setup.exe” directly from the CD. Use the Windows Explorer to browse the CD and double click on the file “setup.exe”. The setup program will prompt you for the name of the directory in which to install GAMS. Accept the default choice which the install program offers. Then the GAMS software will be installed. B. License file: You will be prompted for a license file during the installation. You do not have one, so choose „No‟ when asked if you wish to copy a license file. GAMS will function in demonstration mode and will only solve small problems. 3. GAMS OPERATION A. Start GAMS: Start GAMS by selecting “Start  All Programs  GAMS  GAMSIDE” from the Windows Desktop3 Figure 1. Starting GAMS. B. Create new GAMS project: To create a new project in GAMS, choose “File  Project  New project” from the GAMSIDE. Figure 2. Creating a new project in GAMS. Navigate from “My Documents” to the “C\:” drive. Create a new directory by pressing the4 “folder” icon . Name the new directory “C:\Example”. Double click on the “Example” folder. Type “Eq1” in the “File name” box and press “Open”. Figure 3. Naming a new project in GAMS. The GAMS window should now show the new Shapley.gpr project window . Figure 4. Naming a new project in GAMS.5 C. Create a new GAMS code file: To create a new GAMS code file, select “File  New” from the GAMSIDE. This will create the file “Untitled_1.gms” in the “C:\Example” directory”. We will then copy the “EQ1” GAMS code into this file from a text file. Figure 5. Creating a new GAMS code file. D. Open GAMS code file: Select “File  Open”. Select “Text files” as the “Files of type” type. Navigate to the directory where you stored the and open the file “EQ1.txt”. Click on this files. Now it is automatically copied to GAMS. Figure 6. Opening the EQ1 text file. E. Tabs and Files: Now the window shows that you have two files open. This is indicated by the two “Tabs” along the top of the window in GAMS. The first tab displays the file “Eq1.txt”. This file, which we just opened, is shown in the active window. The second tab displays the “untitled_1.gms” file that we recently created. This is the GAMS Code file that6 we are creating. To move back and forth between the two files, simply click on the appropriate tab at the top of the window. Figure 7. Multiple files open in GAMS. F. Copy text file: Now we will copy all of the text from the


View Full Document

UT CE 385 - Introduction to GAMS

Download Introduction to GAMS
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Introduction to GAMS and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Introduction to GAMS 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?