mies_init_population | R Documentation |
Set up an OptimInstance
for MIES optimization.
This adds the dob
and eol
columns to the instance's archive, and makes sure there are at least mu
survivors
(i.e. entries with eol
set to NA
) present. If there are already >= mu
prior evaluations present, then the last
mu
of these remain alive (the other's eol
set to 0); otherwise, up to mu
new randomly sampled configurations
are evaluated and added to the archive and have eol
set to NA
.
mies_init_population(
inst,
mu,
initializer = generate_design_random,
survival_selector = SelectorBest$new()$prime(inst$search_space),
budget_id = NULL,
fidelity = NULL,
fidelity_new_individuals_only = FALSE,
fidelity_monotonic = TRUE,
additional_component_sampler = NULL
)
inst |
( |
mu |
( |
initializer |
( |
survival_selector |
( |
budget_id |
( |
fidelity |
( |
fidelity_new_individuals_only |
( |
fidelity_monotonic |
( |
additional_component_sampler |
( |
invisible OptimInstance
: the input
instance, modified by-reference.
Other mies building blocks:
mies_evaluate_offspring()
,
mies_generate_offspring()
,
mies_get_fitnesses()
,
mies_select_from_archive()
,
mies_step_fidelity()
,
mies_survival_comma()
,
mies_survival_plus()
library("bbotk")
lgr::threshold("warn")
# Define the objective to optimize
objective <- ObjectiveRFun$new(
fun = function(xs) {
z <- exp(-xs$x^2 - xs$y^2) + 2 * exp(-(2 - xs$x)^2 - (2 - xs$y)^2)
list(Obj = z)
},
domain = ps(x = p_dbl(-2, 4), y = p_dbl(-2, 4)),
codomain = ps(Obj = p_dbl(tags = "maximize"))
)
# Get a new OptimInstance
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 100)
)
mies_init_population(inst = oi, mu = 3)
# 3 evaluations, archive contains 'dob' and 'eol'
oi$archive
###
# Advanced demo, making use of additional components and fidelity
##
# Get a new OptimInstance
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 100)
)
mies_init_population(inst = oi, mu = 3, budget_id = "y", fidelity = 2,
additional_component_sampler = Sampler1DRfun$new(
param = ps(additional = p_dbl(-1, 1)), rfun = function(n) rep(-1, n)
)
)
# 3 evaluations. We also have 'additional', sampled from rfun (always -1),
# which is ignored by the objective. Besides, we have "y", which is 2,
# according to 'fidelity'.
oi$archive
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.