Sum over all observations except the observation under investigation

Problems with syntax of GAMS
Post Reply
teo21r
User
User
Posts: 3
Joined: 5 months ago

Sum over all observations except the observation under investigation

Post by teo21r » 1 month 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: 245
Joined: 4 years ago

Re: Sum over all observations except the observation under investigation

Post by Fred » 1 month 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

Post Reply