Shrink a ParamSet towards a point.Source:
Shrinks a paradox::ParamSet towards a point. Boundaries of numeric values are shrinked to an interval around the point of half of the previous length, while for discrete variables, a random (currently not chosen) level is dropped.
Note that for paradox::ParamLgls the value to be shrinked around is set as
default value instead of dropping a level. Also, a tag
Note that the returned paradox::ParamSet has lost all its original
defaults, as they may have become infeasible.
If the paradox::ParamSet has a trafo,
x is expected to contain the
Should feasibility of the parameters be checked? If feasibility is not checked, and invalid values are present, no shrinking will be done. Must be turned off in the case of the paradox::ParamSet having a trafo. Default is
library(paradox) library(data.table) param_set = ParamSet$new(list( ParamDbl$new("x1", lower = 0, upper = 10), ParamInt$new("x2", lower = -10, upper = 10), ParamFct$new("x3", levels = c("a", "b", "c")), ParamLgl$new("x4")) ) x = data.table(x1 = 5, x2 = 0, x3 = "b", x4 = FALSE) shrink_ps(param_set, x = x) #> <ParamSet> #> id class lower upper nlevels default value #> 1: x1 ParamDbl 2.5 7.5 Inf <NoDefault> #> 2: x2 ParamInt -5.0 5.0 11 <NoDefault> #> 3: x3 ParamFct NA NA 2 <NoDefault> #> 4: x4 ParamLgl NA NA 2 FALSE