mies_aggregate_generations {miesmuschel} | R Documentation |
Get Aggregated Performance Values by Generation
Description
Get evaluated performance values from an OptimInstance
aggregated for each generation.
This may either concern all individuals that were alive at the end of a given generation (survivors_only
TRUE
)
or at any point during a generation (survivors_only
FALSE
).
The result is a single data.table
object with a dob
column indicating the
generation, as well as one column for each aggregations
entry crossed with each objective of inst
.
See mies_generation_apply()
on how to apply functions to entire fitness-matrices, not only individual objectives.
Usage
mies_aggregate_generations(
inst,
objectives = inst$archive$codomain$ids(),
aggregations = list(min = min, mean = mean, max = max, median = stats::median, size =
length),
as_fitnesses = TRUE,
survivors_only = TRUE,
condition_on_budget_id = NULL
)
Arguments
inst |
( |
objectives |
( |
aggregations |
(named |
as_fitnesses |
( |
survivors_only |
( |
condition_on_budget_id |
( |
Value
a data.table
with the column "dob"
, indicating the generation, as well as further
columns named by the items in aggregations
. There is more on element in objectives
(or more than one element not being minimized/maximized when as_fitnesses
is TRUE
), then columns are named <aggregations element name>.<objective name>
.
Otherwise, they are named by <aggregations element name>
only. To get a guarantee that elements are only named after elements in aggregations
, set objectives
to a length 1 character
.
See Also
Other aggregation methods:
mies_aggregate_single_generation()
,
mies_get_generation_results()
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)
op$optimize(oi)
# negates objectives that are minimized:
mies_aggregate_generations(oi)
# silly aggregation: first element
mies_aggregate_generations(oi, aggregations = list(first = function(x) x[1]))
# real objective values:
mies_aggregate_generations(oi, as_fitnesses = FALSE)
# Individuals that died are included:
mies_aggregate_generations(oi, survivors_only = FALSE)