Cvxopt fails with float division by zero

436 views
Skip to first unread message

Sergio

unread,
Sep 30, 2013, 10:05:30 AM9/30/13
to cvx...@googlegroups.com
Hi,

I have a problem where cvxopt at times fails with a 'float division by zero' exception.

This uses the conelp solver and exits with a stack trace ending in

File "/home/callegar/.local/lib/python2.7/site-packages/cvxpy/procedures/call_solver.py", line 77, in call_solver

r = solvers.conelp(c,G,h,dims,A,b)

File "/home/callegar/.local/lib/python2.7/site-packages/cvxopt/coneprog.py", line 1400, in conelp

misc.update_scaling(W, lmbda, ds, dz)

File "/home/callegar/.local/lib/python2.7/site-packages/cvxopt/misc.py", line 628, in update_scaling

a = 1.0 / math.sqrt(lmbda[ind+i])

ZeroDivisionError: float division by zero

The problems derives from an application where cvxopt is indirectly called via the cvxpy DCP wrapper by Tinoco de Rubeira (http://www.stanford.edu/~ttinoco/cvxpy/start.html, possibly now superseeded).


What is puzzling me is that the ZeroDivisionError only occurs about 1 time over 5 restarting the same code with the same data.


Any clue at how to avoid it?



Martin

unread,
Oct 4, 2013, 4:16:04 AM10/4/13
to cvx...@googlegroups.com
Hi,

Do you have a small example? Multithreaded execution may lead to different results with the same data because of roundoff errors.

Martin

Sergio Callegari

unread,
Oct 4, 2013, 4:34:45 AM10/4/13
to cvx...@googlegroups.com
On 04/10/2013 10:16, Martin wrote:
Hi,

Do you have a small example? Multithreaded execution may lead to different results with the same data because of roundoff errors.

Martin

Hi,

So far I have some code that is not suitable as an example because there are too many things that are not relevant. But I'll try to distill an example from it...
Is it a problem if the example relies on cvxpy for calling cvxopt?

Two aspects that I can anticipate are: that to get results suitable for the application (i.e. comparable with results obtained otherwise) I need to use very strict reltol/abstol (e.g. 1E-18) which basically mean letting cvxopt often stop on the iteration limit. Furthermore, I have a quadratic form as a minimization goal that is positive definite, but with some of the eigenvalues really close to zero.

Currently, to hack around the problem I'm wrapping the call to the otpimizer in a try statement and repeat the call every time it exits with ZeroDivisionError.  Unfortunately this approach is very time consuming.

Thanks for your message and for providing an explanation to the different behavior at different invocations.

Best regards

Sergio


On Monday, September 30, 2013 4:05:30 PM UTC+2, Sergio wrote:
Hi,

I have a problem where cvxopt at times fails with a 'float division by zero' exception.

This uses the conelp solver and exits with a stack trace ending in

File "/home/callegar/.local/lib/python2.7/site-packages/cvxpy/procedures/call_solver.py", line 77, in call_solver

r = solvers.conelp(c,G,h,dims,A,b)

File "/home/callegar/.local/lib/python2.7/site-packages/cvxopt/coneprog.py", line 1400, in conelp

misc.update_scaling(W, lmbda, ds, dz)

File "/home/callegar/.local/lib/python2.7/site-packages/cvxopt/misc.py", line 628, in update_scaling

a = 1.0 / math.sqrt(lmbda[ind+i])

ZeroDivisionError: float division by zero

The problems derives from an application where cvxopt is indirectly called via the cvxpy DCP wrapper by Tinoco de Rubeira (http://www.stanford.edu/~ttinoco/cvxpy/start.html, possibly now superseeded).


What is puzzling me is that the ZeroDivisionError only occurs about 1 time over 5 restarting the same code with the same data.


Any clue at how to avoid it?



--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Martin

unread,
Oct 4, 2013, 4:43:14 AM10/4/13
to cvx...@googlegroups.com
The problem is the strict reltol/abstol which is far beyond what you can expect from a double precision solver. Consider using SDPA-GMP (http://sdpa.sourceforge.net) if you need high accuracy.

Martin

Sergio Callegari

unread,
Oct 4, 2013, 7:27:16 AM10/4/13
to cvx...@googlegroups.com
On 04/10/2013 10:43, Martin wrote:
The problem is the strict reltol/abstol which is far beyond what you can expect from a double precision solver. Consider using SDPA-GMP (http://sdpa.sourceforge.net) if you need high accuracy.

Martin
I was expecting something like that. Still would be nice if cvxopt could go as far as it can without erroring out (which basically wastes all the work done up to that point I guess). Would it be enough to check the lmbda vector for null entries before attempting the a = 1.0 / math.sqrt(lmbda[ind+i]) division?

Thanks

Sergio
Reply all
Reply to author
Forward
0 new messages