Why doesn't Python's CXVOPT satisfy the constraints of my problem?

37 Views Asked by At

I am trying to solve a non-linear optimization problem using CXVOPT, but it is not satisfying my constraint which requires the sum of the elements of my solution vector to equal to 1.

Here is the code I am using to setup the problem.

import numpy as np
from cvxopt import blas, solvers, matrix

d = list(np.arange(0.8, 1.26, 0.05))

V = np.diag(d)

P = matrix(V)
q = matrix(0.0, (10, 1))
A = matrix(1.0, (1, 10))
b = matrix(1.0)

sol = solvers.qp(P, q, A, b)

I am expecting sum(sol['x']) to be equal to 1, but instead it is -2.2858986009043038e-07, which is very close to zero.

0

There are 0 best solutions below