How can I linearize a quadratic equation or constraint?
AnsweredI have a multi-objective optimization problem, of which the first equation includes a quadratic element. It is my understanding that quadratic equations cannot be handled in multi-objective problems, and that they often increase solving time. So, I want to linearize it to make it easy. The part of my objective function that includes a quadratic element is:
obj_profit += gp.quicksum(N_f[key[0], key[2]] * N_P[key] * b for key in routing_key)
Where \( N_{P,r} \) and \( N_{F,m} \) are optimization variables in the form of positive integers subject to certain constraints. In order to linearize the problem, I have added the constraint:
gurobi_model.addConstrs((N_P[key] * N_F[key[0], key[2]] == N_freq_times_p[key] for key in routing_key), "Freq_Premium_Times_Pax")
so that the objective function now becomes:
obj_profit += gp.quicksum(N_freq_times_p[key] * b for key in routing_key)
However, I still get the error message gurobipy.GurobiError: Quadratic equality constraints are non-convex. Set NonConvex parameter to 2 to solve model.
Is there a step I am missing in the linearization of the equation?
Thanks in advance!
-
Hi Laura,
The added equality quadratic constraints makes the problem nonconvex and you need to explicitly set the parameter NonConvex=2 to tell Gurobi that it needs to solve a nonconvex problem.
Best regards,
Maliheh
0
Please sign in to leave a comment.
Comments
1 comment