我正在尝试使用cvxpy(以及cvxopt)在28个节点和37行的相对简单的网络中建模最优潮流,但得到“Rank(A)< p或Rank([G; A] ])< n“错误。
(使用相同的代码,我可以找到最简单的网络,包含4个节点和4个线路的最佳解决方案。)
我已经非常仔细地检查了约束是不一致的(使用我对Stack Overflow上这个问题的回答: Check constraints are ok in cvxpy with actual values)
这是追溯:
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
当我查看/Library/Python/2.7/site-packages/cvxopt/coneprog.py“,第687行时,它实际上是在解决算术错误
685 try: f = kktsolver(W)
686 except ArithmeticError:..
687 raise ValueError("Rank(A) < p or Rank([G; A]) < n")
这有意义吗?为什么算术错误,例如OverflowError
,ZeroDivisionError
,FloatingPointError
,除非cvxpy已经扩展了ArithmeticError,这意味着问题描述不清楚,即具有Rank(A)&lt; p或Rank([G; A])&lt; N“?
答案 0 :(得分:5)
嗯,事实证明删除一些冗余约束确实解决了问题(正如cvxopt谷歌群组所建议的那样:https://groups.google.com/forum/?fromgroups=#!topic/cvxopt/qlu3CK1TdVQ。我不确定为什么会抛出ArithmeticError
。
实际上,我删除的约束不仅仅依赖于其他约束,而且保证满足任何输入,因为我是如何构造问题的。