کامپیوتر و IT و اینترنتعلوم مهندسی

GAMS general algebraic modeling system

صفحه 1:
@ GOS Gaver Gi surg Gorin ‏یی زین‎ Presa Van Oppied OR Ordetery Onurse 4estruntor: Dr. bbus Get Prepares by: Osan Barck

صفحه 2:
2 ۵00۵ ‏توالت‎ ‎© Dreceportaiva Problew © ew warket (Dorp) © poral oa sul * OrPramc * Or yarer oP the reat ‏كحت كلابب‎ without the ovatract — 2 ways 8 higher Pretght ooste Por the suller plat — OG ways to dePioe ‏اس سح‎ ۶ )۳وجلصم‎ ۲ subsequed pears: + seh Prakres (PF we have koe) 8 @has sttecet © barge tables * Phebe, Por, ced while states presectaton ts beased rt ‎DDS 1D Recah‏ ناهوس ‎carl fe‏ ی همص مود ادهصاه ها سسوم معا فالتا ‎exnd GOOG Over's Burke ‎

صفحه 3:
9

صفحه 4:
‎wis existoc wodels ood wodPy theo‏ ما موه نو ‎Ourngewed Griewe oct OR ‎Ore Covwwies QRevreutiocad Dodets ‏اه‎ ‏ایحا‎ ‎Over Covwxwies ‎Oolertioa oP prograns ‎Opricuhurd Coowwies Opptied Ceveral Cquiibrivey Coowwic Oevelopwet Coen Coowwirs Piece ‎Poresiry

صفحه 5:
© Crt GOOG © Open wew proient, suve it he desktop (cay unre) © Open Proasportatica Problew Prow the Dude Library © ype 'D 7 © Gave the Pie to the deshiop (“Progra!”, use “Gave oe" in “Pie” wen) * Oka chogges should we woke to odd 0 cew worket io

صفحه 6:
۰ ‏سس () - عالمو)‎ = 8.9 thousands wiles * Gao Diew — Oorqeatowa = 6.0 thousueds wes © Orie ‏صا اصوصن هن‎ pour progeny usicKy en © "SOctext ... 90۳۳ — culiple-haes cowed © Gave the Pie, Rua

صفحه 7:
© Oket is the wodel status? © Okt phrst supphes © Dorman? Wow ona oases? * Oko a the wit ‏عمج موس‎ ° Okt story do the wargedt voles Por equines tell? © Now wal he costs choage Pe “Porce” Geutle pratt supply dO cases to Oorxpriows?

صفحه 8:
۹ و ° poatrant va delivery oP WO cases ‏موه مس‎ 0 Ooo xPx(“Geutle”, “Ovrgctewa”) = 10; ° Dura oP evko prict $OPPistiey — Rter ‏ناس‎ ceeded tite, startiagy a the Pirst position ۰ the hoe با ماه له موی اه ی ‎OD, leoool = 0:‏ ۶ سا مرن ° bow do the wicked troasportaiiva ‏وه سوه‎

صفحه 9:
& Cowper the costs ued shipwed poteras wit ood

صفحه 10:
سو © - وا لجع ۱ عره©) ‎ad f=)‏ وه وس عم( وه مت ‎Gave pour‏ &° اطلت با مت تال او با او ۶ )9۳9 ‏علا‎ Gole stewed, declare wew Poraweters RECU4)) 364 BAT ced cssica thew the voles xL(i,j) ord zh; © Oefice the ‏مدصت‎ © Give wwher Gober stctewedt °° Oevhre ww Poruweters RECO(1j) ad at, ord este thew the value oP ‏ناد لجه (ز) راع‎ © Cowper oot, tO, RECT an REGCE (Diepky ptateceul)

صفحه 11:
save the results in new parameters Parameters costl "minimal transportation costs w/o contract’ RES1(i,j) "shipment w/o contract"; costl = z.L; RESL(i,j) = x-L(i,3): enforse the contract ¢.fx('seattle', 'morgantownWv') = 10; solve the model for the new settings solve transport using 1p minimizing 2: save the results in new parameters Marameters cost2 minimal transportation costs with contract RES2 (i,j) shipment given the contract; cost2 = 2.1; RES2 (i,j) = x-L(i,j)i

صفحه 12:
Loop(Courvitay Get Dawe, Coward); °° Loop. reped the set oP coweends Por ol eleweats oP ie ‏اعد اور‎ © Gave pour proynny os Progen, write cores °° ODetete the eed oP pour proenne startiog with the Pirst Goble 5۳9 ۱ slide)

صفحه 13:
‎ther bore‏ صا نت ‎Model transport /all/ ; +‏ ‎* declare a set with elements solvel and solve2 Set SOL solutions /solvel, solve2/; ‎+ declare parameters to save solution results Parameters mincost (SOL) transportation costs for 2 models RES (SOL, i,j) shipment pattern for 2 models; ‎Loop (SOL, Solve transport using lp minimizing 2; RES (SOL, i, 4) ‏یت در‎ + mincost (SOL) = 2.1: ‎prepare for second solve x.fx('seattle', 'morgantownmv') = 10; ‎ve ‎Display nincost, RES:

صفحه 14:
9B producer ts sual, Freight posts ane kicker © $-perar: BOOS’ way ty say ‘oop PF ‎dolar va the right‏ - :((0(<2000) 9083 - زد ‎PW)S(al)>COD) = OD; — - dolar va the teh‏ ‎PQ) wll be OO ody BP plants tprodwes wore tar GOO

