ValueError: Rank(A) < p or Rank([P; A; G]) < n

115 views
Skip to first unread message

應雨軒

unread,
Feb 15, 2021, 6:15:09 PM2/15/21
to CVXOPT
Hi, I am learning how to use cvxopt to solve qp problems.
But I encountered some problems when I practicing some examples from this website
https://cvxopt.org/examples/tutorial/qp.html
My cvxopt version is 1.19,and I use python2.7
After I run this code, I got error message : ValueError: Rank(A) < p or Rank([P; A; G]) < n
Can some one give me some advices? Thank you

Martin

unread,
Feb 15, 2021, 6:22:23 PM2/15/21
to CVXOPT
You most likely have redundant constraints. The rank condition is an assumption that is used in the KKT solver; see Quadratic Cone Programs in the user's guide. 

應雨軒

unread,
Feb 16, 2021, 1:39:42 AM2/16/21
to CVXOPT
My code is below:

from cvxopt import matrix, solvers
Q = 2*matrix([ [2, .5], [.5, 1] ])
p = matrix([1.0, 1.0])
G = matrix([[-1.0,0.0],[0.0,-1.0]])
h = matrix([0.0,0.0])
A = matrix([1.0, 1.0], (1,2))
b = matrix(1.0)
sol=solvers.qp(Q, p, G, h, A, b)

I think there are not any redundant constraints, or there are something I didn't notice?
I can't successfully use cvxopt in pycharm, so I wonder if there are something wrong with my code, or maybe There are some problems when I install cvxopt
Thank you
Martin 在 2021年2月16日 星期二上午7:22:23 [UTC+8] 的信中寫道:

Martin

unread,
Feb 16, 2021, 7:14:30 AM2/16/21
to CVXOPT
It appears to be a problem with your installation. The code that you posted produces the following output:

     pcost       dcost       gap    pres   dres
 0:  1.8889e+00  7.7778e-01  1e+00  2e-16  2e+00
 1:  1.8769e+00  1.8320e+00  4e-02  2e-16  6e-02
 2:  1.8750e+00  1.8739e+00  1e-03  2e-16  5e-04
 3:  1.8750e+00  1.8750e+00  1e-05  1e-16  5e-06
 4:  1.8750e+00  1.8750e+00  1e-07  1e-16  5e-08
Optimal solution found.

How did you install CVXOPT?

應雨軒

unread,
Feb 17, 2021, 9:12:16 AM2/17/21
to cvx...@googlegroups.com
I use python 2.7,so I downloaded numpy cp27 and cvxopt cp27(red circle in the below pictures)
Then pip instal in pycharm
Are there anything wrong ?
Thank you
 555.png
666.png

Martin <martin.skovg...@gmail.com> 於 2021年2月16日 週二 下午8:14寫道:
--
You received this message because you are subscribed to a topic in the Google Groups "CVXOPT" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cvxopt/EzPKxqg-aYg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cvxopt+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cvxopt/a5c28ef5-bf84-4e74-b63b-b4d78060e15en%40googlegroups.com.

Martin

unread,
Feb 17, 2021, 5:33:28 PM2/17/21
to CVXOPT
This is an old version of CVXOPT and not an official release. Have you tried installing CVXOPT using "pip install cvxopt"? 

應雨軒

unread,
Feb 19, 2021, 3:32:43 AM2/19/21
to cvx...@googlegroups.com
After I typed "pip install cvxopt "in my pycharm terminal,I got this error message 
I can't install cvxopt by using "pip install cvxopt

Martin <martin.skovg...@gmail.com> 於 2021年2月18日 週四 上午6:33寫道:
12333.png
Reply all
Reply to author
Forward
0 new messages