Function to create a CallbackOptimization.
Optimization callbacks can be called from different stages of optimization process.
The stages are prefixed with on_*
.
Start Optimization
- on_optimization_begin
Start Optimizer Batch
- on_optimizer_before_eval
- on_optimizer_after_eval
End Optimizer Batch
- on_result
- on_optimization_end
End Optimization
See also the section on parameters for more information on the stages. A optimization callback works with ContextOptimization.
callback_optimization(
id,
label = NA_character_,
man = NA_character_,
on_optimization_begin = NULL,
on_optimizer_before_eval = NULL,
on_optimizer_after_eval = NULL,
on_result = NULL,
on_optimization_end = NULL,
fields = list()
)
(character(1)
)
Identifier for the new instance.
(character(1)
)
Label for the new instance.
(character(1)
)
String in the format [pkg]::[topic]
pointing to a manual page for this object.
The referenced help package can be opened via method $help()
.
(function()
)
Stage called at the beginning of the optimization.
Called in Optimizer$optimize()
.
The functions must have two arguments named callback
and context
.
(function()
)
Stage called after the optimizer proposes points.
Called in OptimInstance$eval_batch()
.
The functions must have two arguments named callback
and context
.
(function()
)
Stage called after points are evaluated.
Called in OptimInstance$eval_batch()
.
The functions must have two arguments named callback
and context
.
(function()
)
Stage called after result are written.
Called in OptimInstance$assign_result()
.
The functions must have two arguments named callback
and context
.
(function()
)
Stage called at the end of the optimization.
Called in Optimizer$optimize()
.
The functions must have two arguments named callback
and context
.
(list of any
)
List of additional fields.
A callback can write data to its state ($state
), e.g. settings that affect the callback itself.
The ContextOptimization allows to modify the instance, archive, optimizer and final result.
# write archive to disk
callback_optimization("bbotk.backup",
on_optimization_end = function(callback, context) {
saveRDS(context$instance$archive, "archive.rds")
}
)
Run the code above in your browser using DataLab