I’m really new to optimization (and to Julia as well)
Hi! Yes, getting used to JuMP takes a bit of time, especially if you don’t have a background in mathematical programming.
As a general rule (with some exceptions), we don’t support arbitrary Julia functions like:
count_nonzero(x) = sum(x .!= 0)
@expression(model, expr, count_nonzero(v))
Instead, if you’re using a solver like Gurobi, you must formulate your problem as a mixed-integer linear or quadratic program using the syntax and functions provided by JuMP.
If you’re using Gurobi, and you want to use the L1-norm, then write:
model = Model()
@variable(model, x[1:4])
@variable(model, t)
@constraint(model, [t; x] in MOI.NormOneCone(length(x) + 1))
@objective(model, Min, t)