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?
Constraint involving cumulative sums
-
- User
- Posts: 108
- Joined: 7 years ago
Re: Constraint involving cumulative sums
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
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
Re: Constraint involving cumulative sums
Yes, it worked and I learnt it! Thank you very much