I am facing a problem with Gams modeling, and will be very appreciated if someone can help me.
I define:
set t
variable x(t).
I want to express this equation as a constraint in my model:
x(t=T)>=sum(t,x(t<=T-1))
which means the variable x at time slot t should be equal or larger than the sum of x at all time slot before t.
I tried a lot of ways to express it as an equation in Gams, but all of them doesn't work. Can someone here help me dealing with this? Thanks!
Lawrence
a question about Gams modeling
Re: a question about Gams modeling
Hi Lawrence
I assume that T is the last period in your model
Cheers
Renger
I assume that T is the last period in your model
Code: Select all
set
t 'periods' /t1*t10/,
lastt(t) 'last period';
* Define the last period by using the total number of elements in the set t
lastt(t)$(ord(t) eq card(t)) = yes;
display lastt;
variable x(t).
alias(t,tt);
x(lastt) =G= sum(tt$(ord(tt) lt card(t), x(tt));
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Re: a question about Gams modeling
Hi Renger,
Your code is very helpful and my problem is solved now. Thank you very much!
Lawrence
Your code is very helpful and my problem is solved now. Thank you very much!
Lawrence