Page 1 of 1

Modeling abs value

Posted: Fri Oct 06, 2017 3:29 pm
by kereviz
hello, i just started using gams, i apologize already for my pace.

I want to model following model, but i could not model the absolute value. I wrote something like the following but it is not true

zobj =e= sum(i,sum(j, f(i,j)* (xplus(i) + xneg(i) -xplus(j) + xneg(j) )))
Can you help me ?

Re: Modeling abs value

Posted: Sun Oct 15, 2017 10:47 am
by nsener
In my opinion, you must change abs part with a dummy decision variables like lambda(i,j) or etc. After defining this non negative decision you must replace abs part of objective with this decision variable. Please do not forget to add below constraints to reflect abs effect to the model:

cons(i,j).. lambda(i,j)=g=x(i)-x(j);
cons2(i,j).. lambda(i,j)=g=x(j)-x(i);

Another important part: define x as free variables and lambda as positive variables.