I am trying to minimise a function with multiple arguments with the Optim.jl library, using a BFGS algorithm.
In the GitHub website of the Optim library, I found the following working example:
using Optim
rosenbrock(x) = (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
result = optimize(rosenbrock, zeros(2), BFGS())
Let's say that my objective function is:
fmin(x, a) = (1.0 - x[1])^a + 100.0 * (x[2] - x[1]^2)^(1-a)
How can I pass the additional - constant - argument a using optimize?
The simplest way is to pass an anonymous function of one variable which calls your original function with the parameters set. For example, using a variant of your fmin:
Alternatively you can make a separate named function of one variable which closes over whatever parameters you like. There's no equivalent to the
args
inscipy.optimize.minimize
in Python where you pass the non-varying arguments separately as a tuple, AFAIK.