| mies_generation {miesmuschel} | R Documentation |
Get the Last Generation that was Evaluated
Description
Gets the last generation that was evaluated as counted by the "dob" column in the OptimInstance's Archive.
This accepts OptimInstances that were not evaluated with miesmuschel and are therefore missing the "dob" column, returning
a value of 0. However, if the "dob" column is invalid (the inferred generation is not integer numeric or not non-negative), an error is thrown.
Usage
mies_generation(inst)
Arguments
inst |
( |
Value
a scalar integer value indicating the last generation that was evaluated in inst. It is 0 when inst is empty, and also typically 0 if all evaluations
in inst so far were performed outside of miesmuschel. Every call of mies_init_population that actually performs evaluations, as well as each call to
mies_evaluate_offspring with non-empty offspring, increases the generation by 1.
Examples
library("bbotk")
lgr::threshold("warn")
# Define the objective to optimize
objective <- ObjectiveRFun$new(
fun = function(xs) {
z <- 10 - 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 = "minimize"))
)
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 6)
)
op <- opt("mies",
lambda = 2, mu = 2,
mutator = mut("gauss", sdev = 0.1),
recombinator = rec("xounif"),
parent_selector = sel("best")
)
set.seed(1)
mies_generation(oi)
op$optimize(oi)
mies_generation(oi)
oi$terminator = trm("evals", n_evals = 10)
op$optimize(oi)
mies_generation(oi)