Skip to content

Commit

Permalink
allow to pass optimizer ID instead of object to noir function as well
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbossek committed Aug 23, 2016
1 parent ae8afe4 commit 98c7ab9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions R/noir.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,28 @@
#' Expects an \code{noir_optimizer} and a \code{smoof_function} and applies the
#' optimizer to the function.
#'
#' @param optimizer [\code{noir_optimizer}]\cr
#' Noir optimizer.
#' @param optimizer [\code{noir_optimizer} | \code{character(1)}]\cr
#' Noir optimizer or string short name of an optimizer.
#' @param obj.fn [\code{smoof_function}]\cr
#' Objective function.
#' @param ... [any]\cr
# User-defined parameter settings for the optimizer.
#' @return [\code{noir_result}]
#' @examples
#' library(smoof)
#' obj.fn = smoof::makeSphereFunction(2L)
#'
#' # setting up the optimizer by hand
#' optimizer = setUpOptimizer("neldermead")
#' res = noir(optimizer, smoof::makeSphereFunction(2L), alpha = 1.5)
#' res = noir(optimizer, obj.fn, alpha = 1.5)
#'
#' # alternatively pass the string representation of the optimizer
#' res = noir("neldermead", obj.fn, alpha = 1.5)
#' @export
noir = function(optimizer, obj.fn, ...) {
if (is.character(optimizer)) {
optimizer = setUpOptimizer(optimizer)
}
assertClass(optimizer, "optimizer")
assertClass(obj.fn, "smoof_function")
hyper.par.set = optimizer$hyper.par.set
Expand Down

0 comments on commit 98c7ab9

Please sign in to comment.