R/mies_methods.R
mies_step_fidelity.Rd
As part of the "rolling-tide" multifidelity-setup, do reevaluation of configurations with
higher fidelity that have survived lower-fidelity selection. The evaluations are done as part of the
current generation, so the dob
value is not increased.
This function should only be called when doing rolling-tide multifidelity, and should not be part of the MIES cycle otherwise.
mies_step_fidelity(
inst,
budget_id,
fidelity,
current_gen_only = FALSE,
fidelity_monotonic = TRUE,
additional_components = NULL
)
(OptimInstance
)
Optimization instance to evaluate.
(character(1)
)
Budget component that is set to the fidelity
value.
(atomic(1)
)
Atomic scalar indicating the value to be assigned to the budget_id
component of offspring.
(logical(1)
)
Whether to only re-evaluate survivors individuals generated in the latest generation (TRUE
), or re-evaluate all currently alive
individuals (FALSE
). In any case, only individuals that were not already evaluated with the chosen fidelity are evaluated,
so this will usually only have an effect when the fidelity of surviving individuals changed between generations.
(logical(1)
)
Whether to only re-evaluate configurations for which the fidelity would increase. Default TRUE
.
(ParamSet
| NULL
)
Additional components to optimize over, not included in search_space
, but possibly used for self-adaption. This must be the ParamSet
of mies_init_population()
's additional_component_sampler
argument.
data.table
: the performance values returned when evaluating the offspring
values
through eval_batch
.
Other mies building blocks:
mies_evaluate_offspring()
,
mies_generate_offspring()
,
mies_get_fitnesses()
,
mies_init_population()
,
mies_select_from_archive()
,
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)
)
budget_id = "y"
# Create an initial population with fidelity ("y") value 1
mies_init_population(oi, mu = 2, budget_id = budget_id, fidelity = 1)
oi$archive
#> <Archive>
#> x y dob eol x_id Obj timestamp batch_nr
#> 1: 0.7544 1 1 NA 1 0.36 2023-09-20 04:41:24.65 1
#> 2: -0.0056 1 1 NA 2 0.38 2023-09-20 04:41:24.65 1
# Re-evaluate these individuals with higher fidelity
mies_step_fidelity(oi, budget_id = budget_id, fidelity = 2)
oi$archive
#> <Archive>
#> x y dob eol x_id Obj timestamp batch_nr
#> 1: 0.7544 1 1 1 1 0.364 2023-09-20 04:41:24.65 1
#> 2: -0.0056 1 1 1 2 0.381 2023-09-20 04:41:24.65 1
#> 3: 0.7544 2 1 NA 1 0.434 2023-09-20 04:41:24.66 2
#> 4: -0.0056 2 1 NA 2 0.054 2023-09-20 04:41:24.66 2
# The following creates a new generation without killing the initial
# generation
offspring = data.frame(x = 0:1)
mies_evaluate_offspring(oi, offspring = offspring, budget_id = budget_id,
fidelity = 3)
oi$archive
#> <Archive>
#> x y dob eol x_id Obj timestamp batch_nr
#> 1: 0.7544 1 1 1 1 0.364 2023-09-20 04:41:24.65 1
#> 2: -0.0056 1 1 1 2 0.381 2023-09-20 04:41:24.65 1
#> 3: 0.7544 2 1 NA 1 0.434 2023-09-20 04:41:24.66 2
#> 4: -0.0056 2 1 NA 2 0.054 2023-09-20 04:41:24.66 2
#> 5: 0.0000 3 2 NA 3 0.014 2023-09-20 04:41:24.67 3
#> 6: 1.0000 3 2 NA 4 0.271 2023-09-20 04:41:24.67 3
# Re-evaluate only individuals from last generation by setting current_gen_only
mies_step_fidelity(oi, budget_id = budget_id, fidelity = 4,
current_gen_only = TRUE)
oi$archive
#> <Archive>
#> x y dob eol x_id Obj timestamp batch_nr
#> 1: 0.7544 1 1 1 1 0.36415 2023-09-20 04:41:24.65 1
#> 2: -0.0056 1 1 1 2 0.38104 2023-09-20 04:41:24.65 1
#> 3: 0.7544 2 1 NA 1 0.43421 2023-09-20 04:41:24.66 2
#> 4: -0.0056 2 1 NA 2 0.05413 2023-09-20 04:41:24.66 2
#> 5: 0.0000 3 2 2 3 0.01360 2023-09-20 04:41:24.67 3
#> 6: 1.0000 3 2 2 4 0.27072 2023-09-20 04:41:24.67 3
#> 7: 0.0000 4 2 NA 3 0.00067 2023-09-20 04:41:24.68 4
#> 8: 1.0000 4 2 NA 4 0.01348 2023-09-20 04:41:24.68 4
# Default: Re-evaluate all that *increase* fidelity: Only the initial
# population is re-evaluated here.
mies_step_fidelity(oi, budget_id = budget_id, fidelity = 3)
oi$archive
#> <Archive>
#> x y dob eol x_id Obj timestamp batch_nr
#> 1: 0.7544 1 1 1 1 0.36415 2023-09-20 04:41:24.65 1
#> 2: -0.0056 1 1 1 2 0.38104 2023-09-20 04:41:24.65 1
#> 3: 0.7544 2 1 2 1 0.43421 2023-09-20 04:41:24.66 2
#> 4: -0.0056 2 1 2 2 0.05413 2023-09-20 04:41:24.66 2
#> 5: 0.0000 3 2 2 3 0.01360 2023-09-20 04:41:24.67 3
#> 6: 1.0000 3 2 2 4 0.27072 2023-09-20 04:41:24.67 3
#> 7: 0.0000 4 2 NA 3 0.00067 2023-09-20 04:41:24.68 4
#> 8: 1.0000 4 2 NA 4 0.01348 2023-09-20 04:41:24.68 4
#> 9: 0.7544 3 2 NA 1 0.15599 2023-09-20 04:41:24.69 5
#> 10: -0.0056 3 2 NA 2 0.01330 2023-09-20 04:41:24.69 5
# To also re-evaluate individuals with *higher* fidelity, use
# 'fidelity_monotonic = FALSE'. This does not re-evaluate the points that already have
# the requested fidelity, however.
mies_step_fidelity(oi, budget_id = budget_id, fidelity = 3, fidelity_monotonic = FALSE)
oi$archive
#> <Archive>
#> x y dob eol x_id Obj timestamp batch_nr
#> 1: 0.7544 1 1 1 1 0.36415 2023-09-20 04:41:24.65 1
#> 2: -0.0056 1 1 1 2 0.38104 2023-09-20 04:41:24.65 1
#> 3: 0.7544 2 1 2 1 0.43421 2023-09-20 04:41:24.66 2
#> 4: -0.0056 2 1 2 2 0.05413 2023-09-20 04:41:24.66 2
#> 5: 0.0000 3 2 2 3 0.01360 2023-09-20 04:41:24.67 3
#> 6: 1.0000 3 2 2 4 0.27072 2023-09-20 04:41:24.67 3
#> 7: 0.0000 4 2 2 3 0.00067 2023-09-20 04:41:24.68 4
#> 8: 1.0000 4 2 2 4 0.01348 2023-09-20 04:41:24.68 4
#> 9: 0.7544 3 2 NA 1 0.15599 2023-09-20 04:41:24.69 5
#> 10: -0.0056 3 2 NA 2 0.01330 2023-09-20 04:41:24.69 5
#> 11: 0.0000 3 2 NA 3 0.01360 2023-09-20 04:41:24.70 6
#> 12: 1.0000 3 2 NA 4 0.27072 2023-09-20 04:41:24.70 6