1 / 29

Introduction to GAMS: Formulation of a general problem

Introduction to GAMS: Formulation of a general problem. Prof. Boyan Bonev Ivanov, Ph.D. Email: bivanov@bas.bg Institute of Chemical Engineering-BAS. What is GAMS?. Formulation of a General Problem. Formulation of a General Problem. Formulation of a General Problem. STEPS

Télécharger la présentation

Introduction to GAMS: Formulation of a general problem

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to GAMS: Formulation of a general problem Prof. Boyan Bonev Ivanov, Ph.D. Email: bivanov@bas.bg Institute of Chemical Engineering-BAS

  2. What is GAMS?

  3. Formulation of a General Problem

  4. Formulation of a General Problem

  5. Formulation of a General Problem STEPS 1. SET definitions (crop) 2. Data entry (Ccrop, acrop,resource, bresource) 3. Variable specifications 4. Equation specifications a. declaration b. algebraic structure 5. Model statement 6. Solve statement

  6. Set Definition In algebraic modeling, we commonly have subscripts. In GAMS, the corresponding items are sets. A set definition has several potential parts. S={a,b,c} Set S /a,b,c/ In general, the syntax in GAMS for simple sets is as follows: set set_name ["text"] [/element ["text"] {,element ["text"]} /] {,set_name ["text"] [/element ["text"] {,element ["text"]} /] ; SET ItemName optional explanatory text for item / element1 optional explanatory text for element , element2 optional explanatory text for element / ;

  7. Set Definition set cq"nutrients" / N, P2O5 / ; setcq "nutrients" / N P2O5 / ; setcq"nutrients" / N “Text 1” P2O5 “Text 2” / ; setcq"nutrients“ / N “Text 1” P2O5“Text 2” / ;

  8. Set Definition Set f "final products" /yncrude"refined crude (million barrels)" lpg"liquified petroleum gas(million barrels)" ammonia"ammonia (million tons)" coke"coke (million tons)" sulfur"sulfur (million tons)" /; sett"time“ /1991 * 2000 /; sets s"Sector" / manuf agri services government / r"regions" / north eastcoast midwest sunbelt / ;

  9. Set Definition Defined set names Explanatory Text Element names

  10. Data Entry Data are entered via four different types of GAMS commands 1) Scalar – for items that are not set dependent 2) Parameters– for items that are vectors (can be multidimensional) 3) Tables– for items with 2 or more dimensions 4) Parameters– direct assignment

  11. Data Entry – SCALAR command Scalar commands: In general, the syntax in GAMS for a scalar declaration is: scalar(s) scalar_name [text] [/signed_num/] { scalar_name [text] [/signed_num/]} ; Scalars rho "discount rate" / .15 / irr "internal rate of return" life "financial lifetime of productive units" /20/; Basic format: SCALAR ItemName optional text / value / ; Example: SCALAR LandAvailable Total Land / 100 / ;

  12. Data Entry – PARAMETER command In general, the syntax in GAMS for a parameter declaration is: parameter(s) param_name [text] [/ element [=] signed_num {,element [=] signed num} /] {,param_name [text] [/ element [=] signed_num {,element [=] signed num} /]} ; Basic format: PARAMETER ItemName(Set) optional text / element1 value , element2 value value2 / ; Example: PARAMETER Revenue(Crop) Revenues from crop production / Corn 109 Wheat 90 Cotton 115 / ResourceAvailable (Resource) Resource availability / Land 100 Labor 500 / ;

  13. Data Entry – PARAMETER command Set i "steel plants“ / hylsa "monterrey" hylsap "puebla" / j "markets" / mexico-df, monterrey, guadalaja / ; parameter dd(j) “distribution of demand” / mexico-df 55, guadalaja 15 / ; Set i "steel plants“ / seattle "monterrey" san-diego "puebla" / Parameter a(i) / seattle = 350, san-diego = 600 / b(i) / seattle 2000, san-diego 4500 / ;

  14. Data Entry – TABLE command In general, the syntax in GAMS for a table declaration is: table table_name [text] EOL element { element } element signed_num { signed_num} EOL {element signed_num { signed_num} EOL} ; sets i "plants" / inchon,ulsan,yosu / m "productive units" atmos-dist "atmospheric distillation unit" steam-cr "steam cracker" aromatics "aromatics unit" hydrodeal "hydrodealkylator" / ; Table ka(m,i) "initial cap. of productive units (100 tons per yr)" inchon ulsan yosu atmos-dist 3702 12910 9875 steam-cr 517 1207 aromatics 181 148 hydrodeal 180 ;

  15. Data Entry – TABLE command Basic format: TABLE ItemName(set1dep,set2dep) optional text set2elem1 set2elem2 Set1element1 value11 value12 Set1element2 value12 value22 ; Example: Elements from Crop set (2nd set) Elements from Resource set (1st set)

  16. Data Entry – Direct assignment Basic format: PARAMETER ItemName(set1dep,set2dep) optional text ; ItemName(set1dep,set2dep) = some expression ; Example:

  17. Summation Digression

  18. Formulation – Variable Declarations Basic format: VARIABLE VarName1(setdependency) optional text VarName2(setdependency) optional text … ; Example:

  19. Formulation – Variable Declarations variables k(t) capital stock (trillion rupees) c(t) consumption (trillion rupees per year) i(t) investment (trillion rupees per year) utility utility measure ; VARIABLE TYPES

  20. Formulation – Variable Declarations variables k(t) capital stock (trillion rupees) c(t) consumption (trillion rupees per year) i(t) investment (trillion rupees per year) utility utility measure ; positive variables k(t) capital stock (trillion rupees) c(t) consumption (trillion rupees per year) ; negative variables i(t) investment (trillion rupees per year); binary variables utility utility measure ;

  21. EQUATION DECLARATIONS THE SYNTAX Equation[s] eqn_name text {, eqn_name} ; AN ILLUSTRATIVE EXAMPLE

  22. EQUATION DEFINITIONS THE SYNTAX eqn_name(domain_list).. expression eqn_type expression ; AN ILLUSTRATIVE EXAMPLE Variables phi, phipsi, philam, phipi, phieps ; equations obj ; obj.. phi =e= phipsi + philam + phipi - phieps ;

  23. EQUATION DEFINITIONS SCALAR EQUATIONS dty.. td =e= sum(i, y(i)) ; INDEXED EQUATIONS dg(t).. g(t) =e= mew(t) + xsi(t)*m(t) ; bd(j,h).. b(j,h) =e= dd(j,h) - y(j,h) ; yd(j,h).. y(j,h) =l= sum(i, p(i,j)*x(i,j)) ; ARITHMETIC OPERATORS IN EQUATION DEFINITIONS dem(i) .. y(i) =e= ynot(i)*(pd*p(i))**thet(i) ;

  24. EQUATION DEFINITIONS EXPRESSIONS IN EQUATION DEFINITIONS

  25. Model Specification " Model Specification MODEL statements are used to identify models that will be solved. They involve 2 steps step 1: gives the name of the model step 2: specifies the names of the equations that will be included in the model enclosed in slashes / / or the word ALL MODEL FarmIncome /EQ1, EQ2, EQ3/ ; MODEL FarmIncome /ALL/ ;

  26. Solve Specification " Solve Specification SOLVE causes GAMS to apply a solver to the named model and identifies the variable to be optimized along with the direction of optimization SOLVE FarmIncome USING LP MAXIMIZING Profit ;

  27. CLASSIFICATION OF MODELS

  28. ORGANIZATION OF GAMS PROGRAMS

  29. References http://www.pse.ice.bas.bg:8080/WWW_Systems_engineerig_laboratory/Distance_learning_systmeng/Distance_systmeng_LT.htm

More Related