non-zero values constraint in QP

30 views
Skip to first unread message

Pravin Bezwada

unread,
Aug 9, 2016, 7:46:15 AM8/9/16
to CVXOPT
Hi all,

I have QP problem as below:

def getweights(params, cov):
    (m,n) = np.shape(params)
    P = matrix(cov)
    q = matrix([0.] * m, (m, 1))
    A = matrix(params.T)
    b = matrix([0.] * n, (n, 1))
    res = solvers.qp(P=P, q=q, A=A, b=b)    
    return res['x']

This always returns zero for all x. I want to add a non zero condition to each x. Could someone please help me?

Best regards,
Pravin

Martin

unread,
Aug 11, 2016, 4:27:18 AM8/11/16
to CVXOPT
It looks like you're solving a QP with equality constraints only. This problem can be solved analytically by solving the equation


[PAAT0][xλ]=[qb]


and since q=0 and b=0 in your case, it is clear that x=0 is a solution. Note that the constraint that x must be nonzero is a nonconvex constraint, but you can add the constraint that x is nonnegative, but this clearly does not help in this case.

Martin

unread,
Aug 11, 2016, 4:29:06 AM8/11/16
to CVXOPT

The equations did not show up as expected, so here there are in text:

P*x + A.T*lambda = -q
A*x = b
Reply all
Reply to author
Forward
0 new messages