I get the following error:
Traceback (most recent call last):
File "svm_dal.py", line 115, in <module>
l1svm_dal(fold,10.,cas,outdir)
File "svm_dal.py", line 54, in l1svm_dal
soln = solvers.cp(F,G,H)
File "/share/apps/python26/lib/python2.6/site-packages/cvxopt/cvxprog.py",
line 1964, in cp
xdot_e, xaxpy_e, xscal_e)
File "/share/apps/python26/lib/python2.6/site-packages/cvxopt/cvxprog.py",
line 676, in cpl
fDf(z[:mnl], rx, beta = 1.0, trans = 'T')
File "/share/apps/python26/lib/python2.6/site-packages/cvxopt/cvxprog.py",
line 1798, in Df_e
trans = 'T')
TypeError: length of x is too small
After briefly going through the code in cvxprog.py, I was unable to
find a plausible cause for this. Any thoughts on what I should be
looking for or how I could resolve this would be much appreciated!!
Thanks!
Cheers,
Anil
#####
import numpy as np
import cvxopt as C
# constraints
G = C.matrix([C.spdiag(C.matrix(1., (N,1))),
C.spdiag(C.matrix(-1., (N,1)))])
H = C.matrix([C.matrix(1., (N,1)), C.matrix(0., (N,1))])
# Defining nonlinear function
def F(x = None, z = None):
if x is None and z is None: return 0, C.matrix(beto)
# find 'active' variables
u = wo+eta*np.dot(Xy,x)
v = shrink(u,mu) # User-defined function
I = v.nonzero()[0]
vI = v[I]
XyI = Xy[I,:]
Yx = np.dot(Y.T,x)
f = C.matrix(-1.*np.sum(x)+bo*Yx +
0.5*eta*Yx**2 + 0.5/eta*np.dot(v.T,v))
Df = C.matrix(-1. + bo*Y + eta*Yx*Y + np.dot(vI.T,XyI))
if z is None: return f, Df.T
K = np.dot(XyI.T,XyI)
H = z[0]*eta*C.matrix(Y*Y.T+K)
return f,Df.T,H
# use cvxopt
soln = solvers.cp(F,G,H)
Thanks and sorry for the spam.
Best,
Anil