Gurobi constraint

Below is the minimum example of the model I am able to solve. Why is the constraint @constraint(model, Cost == (x-y)*z) allowed in Gurobi? Isn’t it nonlinear?

using JuMP
using Gurobi
model = Model(with_optimizer(Gurobi.Optimizer))
@variable(model, 100>= x >=0)
@variable(model, 100>= y >=0)
@variable(model, z, binary = true)

Cost = @variable(model, Cost)
@constraint(model, Cost == (x-y)*z)
@objective(model, Min, x + Cost)
JuMP.optimize!(model)

Gurobi supports quadratic constraints and objectives. In this case, it is even able to reformulate your model into a mixed-integer linear program. However, Gurobi is still able to solve non-convex quadratic programs. You may be interested in watching https://www.gurobi.com/resource/non-convex-quadratic-optimization/.

p.s. I edited the formatting of your post, you should take a read of PSA: make it easier to help you.

3 Likes

Thank you!

1 Like