mies_evaluate_offspring | R Documentation |
Calls $eval_batch
of a given OptimInstance
on a set
of configurations as part of a MIES operation. The dob
extra-info in the archive
is also set properly to indicate a progressed generation.
This function can be used directly, but it is easier to use it within the OptimizerMies
class if standard GA operation is desired.
Multifidelity evaluation is supported as described in vignette("mies-multifid")
. For this,
an extra component named after budget_id
is appended to each individual, chosen from
the fidelity
argument and depending on the value of survivor_budget
. budget_id
should
have the same values as given to the other mies_*
functions.
mies_evaluate_offspring(
inst,
offspring,
budget_id = NULL,
fidelity = NULL,
reevaluate_fidelity = NULL,
fidelity_monotonic = TRUE
)
inst |
( |
offspring |
( |
budget_id |
( |
fidelity |
( |
reevaluate_fidelity |
( |
fidelity_monotonic |
( |
invisible data.table
: the performance values returned when evaluating the offspring
values
through eval_batch
.
Other mies building blocks:
mies_generate_offspring()
,
mies_get_fitnesses()
,
mies_init_population()
,
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)
# Initial state:
oi$archive
# 'offspring' is just a data.frame of values to evaluate.
# In general it should be created using 'mies_generate_offspring()'.
offspring = data.frame(x = 1:2, y = 2:1)
mies_evaluate_offspring(oi, offspring = offspring)
# This evaluated the given points and assigned them 'dob' 2.
oi$archive
# Note that at this point one would ordinarily call a 'mies_survival_*()'
# function.
###
# Advanced demo, making use of additional components and doing multi-fidelity
##
# declare 'y' the budget parameter. It will not be in the 'offspring'
# table any more.
budget_id = "y"
# but: offspring may contain any other value that is appended to 'oi'. These
# are ignored by the objective.
offspring = data.frame(x = 0:1, z = 3)
mies_evaluate_offspring(oi, offspring = offspring, budget_id = budget_id,
fidelity = 1)
# This now has the additional column 'z'. Values of y for the new evaluations
# are 1.
oi$archive
offspring = data.frame(x = 2, z = 3)
# Increasing the fidelity will not cause re-evaluation of existing individuals
# when `reevaluate_fidelity` is not given.
mies_evaluate_offspring(oi, offspring = offspring, budget_id = budget_id,
fidelity = 2)
oi$archive
offspring = data.frame(x = 3, z = 3)
# Depending on the effect of fidelity, this may however have a biasing effect,
# so it may be desirable to re-evaluate surviving individuals from previous
# generations. The 'reevaluate_fidelity' may even be different from 'fidelity'
mies_evaluate_offspring(oi, offspring = offspring, budget_id = budget_id,
fidelity = 3, reevaluate_fidelity = 2)
# In this example, only individuals with 'y = 1' were re-evaluated, since
# 'fidelity_monotonic' is TRUE.
oi$archive
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.