Python 2.6.2 crash

39 views
Skip to first unread message

Virgil Stokes

unread,
Jun 15, 2009, 8:02:33 AM6/15/09
to cvx...@googlegroups.com
I have just started to try to use cvxopt in Python 2.6.2 on a Windows
Vista platform. I have installed

cvxopt-1.2.win32-py2.6.exe

and all the other latest (for Python 2.6.2) dependent packages required
by cvxopt.

When I tried to run one of the examples,

"Optimal trade-off curve for a regularized least-squares problem (fig.
4.11)"

which is at the CVXOPT homepage (under Examples), this did not work ---
in fact it crashed my Python 2.6.2. After trying several different
modifications, I found that
the following code did work.

#import pylab
from pickle import load
from cvxopt import blas, lapack, matrix
from cvxopt import solvers
solvers.options['show_progress'] = 0

data = load(open("rls.bin",'r'))
A, b = data['A'], data['b']
m, n = A.size

# LS solution
xls = +b
lapack.gels(+A, xls)
xls = xls[:n]

# We compute the optimal values of
#
# minimize/maximize || A*x - b ||_2^2
# subject to x'*x = alpha
#
# via the duals.
#
# Lower bound:
#
# maximize -t - u*alpha
# subject to [u*I, 0; 0, t] + [A, b]'*[A, b] >= 0
#
# Upper bound:
#
# minimize t + u*alpha
# subject to [u*I, 0; 0, t] - [A, b]'*[A, b] >= 0.
#
# Two variables (t, u).

G = matrix(0.0, ((n+1)**2, 2))
G[-1, 0] = -1.0 # coefficient of t
G[: (n+1)**2-1 : n+2, 1] = -1.0 # coefficient of u
h = matrix( [ [ A.T * A, b.T * A ], [ A.T * b, b.T * b ] ] )
c = matrix(1.0, (2,1))

nopts = 40
alpha1 = [ 2.0/(nopts/2-1) * alpha for alpha in xrange(nopts/2) ] + \
[ 2.0 + (15.0 - 2.0)/(nopts/2) * alpha for alpha in
xrange(1,nopts/2+1) ]
lbnds = [ blas.nrm2(b)**2 ]
for alpha in alpha1[1:]:
c[1:] = alpha
lbnds += [ -blas.dot(c, solvers.sdp(c, Gs=[G], hs=[h])['x']) ]

nopts = 10
alpha2 = [ 1.0/(nopts-1) * alpha for alpha in xrange(nopts) ]
ubnds = [ blas.nrm2(b)**2 ]
for alpha in alpha2[1:]:
c[1:] = alpha
ubnds += [ blas.dot(c, solvers.sdp(c, Gs=[G], hs=[-h])['x']) ]

import pylab

pylab.figure(1, facecolor='w')
pylab.plot(lbnds, alpha1, 'b-', ubnds, alpha2, 'b-')
kmax = max([ k for k in xrange(len(alpha1)) if alpha1[k] <
blas.nrm2(xls)**2 ])
pylab.plot( [ blas.nrm2(b)**2 ] + lbnds[:kmax] +
[ blas.nrm2(A*xls-b)**2 ], [0.0] + alpha1[:kmax] +
[ blas.nrm2(xls)**2 ], '-', linewidth=2)
pylab.plot([ blas.nrm2(b)**2, blas.nrm2(A*xls-b)**2 ],
[0.0, blas.nrm2(xls)**2], 'bo')
pylab.fill(lbnds[-1::-1] + ubnds + [ubnds[-1]],
alpha1[-1::-1] + alpha2+ [alpha1[-1]], facecolor = '#D0D0D0')
pylab.axis([0, 15, -1.0, 15])
pylab.xlabel('||A*x-b||_2^2')
pylab.ylabel('||x||_2^2')
pylab.grid()
pylab.title('Regularized least-squares (fig. 4.11)')
pylab.show()

What was changed? The import pylab was moved to after the reference to
solvers...
This seems to be critical; i.e., it crashes Python 2.6.2 otherwise.
Note, this same problem was present in other examples that used pylab.

Can anyone tell me why this happens? And how it should be fixed?

Thank you,

--V. Stokes

Joachim Dahl

unread,
Jun 15, 2009, 8:13:22 AM6/15/09
to cvx...@googlegroups.com
cvxopt-1.2 is actually an incorrect version number for version 1.1.1,
which occured when building
the latest version on Windows.

Going from version cvxopt-1.1 to cvxopt-1.1.1, MinGW used for building
CVXOPT on Windows started
giving compiler errors I couldn't resolve - probably after an upgrade of
MinGW. Instead I build a version
using Cygwin, and I suspect that might be why you're experiencing the
crash. Can you try it the problem
is present with this version:

http://abel.ee.ucla.edu/src/Win32-binaries/cvxopt-1.1.win32-py2.6.exe

It is also possible that there are internal differences between Python
2.5 and Python 2.6 that we have
not been aware of, and that they are causing CVXOPT to crash the Python
interpreter.

For our next release, I will have to figure out how to correctly setup
MinGW again, but building
numerical libraries on a Windows platform is very tedious and depends on
a lot of ported GNU tools

Joachim


Virgil Stokes skrev:

Virgil Stokes

unread,
Jun 15, 2009, 8:22:52 AM6/15/09
to cvx...@googlegroups.com
Joachim Dahl wrote:
> cvxopt-1.2 is actually an incorrect version number for version 1.1.1,
> which occured when building
> the latest version on Windows.
>
> Going from version cvxopt-1.1 to cvxopt-1.1.1, MinGW used for building
> CVXOPT on Windows started
> giving compiler errors I couldn't resolve - probably after an upgrade of
> MinGW. Instead I build a version
> using Cygwin, and I suspect that might be why you're experiencing the
> crash. Can you try it the problem
> is present with this version:
>
> http://abel.ee.ucla.edu/src/Win32-binaries/cvxopt-1.1.win32-py2.6.exe
>
But this will not install with 2.6.2! The install software requires 2.5

> It is also possible that there are internal differences between Python
> 2.5 and Python 2.6 that we have
> not been aware of, and that they are causing CVXOPT to crash the Python
> interpreter.
>
> For our next release, I will have to figure out how to correctly setup
> MinGW again, but building
> numerical libraries on a Windows platform is very tedious and depends on
> a lot of ported GNU tools
>
> Joachim
>
Note, Joachim
I did get it to work (at least this example) by just moving the import
pylab.

--V. Stokes

Virgil Stokes

unread,
Jun 15, 2009, 8:30:02 AM6/15/09
to cvx...@googlegroups.com, dahl.j...@gmail.com
Oops Joachim (and cvxopt list),
I accidentally tried to install an older version.
Indeed Joachim, you were correct (at least for some examples that I have now tried). This version that you recommended is working correctly on the examples at cvxopt's homepage! :-)

Sorry, about my previous response. :-(

And thanks Joachim for providing the link to this working binary.

--V. Stokes

Joachim Dahl

unread,
Jun 15, 2009, 8:34:17 AM6/15/09
to cvx...@googlegroups.com
It's difficult to guess why the latest version is crashing - I suspect
Cygwin is to blame...
Hopefully, the next version of CVXOPT will resolve the problem.

Eventually, we will also support Python 3.0, which I think is better
supported on Windows
(wrt. C extension modules, etc).



Virgil Stokes skrev:
Reply all
Reply to author
Forward
0 new messages