Julianno Sambatti
Julianno Sambatti

Reputation: 119

fmin python function with multiple arguments

I want to find the minimum of a function with 3 args but want to fix two and only vary one of them, e.g.,

def f(x, y, z):
    result =  f(x,y,z)
    return result

y and z are constants. x is the only parameter I want to vary.

optimize.fmin (http://docs.scipy.org/doc/scipy-0.17.0/reference/generated/scipy.optimize.fmin.html) seems ideal for that, but the documentation is unclear on how to specify which parameters are constants and which are to be varied. Any hints on how to do it

Upvotes: 1

Views: 2022

Answers (1)

lejlot
lejlot

Reputation: 66835

optimize always assumes the first argument is the one that varies, and remaining ones have to be fixed beforehand, either by creating partial function or by passing additional arguments as args, thus

print fmin(foo, x0=..., args={'y': ..., 'z': ...})

Upvotes: 1

Related Questions