Change Equation over time

Problems with modeling
Post Reply
pelorn
User
User
Posts: 14
Joined: 4 years ago

Change Equation over time

Post by pelorn »

I am trying to update the DICE2013 model in GAMS. I want to solve parts of it recursively.

If I have an equation like the one below, how can I tell GAMS that after, say 5 periods t, it should update the equation?

I(t) =E= S(t) * Y(t);

So that after 5 periods, the function for example becomes:

I(t) =E= S(t) * AY(t);

Thank you
Fred
Posts: 373
Joined: 7 years ago

Re: Change Equation over time

Post by Fred »

Hi,

You can have two different equations, one for t<=5 and one for t>=6.
Assuming that t is an ordered set (https://www.gams.com/latest/docs/UG_OrderedSets.html), this can be done as follows:

Code: Select all

equation eq1(t), eq2(t);
[...]
eq1(t)$(ord(t)<=5).. I(t) =E= S(t) * Y(t);
eq2(t)$(ord(t)>=6).. I(t) =E= S(t) * AY(t);
I hope this helps!

Fred
pelorn
User
User
Posts: 14
Joined: 4 years ago

Re: Change Equation over time

Post by pelorn »

Hi Fred,

Thanks for your answer. It should be the same equation though as I try to maximize this one equation. Any idea?

Thanks heaps
Fred
Posts: 373
Joined: 7 years ago

Re: Change Equation over time

Post by Fred »

You can just move the dollar condition into the equation body.

Code: Select all

eq(t).. I(t) =E= S(t) * (Y(t)$(ord(t)<=5) + AY(t)$(ord(t)>=6)) ;
I hope this helps!

Fred
pelorn
User
User
Posts: 14
Joined: 4 years ago

Re: Change Equation over time

Post by pelorn »

Cool, thank you!
Post Reply