[SciPy-user] Correct syntax for optimize.fmin_powell

Robert Kern rkern at ucsd.edu
Mon Sep 12 14:56:06 CDT 2005

J. Stark wrote:
> Can someone point me to the correct syntax for optimize.fmin_powell when
> the objective function takes side arguments. I have tried every
> possibility I can think of, most of which work fine for optimize.fmin,
> but keep getting error messages, mainly due to an incorrect number of
> arguments. I have looked at the source, but that hasn't helped.
> I am typically trying to something like
> def test_arg((x,y),(a,b)):
>     return (x-a)**2 + (y-b)**2
> min = optimize.fmin_powell(test_arg,(1.0,2.0), ((5.0,6.0),))
> This works with optimize.fmin, but fails with optimize.fmin_powell.

Works for me.

In [2]: def test_arg((x,y),(a,b)):
   ...:     return (x-a)**2 + (y-b)**2

In [3]: min = optimize.fmin_powell(test_arg,(1.0,2.0), ((5.0,6.0),))
Optimization terminated successfully.
         Current function value: 0.000000
         Iterations: 2
         Function evaluations: 22

Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

More information about the SciPy-user mailing list