If I have a loss function that I want to use for optimizing a set of parameters, can that function take additional arguments as well (e.g., arrays that might vary in size, and boolean statements)?
If the answer is “yes”, how do I pass these other arguments to Optim.optimize?
This is done using a closure, for example, obj = θ -> -1.0*H(θ, θnn, 10, auxstat, NNmodel, info)
The free argument θ is what is optimized over, and the others are fixed. Then you call an optimizer in Optim.jl doing something like θsa = (Optim.optimize(obj, model.lb, model.ub, θnn, SAMIN(rt=rt, verbosity=sa_verbosity),Optim.Options(iterations=10^6))).minimizer