I just wanted to confirm if this is the right way to solve a nonconvex problem with bilinear terms (continuous times continuous variables) using Gurobi. I assumed to define a nonlinear constraint or objective, I should be using @NLconstraint
; however, I get the following error:
ERROR: The solver does not support nonlinear problems (i.e., NLobjective and NLconstraint).
So, basically the following problem throws the error:
using JuMP, Gurobi
model = Model(Gurobi.Optimizer)
set_optimizer_attribute(model, "NonConvex", 2)
@variable(model, x >= 0)
@variable(model, 0 <= y <= 10)
@NLconstraint(model, x*y <= 10)
@NLobjective(model, Max, x*y-3*x+2*y)
optimize!(model)
However, the following model works fine:
using JuMP, Gurobi
model = Model(Gurobi.Optimizer)
set_optimizer_attribute(model, "NonConvex", 2)
@variable(model, x >= 0)
@variable(model, 0 <= y <= 10)
@constraint(model, x*y <= 10)
@objective(model, Max, x*y-3*x+2*y)
optimize!(model)
So, I suppose if I am trying to solve a nonlinear problem with Gurobi I am fine with using @constraint
instead of @NLconstraint
even if the expression has nonlinear terms?