Sum over all observations except the observation under investigation

Dear all,

The following code provides a partial example of a code that is run separately for each of the 3 observations in set i.
SETS i /1*3/
.
ALIAS (ii, i) ;

out(i,outp)… sum(ii,lm(i,ii)y(outp,ii))=E=y(outp,i)(1+beta1(i));

model uno /out ,…/;
solve uno using nlp maximizing z;

In the GAMS .lst file, equation “out” for observation 1 will look like that

lm(1,1)*y(outp,1)+lm(1,2)*y(outp,2)+lm(1,3)y(outp,3)=y(outp,1)(1+beta1(1))

How can I write equation “out” in a way that its left-hand side summation does not include the observation under investigation. In the previous example, the “out” equation will look as follows:

lm(1,2)*y(outp,2)+lm(1,3)y(outp,3)=y(outp,1)(1+beta1(1))

Thanks,
Teo

Hi Teo,

You could use a dollar condition as follows

out(i,outp).. sum(ii$(not sameas(i,ii)),lm(i,ii)*y(outp,ii))=E=y(outp,i)*(1+beta1(i));

I hope this helps!

Fred

Thank you, Fred! That was very helpful!

Teo