Get evaluated performance values from an OptimInstance
for all individuals that were alive
at a given generation. Depending on survivors_only
, all individuals alive at the end of a generation are returned,
or all individuals alive at any point during a generation.
The resulting data.table
object is formatted for easy manipulation to get relevant
information about optimization progress. To get aggregated values per generation, use by = "dob"
.
mies_get_generation_results(
inst,
as_fitnesses = TRUE,
survivors_only = TRUE,
condition_on_budget_id = NULL
)
(OptimInstance
)
Optimization instance to evaluate.
(logical(1)
)
Whether to transform performance values into "fitness" values that are always to be maximized.
This means that values that objectives that should originally be minimized are multiplied with -1,
and that parts of the objective codomain that are neither being minimized nor maximized are dropped.
Default TRUE
.
(logical(1)
)
Whether to ignore configurations that have "eol"
set to the given generation, i.e. individuals that were killed during that generation.
When this is TRUE
(default), then only individuals that are alive at the end of a generation are considered; otherwise all individuals
alive at any point of a generation are considered. If it is TRUE
, this leads to individuals that have "dob"
== "eol"
being ignored.
(character(1)
| NULL
)
Budget component when doing multi-fidelity optimization. When this is given, then for each generation, only individuals with the highest value for this
component are considered. If survivors_only
is TRUE
, this means the highest value of all survivors of a given generation, if it is FALSE
, then it
is the highest value of all individuals alive at any point of a generation. To ignore possible budget-parameters, set this to NULL
(default).
This is inparticular necessary when fidelity is not monotonically increasing (e.g. if it is categorical).
a data.table
with the column "dob"
, indicating the generation, as well as further
columns named by the OptimInstance
's objectives.
Other aggregation methods:
mies_aggregate_generations()
,
mies_aggregate_single_generation()
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)
op$optimize(oi)
#> x y x_domain Obj
#> <num> <num> <list> <num>
#> 1: -0.406948 1.43712 <list[2]> 9.897011
# negates objectives that are minimized:
mies_get_generation_results(oi)
#> dob Obj
#> <int> <num>
#> 1: 1 -9.897011
#> 2: 1 -10.010770
#> 3: 2 -9.897011
#> 4: 2 -10.000021
#> 5: 3 -9.897011
#> 6: 3 -9.944994
# real objective values:
mies_get_generation_results(oi, as_fitnesses = FALSE)
#> dob Obj
#> <int> <num>
#> 1: 1 9.897011
#> 2: 1 10.010770
#> 3: 2 9.897011
#> 4: 2 10.000021
#> 5: 3 9.897011
#> 6: 3 9.944994
# Individuals that died are included:
mies_get_generation_results(oi, survivors_only = FALSE)
#> dob Obj
#> <int> <num>
#> 1: 1 -9.897011
#> 2: 1 -10.010770
#> 3: 2 -9.897011
#> 4: 2 -10.010770
#> 5: 2 -10.000021
#> 6: 2 -10.303884
#> 7: 3 -9.897011
#> 8: 3 -10.000021
#> 9: 3 -9.944994
#> 10: 3 -10.001237