Modeling quadratic constraints in different variables
AnsweredI saw on the website that one can write quadratic constraints of the form x*x + y*y <= c, but Is it possible to write a constraint of the form x^T y <= c where x and y are vectors?
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 Surya,
Yes, this is possible:
import gurobipy as gp
import numpy as np
m = gp.Model()
n = 3
x = m.addMVar(n, name='x')
y = m.addMVar(n, name='y')
c = 2
m.addConstr(x @ np.eye(3) @ y <= c)Resulting in this QP:
Minimize
Subject To
qc0: [ x[0] * y[0] + x[1] * y[1] + x[2] * y[2] ] <= 2
Bounds
EndCheers,
Matthias1
Post is closed for comments.
Comments
2 comments