Page 1 of 1

This“ Activity level ” attribute is not reset

Posted: Tue Feb 28, 2023 1:00 pm
by zifeiyu
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.

Re: This“ Activity level ” attribute is not reset

Posted: Tue Feb 28, 2023 3:49 pm
by bussieck
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

Re: This“ Activity level ” attribute is not reset

Posted: Wed Mar 01, 2023 1:52 am
by zifeiyu
bussieck wrote: 1 year 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!!!