From 91250d5250ab4c114cd93da9595f7e20de7346c0 Mon Sep 17 00:00:00 2001 From: Lennart Schneider Date: Tue, 22 Aug 2023 22:12:03 +0200 Subject: [PATCH 1/5] feat: draft SamplerMbo --- DESCRIPTION | 2 + NAMESPACE | 1 + R/SamplerMbo.R | 174 +++++++++++++++++++++++++++++++++++++++++++++ R/zzz.R | 2 +- man/SamplerMbo.Rd | 176 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 354 insertions(+), 1 deletion(-) create mode 100644 R/SamplerMbo.R create mode 100644 man/SamplerMbo.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 2f73386d..18556be1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -59,6 +59,7 @@ Suggests: lhs, mlr3learners (>= 0.5.4), mlr3pipelines (>= 0.4.2), + mlr3hyperband (>= 0.4.4), nloptr, ranger, rgenoud, @@ -93,6 +94,7 @@ Collate: 'ResultAssigner.R' 'ResultAssignerArchive.R' 'ResultAssignerSurrogate.R' + 'SamplerMbo.R' 'Surrogate.R' 'SurrogateLearner.R' 'SurrogateLearnerCollection.R' diff --git a/NAMESPACE b/NAMESPACE index 1a02acdc..57f05b24 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -20,6 +20,7 @@ export(OptimizerMbo) export(ResultAssigner) export(ResultAssignerArchive) export(ResultAssignerSurrogate) +export(SamplerMbo) export(Surrogate) export(SurrogateLearner) export(SurrogateLearnerCollection) diff --git a/R/SamplerMbo.R b/R/SamplerMbo.R new file mode 100644 index 00000000..5408d73f --- /dev/null +++ b/R/SamplerMbo.R @@ -0,0 +1,174 @@ +#' @title Sampler Suitable for Combining Hyperband With Model Based Optimization +#' +#' @description +#' This class provides a [paradox::Sampler] that allows for sampling points relying on Model Based Optimization. +#' Using this sampler together with [mlr3hyperband::OptimizerHyperband] or [mlr3hyperband::TunerHyperband] allows for constructing an optimizer +#' that performs a combination of Hyperband and Model Based Optimization similarly as the BOHB algorithm in the context of multifidelity optimization. +#' +#' @export +#' @examples +#'if (requireNamespace("mlr3learners") & +#' requireNamespace("DiceKriging") & +#' requireNamespace("rgenoud") & +#' requireNamespace("mlr3hyperband")) { +#' +#' library(bbotk) +#' library(paradox) +#' library(mlr3hyperband) +#' +#' # Augmented Branin function +#' fun = function(xs) { +#' y = +#' ( +#' xs[["x2"]] - ((5.1 / (4 * pi^2)) - 0.1 * (1 - (xs[["fidelity"]] / 100))) * +#' xs[["x1"]]^2 + (5 / pi) * xs[["x1"]] - 6 +#' ) ^ 2 + +#' 10 * (1 - (1 / (8 * pi))) * cos(xs[["x1"]]) + 10 +#' list(y = y) +#' } +#' domain = ps( +#' x1 = p_dbl(lower = -5, upper = 10), +#' x2 = p_dbl(lower = 0, upper = 15), +#' fidelity = p_int(lower = 1, upper = 100, tags = "budget")) +#' codomain = ps(y = p_dbl(tags = "minimize")) +#' objective = ObjectiveRFun$new(fun = fun, domain = domain, codomain = codomain) +#' +#' instance = OptimInstanceSingleCrit$new(objective = objective, terminator = trm("none")) +#' +#' surrogate = default_surrogate(instance) +#' +#' acq_function = acqf("ei") +#' +#' acq_optimizer = acqo( +#' optimizer = opt("random_search", batch_size = 100), +#' terminator = trm("evals", n_evals = 100)) +#' +#' sampler = SamplerMbo$new( +#' instance = instance, +#' surrogate = surrogate, +#' acq_function = acq_function, +#' acq_optimizer = acq_optimizer) +#' +#' optimizer = opt("hyperband", eta = 3, sampler = sampler, repetitions = 1) +#' optimizer$optimize(instance) +#' } +SamplerMbo = R6Class("SamplerMbo", inherit = paradox::Sampler, + public = list( + #' @field instance ([bbotk::OptimInstance)\cr + #' The instance that is to be optimized. + instance = NULL, + + #' @field budget_id (`character(1)`)\cr + #' Id of the budget parameter part of the search space of the instance (i.e., the single numeric or integer parameter tagged via `"budget"`). + budget_id = NULL, + + #' @field search_space_sampler ([paradox::Domain])\cr + #' Search space the sampler operates on. + #' This is the same as the search space of the [bbotk::OptimInstance] to be optimized but excludes the parameter specified via `budget_id`. + search_space_sampler = NULL, + + #' @field rho (`numeric(1)`)\cr + #' Fraction of configurations that should be sampled uniformly at random. + rho = NULL, + + #' @field Nmin (`integer(1)`)\cr + #' Minimum number of observations required for any budget level for the model based proposal mechanism to take action. + Nmin = NULL, + + #' @field tmp_archive ([bbotk::Archive])\cr + #' Temporal archive which is a copy of the archive of the [bbotk::OptimInstance] used for updating the surrogate model within the model based proposal mechanism. + tmp_archive = NULL, + + #' @template field_surrogate + surrogate = NULL, + + #' @template field_acq_function + acq_function = NULL, + + #' @field acq_function_domain ([paradox::Domain])\cr + #' The domain of the acquisition function within the model based proposal mechanism. + #' This is the same as `search_space_sampler` without any potential transformation functions. + acq_function_domain = NULL, + + #' @template field_acq_optimizer + acq_optimizer = NULL, + + #' @field sampler_random ([paradox::SamplerUnif])\cr + #' The sampler responsible for proposing points uniformly at random based on the fraction specified as `rho`. + sampler_random = NULL, + + #' @description + #' Creates a new instance of this [R6][R6::R6Class] class. + #' + #' @param instance ([bbotk::OptimInstance)\cr + #' The instance that is to be optimized. + #' Note that this is required as the model based sampling requires access to the evaluations logged in the [bbotk::Archive]. + #' @template param_surrogate + #' @template param_acq_function + #' @template param_acq_optimizer + #' @param rho (`numeric(1)`)\cr + #' Fraction of configurations that should be sampled uniformly at random. + #' @param Nmin (`integer(1)`)\cr + #' Minimum number of observations required for any budget level for the model based proposal mechanism to take action. + #' Default is to use the number of parameters of the search space of the instance + 2. + initialize = function(instance, surrogate, acq_function, acq_optimizer, rho = 0.25, Nmin = NULL) { + self$instance = assert_r6(instance, classes = "OptimInstance") + self$budget_id = self$instance$search_space$ids(tags = "budget") + if (length(self$budget_id) != 1L) { + stop('Exactly one parameter must be tagged with "budget."') + } + assert_choice(self$instance$search_space$class[[self$budget_id]], c("ParamInt", "ParamDbl")) + self$search_space_sampler = self$instance$search_space$clone(deep = TRUE)$subset(setdiff(self$instance$search_space$ids(), self$budget_id)) + self$rho = assert_number(rho, lower = 0, upper = 1) + if (is.null(Nmin)) { + Nmin = self$instance$search_space$length + 2L # budget param is in search space therefore d - 1 + 1 which is d + } + self$Nmin = assert_int(Nmin, lower = 1L) + self$tmp_archive = self$instance$archive$clone(deep = TRUE) + self$surrogate = assert_r6(surrogate, classes = "Surrogate") + self$acq_function = assert_r6(acq_function, classes = "AcqFunction") + self$acq_function_domain = self$search_space_sampler$clone(deep = TRUE) + self$acq_function_domain$trafo = NULL + self$acq_optimizer = assert_r6(acq_optimizer, classes = "AcqOptimizer") + self$surrogate$archive = self$tmp_archive + self$surrogate$cols_x = setdiff(surrogate$cols_x, self$budget_id) + self$acq_function$surrogate = self$surrogate + self$acq_function$domain = self$acq_function_domain + self$acq_optimizer$acq_function = self$acq_function + self$sampler_random = SamplerUnif$new(self$search_space_sampler) + super$initialize(self$search_space_sampler) + # FIXME: check if instance, surrogate, acq_function and acq_optimizer work for the instance + } + ), + private = list( + .sample = function(n) { + # we need at the minimum Nmin observations for any budget + # so if we have less then Nmin in total we surely cannot do a model based proposal + if (self$instance$archive$n_evals < self$Nmin) { + return(self$sampler_random$sample(n)$data) + } + budget_table = self$instance$archive$data[, .N, by = eval(self$budget_id)][N >= self$Nmin] + # a fraction of rho of the n candidate points are proposed uniformly at random + propose_random = runif(n, min = 0, max = 1) <= self$rho + n_random = sum(propose_random) + xdt = if (n_random < n) { + # we order the budget table by the budget id and take the largest budget that has at least Nmin observations + setorderv(budget_table, cols = self$budget_id, order = -1L) + data = self$instance$archive$data[get(self$budget_id) == budget_table[1L, ][[self$budget_id]], ] + # we then do one iteration of BO based on this subset of observations excluding the budget id as a parameter + self$tmp_archive$data = data + self$acq_function$surrogate$archive = self$tmp_archive + self$acq_function$domain = self$acq_function_domain + self$acq_function$surrogate$update() + self$acq_function$update() + self$acq_optimizer$param_set$values$n_candidates = n - n_random + xdt = self$acq_optimizer$optimize()[, self$search_space_sampler$ids(), with = FALSE] + xdt_random = self$sampler_random$sample(n_random)$data + rbind(xdt, xdt_random) + } else { + self$sampler_random$sample(n_random)$data + } + xdt + } + ) +) diff --git a/R/zzz.R b/R/zzz.R index 74689172..ae16b1eb 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -44,7 +44,7 @@ register_mlr3tuning = function() { } # nocov end # static code checks should not complain about commonly used data.table columns -utils::globalVariables("y_scal") +utils::globalVariables(c("N", "y_scal")) if (!Sys.getenv("DEVTOOLS_LOAD") == "true") { leanify_package() diff --git a/man/SamplerMbo.Rd b/man/SamplerMbo.Rd new file mode 100644 index 00000000..5f5a4c59 --- /dev/null +++ b/man/SamplerMbo.Rd @@ -0,0 +1,176 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/SamplerMbo.R +\name{SamplerMbo} +\alias{SamplerMbo} +\title{Sampler Suitable for Combining Hyperband With Model Based Optimization} +\description{ +This class provides a \link[paradox:Sampler]{paradox::Sampler} that allows for sampling points relying on Model Based Optimization. +Using this sampler together with \link[mlr3hyperband:mlr_optimizers_hyperband]{mlr3hyperband::OptimizerHyperband} or \link[mlr3hyperband:mlr_tuners_hyperband]{mlr3hyperband::TunerHyperband} allows for constructing an optimizer +that performs a combination of Hyperband and Model Based Optimization similarly as the BOHB algorithm in the context of multifidelity optimization. +} +\examples{ +if (requireNamespace("mlr3learners") & + requireNamespace("DiceKriging") & + requireNamespace("rgenoud") & + requireNamespace("mlr3hyperband")) { + + library(bbotk) + library(paradox) + library(mlr3hyperband) + + # Augmented Branin function + fun = function(xs) { + y = + ( + xs[["x2"]] - ((5.1 / (4 * pi^2)) - 0.1 * (1 - (xs[["fidelity"]] / 100))) * + xs[["x1"]]^2 + (5 / pi) * xs[["x1"]] - 6 + ) ^ 2 + + 10 * (1 - (1 / (8 * pi))) * cos(xs[["x1"]]) + 10 + list(y = y) + } + domain = ps( + x1 = p_dbl(lower = -5, upper = 10), + x2 = p_dbl(lower = 0, upper = 15), + fidelity = p_int(lower = 1, upper = 100, tags = "budget")) + codomain = ps(y = p_dbl(tags = "minimize")) + objective = ObjectiveRFun$new(fun = fun, domain = domain, codomain = codomain) + + instance = OptimInstanceSingleCrit$new(objective = objective, terminator = trm("none")) + + surrogate = default_surrogate(instance) + + acq_function = acqf("ei") + + acq_optimizer = acqo( + optimizer = opt("random_search", batch_size = 100), + terminator = trm("evals", n_evals = 100)) + + sampler = SamplerMbo$new( + instance = instance, + surrogate = surrogate, + acq_function = acq_function, + acq_optimizer = acq_optimizer) + + optimizer = opt("hyperband", eta = 3, sampler = sampler, repetitions = 3) + optimizer$optimize(instance) +} +} +\section{Super class}{ +\code{\link[paradox:Sampler]{paradox::Sampler}} -> \code{SamplerMbo} +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{instance}}{([bbotk::OptimInstance)\cr +The instance that is to be optimized.} + +\item{\code{budget_id}}{(\code{character(1)})\cr +Id of the budget parameter part of the search space of the instance (i.e., the single numeric or integer parameter tagged via \code{"budget"}).} + +\item{\code{search_space_sampler}}{(\link[paradox:Domain]{paradox::Domain})\cr +Search space the sampler operates on. +This is the same as the search space of the \link[bbotk:OptimInstance]{bbotk::OptimInstance} to be optimized but excludes the parameter specified via \code{budget_id}.} + +\item{\code{rho}}{(\code{numeric(1)})\cr +Fraction of configurations that should be sampled uniformly at random.} + +\item{\code{Nmin}}{(\code{integer(1)})\cr +Minimum number of observations required for any budget level for the model based proposal mechanism to take action.} + +\item{\code{tmp_archive}}{(\link[bbotk:Archive]{bbotk::Archive})\cr +Temporal archive which is a copy of the archive of the \link[bbotk:OptimInstance]{bbotk::OptimInstance} used for updating the surrogate model within the model based proposal mechanism.} + +\item{\code{surrogate}}{(\link{Surrogate} | \code{NULL})\cr +The surrogate.} + +\item{\code{acq_function}}{(\link{AcqFunction} | \code{NULL})\cr +The acquisition function.} + +\item{\code{acq_function_domain}}{(\link[paradox:Domain]{paradox::Domain})\cr +The domain of the acquisition function within the model based proposal mechanism. +This is the same as \code{search_space_sampler} without any potential transformation functions.} + +\item{\code{acq_optimizer}}{(\link{AcqOptimizer} | \code{NULL})\cr +The acquisition function optimizer.} + +\item{\code{sampler_random}}{(\link[paradox:SamplerUnif]{paradox::SamplerUnif})\cr +The sampler responsible for proposing points uniformly at random based on the fraction specified as \code{rho}.} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-SamplerMbo-new}{\code{SamplerMbo$new()}} +\item \href{#method-SamplerMbo-clone}{\code{SamplerMbo$clone()}} +} +} +\if{html}{\out{ +
Inherited methods + +
+}} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-SamplerMbo-new}{}}} +\subsection{Method \code{new()}}{ +Creates a new instance of this \link[R6:R6Class]{R6} class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{SamplerMbo$new( + instance, + surrogate, + acq_function, + acq_optimizer, + rho = 0.25, + Nmin = NULL +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{instance}}{([bbotk::OptimInstance)\cr +The instance that is to be optimized. +Note that this is required as the model based sampling requires access to the evaluations logged in the \link[bbotk:Archive]{bbotk::Archive}.} + +\item{\code{surrogate}}{(\link{Surrogate} | \code{NULL})\cr +The surrogate.} + +\item{\code{acq_function}}{(\link{AcqFunction} | \code{NULL})\cr +The acquisition function.} + +\item{\code{acq_optimizer}}{(\link{AcqOptimizer} | \code{NULL})\cr +The acquisition function optimizer.} + +\item{\code{rho}}{(\code{numeric(1)})\cr +Fraction of configurations that should be sampled uniformly at random.} + +\item{\code{Nmin}}{(\code{integer(1)})\cr +Minimum number of observations required for any budget level for the model based proposal mechanism to take action. +Default is to use the number of parameters of the search space of the instance + 2.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-SamplerMbo-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{SamplerMbo$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} From 434dc7077a60e6d7ff65ddd23f4e0e2cc73f39a1 Mon Sep 17 00:00:00 2001 From: Lennart Schneider Date: Tue, 22 Aug 2023 23:11:32 +0200 Subject: [PATCH 2/5] spead up example --- R/SamplerMbo.R | 4 ++-- man/SamplerMbo.Rd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/SamplerMbo.R b/R/SamplerMbo.R index 5408d73f..6aafd393 100644 --- a/R/SamplerMbo.R +++ b/R/SamplerMbo.R @@ -29,7 +29,7 @@ #' domain = ps( #' x1 = p_dbl(lower = -5, upper = 10), #' x2 = p_dbl(lower = 0, upper = 15), -#' fidelity = p_int(lower = 1, upper = 100, tags = "budget")) +#' fidelity = p_int(lower = 10, upper = 100, tags = "budget")) #' codomain = ps(y = p_dbl(tags = "minimize")) #' objective = ObjectiveRFun$new(fun = fun, domain = domain, codomain = codomain) #' @@ -49,7 +49,7 @@ #' acq_function = acq_function, #' acq_optimizer = acq_optimizer) #' -#' optimizer = opt("hyperband", eta = 3, sampler = sampler, repetitions = 1) +#' optimizer = opt("hyperband", eta = 3, sampler = sampler, repetitions = 2) #' optimizer$optimize(instance) #' } SamplerMbo = R6Class("SamplerMbo", inherit = paradox::Sampler, diff --git a/man/SamplerMbo.Rd b/man/SamplerMbo.Rd index 5f5a4c59..1a7f3f9b 100644 --- a/man/SamplerMbo.Rd +++ b/man/SamplerMbo.Rd @@ -31,7 +31,7 @@ if (requireNamespace("mlr3learners") & domain = ps( x1 = p_dbl(lower = -5, upper = 10), x2 = p_dbl(lower = 0, upper = 15), - fidelity = p_int(lower = 1, upper = 100, tags = "budget")) + fidelity = p_int(lower = 10, upper = 100, tags = "budget")) codomain = ps(y = p_dbl(tags = "minimize")) objective = ObjectiveRFun$new(fun = fun, domain = domain, codomain = codomain) @@ -51,7 +51,7 @@ if (requireNamespace("mlr3learners") & acq_function = acq_function, acq_optimizer = acq_optimizer) - optimizer = opt("hyperband", eta = 3, sampler = sampler, repetitions = 3) + optimizer = opt("hyperband", eta = 3, sampler = sampler, repetitions = 2) optimizer$optimize(instance) } } From bd3af10b174d5990c857480b96b3a78503852353 Mon Sep 17 00:00:00 2001 From: Lennart Schneider Date: Wed, 23 Aug 2023 15:40:36 +0200 Subject: [PATCH 3/5] minor refactor --- R/SamplerMbo.R | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/R/SamplerMbo.R b/R/SamplerMbo.R index 6aafd393..bf2122ea 100644 --- a/R/SamplerMbo.R +++ b/R/SamplerMbo.R @@ -85,11 +85,6 @@ SamplerMbo = R6Class("SamplerMbo", inherit = paradox::Sampler, #' @template field_acq_function acq_function = NULL, - #' @field acq_function_domain ([paradox::Domain])\cr - #' The domain of the acquisition function within the model based proposal mechanism. - #' This is the same as `search_space_sampler` without any potential transformation functions. - acq_function_domain = NULL, - #' @template field_acq_optimizer acq_optimizer = NULL, @@ -127,13 +122,10 @@ SamplerMbo = R6Class("SamplerMbo", inherit = paradox::Sampler, self$tmp_archive = self$instance$archive$clone(deep = TRUE) self$surrogate = assert_r6(surrogate, classes = "Surrogate") self$acq_function = assert_r6(acq_function, classes = "AcqFunction") - self$acq_function_domain = self$search_space_sampler$clone(deep = TRUE) - self$acq_function_domain$trafo = NULL self$acq_optimizer = assert_r6(acq_optimizer, classes = "AcqOptimizer") self$surrogate$archive = self$tmp_archive self$surrogate$cols_x = setdiff(surrogate$cols_x, self$budget_id) self$acq_function$surrogate = self$surrogate - self$acq_function$domain = self$acq_function_domain self$acq_optimizer$acq_function = self$acq_function self$sampler_random = SamplerUnif$new(self$search_space_sampler) super$initialize(self$search_space_sampler) @@ -157,8 +149,6 @@ SamplerMbo = R6Class("SamplerMbo", inherit = paradox::Sampler, data = self$instance$archive$data[get(self$budget_id) == budget_table[1L, ][[self$budget_id]], ] # we then do one iteration of BO based on this subset of observations excluding the budget id as a parameter self$tmp_archive$data = data - self$acq_function$surrogate$archive = self$tmp_archive - self$acq_function$domain = self$acq_function_domain self$acq_function$surrogate$update() self$acq_function$update() self$acq_optimizer$param_set$values$n_candidates = n - n_random From 754198d96095ab92f5de7be9a47d0ab66ab95b35 Mon Sep 17 00:00:00 2001 From: Lennart Schneider Date: Thu, 24 Aug 2023 13:37:38 +0200 Subject: [PATCH 4/5] .. --- R/SamplerMbo.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/SamplerMbo.R b/R/SamplerMbo.R index bf2122ea..8e43bc9d 100644 --- a/R/SamplerMbo.R +++ b/R/SamplerMbo.R @@ -140,6 +140,9 @@ SamplerMbo = R6Class("SamplerMbo", inherit = paradox::Sampler, return(self$sampler_random$sample(n)$data) } budget_table = self$instance$archive$data[, .N, by = eval(self$budget_id)][N >= self$Nmin] + if (nrow(budget_table) == 0L) { + return(self$sampler_random$sample(n)$data) + } # a fraction of rho of the n candidate points are proposed uniformly at random propose_random = runif(n, min = 0, max = 1) <= self$rho n_random = sum(propose_random) From 25a0a23c74171e5450c58176e7cee55483d3ad1b Mon Sep 17 00:00:00 2001 From: Lennart Schneider Date: Tue, 20 Aug 2024 14:35:33 +0200 Subject: [PATCH 5/5] docs: rerun --- R/SamplerMbo.R | 8 ++++---- man/SamplerMbo.Rd | 10 +++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/R/SamplerMbo.R b/R/SamplerMbo.R index 8e43bc9d..078c921b 100644 --- a/R/SamplerMbo.R +++ b/R/SamplerMbo.R @@ -2,7 +2,7 @@ #' #' @description #' This class provides a [paradox::Sampler] that allows for sampling points relying on Model Based Optimization. -#' Using this sampler together with [mlr3hyperband::OptimizerHyperband] or [mlr3hyperband::TunerHyperband] allows for constructing an optimizer +#' Using this sampler together with [mlr3hyperband::OptimizerBatchHyperband] or [mlr3hyperband::TunerBatchHyperband] allows for constructing an optimizer #' that performs a combination of Hyperband and Model Based Optimization similarly as the BOHB algorithm in the context of multifidelity optimization. #' #' @export @@ -15,10 +15,10 @@ #' library(bbotk) #' library(paradox) #' library(mlr3hyperband) -#' +#' #' # Augmented Branin function #' fun = function(xs) { -#' y = +#' y = #' ( #' xs[["x2"]] - ((5.1 / (4 * pi^2)) - 0.1 * (1 - (xs[["fidelity"]] / 100))) * #' xs[["x1"]]^2 + (5 / pi) * xs[["x1"]] - 6 @@ -78,7 +78,7 @@ SamplerMbo = R6Class("SamplerMbo", inherit = paradox::Sampler, #' @field tmp_archive ([bbotk::Archive])\cr #' Temporal archive which is a copy of the archive of the [bbotk::OptimInstance] used for updating the surrogate model within the model based proposal mechanism. tmp_archive = NULL, - + #' @template field_surrogate surrogate = NULL, diff --git a/man/SamplerMbo.Rd b/man/SamplerMbo.Rd index 1a7f3f9b..baf916a3 100644 --- a/man/SamplerMbo.Rd +++ b/man/SamplerMbo.Rd @@ -5,7 +5,7 @@ \title{Sampler Suitable for Combining Hyperband With Model Based Optimization} \description{ This class provides a \link[paradox:Sampler]{paradox::Sampler} that allows for sampling points relying on Model Based Optimization. -Using this sampler together with \link[mlr3hyperband:mlr_optimizers_hyperband]{mlr3hyperband::OptimizerHyperband} or \link[mlr3hyperband:mlr_tuners_hyperband]{mlr3hyperband::TunerHyperband} allows for constructing an optimizer +Using this sampler together with \link[mlr3hyperband:mlr_optimizers_hyperband]{mlr3hyperband::OptimizerBatchHyperband} or \link[mlr3hyperband:mlr_tuners_hyperband]{mlr3hyperband::TunerBatchHyperband} allows for constructing an optimizer that performs a combination of Hyperband and Model Based Optimization similarly as the BOHB algorithm in the context of multifidelity optimization. } \examples{ @@ -17,10 +17,10 @@ if (requireNamespace("mlr3learners") & library(bbotk) library(paradox) library(mlr3hyperband) - + # Augmented Branin function fun = function(xs) { - y = + y = ( xs[["x2"]] - ((5.1 / (4 * pi^2)) - 0.1 * (1 - (xs[["fidelity"]] / 100))) * xs[["x1"]]^2 + (5 / pi) * xs[["x1"]] - 6 @@ -86,10 +86,6 @@ The surrogate.} \item{\code{acq_function}}{(\link{AcqFunction} | \code{NULL})\cr The acquisition function.} -\item{\code{acq_function_domain}}{(\link[paradox:Domain]{paradox::Domain})\cr -The domain of the acquisition function within the model based proposal mechanism. -This is the same as \code{search_space_sampler} without any potential transformation functions.} - \item{\code{acq_optimizer}}{(\link{AcqOptimizer} | \code{NULL})\cr The acquisition function optimizer.}