简体   繁体   中英

scipy.optimize.basinhopping. Object function with argument(s)

So, I have a function f=(x,a,b), which I want to minimize using scipy.optimize.basinhopping. x - is the variable I'm optimizing over and a,b are parameters. It's not really clear how to pass values of a,b to the object function. Or this is not possible? For example, in scipy.optimize.minimize there is a special parameter "args" for this. Thanks!

What's unclear about the docs ?

func : callable f(x, *args)

Function to be optimized. args can be passed as an optional item in the dict minimizer_kwargs

...

See also minimize

The local minimization function called once for each basinhopping step. minimizer_kwargs is passed to this routine.

So it's somewhat like:

minimizer_kwargs = {"args": (a, b)}
ret = basinhopping(func, x0, minimizer_kwargs=minimizer_kwargs)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM