GAMS: General Algebraic Modeling System Part2 - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

GAMS: General Algebraic Modeling System Part2

Description:

ORD and CARD (program 8) Population(t) = a**t, t = 1, 2, ... ORD('1975') = 1. ORD('1976') = 2. CARD: the total number of elements in the set. Example: ... – PowerPoint PPT presentation

Number of Views:573
Avg rating:5.0/5.0
Slides: 30
Provided by: Jo91
Category:

less

Transcript and Presenter's Notes

Title: GAMS: General Algebraic Modeling System Part2


1
GAMS General Algebraic Modeling SystemPart2
  • Tanya Borisova and Xiaobing Zhao
  • For Graduate Seminar ARE 696 by Dr. Fletcher
  • Tatiana.Borisova_at_mail.wvu.edu

2
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 on
  • http//www.sls.wageningen-ur.nl/enr/education/scen
    ariostudies_and_the_environment/gams/GAMS20Reader
    .pdf
  • and GAMS Users Guide

3
Lets start!
  • Transportation problem

4
GAMS Model Library
  • Collection of programs
  • You can begin with existing models and modify
    them
  • Management Science and OR
  • Micro Economics
  • Recreational Models
  • Statistics
  • International Trade
  • Macro Economics
  • Agricultural Economics
  • Applied General Equilibrium
  • Economic Development
  • Energy Economics
  • Finance
  • Forestry

5
Transportation Problem
  • Start GAMS
  • Open new project, save it to the desktop (any
    name)
  • Open Transportation Problem from the Model
    Library
  • type Trnsport
  • 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)

6
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

7
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?

8
Contract on Supply(program 2)
  • Save your program as Program2, write comments
  • contract on delivery of 10 cases from Seattle to
    Morgantown
  • x.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?

9
Result comparison
  • Compare the costs and shipment patterns with and
    without the contract
  • save Solve results in a parameter
  • multi-dimensional parameters, Loop statement

10
Save Solve Results in a New Parameter (program 3)
  • Save your program as Program3, write comments
  • Delete the contract definition from the model
  • After 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 contract
  • Give another Solve statement
  • Declare new Parameters RES2(i,j) and cost2, and
    assign them the value of x.L(i,j) and z.L
  • Compare cost1, cost2, RES1 and RES2 (Display
    statement)

11
(No Transcript)
12
Solve Results Multi-Dimensional Parameters and
Loop Statement(program 4)
  • Loop(ControllingSetName, Commands)
  • Loop repeat the set of commands for all elements
    of the controlling set
  • Save your program as Program4, write comments
  • Delete the end of your program starting with the
    first Solve statement
  • Type instead (new slide)

13
You have this line
14
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)gt500) - dollar on the
    right
  • f(i)(a(i)gt500) 90 - dollar on the
    left
  • f(i) will be 90 only if plants i produces
    more than 500

15
Dollar-operator (cont.)
  • Dollar on the left f(i)(a(i)gt500) 90
  • - f(i), such that a(i)gt500, equals 90
  • - meaning if (a(i) gt 500), then f(i) 90
  • - no assignment is made unless the logical
    condition is satisfied
  • Dollar on the right f(i)
    90(a(i)gt500)
  • - f(i) 90 if a(i)gt500
  • - meaning if (a(i) gt 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.

16
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)

17
(No Transcript)
18
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

19
Dollar-operator with Subsets (cont.)
  • smalli(i) True for all i that are members of
    smalli, and False otherwise

20
Dynamic models Leads and Lags(program 7)
  • Simplified population example
  • Population grows with time
  • population(t) apopulation(t-1)
  • Lag relationship between time periods T and T-1
  • Lead relationship between time periods T and T1

21
Open a new file, save as program7, write a comment
22
ORD and CARD(program 8)
  • Population(t) at, 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

23
Open a new file, save it as program8, write
comments
24
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

25
Large Tables
26
FOR statement(program 10)
  • Example
  • Open new file, save it as Program10, write a
    comment to the program

27
WHILE statement(program 11)
  • Example
  • Open new file, save it as Program11, write
    comments

Numerical relationship operator
28
Numerical Relationship Operators
29
IF-ELSE STATEMENT(program 12)
  • Example
  • Open new file, save it as Program12, write a
    comment
Write a Comment
User Comments (0)
About PowerShow.com