[SciPy-dev] Inconsistent behavior in optimize wrt the type of the initial guess (array versus matrix)

Tim Leslie tim.leslie at gmail.com
Thu Jan 11 08:10:35 CST 2007


On 1/11/07, Nils Wagner <nwagner at iam.uni-stuttgart.de> wrote:
>  Hi,
>
> I have observed some inconsistent behavior of the optimization routines
> wrt to the type of the initial guess.
> I mean matrix versus array.
>
> For example optimize.fmin_ncg works with a matrix input while fmin_bfgs
> segfaults.

I can confirm this segfault. Nils, would you like to open a ticket for
this so it doesn't get lost?

Cheers,

Tim

> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 46912509653888 (LWP 30417)]
> dotblas_matrixproduct (dummy=<value optimized out>, args=<value
> optimized out>) at _dotblas.c:233
> 233             Py_DECREF(ap1);
> (gdb) bt
> #0  dotblas_matrixproduct (dummy=<value optimized out>, args=<value
> optimized out>) at _dotblas.c:233
>
> Any comments ?
>
> Nils
>
> from scipy import *
>
> def g(x):
>     return 1./(1-cos(x))
>
> def g_p(x):
>     return -sin(x)/(1.-cos(x))**2
>
> def d(x):
>     return pow(x,2)+pow((g(x)-1.0),2)
> #   return sqrt(x**2+(g(x)-1.0)**2)
>
> def d_p(x):
>     return 2*x+2*(g(x)-1.0)*g_p(x)
>
> def f(x):
>     return x+(g(x)-1.)*g_p(x)
>
> x_0 = matrix(0.3)
> print x_0
> x_opt = optimize.fmin_cg(d,x_0) # ValueError: The truth value of an
> array with more than one element is ambiguous. Use a.any() or a.all()
> #x_opt = optimize.fmin_powell(d,x_0) # ValueError: Initial guess must be
> a scalar or rank-1 sequence.
> #x_opt = optimize.fmin_bfgs(d,x_0) # Segfaults with a matrix input
> #x_opt = optimize.fmin_ncg(d,x_0,d_p) # Works for me with a matrix input
> print x_opt
>
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
>


More information about the Scipy-dev mailing list