Page 1 of 1

a question about Gams modeling

Posted: Wed Nov 15, 2017 7:58 am
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

Re: a question about Gams modeling

Posted: Thu Nov 16, 2017 12:20 pm
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

Re: a question about Gams modeling

Posted: Fri Nov 17, 2017 2:00 am
by lawrence
Hi Renger,

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

Lawrence