Reputation: 735
I have a function defined as follows
def function(a, b, c, d):
### some calculation
return output
I was to use scipy.minimise
to minimize the output with respect to variable a
alone. Is there a way to tell it to just solve for the first variable (while keeping b
, c
and d
constant).
Thanks.
Upvotes: 0
Views: 79
Reputation: 1290
From docs:
The objective function to be minimized:
fun(x, *args) -> float
and
argstuple
, optional: Extra arguments passed to the objective function and its derivatives (fun
,jac
andhess
functions).
So simply use a wrapper (or rewrite the definition and the first lines in your function):
def functionWrapper(x, args):
a = x
b,c,d = args
return function(a,b,c,d)
And the minimization call
minimize(functionWrapper,initialGuess,(bValue,cValue,dValue,));
where bValue
,cValue
,dValue
are the constant values for the coefficients.
Upvotes: 1