• Gurobi Staff

Hello,

Your model is nonconvex because of the equality constraint $$aux = x^2 - x$$. Nonlinear equality constraints are always nonconvex. Since $$x^2-x$$ is $$\geq 0$$ for all $$x \in [0,1]$$, you could reformulate your model as

M=10import gurobipy as gpm=gp.Model()x=m.addVar(vtype='C',lb=0,ub=1)m.setObjective(x**2-0.6*x+M*(-x**2 + x))m.optimize()

Alternatively, you can just set the NonConvex parameter to 2 and let Gurobi solve the nonconvex model. In your case, it does not make any difference, because the model is (luckily) very small and simple.

m.setParam("NonConvex",2)

Best regards,
Jaromił

Thank you so much! Jaromił Najman

I am working on a large-scale problem.

I created this small example.

But the objective function will be concave here. Gurobipy can find the minimum for a concave function if the problem is simple, as you mentioned in this post: https://support.gurobi.com/hc/en-us/community/posts/10860412140049-Maximizing-convex-function

m.setObjective(x**2-0.6*x+M*(-x**2 + x))