a question about Gams modeling

Problems with modeling
Post Reply
lawrence
User
User
Posts: 2
Joined: 6 years ago

a question about Gams modeling

Post by lawrence »

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
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: a question about Gams modeling

Post by Renger »

Hi Lawrence

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));

Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
lawrence
User
User
Posts: 2
Joined: 6 years ago

Re: a question about Gams modeling

Post by lawrence »

Hi Renger,

Your code is very helpful and my problem is solved now. Thank you very much!

Lawrence
Post Reply