Modeling abs value

Problems with modeling
Post Reply
kereviz
User
User
Posts: 1
Joined: 2 years ago

Modeling abs value

Post by kereviz » 2 years ago

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 ?
Attachments
Screenshot_1.png
Screenshot_1.png (10.47 KiB) Viewed 962 times

nsener
User
User
Posts: 4
Joined: 2 years ago

Re: Modeling abs value

Post by nsener » 2 years ago

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.

Post Reply