R/isSingleobjective.R

Defines functions isSingleobjective.smoof_wrapped_function isSingleobjective.smoof_function isSingleobjective

Documented in isSingleobjective

#' Checks whether the given function is single-objective.
#'
#' @template arg_smoof_function
#' @return [\code{logical(1)}] \code{TRUE} if function is single-objective, \code{FALSE} otherwise.
#' @export
isSingleobjective = function(fn) {
  UseMethod("isSingleobjective")
}

#' @export
isSingleobjective.smoof_function = function(fn) {
  return(attr(fn, "n.objectives") == 1L)
}

#' @export
isSingleobjective.smoof_wrapped_function = function(fn) {
  return(isSingleobjective(getWrappedFunction(fn)))
}
jakobbossek/smoof documentation built on Feb. 17, 2024, 2:23 a.m.