Re: "Rank(A) < p or Rank([G; A]) < n" error from ArithmeticError exception

5,151 views
Skip to first unread message

Martin

unread,
Jun 7, 2013, 10:15:23 AM6/7/13
to cvx...@googlegroups.com
Hi Matthew,

The issue is most likely that you have redundant constraints. For example, you get the error if you try to solve a problem with the constraints

x1 >= 1
x2 >= 1
x3 + x4 >= 0
x1 + x2 >= 1

which can be expressed as G*x + s = h with 

G = [ -1  0  0  0 ]   h = [ -1 ]
    [  0 -1  0  0 ]       [ -1 ]
    [  0  0 -1 -1 ]       [  0 ]
    [ -1 -1  0  0 ]       [ -1 ].

Notice that G has four rows, but its last row is clearly a consequence of the first two, so the rank is only three. 

Martin


On Friday, June 7, 2013 12:32:14 AM UTC-7, Matthew Jeppesen wrote:
Hi folks, 

I'm trying to use cvxpy (and hence cvxopt) to model optimal power flow in a relatively simple network with 28 nodes and 37 lines, but getting a "Rank(A) < p or Rank([G; A]) < n" error.

(Using the same code, I can find successfully find the optimal solution for a much simpler network with 4 nodes and 4 lines.)

I've checked very carefully that the constraints are not inconsistent (using my answer to my own question on Stack Overflow: 

Here is the traceback:

File "main.py", line 201, in test_simple_optimisation
    p, bids, offers = optimize_flow(bids, offers, lines, nodes, injections_from_schedule, shift_factors, admittance.T)
  File "main.py", line 143, in optimize_flow
    p.solve()
  File "build/bdist.macosx-10.8-intel/egg/cvxpy/programs.py", line 169, in solve
    obj,valid = solve_prog(new_p,quiet)
  File "build/bdist.macosx-10.8-intel/egg/cvxpy/procedures/solve_prog.py", line 44, in solve_prog
    sol = call_solver(p_expanded,quiet)
  File "build/bdist.macosx-10.8-intel/egg/cvxpy/procedures/call_solver.py", line 78, in call_solver
    r =  solvers.conelp(c,G,h,dims,A,b)
  File "/Library/Python/2.7/site-packages/cvxopt/coneprog.py", line 687, in conelp
    raise ValueError("Rank(A) < p or Rank([G; A]) < n")
ValueError: Rank(A) < p or Rank([G; A]) < n

When I look at /Library/Python/2.7/site-packages/cvxopt/coneprog.py", line 687, it is actually rescuing an arithmetic error

 685         try: f = kktsolver(W)
 686         except ArithmeticError:..
 687             raise ValueError("Rank(A) < p or Rank([G; A]) < n")

Does that make sense? Why would an arithmetic error (i.e. something like an OverflowError, ZeroDivisionError, FloatingPointError, unless cvxpy has extended it) mean that the problem is ill described i.e. has Rank(A) < p or Rank([G; A]) < n" ? 

Thanks, 

Matthew 

Joachim Dahl

unread,
Jun 7, 2013, 10:45:20 AM6/7/13
to cvx...@googlegroups.com

Network problems often have dependency in the constraints.

--
You received this message because you are subscribed to the Google Groups "CVXOPT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cvxopt+un...@googlegroups.com.
To post to this group, send email to cvx...@googlegroups.com.
Visit this group at http://groups.google.com/group/cvxopt?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Matthew Jeppesen

unread,
Jun 12, 2013, 1:46:30 AM6/12/13
to cvx...@googlegroups.com
Thanks, I removed some constraints and the optimiser now solves the problem correctly.

Actually, the constraints I removed were not just dependent on other constraints, but guaranteed to be satisfied for any input, because of how I constructed the problem. 

Thanks again, and great software, 

Matthew

ymous

unread,
Apr 16, 2014, 11:11:37 AM4/16/14
to cvx...@googlegroups.com
What if I have


x1 >= 1
x2 >= 1
x1 + x2 >= 10

These are not redundant, but the matrix will be rank deficient.  What can I do ???

Martin S. Andersen

unread,
Apr 16, 2014, 12:33:46 PM4/16/14
to cvx...@googlegroups.com
Forget my explanation with the rows. The rank of G should be equal to the number of columns in G. This is clearly not the case in my example since the third and the fourth columns of G are the same, but your example is fine.

--
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/qlu3CK1TdVQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cvxopt+un...@googlegroups.com.

To post to this group, send email to cvx...@googlegroups.com.
Visit this group at http://groups.google.com/group/cvxopt.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages