For "abs(X) <= 3" where X is a variable, you can write "-3 <= X <= 3". But for "abs(X) + abs(Y) <= 3" a more extensive reformulation is necessary. Since this constraint consists of a convex piecewise-linear function to the left of a <= constraint, it can be converted to a linear formulation using only continuous variables. There are several possibilities:
1. Use AMPL's
piecewise-linear notation to express the absolute value function explicitly as a piecewise-linear function with slope -1 to the left of 0 and +1 to the right of 0:
var X; var Y;
subj to absConstr: <<0;-1,+1>> X + <<0;-1,+1>> Y <= 3;AMPL will then automatically convert to a linear formulation before sending the problem to the solver.
2. Represent each variable as the difference of two nonnegative variables, and the absolute value as the sum of those variables:
var Xpos >= 0; var Xneg >= 0; var X = Xpos - Xneg;
var Ypos >= 0; var Yneg >= 0; var Y = Ypos - Yneg;
subj to absConstr: (Xpos + Xneg) + (Ypos + Yneg) <= 3;(AMPL uses this approach when it converts to a linear formulation.)
3. For abs(X) substitute a new variable that is >= X and >= -X, and similarly for abs(Y):
var X; var Y;
var Xabs >= 0; var Yabs >= 0;
subj to absConstr: Xabs + Yabs <= 3;
subj to XabsGE: Xabs >= -X; subj to XabsLE: Xabs >= X;
subj to YabsGE: Yabs >= -Y; subj to YabsLE: Yabs >= Y;