[SciPy-User] fmin_bfgs failing on simple problem

John Salvatier jsalvati at u.washington.edu
Tue Apr 17 14:14:31 EDT 2012


Well that's good news. I have scipy .9.0b1, what version do you have?

On Tue, Apr 17, 2012 at 11:13 AM, Nathaniel Smith <njs at pobox.com> wrote:

> On Tue, Apr 17, 2012 at 6:35 PM, John Salvatier
> <jsalvati at u.washington.edu> wrote:
> > Hi all!
> >
> > I am having a problem with the fmin_bfgs solver that's surprising to me.
> > Here's the toy problem I've set up:
> >
> > from scipy.optimize import fmin_bfgs, fmin_ncg
> > from numpy import *
> > import numpy as np
> >
> > def f(x ):
> >     if x < 0:
> >         return 1.79769313e+308
> >     else :
> >         return x + 1./x
> >
> >
> > xs = fmin_bfgs(f, array( [10.]), retall = True)
> >
> > The solver returns [nan] as the solution.
> >
> > The problem is designed to be stiff: between 0 and 1, it slopes upward to
> > infinity but between 1 and infinity, it slopes up at a slope of 1. Left
> of 0
> > the function has a "nearly infinite" value. If bfgs encounters  a value
> > that's larger than the current value, it should try a different step
> size,
> > no? Why does fmin_bfgs fail in this way?
>
> I can't reproduce this (on my computer it converges to 0.99999992),
> but have you tried making that < into a <=? The divide-by-zero at f(0)
> might be making it freak out.
>
> -- Nathaniel
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20120417/b9f78138/attachment.html>


More information about the SciPy-User mailing list