python - Passing args in scipy optimize.minimize objective function ( getting error on number of arguments) -


i'm trying use scipy's optimizer.minimize function i'm unable figure out exact way pass args objective function. have following code according me should work fine giving me error on number of arguments.

result = minimize(compute_cost, x0, args=(parameter), method='cobyla',constraints=cons, options={'maxiter':10000,'rhobeg':20}) 

here function signature objective function: def compute_cost(x,parameter)

parameter dict has 51 key value pair.

this gives following error:

capi_return null call-back cb_calcfc_in__cobyla__user__routines failed. traceback (most recent call last): file "c:\..\resource_optimizer.py", line 138, in <module> result = minimize(compute_cost, x0, args=(parameter), method='cobyla',constraints=cons, options={'maxiter':10000,'rhobeg':20}) file "c:\python27\lib\site-packages\scipy\optimize\_minimize.py", line 432, in minimize return _minimize_cobyla(fun, x0, args, constraints, **options) file "c:\python27\lib\site-packages\scipy\optimize\cobyla.py", line 246, in _minimize_cobyla dinfo=info) file "c:\python27\lib\site-packages\scipy\optimize\cobyla.py", line 238, in calcfc f = fun(x, *args) typeerror: compute_cost() takes 2 arguments (52 given)

can me figure out.

change args=(parameter) args=(parameter,), args tuple containing single element.

args=(parameter) equivalent args=parameter. when that, each element of parameter passed separate argument objective function.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -