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

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

Sum over all observations except the observation under investigation

Post by teo21r » 4 months ago

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

Post by Fred » 3 months ago

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
User
Posts: 4
Joined: 8 months ago

Re: Sum over all observations except the observation under investigation

Post by teo21r » 3 weeks ago

Thank you, Fred! That was very helpful!

Teo

Post Reply