User Tools

Site Tools


gams:model_predecessor_successor_relations

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gams:model_predecessor_successor_relations [2014/01/16 10:00]
admin
gams:model_predecessor_successor_relations [2020/05/18 14:10] (current)
Lutz Westermann
Line 7: Line 7:
 delta(d,h) =e= x(d,h) - x(pred(d,​h)) ; delta(d,h) =e= x(d,h) - x(pred(d,​h)) ;
  
-delta(d,) =l= constant ; //+delta(d,h) =l= constant ; //
  
-The GAMS lingo for this is lag and lead operators: ''​x(d,​h-1)''​ e.g. shows the previous hour.  +The GAMS lingo for this is [[https://​www.gams.com/​latest/​docs/​UG_OrderedSets.html#​UG_OrderedSets_LagLeadOperators|lag and lead operators]]: ''​x(d,​h-1)''​ e.g. shows the previous hour.  
-The '''​-'''​ is not a numerical minus but a lag. Trouble+ 
 +The ''​-''​ is not a numerical minus but a lag. Trouble
 is that the predecessor for ''​x(d,'​h1'​)'' ​ is ''​x(d-1,'​h24'​)''​. You also have is that the predecessor for ''​x(d,'​h1'​)'' ​ is ''​x(d-1,'​h24'​)''​. You also have
 to decide what predecessor of  '''​d1''','''​h1'''​ is.  to decide what predecessor of  '''​d1''','''​h1'''​ is. 
Line 18: Line 19:
 predecessor (meaning ''​delta('​d1','​h1'​) = x('​d1','​h1)''​). I am assuming predecessor (meaning ''​delta('​d1','​h1'​) = x('​d1','​h1)''​). I am assuming
 your sets look like this your sets look like this
 +
 <​code>​ <​code>​
-set d / d1*d365 / +Set d / d1*d365 / 
-      h / h1*h24 /+    h / h1*h24 ​ /;
 </​code>​ </​code>​
 +
 Now here is what you can do: Now here is what you can do:
-''​delta(d,h) =e= x(d,h) - x(d-(1$sameas('​h1'​)),​h--1)) ;''​+ 
 +<​code>​ 
 +delta(d,h) =e= x(d,h) - x(d-(1$sameas('​h1'​)),​h--1)) ; 
 +</​code>​ 
  
 Not so elegant, but it will work. I prefer working with an additional Not so elegant, but it will work. I prefer working with an additional
 set of all hours in the year and a map between d,h and all hours in the year: set of all hours in the year and a map between d,h and all hours in the year:
 +
 <​code>​ <​code>​
-sets h /h1*h24/, d /d1*d365/, dh(d,h) /#d.#h/ +Set h /​h1*h24/, ​  ​         /d1*d365/, dh(d,h) /#d.#h/ 
-sets t /t1*t8760/, tdh(t,d,h) /#t:#dh/, dht/#dh:#t/+Set t /t1*t8760/, tdh(t,d,h) /#​t:#​dh/, ​ dht     ​/#dh:#t/;
 </​code>​ </​code>​
-This matching operators (''​.''​ and  '':''​)  ​are new syntax and will work with + 
-22.7 and higherYou can do the maps also with older GAMS statements.+''​.''​ and  '':''​ are called [[https://​www.gams.com/​latest/​docs/​UG_SetDefinition.html#​UG_SetDefinition_Multi-dimensionalSets|matching operators]].
 Now I would have the variable ''​x''​ and ''​delta''​ over ''​t''​ and then the Now I would have the variable ''​x''​ and ''​delta''​ over ''​t''​ and then the
-constraint looks simple: ​''​delta(t) =e= x(t) - x(t-1) (or x(t--1) for steady state)''​+constraint looks simple: ​ 
 + 
 +<​code>​ 
 +delta(t) =e= x(t) - x(t-1)(or x(t--1) for steady state) 
 +</​code>​ 
  
 In case you have data by ''​d,​h''​ you can use the map ''​tdh'',​ for example: In case you have data by ''​d,​h''​ you can use the map ''​tdh'',​ for example:
 ''​delta(t) =l= sum(tdh(t,​d,​h),​ maxdeviation(d,​h));''​ ''​delta(t) =l= sum(tdh(t,​d,​h),​ maxdeviation(d,​h));''​
IMPRESSUM / LEGAL NOTICEPRIVACY POLICY gams/model_predecessor_successor_relations.1389862835.txt.gz · Last modified: 2014/01/16 10:00 by admin