User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
gams:model_an_absolute_value_in_a_linear_model [2007/11/06 21:06]
Franz Nelissen
gams:model_an_absolute_value_in_a_linear_model [2007/11/06 21:14]
Franz Nelissen
Line 5: Line 5:
 <​code>​ <​code>​
 obj..   ​z=e=sum(j,​ abs(x(j))); obj..   ​z=e=sum(j,​ abs(x(j)));
-cons(i) ​   sum(j, a(i,​j)*x(j)) =l= b(i);+cons(i)..   sum(j, a(i,​j)*x(j)) =l= b(i);
 model foo /all/; model foo /all/;
Line 19: Line 19:
 positive variable xplus(j), xneg(j); positive variable xplus(j), xneg(j);
 obj..   ​z=e=sum(j,​ xplus(j) + xneg(j)); obj..   ​z=e=sum(j,​ xplus(j) + xneg(j));
-cons(i) ​    ​sum(j, a(i,​j)*(xplus(j) - xneg(j))) =l= b(i);+cons(i)..   sum(j, a(i,​j)*(xplus(j) - xneg(j))) =l= b(i);
 model foo /all/; model foo /all/;
Line 25: Line 25:
 </​code>​ </​code>​
-positive variable xplus(j), xneg(j); 
-obj..   z =e= sum(j, xplus(j) + xneg(j)); 
-cons(i).. ​    ​sum(j,​ a(i,j) *(xplus(j) - xneg(j))) =l= b(i) 
-model foo /all/; 
-solve foo minimizing z using lp; 
-  ​ 
-However the absolute values can be avoided by replacing each  
-values ... 
-and |x | as follows. 
-j j 
IMPRESSUM / LEGAL NOTICEPRIVACY POLICY gams/model_an_absolute_value_in_a_linear_model.txt ยท Last modified: 2020/05/19 07:00 by Frederik Fiand