mies_evaluate_offspring: Evaluate Proposed Configurations Generated in a MIES...

View source: R/mies_methods.R

mies_evaluate_offspringR Documentation

Evaluate Proposed Configurations Generated in a MIES Iteration

Description

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.

Usage

mies_evaluate_offspring(
  inst,
  offspring,
  budget_id = NULL,
  fidelity = NULL,
  reevaluate_fidelity = NULL,
  fidelity_monotonic = TRUE
)

Arguments

inst

(OptimInstance)
Optimization instance to evaluate.

offspring

(data.frame)
Proposed configurations to be evaluated, must have columns named after the inst's search space, minus budget_id if not NULL.

budget_id

(character(1) | NULL)
Budget component when doing multi-fidelity optimization. This component of the search space is added to individuals according to fidelity. Should be NULL when no multi-fidelity optimization is performed (default).

fidelity

(atomic(1) | NULL)
Atomic scalar indicating the value to be assigned to the budget_id component of offspring. This value must be NULL if no multi-fidelity optimization is performed (the default).

reevaluate_fidelity

(atomic(1))
Fidelity with which to evaluate alive individuals from previous generations that have a budget value below (if fidelity_monotonic is TRUE) or different from the current fidelity value. Default NULL: Do not re-evaluate. Must be NULL when budget_id and fidelity are NULL. See also mies_step_fidelity.

fidelity_monotonic

(logical(1))
When reevaluate_fidelity is non-NULL, then this indicates whether individuals should only ever be re-evaluated when fidelity would be increased. Default TRUE. Ignored when reevaluate_fidelity is NULL

Value

invisible data.table: the performance values returned when evaluating the offspring values through eval_batch.

See Also

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()

Examples

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


miesmuschel documentation built on Sept. 11, 2024, 8:23 p.m.