Hi, All,
I found a strange thing when dealing with sum syntax.
The model works if I choose
DATA(‘CTOTS’,J2)=DATA(‘CTOTS’,J2)*sum(I2,DATA(I2,‘RTOTS’))/P_scale;
where
P_scale=sum(J2,DATA(‘CTOTS’,J2));
However, if I simple replace P_scale
DATA(‘CTOTS’,J2)=DATA(‘CTOTS’,J2)*sum(I2,DATA(I2,‘RTOTS’))/sum(J2,DATA(‘CTOTS’,J2));
GAMS will report “Set is under control already”
The full code is attached. Thanks in advance.
Best/JG
Set I
I2(I)
J
J2(J);
Scalar P_scale;
TABLE DATA(I<,J<)
COL1 COL2 COL3 COL4 RTOTS
ROW1 0 3 2 7 100
ROW2 11 4 3 11 50
ROW3 18 6 0 7 30
ROW4 8 5 5 0 10
CTOTS 80 50 30 30
*=========================================================================*
;
I2(I)$(not sameas(I,"CTOTS"))= YES;
J2(J)$(not sameas(J,"RTOTS"))= YES;
DATA(I2,'RTOTS')=100;
DATA('CTOTS',J2)=sum(i2,DATA(i2,j2));
P_scale=sum(J2,DATA('CTOTS',J2));
DATA('CTOTS',J2)=DATA('CTOTS',J2)*sum(I2,DATA(I2,'RTOTS'))/P_scale;
*DATA('CTOTS',J2)=DATA('CTOTS',J2)*sum(I2,DATA(I2,'RTOTS'))/sum(J2,DATA('CTOTS',J2));
Display DATA;