Two dependent variables in an additional equation

Problems with modeling
Post Reply
Miette
User
User
Posts: 2
Joined: 1 year ago

Two dependent variables in an additional equation

Post by Miette »

Hello together,
I'm new here and very new to GAMS, too. Please excuse me if my question would be answered very easily, somehow I struggle a lot. But I'd be happy about some advise, as I do not understand how GAMS functions quiet well enough.
I have to add an equation to an existing model. It's about costs, meaning that a new variable (eg 'price(t)') shall be equal to another variable 'price2(t-1)'. This shall be calculated for each period t. The problem that I struggle with it that the starting value of price(t) shall be given, and price2 shall be calculated using the model in which I implement this equation. So price2 depends on price(t), which is given for the first period, and in the second period, price(t) shall depend on price2(t-1).

My first idea is the following:

Code: Select all

Scalar price /7/; 
Equation eq1; 
eq1 .. price(t)$ord(t)>1) =e= price2(t-1)
But I'm not sure if it would be better to work with a loop?

Please excuse me if there is some information missing, I really do not have a feeling for this program yet, so I cannot say which information bits are important and which are not. I'd be very happy if someone could give me at least some starting information, or a hint on what basics I am missing and I should revise. I already took an online course and have former experience with MATLAB, but I feel completely lost.
Thank you!
User avatar
bussieck
Moderator
Moderator
Posts: 1038
Joined: 7 years ago

Re: Two dependent variables in an additional equation

Post by bussieck »

Almost there. You need to fix the variable price in the first period to the externally given price. Moreover, you need at add an index t to your equation, because you want to have equality for all (but the first) t. The condition to skip the first t also goes on the equation:

Code: Select all

Equation eq1(t); 
eq1(t)$(ord(t)>1) .. price(t) =e= price2(t-1)
price.fx(t)$(ord(t)=1) = 7;
-Michael
Miette
User
User
Posts: 2
Joined: 1 year ago

Re: Two dependent variables in an additional equation

Post by Miette »

Thank you a lot, that looks good! Seems like I have to dig deeper in all this index stuff.
I'm gonna try it with your code, thanks again :)
Post Reply