Professional Documents
Culture Documents
GAMS/GAMSIDE
Formulation
Pei Huang
Based on materials written by Gillig & McCarl and improved upon by many previous lab instructors
Special thanks to Mario Andres Fernandez
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
1 / 19
Overview
GAMS/GAMSIDE
Formulation
Outline
1
Overview
Information
Topics
Introduction to GAMS/GAMSIDE
GAMS Language
GAMSIDE
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
2 / 19
Overview
GAMS/GAMSIDE
Formulation
Info
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
3 / 19
Overview
GAMS/GAMSIDE
Formulation
Info
Purpose: Connect lecture materials to practical programming in
GAMS.
You will do Handson exercises, plus additional model exposure in lab
but no assigned.
6 assignments
Equally weighted
Usually one week after assignment, by 5 pm
Printed / electronic copy
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
4 / 19
Overview
GAMS/GAMSIDE
Formulation
Topics
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
5 / 19
Overview
GAMS/GAMSIDE
Formulation
Topics
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
5 / 19
Overview
GAMS/GAMSIDE
Formulation
Topics
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
5 / 19
Overview
GAMS/GAMSIDE
Formulation
Topics
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
5 / 19
Overview
GAMS/GAMSIDE
Formulation
Topics
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
5 / 19
Overview
GAMS/GAMSIDE
Formulation
Topics
Conditionals
GAMS Check: Pre/Post Solution Analysis
Examining A Model for Flaws
Report Writing
Comparative Analysis: Multiple Submissions and Loops
Non-linear Programming Problems
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
6 / 19
Overview
GAMS/GAMSIDE
Formulation
Topics
Conditionals
GAMS Check: Pre/Post Solution Analysis
Examining A Model for Flaws
Report Writing
Comparative Analysis: Multiple Submissions and Loops
Non-linear Programming Problems
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
6 / 19
Overview
GAMS/GAMSIDE
Formulation
Topics
Conditionals
GAMS Check: Pre/Post Solution Analysis
Examining A Model for Flaws
Report Writing
Comparative Analysis: Multiple Submissions and Loops
Non-linear Programming Problems
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
6 / 19
Overview
GAMS/GAMSIDE
Formulation
Topics
Conditionals
GAMS Check: Pre/Post Solution Analysis
Examining A Model for Flaws
Report Writing
Comparative Analysis: Multiple Submissions and Loops
Non-linear Programming Problems
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
6 / 19
Overview
GAMS/GAMSIDE
Formulation
Topics
Conditionals
GAMS Check: Pre/Post Solution Analysis
Examining A Model for Flaws
Report Writing
Comparative Analysis: Multiple Submissions and Loops
Non-linear Programming Problems
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
6 / 19
Overview
GAMS/GAMSIDE
Formulation
Topics
Conditionals
GAMS Check: Pre/Post Solution Analysis
Examining A Model for Flaws
Report Writing
Comparative Analysis: Multiple Submissions and Loops
Non-linear Programming Problems
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
6 / 19
Overview
GAMS/GAMSIDE
Formulation
What is GAMS?
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
7 / 19
Overview
GAMS/GAMSIDE
Formulation
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
8 / 19
Overview
GAMS/GAMSIDE
Formulation
A simple problem
Suppose we wish to solve the optimization problem
Objective
0.8
Variables:
Sustenance
Equations
Objective
Constraints: Money, Time, Sustenance
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
9 / 19
Overview
GAMS/GAMSIDE
Formulation
Using GAMS
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
10 / 19
Overview
GAMS/GAMSIDE
Formulation
Using GAMS
Variable specications
Objective function
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
10 / 19
Overview
GAMS/GAMSIDE
Formulation
Using GAMS
Variable specications
Objective function
Considered variables
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
10 / 19
Overview
GAMS/GAMSIDE
Formulation
Using GAMS
Variable specications
Objective function
Considered variables
Equation specications
Declaration
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
10 / 19
Overview
GAMS/GAMSIDE
Formulation
Using GAMS
Variable specications
Objective function
Considered variables
Equation specications
Declaration
Algebraic structure
specication
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
10 / 19
Overview
GAMS/GAMSIDE
Formulation
Using GAMS
Variable specications
Objective function
Considered variables
Equation specications
Declaration
Algebraic structure
specication
Model statement
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
10 / 19
Overview
GAMS/GAMSIDE
Formulation
Using GAMS
Variable specications
Objective function
Considered variables
Equation specications
Declaration
Algebraic structure
specication
Model statement
Solve statement
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
10 / 19
Overview
GAMS/GAMSIDE
Formulation
Variable Specication
Types of variables
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
Variable
Unrestricted variables
Positive Variable
Nonnegative
Binary Variable
0 or 1
Integer Variable
0, 1, 2, . . . , 9999
11 / 19
Overview
GAMS/GAMSIDE
Formulation
Variable Specication
Types of variables
Variable
Unrestricted variables
Positive Variable
Nonnegative
Binary Variable
0 or 1
Integer Variable
0, 1, 2, . . . , 9999
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
11 / 19
Overview
GAMS/GAMSIDE
Formulation
Variable Specication
Types of variables
Variable
Unrestricted variables
Positive Variable
Nonnegative
Binary Variable
0 or 1
Integer Variable
0, 1, 2, . . . , 9999
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
11 / 19
Overview
GAMS/GAMSIDE
Formulation
Variable Specication
Types of variables
Variable
Unrestricted variables
Positive Variable
Nonnegative
Binary Variable
0 or 1
Integer Variable
0, 1, 2, . . . , 9999
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
11 / 19
Overview
GAMS/GAMSIDE
Formulation
Equation Specication
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
12 / 19
Overview
GAMS/GAMSIDE
Formulation
Equation Specication
Name each equation in
the model.
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
12 / 19
Overview
GAMS/GAMSIDE
Formulation
Equation Specication
Name each equation in
the model.
Specify the algebraic
structure.
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
12 / 19
Overview
GAMS/GAMSIDE
Formulation
Equation Specication
Name each equation in
the model.
Specify the algebraic
structure.
Two dots following each
equation name
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
12 / 19
Overview
GAMS/GAMSIDE
Formulation
Equation Specication
Name each equation in
the model.
Specify the algebraic
structure.
Two dots following each
equation name
The specic forms of
constraints
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
Syntax
Constraint forms
=e=
equal
=l=
=g=
12 / 19
Overview
GAMS/GAMSIDE
Formulation
Model Statement
Name the model
Specify equations that will
be included in the model
in slashes /
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
13 / 19
Overview
GAMS/GAMSIDE
Formulation
Model Statement
Name the model
Specify equations that will
be included in the model
in slashes /
Examples
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
13 / 19
Overview
GAMS/GAMSIDE
Formulation
Solve Statement
Examples
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
14 / 19
Overview
GAMS/GAMSIDE
Formulation
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
15 / 19
Overview
GAMS/GAMSIDE
Formulation
GAMS Output
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
16 / 19
Overview
GAMS/GAMSIDE
Formulation
GAMS Output
Output navigation
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
16 / 19
Overview
GAMS/GAMSIDE
Formulation
GAMS Output
Output navigation
Objective function
solution
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
16 / 19
Overview
GAMS/GAMSIDE
Formulation
GAMS Output
Output navigation
Objective function
solution
Equation solutions
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
16 / 19
Overview
GAMS/GAMSIDE
Formulation
GAMS Output
Output navigation
Objective function
solution
Equation solutions
Variable solutions
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
16 / 19
Overview
GAMS/GAMSIDE
Formulation
GAMS Project
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
17 / 19
Overview
GAMS/GAMSIDE
Formulation
GAMS Project
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
17 / 19
Appendix
Heads On 1
Sove the feeding problem using GAMS
Cost/lb
1
2
3
=1
Unit
Non negative
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
18 / 19
Appendix
Requirements
Create HandsOn1.gms with * your name on the rst line of the code.
A good programming habit: make comments in your code.
Turn in an electronic copy of *.gms le for Part 1 via email.
Turn in a hard copy of *.lst le (from Solution Report to the end) for
ALL three parts.
You can work as a group with no more than three people.
The hands on is due by 5:00pm, September 12.
Pei Huang | Texas A&M University | AGEC 641 Lab Session, Fall 2013
19 / 19