## This“ Activity level ” attribute is not reset Topic is solved

Problems with syntax of GAMS
zifeiyu
User Posts: 3
Joined: 3 weeks ago

### This“ Activity level ” attribute is not reset

GAMS Documentation say 'Activity level for the variable, also the current value or starting point. This attribute is reset to a new value when a model containing the variable is solved. The activity level is used to construct a basis for the model.' but the g_lin.l is not reset ！
thanks！

g_lin.l(t,i,b)=1000;

objective function.. cost=cost1+cost2;
cost2= sum((t,i)\$( (g_lin.l(t,i,'b1')+g_lin.l(t,i,'b2')+g_lin.l(t,i,'b3'))<100), sum(b,30*gs(t,i,b,ny)) ;
...

I found the g_lin.l(t,i,b) always equal to 1000, and the cost2=0. but the result of g_lin<100.

bussieck
Moderator Posts: 933
Joined: 6 years ago

### Re: This“ Activity level ” attribute is not reset

The var.l in equation syntax just replaces the val.l with the initial value, so GAMS and the solver see:

Code: Select all

``cost2 =e= sum((t,i)\$( (1000+1000+1000)<100), sum(b,30*gs(t,i,b,ny)) ;``
the 3000<100 is false for every pair (t,i) and hence the sum is epty making cost2 = 0. Makes all sense. What many people who use var.l in equation algebra usually want to do is to express some logical condition:

Code: Select all

``cost2 =e= sum((t,i)\$( g_lin(t,i,'b1')+g_lin(t,i,'b2')+g_lin(t,i,'b3')<100 ), sum(b,30*gs(t,i,b,ny)) ;``
In English "for every pair (t,i) add sum(b,30*gs(t,i,b,ny) to cost2 if g_lin(t,i,'b1')+g_lin(t,i,'b2')+g_lin(t,i,'b3') is less than 100". If that's what you want to say you need to reformulate your logical condition into regular algebra. Binary variables help you with that. Search the forum for "logical condition" and you find tons of hints.

-Michael

zifeiyu
User Posts: 3
Joined: 3 weeks ago

### Re: This“ Activity level ” attribute is not reset

bussieck wrote:
3 weeks ago
The var.l in equation syntax just replaces the val.l with the initial value, so GAMS and the solver see:

Code: Select all

``cost2 =e= sum((t,i)\$( (1000+1000+1000)<100), sum(b,30*gs(t,i,b,ny)) ;``
the 3000<100 is false for every pair (t,i) and hence the sum is epty making cost2 = 0. Makes all sense. What many people who use var.l in equation algebra usually want to do is to express some logical condition:

Code: Select all

``cost2 =e= sum((t,i)\$( g_lin(t,i,'b1')+g_lin(t,i,'b2')+g_lin(t,i,'b3')<100 ), sum(b,30*gs(t,i,b,ny)) ;``
In English "for every pair (t,i) add sum(b,30*gs(t,i,b,ny) to cost2 if g_lin(t,i,'b1')+g_lin(t,i,'b2')+g_lin(t,i,'b3') is less than 100". If that's what you want to say you need to reformulate your logical condition into regular algebra. Binary variables help you with that. Search the forum for "logical condition" and you find tons of hints.

-Michael
Thank you very much！！！