Function to create a CallbackAsync.
Optimization callbacks can be called from different stages of optimization process.
The stages are prefixed with on_*
.
Start Optimization
- on_optimization_begin
Start Worker
- on_worker_begin
Start Optimization on Worker
- on_optimizer_before_eval
- on_optimizer_after_eval
End Optimization on Worker
- on_worker_end
End Worker
- on_result_begin
- on_result_end
- on_optimization_end
End Optimization
See also the section on parameters for more information on the stages. A optimization callback works with ContextAsync.
Usage
callback_async(
id,
label = NA_character_,
man = NA_character_,
on_optimization_begin = NULL,
on_worker_begin = NULL,
on_optimizer_before_eval = NULL,
on_optimizer_after_eval = NULL,
on_worker_end = NULL,
on_result_begin = NULL,
on_result_end = NULL,
on_result = NULL,
on_optimization_end = NULL
)
Arguments
- id
(
character(1)
)
Identifier for the new instance.- label
(
character(1)
)
Label for the new instance.- man
(
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()
.- on_optimization_begin
(
function()
)
Stage called at the beginning of the optimization in the main process. Called inOptimizer$optimize()
. The functions must have two arguments namedcallback
andcontext
.- on_worker_begin
(
function()
)
Stage called at the beginning of the optimization on the worker. Called in the worker loop. The functions must have two arguments namedcallback
andcontext
.- on_optimizer_before_eval
(
function()
)
Stage called after the optimizer proposes points. Called inOptimInstance$.eval_point()
. The functions must have two arguments namedcallback
andcontext
. The argument ofinstance$.eval_point(xs)
andxs_trafoed
andextra
are available in thecontext
. Orxs
andxs_trafoed
ofinstance$.eval_queue()
are available in thecontext
.- on_optimizer_after_eval
(
function()
)
Stage called after points are evaluated. Called inOptimInstance$.eval_point()
. The functions must have two arguments namedcallback
andcontext
. The outcomey
is available in thecontext
.- on_worker_end
(
function()
)
Stage called at the end of the optimization on the worker. Called in the worker loop. The functions must have two arguments namedcallback
andcontext
.- on_result_begin
(
function()
)
Stage called before result are written. Called inOptimInstance$assign_result()
. The functions must have two arguments namedcallback
andcontext
. The arguments of$.assign_result(xdt, y, extra)
are available in thecontext
.- on_result_end
(
function()
)
Stage called after result are written. Called inOptimInstance$assign_result()
. The functions must have two arguments namedcallback
andcontext
. The final resultinstance$result
is available in thecontext
.- on_result
(
function()
)
Deprecated. Useon_result_end
instead. Stage called after result are written. Called inOptimInstance$assign_result()
. The functions must have two arguments namedcallback
andcontext
.- on_optimization_end
(
function()
)
Stage called at the end of the optimization in the main process. Called inOptimizer$optimize()
. The functions must have two arguments namedcallback
andcontext
.
Details
A callback can write data to its state ($state
), e.g. settings that affect the callback itself.
The ContextAsync allows to modify the instance, archive, optimizer and final result.