Constraint involving cumulative sums

Problems with syntax of GAMS
Post Reply
aycaaltay
User
User
Posts: 2
Joined: 6 years ago

Constraint involving cumulative sums

Post by aycaaltay »

Hi. I am new to the most parts of GAMS and I couldn't figure out how to write a constraint.
- I have a set i and its alias j.
- I also have set k.
- The variable is y(i,j,k).
- I have a parameter of p(j) and a scalar M.
- The constraint is for every j and k, and goes as this

y(i,j,k)= M- p(k)* ( y(1,j,k)+y(2,j,k)+...+y(i-1,j,k) ) - p(k)*( y(j,1,k)+y(j,2,k)+...+y(j,i-1,k) )

How can I code this cumulative sum?
cladelpino
User
User
Posts: 108
Joined: 7 years ago

Re: Constraint involving cumulative sums

Post by cladelpino »

If I understand properly you may need another set:

alias(t,i);

y(i,j,k) =e= M - p(k) * ( sum(t$(ord(t)<ord(i)), y(t,j,k) ) - p(k) * ( sum(t$(ord(t)<ord(i)), y(j,t,k) )

Is this what you want ?

Best
Claudio
aycaaltay
User
User
Posts: 2
Joined: 6 years ago

Re: Constraint involving cumulative sums

Post by aycaaltay »

Yes, it worked and I learnt it! Thank you very much
Post Reply