Absolute value in objective function

293 views
Skip to first unread message

MANUEL JOSE OSPINA OSPINA

unread,
Jun 28, 2022, 2:24:15 PM6/28/22
to AMPL Modeling Language

I have the ABS function in the objective function, how should I work it, with Piecewise, maybe? this is my function

minimize VALOR:
W1 * abs(METAU -OBJ1)/UMAX + W2 * abs(METAC - OBJ2)/CMAX;

AMPL Google Group

unread,
Jul 1, 2022, 1:40:41 AM7/1/22
to AMPL Modeling Language
You could define new variables "Abs1" and "Abs2" to represent the absolute values, so that your objective function becomes

minimize VALOR:
W1 * Abs1/UMAX + W2 * Abs2/CMAX;

Then add constraints to relate the new variables to the absolute values;

Abs1 >= METAU - OBJ1
Abs1 >= OBJ1 - METAU

Abs2 >= METAC - OBJ2
Abs2 >= OBJ2 - METAC

These constraints imply that, for example, Abs1 >= abs(METAU - OBJ1) -- but since the objective is being minimized, then as long as W1 and UMAX are nonnegative params, you will have Abs1 = abs(METAU - OBJ1) in any optimal solution.

If one of METAU, OBJ1 is a variable and the other one is a param, then you could also use AMPL's piecewise-linear notation.


--
Robert Fourer
am...@googlegroups.com
{#HS:1934227401-110740#}
Reply all
Reply to author
Forward
0 new messages