Page 1 of 1

limited sums

Posted: Tue Jan 19, 2021 7:03 pm
by anonyms14225
Hi,

I have a binary variable y(i,j,k) and i want to add this constraint:

y(i,j,k)+y(i,j,k+1)+y(i,j,k+2) =l= 1; for all i's and j's.

For example
y(1,1,1)+y(1,1,2)+y(1,1,3)<=1;

I'm new to GAMS, sorry if that's a rather silly question

Re: limited sums

Posted: Tue Jan 19, 2021 9:49 pm
by Renger
Hi
Looks fine. However, notice that if you are at the last k and the one before that the constraint will read

Code: Select all


last k
y(i,j,k)=l= 1;
* Last k - 1
y(i,j,k)+y(i,j,k+1) =l= 1;
Cheers

Renger

Re: limited sums

Posted: Tue Jan 19, 2021 9:54 pm
by anonyms14225
Thank you for this heads up! But, my question was unclear, i meant to ask how to add "for all i's & j's" to my model. Normally i use sum((i, j), y(i, j, k,)) but since it is limited i don't know how to do it.

Re: limited sums

Posted: Wed Jan 20, 2021 7:59 am
by Renger
Your question is still not clear to me. The equation is for all i,j,k. I don't understand what you mean by summing is a problem.
Cheers
Renger