GAMS General Algebraic Modeling Software A brief introduction. - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

GAMS General Algebraic Modeling Software A brief introduction.

Description:

GAMS General Algebraic Modeling Software. A brief introduction. GAMS homepage: ... A high level modeling system. Components. Language compiler. Integrated ... – PowerPoint PPT presentation

Number of Views:1024
Avg rating:3.0/5.0
Slides: 29
Provided by: amarkumar9
Category:

less

Transcript and Presenter's Notes

Title: GAMS General Algebraic Modeling Software A brief introduction.


1
GAMS General Algebraic Modeling SoftwareA
brief introduction.
  • GAMS homepage
  • http//www.gams.com
  • Additional Reference
  • http//gilbreth.ecn.purdue.edu/rardin/gams/notes.
    html

2
Introduction
  • A high level modeling system
  • Components
  • Language compiler
  • Integrated high performance solvers
  • Models supported
  • Linear Programs
  • Non-Linear Programs
  • Mixed Integer Optimization
  • Platforms
  • PC
  • Workstations
  • Mainframes

3
Introduction
  • Advantages/Uses
  • Easy representation of models
  • Allows users to concentrate on modeling
  • Programming similar to commonly used programming
    languages
  • Solvers and models can be switched easily
  • Easy to identify errors
  • Available Solvers
  • CPLEX
  • XPRESS
  • OSL
  • CONOPT
  • MINOS

4
Basics
  • How to compile a GAMS code ?
  • Models encoded in filename.gms
  • Compilation from command line on Unix/MSDOS
    gams filename
  • Windows Environment
  • GAMS creates input file to the solver
  • Output generated in filename.lst

5
Transportation Problem An Example
  • A set of supply points with a finite amount of
    supply
  • A set of demand points with a finite amount of
    demand
  • Cost of satisfying the demand using the available
    supply
  • Objective Satisfy all the demand at a minimum
    cost
  • Issues Balance of supply and demand

6
Mathematical Formulation
7
Mathematical Formulation
8
Sample Data
Cost of transportation 10 per mile
9
GAMS Code
10
GAMS CODE Continued..
11
Results
12
Structure of GAMS Model
Inputs
Outputs
  • Set
  • Declaration
  • Assignment - indices
  • Data (Parameters, Tables, Scalars)
  • Declaration
  • Assignment - values
  • Variables
  • Declaration
  • Type Assignment
  • Assignments of Bounds (optional)
  • Equations
  • Declaration
  • Definition
  • Model and Solve Statements
  • Display Statements (optional)
  • Echo Print
  • Errors (if present)
  • Reference Maps
  • Equation Listings
  • Status Reports
  • Results

13
Remarks
  • An entity cannot be referenced before declaration
  • Lines beginning with are treated as a comments
    / Statements between declarations and assignments
  • Upper and Lower case letters are not
    distinguished
  • Names of entities should start with a letter and
    can be followed up to 9 letters or digits
  • Duplication not allowed

14
Sets
  • Basic building blocks Correspond to indices in
    Mathematical Formulation
  • Different ways of declaration
  • sets
  • i supply points /1, 2/
  • j demand points /1, 2, 3/
  • set j demand points /13/
  • sets j
  • include j.inc
  • In file inclusion all the indices should be
    enclosed between /./
  • Alias(i,k)
  • Multidimensional sets
  • Dynamic Sets

15
Data
  • Different formats for data entry
  • Lists
  • Tables
  • Direct Assignments
  • Assignments from files
  • Data entry by lists
  • parameter d(j) demand at point j
  • /1 100
  • 2 200
  • 3 300/
  • List must be enclosed within slashes, entries
    separated by commas or separate lines
  • Domain Checking
  • Default value is zero
  • Scalar is considered as a parameter with no
    domain
  • Parameters with multi-dimensional domains can
    also be entered by lists

16
Data
  • Data entry by tables
  • table dist(i,j) distance from i to j
  • 1 2 3
  • 1 10.2 5.3 50
  • 2 30 21.2 4.5
  • Declares parameter dist and specifies its domain
    as set of ordered pairs of Cartesian product of
    i, j
  • Blanks are interpreted as zeros
  • Domain checking
  • Entering tables with more than one dimension

