I need help with a if sentence

Problems with syntax of GAMS
Post Reply
dgormaz
User
User
Posts: 10
Joined: 5 years ago

I need help with a if sentence

Post by dgormaz »

Hello.
I'm trying to put a if statement in a constraint but i can't
I'm trying with:
economic31(MW12, I1)$(FM2_2.L>0).. OpC31(MW12,I1)=E= (g*((HI1(I1)-HMW12(MW12))))+(OpF4*Dist31(MW12,I1)*(FM2_2(MW12,I1)**2));
** Error 148 Dimension different
economic31(MW12, I1)$((FM2_2(MW12,I1).L)>0).. OpC31(MW12,I1)=E= (g*((HI1(I1)-HMW12(MW12))))+(OpF4*Dist31(MW12,I1)*(FM2_2(MW12,I1)**2)); (this one is illogical but i have to try)
** Error 8 ')' expected, Error 36
economic31(MW12, I1)$(FM2_2(MW12, I1)>0).. OpC31(MW12,I1)=E=(g*((HI1(I1)-HMW12(MW12))))+(OpF4*Dist31(MW12,I1)*(FM2_2(MW12,I1)**2));
** Error 52 Endogenous '$- control operations not allowed

HELP!
Thanks
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: I need help with a if sentence

Post by Renger »

Hi
Note that you can't use variables in $-conditions in your equations as shown in the last error "Endogenous '$- control operations not allowed "
The dimension error is caused by FM2_2.L>0. Here you forgot to add the dimensions of FM2_2, but again, endogenous $-control operations are not allowed.
You will have to find a way to write this condition as an extra constraint.
CHeers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Post Reply