-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set default options and settings for Optim.optimize() #7
Comments
Something like mydefault(; additionals...)::Optim.Options = Optim.Options(extended_trace=true, callback=miunitstop; additionals...) should work. This way, the call would become optimize(x -> -loglikelihood(model(x), data), x0, BFGS(), mydefault()) while keeping flexibility to pass keyword arguments to control the options. |
import Optim: default_options
using Optim: BFGS
default_options(::BFGS) = (; extended_trace=true, callback=miunitstop) This will set the default options for However, there is no such mechanism for See also |
I overrode function MiunitOptions(; additionals...)::Optim.Options
Optim.Options(extended_trace=true, callback=miunitstop; additionals...)
end
import Optim: optimize
function optimize(f,
l::AbstractArray,
u::AbstractArray,
initial_x::AbstractArray,
F::T) where {T <: Fminbox}
optimize(f, l, u, initial_x, F, MiunitOptions())
end I've opened an issue at Optim (JuliaNLSolvers/Optim.jl#1028). If this gets resolved, this can be replaced with something like |
Right now one has to type the following to perform fitting.
optimize(x -> -loglikelihood(model(x), data), x0, BFGS(), Optim.Options(extended_trace=true, callback=miunitstop))
While defining the function and giving x0 may be necessary and would be better stated explicitly, the method BFGS() and the options are not, as they should be the same unless there is a really good reason).
It is possible to wrap the call but I still want to keep it as explicit as possible. A variable for configuration would make things easier such as the PLOTS_DEFAULTS in the case of Plots.jl.
The text was updated successfully, but these errors were encountered: