a question about Gams modeling

Problems with modeling
Post Reply
lawrence
User
User
Posts: 2
Joined: 5 months ago

a question about Gams modeling

Post by lawrence » 5 months ago

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: 111
Joined: 1 year ago

Re: a question about Gams modeling

Post by Renger » 5 months ago

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

lawrence
User
User
Posts: 2
Joined: 5 months ago

Re: a question about Gams modeling

Post by lawrence » 5 months ago

Hi Renger,

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

Lawrence

Post Reply