Date post: | 26-Dec-2015 |
Category: |
Documents |
Upload: | chrystal-sutton |
View: | 228 times |
Download: | 0 times |
GAMS General Algebraic Modeling System
Presentation No.2
GAMS General Algebraic Modeling System
Presentation No.2
Instructor: Dr. Abbas SeifiPrepares by: Masoud Barah
Applied OR Modeling Course
Plan for Today
GAMS model library Transportation Problem
new market (Morgantown) contract on supply
• Definition• Comparison of the results with and without the contract – 2 ways
higher freight costs for the smaller plant – 2 ways to define Population Model
Population for subsequent years Useful Features (if we have time)
Alias statement Large tables If-else, for, and while statements
presentation is based onhttp://www.sls.wageningen-ur.nl/enr/education/scenariostudies_and_the_environment/gams/GAMS%20Reader.pdf
and GAMS User’s Guide
GAMS Model Library
Agricultural Economics Applied General
Equilibrium Economic Development Energy Economics Finance Forestry
Management Science and OR
Micro Economics Recreational Models Statistics International Trade Macro Economics
• Collection of programs • You can begin with existing models and modify them
Transportation Problem
Start GAMSOpen new project, save it to the desktop (any
name)Open Transportation Problem from the Model
Library type “Transport”
Save the file to the desktop (“Program1”, use “Save as” in “File” menu)
What changes should we make to add a new market to the system? (Morgantown)
New Market(program 1)
Add a new market – MorgantownWV New member of set j Demand = 40 (hypothetical) Distances:
• Seattle – Morgantown = 2.2 thousands miles
• San Diego – Morgantown = 2.1 thousands miles
Write a comment to your program using “*” – one-line comment “$Ontext … $Offtext” – multiple-lines comment
Save the file, Run
Results
What is the model status?
What plant supplies to Morgantown? How many cases?
What are the minimal transportation costs?
What story do the marginal values for equations tell?
How will the costs change if we “force” Seattle plant to supply 10 cases to Morgantown?
Contract on Supply(program 2)
Save your program as Program2, write commentscontract on delivery of 10 cases from Seattle to
Morgantownx.fx(“Seattle”, “Morgantown”) = 10;
Turn off echo print$Offlisting – After defining model title, starting on the first
position in the line
Turn off equation and column listing option limrow = 0, limcol = 0;
How do the minimal transportation costs change?
Result comparison
Compare the costs and shipment patterns with and without the contract save Solve results in a parameter multi-dimensional parameters, Loop statement
Save Solve Results in a New Parameter (program 3)
Save your program as Program3, write comments
Delete the contract definition from the modelAfter the Solve statement, declare new Parameters
RES1(i,j) and cost1 and assign them the values x.L(i,j) and z.L;
Define the contractGive another Solve statementDeclare new Parameters RES2(i,j) and cost2, and
assign them the value of x.L(i,j) and z.LCompare cost1, cost2, RES1 and RES2 (Display
statement)
Solve Results: Multi-Dimensional Parameters and Loop Statement (program 4)
Loop(Controlling Set Name, Commands);
Loop: repeat the set of commands for all elements of the controlling set
Save your program as Program4, write commentsDelete the end of your program starting with the
first Solve statement Type instead: (new slide)
Freight Costs depend on Plant Size (program 5)
If producer is small, freight costs are higher$-operator: GAMS’ way to say ‘only if’
f(i) = 90$(a(i)>500); - dollar on the right
f(i)$(a(i)>500) = 90; - dollar on the left
f(i) will be 90 only if plants i produces more than 500
Dollar-operator (cont.)
Dollar on the left: f(i)$(a(i)>500) = 90;
- “f(i), such that a(i)>500, equals 90”
- meaning if (a(i) > 500), then f(i) = 90
- no assignment is made unless the logical condition is satisfied
Dollar on the right: f(i) = 90$(a(i)>500);
- “f(i) = 90 if a(i)>500”
- meaning if (a(i) > 500), then f(i) = 90, else f(i) = 0
- assignment is always made.
no variables can be used do define logical condition for GAMS technical reasons.
Dollar-operator (cont.)
Save your program as Program5, write comments
Transportation costs are higher for a smaller producer Comment out declaration of Scalar f Add f(i) to the set of Parameters Make freight costs higher by $5/case if the plant
produces less than 500 cases Print the values of parameter f (Display statement)
Dollar-operator with Subsets(program 6)
Save your program as program6, add comments
One can define subsets containing part of the elements of another set using a Set statement
Dollar-operator with Subsets(cont.)
smalli(i) = “True” for all i that are members of smalli, and “False” otherwise
Dynamic models: Leads and Lags(program 7)
Simplified population example Population grows with time population(t) = a*population(t-1)
Lag: relationship between time periods T and T-1
Lead: relationship between time periods T and T+1
ORD and CARD(program 8)
Population(t) = a**t, t = 1, 2, …
ORD: gives the relative position of a member in a set Example:
ORD(“1975”) = 1
ORD(“1976”) = 2
CARD: the total number of elements in the set Example:
CARD(T) = 30
Alias Statement (program 9)
give another name to a previously declared set
Alias (t,tp); Example:
Open new file, save it as Program9, write comments
FOR statement(program 10)
ExampleOpen new file, save it as Program10, write a comment to
the program
WHILE statement(program 11)
Example Open new file, save it as Program11, write comments
Numerical relationship operator