صفحه 15:
© Dole va the eR P(W)$(a(i>COO) = BO; - Pi), awk tha of)>SOO, rants OO” -weniny # (aj) > SOO), thea Pi) = OO =o essipevedt is wade unless he bnyicd ovation is suishied © Optar va the right! ‏راع‎ - 9030-2000 (, - “Pi = 80 F of>SOO" + weeny F (afi) > GOO), thes P(i) = OO, eb Pi) = O > assiqaed is chaps wade. ” w vertubles vod be used do dePioe ‏عروثا ججشتلجمت أمصوها‎ COG teckucd reuvds.

صفحه 16:
& Gave pour ‏اس ار ,وت و مت‎ & Dreasportaiiva costs are higher Por a swuler producer © Covered cul ‏و ناویل‎ Grote F © Odd Ai) to the set oP Poraweters ۶ Duke Preight costs higher by $G/rase Phe phot produces fess thot GOO vases ۶ riot the vdlues oP poraeter P (Display stitecet)

صفحه 17:
Parameters f (i) freight in dollars per case per thousand miles c(i, j) transport cost in thousands of dollars per case; + 5${a(i) < S00); (i) * dij) / 1000 ۶ Display f;

صفحه 18:
Ove con deRue subsets cvatutiy port of the eleweuts oP waver ‏و روص اعد‎ Get stotewedt sets i canning plants / seattle, san-diego / smalli(i) subset of set i - small plants /seattle/ j markets / new-york, chicago, topeka, morgantown / ;

صفحه 19:
۳ weobers of sual, ud “(Puse” viherwise Parameter f(i) freight cost c(i,j) transport cost in thousands of dollars per case + ۶)1( 2 90 1 ۶ e(i,j) = £(4) * ‏(زژیذاه‎ / 1000 :

صفحه 20:
& beg! netaiceship betwee tee periods T ond D-C bead: relticaship betwers toe periods 1١ D+

صفحه 21:
+ program illustrating Lead operator Set T /1975*2004/; Parameter Population(T) population at time T; Population("1975") = 3; * calculate population for ali years in T Loop(T, Population(T+1) = Population(T)* 1.1); Display Population; ‘Dp! Open ace Ble, save oe prounne’?, wrte ‏لمجت و‎

صفحه 22:
... ,© 4 ۱2 رکه ع ‎Poputaiva(!)‏ © © ORO: ques the relaive posiiog of a wewber ao set © Cxevple: ORO(ORS’) = 4 ۵606۵ ‏-(«۵م‎ 9 © CORO: the total cuceber of eleweuts iat the set © Cxervple: CORO(T) = 90

صفحه 23:
* program illustrating the use of ORD operator: x(t) = a**t Set T time periods ۶ Parameter Population(T) population at time T; Sealar a /3/; * calculate population for all years in T Loop(T, Population(T) = a ** ORD(T)); Display Population; Nip: Opew a cew Ale, save he pron, write cower

صفحه 24:
° gue ‏ای‎ ue ty ‏تما پا و‎ vet lies (1,17); © Open caw Pie, save thas Progr, wie ovaries set i /il*i3/; alias (i,j); 5 parameters a(i,j), b(i,i); 2 )1,( ۶ (0,1) هن ‎b(i,i)‏ uniform (0,1); display a, b;

صفحه 25:
‘able ka(m,i) initial capital of productive unit inchon ulsan lacmos-dist 3702 12910 lsteam-car 537 _use the plus sign __ ‏و‎ move some of yosu the columns to the latmos-dist 9875 next lines lsteam-car 1207

صفحه 26:
)< Opes cew Pie, seve its Progra, vorite ‏دملا صا لمجخخصصص ه‎ ۴ Poy * example of ron statement paraneter =: ‏مه و‎ 0.3 by 1.4,

صفحه 27:
Open caw Ae, save tas Proyrowkl, write cori parameter s; oe S$ = -3.4; aa while(s le 0.3, s=s+1.4; display s; 1

صفحه 28:
strictly less than less than-or-equal to equal to not equal to greater than or equal to strictly greater than

صفحه 29:
1۳-0۵۵ 0 © Open caw Fle, seve ۱ ‏اه و 6و6 و‎ *program illustrating if-else statement parameter index; index = uniform(0,1); if((index le 0.5), display index, "index is less than 0.5"; else display index, "index is greater than 0.5"; Ve

GAMS General General Algebraic Algebraic Modeling Modeling System System Presentation Presentation No.2 No.2 Applied OR Modeling Course Instructor: Dr. Abbas Seifi Prepares by: Masoud Barah 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/scenariostudies_and_the_environment/gams/GAMS%20Reader.p df and GAMS User’s Guide !Lets start  Transportation problem GAMS Model Library • Collection of programs • You can begin with existing models and modify them       Agricultural Economics Applied General Equilibrium Economic Development Energy Economics Finance Forestry  Management Science and OR  Micro Economics  Recreational Models  Statistics  International Trade  Macro Economics Transportation Problem  Start GAMS  Open 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 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? 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 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) 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 comments  Delete the end of your program starting with the first Solve statement  Type instead: (new slide) You have this line 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); f(i)$(a(i)>500) = 90; - dollar on the right - 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 Tip: Open a new file, save as program7, write a comment 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 Tip: Open a new file, save it as program8, write comments 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 Large Tables FOR statement (program 10) Example  Open 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 Numerical Relationship Operators IF-ELSE STATEMENT (program 12)  Example  Open new file, save it as Program12, write a comment

51,000 تومان