isFeasible: Check if parameter value is valid.

Description Usage Arguments Value Examples

View source: R/isFeasible.R

Description

Check if a parameter value satisfies the constraints of the parameter description. This includes the requires expressions and the forbidden expression, if par is a ParamSet(). If requires is not satisfied, the parameter value must be set to scalar NA to be still feasible, a single scalar even in a case of a vector parameter. If the result is FALSE the attribute "warning" is attached which gives the reason for the negative result.

If the parameter has cnames, these are also checked.

Usage

1
isFeasible(par, x, use.defaults = FALSE, filter = FALSE)

Arguments

par

(Param | ParamSet)
Parameter or parameter set.

x

(any)
Single value to check against the Param or ParamSet. For a ParamSet x must be a list. x has to contain the untransformed values. If the list is named, it is possible to only pass a subset of parameters defined in the ParamSet() par. In that case, only conditions regarding the passed parameters are checked. (Note that this might not work if one of the passed params has a requires setting which refers to an unpassed param.)

use.defaults

(logical(1))
Whether defaults of the Param()/ParamSet() should be used if no values are supplied. If the defaults have requirements that are not met by x it will be feasible nonetheless. Default is FALSE.

filter

(logical(1))
Whether the ParamSet() should be reduced to the space of the given Param Values. Note that in case of use.defaults = TRUE the filtering will be conducted after the insertion of the default values. Default is FALSE.

Value

logical(1).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
p = makeNumericParam("x", lower = -1, upper = 1)
isFeasible(p, 0) # True
isFeasible(p, 2) # False, out of bounds
isFeasible(p, "a") # False, wrong type
# now for parameter sets
ps = makeParamSet(
  makeNumericParam("x", lower = -1, upper = 1),
  makeDiscreteParam("y", values = c("a", "b"))
)
isFeasible(ps, list(0, "a")) # True
isFeasible(ps, list("a", 0)) # False, wrong order

ParamHelpers documentation built on March 26, 2020, 7:40 p.m.