17
Data
  • Data entry by direct assignment
  • parameter c(i,j) cost of transportation from i to
    j
  • c(i,j) M dist_1(i,j)10
  • Semicolon between two statements
  • Parameters used in computation have to be
    previously declared
  • Domain checking
  • Specific elements in the domain can be assigned
    by
  • c(1,3) 100
  • Different possible operations possible using
    functions available in GAMS
  • csq sqr(c)
  • e m csq
  • w l/lamda
  • eoq(i) sqrt( 2 demand(i) ordcost(i) /
    holdcost(i))
  • t(i) min(p(i), q(i)/r(i), log(s(i)))
  • euclidean(i,j) qrt(sqr(xi(i) - xi(j)
    sqr(x2(i) - x2(j)))
  • present(j) future(j)exp(-interesttime(j))

18
Data
  • Data entry by assignment from files
  • Files can have a structure of list or tables
  • parameter s(i)
  • SUPPLY DATA
  • include supply.inc
  • Format //
  • parameter c(i,j)
  • COST DATA
  • include cost.inc
  • Format
  • Table c(i,j)
  • j
  • i -

19
Variables
  • Decision variables must be declared
  • free variable z cost of transportation
  • positive variable x(i,j) amount transported
    from i to j
  • Or
  • Variables
  • x(i,j) amount transported from i to j
  • z cost of transportation
  • positive variable x
  • Default type is free
  • Different permissible types for variables

20
Variables
  • z is a scalar quantity serves to model
    objective value either maximization or
    minimization
  • Assignment of bounds to variables
  • Different possible fields of a variable
  • .lo lower bound
  • .l level or primal value
  • .up upper bound
  • .m marginal or dual value
  • Set automatically according to variable type
  • Can be overwritten by
  • x.up(i,j) 100
  • x.lo(i,j) 10

21
Summation and Product in GAMS
  • Not possible to have standard mathematical
    notation for summation and product
  • Summation
  • sum(index of summation, summand)
  • sum(j, x(i,j)) is equivalent to
  • sum((i,j), c(i,j)x(i,j)) is equivalent to
  • Product
  • prod(j, x(i, j)) is equivalent to
  • Product and Summation can be used to make
    assignments and in implementing equations
  • Conditional summation and product

22
Equations
  • Must be declared and defined in separate
    statements
  • Declaration
  • equations obj, const1, const2
  • Definition
  • The name of the equation being defined
  • The domain
  • Domain restriction condition (optional)
  • The symbol '..'
  • Left-hand-side expression
  • Relational operator l, e, or g
  • Right-hand-side expression
  • Multiple equations are created based on the
    domain
  • dollar and such-that operators
  • Difference between and e
  • Variables can appear in the right hand side

23
Equations
  • obj..
  • zesum((i,j),c(i,j)x(i,j))
  • const1(i)..
  • sum(j,x(i,j)) e s(i)
  • const2(j)..
  • sum(i,x(i,j)) e d(j)

24
Model and Solve Statements
  • model is a keyword in GAMS collection of
    equations
  • Syntax
  • model modelname /all/
  • model formulation /all/
  • model formulation /obj, const1, const2/
  • Specific constraints can be implemented
  • Option Statements
  • option lp cplex

25
Model and Solve Statements
  • Solve Statement
  • solve formulation using lp minimizing z
  • Format of Solve statement
  • The key word solve
  • The name of the model to be solved
  • The key word using
  • An available solution procedure. The complete
    list is
  • lp for linear programming
  • nlp for nonlinear programming
  • mip for mixed integer programming
  • rmip for relaxed mixed integer programming
  • minlp for mixed integer nonlinear programming
  • rminlp for relaxed mixed integer nonlinear
    programming
  • The keyword "minimizing" or "maximizing"
  • The name of the variable to be optimized

26
Display Statements
  • display x.l,z.l
  • Displays the primal values (solution) of x(i,j)
    and objective z in filename.lst file
  • Printing solution in customized format
  • file soln/assign.out/
  • put soln
  • soln.sw20
  • PRINTS OUT THE SOLUTION
  • loop((i,j,t)(x.l(i,j,t) gt 0), put _at_2 i.te(i),
    _at_18, j.te(j), _at_38 x.l(i,j,t) 30 /)

27
GAMS Output
  • Echo Print
  • Errors (if present)
  • Example 160
  • Summary of the error messages is given at the end
    of the filename.lst file
  • Reference Maps
  • Equation Listings
  • Status Reports
  • Results

28
Questions ?
Write a Comment
User Comments (0)
About PowerShow.com