GAMS general algebraic modeling system
اسلاید 1: GAMS General Algebraic Modeling System Presentation No.2Instructor: Dr. Abbas SeifiPrepares by: Masoud BarahApplied OR Modeling Course
اسلاید 2: Plan for TodayGAMS model libraryTransportation Problemnew market (Morgantown)contract on supply DefinitionComparison of the results with and without the contract – 2 ways higher freight costs for the smaller plant – 2 ways to definePopulation ModelPopulation for subsequent years Useful Features (if we have time)Alias statementLarge tablesIf-else, for, and while statementspresentation is based onhttp://www.sls.wageningen-ur.nl/enr/education/scenariostudies_and_the_environment/gams/GAMS%20Reader.pdfand GAMS User’s Guide
اسلاید 3: Lets start!Transportation problem
اسلاید 4: GAMS Model LibraryAgricultural EconomicsApplied General EquilibriumEconomic DevelopmentEnergy EconomicsFinanceForestryManagement Science and ORMicro EconomicsRecreational ModelsStatisticsInternational TradeMacro Economics Collection of programs You can begin with existing models and modify them
اسلاید 5: Transportation ProblemStart 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)
اسلاید 6: New Market (program 1)Add a new market – MorgantownWV New member of set jDemand = 40 (hypothetical)Distances:Seattle – Morgantown = 2.2 thousands milesSan Diego – Morgantown = 2.1 thousands milesWrite a comment to your program using “*” – one-line comment“$Ontext … $Offtext” – multiple-lines commentSave the file, Run
اسلاید 7: ResultsWhat 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 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?
اسلاید 9: Result comparison Compare the costs and shipment patterns with and without the contractsave Solve results in a parametermulti-dimensional parameters, Loop statement
اسلاید 10: Save Solve Results in a New Parameter (program 3)Save your program as Program3, write commentsDelete 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)
اسلاید 11:
اسلاید 12: 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 setSave your program as Program4, write commentsDelete 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)>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
اسلاید 15: 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 satisfiedDollar 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.
اسلاید 16: Dollar-operator (cont.)Save your program as Program5, write commentsTransportation costs are higher for a smaller producerComment out declaration of Scalar fAdd f(i) to the set of ParametersMake freight costs higher by $5/case if the plant produces less than 500 cases Print the values of parameter f (Display statement)
اسلاید 17:
اسلاید 18: Dollar-operator with Subsets (program 6)Save your program as program6, add commentsOne 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 examplePopulation grows with timepopulation(t) = a*population(t-1)Lag: relationship between time periods T and T-1Lead: relationship between time periods T and T+1
اسلاید 21: Tip: Open a new file, save as program7, write a comment
اسلاید 22: ORD and CARD (program 8)Population(t) = a**t, t = 1, 2, …ORD: gives the relative position of a member in a setExample: ORD(“1975”) = 1 ORD(“1976”) = 2CARD: the total number of elements in the setExample: CARD(T) = 30
اسلاید 23: Tip: 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)ExampleOpen new file, save it as Program10, write a comment to the program
اسلاید 27: WHILE statement (program 11)ExampleOpen new file, save it as Program11, write commentsNumerical relationship operator
اسلاید 28: Numerical Relationship Operators
اسلاید 29: IF-ELSE STATEMENT (program 12) ExampleOpen new file, save it as Program12, write a comment
نقد و بررسی ها
هیچ نظری برای این پاورپوینت نوشته نشده است.