OptimizerAsyncMbo
class that implements Asynchronous Model Based Optimization (AMBO).
AMBO starts multiple sequential MBO runs on different workers.
The worker communicate asynchronously through a shared archive relying on the rush package.
The optimizer follows a modular layout in which the surrogate model, acquisition function, and acquisition optimizer can be changed.
The SurrogateLearner will impute missing values due to pending evaluations.
A stochastic AcqFunction, e.g., AcqFunctionStochasticEI or AcqFunctionStochasticCB is used to create varying versions of the acquisition
function on each worker, promoting different exploration-exploitation trade-offs.
The AcqOptimizer class remains consistent with the one used in synchronous MBO.
In contrast to OptimizerMbo, no loop_function can be specified that determines the AMBO flavor as OptimizerAsyncMbo
simply relies on
a surrogate update, acquisition function update and acquisition function optimization step as an internal loop.
Currently, only single-objective optimization is supported and OptimizerAsyncMbo
is considered an experimental feature and API might be subject to changes.
Note that in general the SurrogateLearner is updated one final time on all available data after the optimization process has terminated. However, in certain scenarios this is not always possible or meaningful. It is therefore recommended to manually inspect the SurrogateLearner after optimization if it is to be used, e.g., for visualization purposes to make sure that it has been properly updated on all available data. If this final update of the SurrogateLearner could not be performed successfully, a warning will be logged.
By specifying a ResultAssigner, one can alter how the final result is determined after optimization, e.g., simply based on the evaluations logged in the archive ResultAssignerArchive or based on the Surrogate via ResultAssignerSurrogate.
Archive
The bbotk::ArchiveAsync holds the following additional columns that are specific to AMBO algorithms:
acq_function$id
(numeric(1)
)
The value of the acquisition function.".already_evaluated"
(logical(1))
Whether this point was already evaluated. Depends on theskip_already_evaluated
parameter of the AcqOptimizer.
If the bbotk::ArchiveAsync does not contain any evaluations prior to optimization, an initial design is needed.
If the initial_design
parameter is specified to be a data.table
, this data will be used.
Otherwise, if it is NULL
, an initial design of size design_size
will be generated based on the generate_design
sampling function.
See also the parameters below.
Parameters
initial_design
data.table::data.table()
Initial design of the optimization. IfNULL
, a design of sizedesign_size
is generated with the specifieddesign_function
. Default isNULL
.design_size
integer(1)
Size of the initial design if it is to be generated. Default is100
.design_function
character(1)
Sampling function to generate the initial design. Can berandom
paradox::generate_design_random,lhs
paradox::generate_design_lhs, orsobol
paradox::generate_design_sobol. Default issobol
.n_workers
integer(1)
Number of parallel workers. IfNULL
, all rush workers specified viarush::rush_plan()
are used. Default isNULL
.
Super classes
bbotk::Optimizer
-> bbotk::OptimizerAsync
-> OptimizerAsyncMbo
Active bindings
surrogate
(Surrogate |
NULL
)
The surrogate.acq_function
(AcqFunction |
NULL
)
The acquisition function.acq_optimizer
(AcqOptimizer |
NULL
)
The acquisition function optimizer.result_assigner
(ResultAssigner |
NULL
)
The result assigner.param_classes
(
character()
)
Supported parameter classes that the optimizer can optimize. Determined based on thesurrogate
and theacq_optimizer
. This corresponds to the values given by a paradox::ParamSet's$class
field.properties
(
character()
)
Set of properties of the optimizer. Must be a subset ofbbotk_reflections$optimizer_properties
. MBO in principle is very flexible and by default we assume that the optimizer has all properties. When fully initialized, properties are determined based on the loop, e.g., theloop_function
, andsurrogate
.packages
(
character()
)
Set of required packages. A warning is signaled prior to optimization if at least one of the packages is not installed, but loaded (not attached) later on-demand viarequireNamespace()
. Required packages are determined based on theacq_function
,surrogate
and theacq_optimizer
.
Methods
Inherited methods
Method new()
Creates a new instance of this R6 class.
If surrogate
is NULL
and the acq_function$surrogate
field is populated, this SurrogateLearner is used.
Otherwise, default_surrogate(instance)
is used.
If acq_function
is NULL
and the acq_optimizer$acq_function
field is populated, this AcqFunction is used (and therefore its $surrogate
if populated; see above).
Otherwise default_acqfunction(instance)
is used.
If acq_optimizer
is NULL
, default_acqoptimizer(instance)
is used.
Even if already initialized, the surrogate$archive
field will always be overwritten by the bbotk::ArchiveAsync of the current bbotk::OptimInstanceAsyncSingleCrit to be optimized.
For more information on default values for surrogate
, acq_function
, acq_optimizer
and result_assigner
, see ?mbo_defaults
.
Usage
OptimizerAsyncMbo$new(
id = "async_mbo",
surrogate = NULL,
acq_function = NULL,
acq_optimizer = NULL,
result_assigner = NULL,
param_set = NULL,
label = "Asynchronous Model Based Optimization",
man = "mlr3mbo::OptimizerAsyncMbo"
)
Arguments
id
(
character(1)
)
Identifier for the new instance.surrogate
(Surrogate |
NULL
)
The surrogate.acq_function
(AcqFunction |
NULL
)
The acquisition function.acq_optimizer
(AcqOptimizer |
NULL
)
The acquisition function optimizer.result_assigner
(ResultAssigner |
NULL
)
The result assigner.param_set
(paradox::ParamSet)
Set of control parameters.label
(
character(1)
)
Label for this object. Can be used in tables, plot and text output instead of the ID.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()
.
Method reset()
Reset the optimizer.
Sets the following fields to NULL
:
surrogate
, acq_function
, acq_optimizer
,result_assigner
Resets parameter values design_size
and design_function
to their defaults.
Method optimize()
Performs the optimization on an bbotk::OptimInstanceAsyncSingleCrit until termination. The single evaluations will be written into the bbotk::ArchiveAsync. The result will be written into the instance object.
Examples
# \donttest{
if (requireNamespace("rush") &
requireNamespace("mlr3learners") &
requireNamespace("DiceKriging") &
requireNamespace("rgenoud")) {
if (redis_available()) {
library(bbotk)
library(paradox)
library(mlr3learners)
fun = function(xs) {
list(y = xs$x ^ 2)
}
domain = ps(x = p_dbl(lower = -10, upper = 10))
codomain = ps(y = p_dbl(tags = "minimize"))
objective = ObjectiveRFun$new(fun = fun, domain = domain, codomain = codomain)
instance = OptimInstanceAsyncSingleCrit$new(
objective = objective,
terminator = trm("evals", n_evals = 10))
rush::rush_plan(n_workers=2)
optimizer = opt("async_mbo", design_size = 4, n_workers = 2)
optimizer$optimize(instance)
} else {
message("Redis server is not available.\nPlease set up Redis prior to running the example.")
}
}
#> Redis server is not available.
#> Please set up Redis prior to running the example.
# }