We are formulating a QP optimization problem in Pyomo + Mosek (commercial).
Unexpectedly, mosek complains the quadratic coefficient is not PSD.
Error: rescode.err_obj_q_not_psd(1295): The quadratic coefficient matrix in the objective is not positive semidefinite as expected for a minimization problem.
Minimal reproducible example:
import pyomo.kernel as pmo
import numpy as np; np.random.seed(1)
n = 5
Q1 = np.random.randn(n, n)
Q1 = Q1.T @ Q1 # theoretically always PSD
m = 5
A1 = np.random.randn(m, n)
b1 = np.random.randn(m)
problem = pmo.block()
problem.x = pmo.variable_list()
for i in range(n):
problem.x.append(pmo.variable())
problem.OBJ = pmo.objective(expr = problem.x @ Q1 @ problem.x, sense = pmo.minimize)
problem.cons = pmo.constraint_list()
tmp_lhs = A1 @ problem.x
for i in range(len(b1)):
problem.cons.append(pmo.constraint(expr= tmp_lhs[i] <= b1[i]))
opt = pmo.SolverFactory("mosek")
opt.solve(problem)
Reasons we think Q1 is PSD:
- All its eigenvalues are positive
- CPLEX (commercial) is able to solve it
Kindly help!