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.
This“ Activity level ” attribute is not reset Topic is solved
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:
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:
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
Code: Select all
cost2 =e= sum((t,i)$( (1000+1000+1000)<100), sum(b,30*gs(t,i,b,ny)) ;
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)) ;
-Michael
Re: This“ Activity level ” attribute is not reset
Thank you very much!!!bussieck wrote: ↑3 weeks agoThe var.l in equation syntax just replaces the val.l with the initial value, so GAMS and the solver see:
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)$( (1000+1000+1000)<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.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)) ;
-Michael