Quadratic equality constraints are non-convex
AnsweredHi all,
I formulate the following problem in Gurobi:

that I belive should be convex but I get the error "GurobiError: Quadratic equality constraints are non-convex".
Can anyone tell me how to check in Gurobi why this formulation is Non-Convex? ... there is a way to convert this in a convex problem?
Here, you can find the code to reproduce the error:
import gurobipy as gp
from gurobipy import GRB
model = gp.Model("quad")
d = 2
x1 = model.addVars(d, name="x1", lb=-GRB.INFINITY, ub=+GRB.INFINITY)
x2 = model.addVars(d, name="x2", lb=-GRB.INFINITY, ub=+GRB.INFINITY)
x3 = model.addVars(d, name="x3", lb=-GRB.INFINITY, ub=+GRB.INFINITY)
Y = model.addVars(2, name="y", lb=-GRB.INFINITY, ub=+GRB.INFINITY)
### OBJECTIVE ###
obj = Y[0] + Y[1]
model.setObjective(obj, GRB.MINIMIZE)
### CONSTRAINS ###
model.addConstr(Y[0] >= 0)
model.addConstr(Y[1] >= 0)
model.addConstr(Y[0] + ((x1[0] - x2[0])**2 + (x1[1] - x2[1])**2) - 1 == 0)
model.addConstr(Y[1] + ((x2[0] - x3[0])**2 + (x2[1] - x3[1])**2) - 1 == 0)
model.optimize()
Thanks!
0
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Lorenzo,
quadratic equality constraints are never convex. The feasible set usually contains discrete points that are not connected and thus the set is non-convex.
Best regards,
Mario0
Post is closed for comments.
Comments
2 comments