-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat: OptimizerChain #145
base: main
Are you sure you want to change the base?
feat: OptimizerChain #145
Conversation
I like the idea conceptually but I don't think I would introduce this into the package as it nothing existencial to the topic of optimization. Also it would need more flexibility to be of practical use (eg. Determine the part of the instance the next optimizer is allowed to see). It would be a nice gallery post, though. |
I think it should be added. |
I agree with @mb706, this is something we will very often need.
|
Co-authored-by: Jakob Richter <code@jakob-r.de>
…to optimizer_chain
param_sets = vector(mode = "list", length = length(optimizers)) | ||
ids_taken = character(0L) | ||
# for each optimizer check whether the id of the param_set | ||
# (decuded from the optimizer class) is already taken; |
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.
typo
private$.ids = map_chr(param_sets, "set_id") | ||
super$initialize( | ||
param_set = ParamSetCollection$new(param_sets), | ||
param_classes = Reduce(intersect, mlr3misc::map(optimizers, "param_classes")), |
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.
I don't think mlr3misc::
is necessary?
.optimize = function(inst) { | ||
terminator = inst$terminator | ||
on.exit({inst$terminator = terminator}) | ||
inner_inst = inst$clone(deep = TRUE) |
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.
would be good if this could be avoided, so when an error happens in the inner optimization then the user's inst
at least has the partial optimization progress. Did I do this in my original implementation?
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.
We specifically do the on.exit()
thing so we can modify the inst
's $terminator
temporarily without needing to clone, or did something get uncovered that does make this necessary?
Clearly distinguish between running optimizers in a chain (without sharing info) vs. chaining optimizers that can rely on the archive data of the previous optimizer runs. |
The idea of
OptimizerChain
is to allow for sequentially running multipleOptimizer
s with potential additionalTerminator
s.Credit to @mb706 who implemented this initially here.
Could also be used for running the same
Optimizer
with random restarts (as shown in the example).