-
Notifications
You must be signed in to change notification settings - Fork 30
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
Allow to pass Optim.Options to bat_findmode #423
Conversation
Ah, I just realize this solution might be a problem since we declared |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #423 +/- ##
==========================================
- Coverage 55.03% 54.86% -0.17%
==========================================
Files 116 117 +1
Lines 5624 5652 +28
==========================================
+ Hits 3095 3101 +6
- Misses 2529 2551 +22 ☔ View full report in Codecov by Sentry. |
src/extdefs/optim_defs.jl
Outdated
TR<:AbstractTransformTarget, | ||
IA<:InitvalAlgorithm | ||
} <: AbstractModeEstimator | ||
optalg::ALG = ext_default(pkgext(Val(:Optim)), Val(:DEFAULT_OPTALG)) | ||
options::OPTS = ext_default(pkgext(Val(:Optim)), Val(:DEFAULT_OPTS)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about algopts
instead of just options
, to be a bit more specific?
Which options would the user set, typically (since BAT will also set some, we need to ensure they don't clash)? |
I was mostly thinking about things like: |
Hm, since those are pretty fundamental, maybe we should offer (some of those) as explicit fields of |
Hm, I'm not quite sure. It sounds a bit unnecessary to wrap all the options (and would again not give full control to the user). On the other hand, I just had a quick look at Optimization.jl. (I'm not sure, do we have any plans to support this in the future instead of only relying on Optim.jl?) But they seem to actually have a unified interface for common options like the iterations and tolerances: https://docs.sciml.ai/Optimization/stable/API/solve/#CommonSolve.solve-Tuple{OptimizationProblem,%20Any} |
No, BAT will need control over these, for example for pathfinder (which requires a trace). In principle, it should be easy for the user to switch between algorithms/backends, so options that most of them will offer we should provide in a generic fashion under common names. |
Yeah, I just mean that in BAT we can overwrite the user input for these two options to always be true. |
So I'm also fine to have these options as individual keywords. But feels a bit like reinventing what Optimization.jl is already offering. |
To certain degree, yes. Optimization.jl used to be an extremely heavy dependency, but it's load time has gone down recently. I would still prefer not to tie BAT to a single optimization backend, even if it's a "meta-backend". But we should definitely add support for Optimization.jl as well. It may not be usable in all cases, though, at least in the past it was tricky to make it store gradient traces, which pathfinder will need. |
Hi @oschulz, here is another proposal. Example: using BAT
posterior = BAT.example_posterior()
using Optim
alg = OptimAlg(;
optalg = Optim.NelderMead(parameters=Optim.FixedParameters()),
maxiters=200,
kwargs = (f_calls_limit=100,),
)
my_mode = bat_findmode(posterior, alg)
using OptimizationOptimJL
alg = OptimizationAlg(;
optalg = OptimizationOptimJL.ParticleSwarm(n_particles=10),
maxiters=200,
kwargs=(f_calls_limit=50,)
)
my_mode = bat_findmode(posterior, alg) We can discuss the naming of the algorithms and keywords. But I wanted to check first whether this is the right way at all. |
Sorry for the delay - that approach looks good to me! |
Hi @oschulz, I just realized this PR is still open. |
Let's merge it. :-) Can you just fix the Docs build failure? |
Ok, Docs build is fixed. Should be ready to merge then 🙂 |
Replaced by #439 |
Closing in favor of #442 |
Allows to pass all the Optim.Options to
bat_findmode
.Example: