## Sum over all observations except the observation under investigation Topic is solved

Problems with syntax of GAMS
teo21r
User Posts: 4
Joined: 8 months ago

### 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

Fred
Posts: 247
Joined: 4 years ago

### Re: Sum over all observations except the observation under investigation

Hi Teo,

You could use a dollar condition as follows

Code: Select all

``````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

teo21r
User Posts: 4
Joined: 8 months ago

### Re: Sum over all observations except the observation under investigation

Thank you, Fred! That was very helpful!

Teo