Absolute value, abs(), on Gurobi solver

Try this:

using JuMP, Gurobi
m = Model(Gurobi.Optimizer)
@variable(m, x)
@constraint(m,   x <= 5)
@constraint(m, - x <= 5)
@objective(m, Min, x)
JuMP.optimize!(m)
@show JuMP.termination_status(m)
@show value.(x)

or use a function

function add_abs_constraint(model::JuMP.Model, expr::GenericAffExpr, rhs)
    @constraint(model,     expr <= rhs)
    @constraint(model,   - expr <= rhs)

   return nothing
end

e.g.

expr = JuMP.@expression(m,  2x - 4)
add_abs_constraint(m, expr, 2)
JuMP.optimize!(m)

should return something from Gurobi like

Solved in 1 iterations and 0.00 seconds
Optimal objective  1.000000000e+00
3 Likes