File: hasFiniteBoxConstraints.R

package info (click to toggle)
r-cran-paramhelpers 1.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 992 kB
  • sloc: ansic: 102; sh: 13; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 743 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#' Checks if a parameter or each parameter of a parameter set has ONLY finite lower and upper bounds.
#'
#' @template arg_par_or_set
#' @template arg_dict
#' @return `logical(1)`
#' @export
hasFiniteBoxConstraints = function(par, dict = NULL) {
  UseMethod("hasFiniteBoxConstraints")
}

#' @export
hasFiniteBoxConstraints.Param = function(par, dict = NULL) {
  bounds = c(getLower(par, dict = dict), getUpper(par, dict = dict))
  if (length(bounds) == 0) {
    return(TRUE)
  }
  return(all(is.finite(bounds)))
}

#' @export
hasFiniteBoxConstraints.ParamSet = function(par, dict = NULL) {
  bounds = c(getLower(par, dict = dict), getUpper(par, dict = dict))
  if (length(bounds) == 0) {
    return(TRUE)
  }
  return(all(is.finite(bounds)))
}