GAMS summing over subset

I am trying to sum over a subset between $$t+1$$ and $$t+U-1$$ as follows $$y_i^t+\sum_{k=t+1}^{t+Ut_i-1}z_i^k\le1$$ but I could not define the condition within sum.

Here is what I have tried:

y(i,t) + sum(t $(ord(t)=t+1 and ord(t)<= t+gendata(i,"U")-1) ,z(i,j)) =l= 1; • Welcome to OR.SE. One possible way would be defining two parameters as$UB$and$LB$in the pre-processing and filter the inner loop (on the summation) based on. Would you try that? Mar 6 '21 at 15:37 • You mean like this: Parameters LB 'lower limit'; LB= t+1; Parameters UB 'Upper limit'; UB= j+gendata(i,"MUP")-1; Uptime2.. u(i,j) + sum(j,$ (ord(j)>= LB AND ord(j)<= UB) ,v(i,j)) =l= 1; Mar 6 '21 at 17:02
• I meant something like this, just in the summation, you have to apply $operator before comma. sum((j)$ (ord(j)>= LB AND ord(j)<= UB, ...). I recommend that first defining a global set on the planning horizon, set t /1...T/, then alias that by other index like $k$. Mar 6 '21 at 19:55
• I surely hope that GAMS produced a ton of error messages for this input. I usually start by studying the first error message, fix it, recompile and repeat. Mar 6 '21 at 22:15
• Related: GAMS Sum over a subset May 5 '21 at 20:41