ParamSet
ParamSet
A set of Param objects.
Please note that when creating a set or adding to it, the parameters of the
resulting set have to be uniquely named with IDs with valid R names.
The set also contains a member variable values
which can be used to store an active configuration / or to partially fix
some parameters to constant values (regarding subsequent sampling or generation of designs).
- Keywords
- datasets
Usage
ParamSet
Format
An object of class R6ClassGenerator
of length 24.
Construction
ParamSet$new(params = named_list())
params
:: namedlist()
List of Param, named with their respective ID. Parameters are cloned.
Fields
set_id
::character(1)
ID of this param set. Default""
. Settable.length
::integer(1)
Number of contained Params.is_empty
::logical(1)
Is theParamSet
empty?class
:: namedcharacter()
Classes of contained parameters, named with parameter IDs.lower
:: nameddouble()
Lower bounds of parameters (NA
if parameter is not numeric). Named with parameter IDs.upper
:: nameddouble()
Upper bounds of parameters (NA
if parameter is not numeric). Named with parameter IDs.levels
:: namedlist()
List of character vectors of allowed categorical values of contained parameters.NULL
if the parameter is not categorical. Named with parameter IDs.nlevels
:: namedinteger()
Number of categorical levels per parameter,Inf
for double parameters or unbounded integer parameters. Named with param IDs.is_bounded
:: namedlogical(1)
Do all parameters have finite bounds? Named with parameter IDs.special_vals
:: namedlist()
oflist()
Special values for all parameters. Named with parameter IDs.storage_type
::character()
Data types of parameters when stored in tables. Named with parameter IDs.tags
:: namedlist()
ofcharacter()
Can be used to group and subset parameters. Named with parameter IDs.default
:: namedlist()
Default values of all parameters. If no default exists, element is not present. Named with parameter IDs.is_number :: named
logical()
Position is TRUE for ParamDbl and ParamInt. Named with parameter IDs.is_categ :: named
logical
Position is TRUE for ParamFct and ParamLgl. Named with parameter IDs.has_deps
::logical(1)
Has the set parameter dependencies?deps
::data.table::data.table()
Table has colsid
(character(1)
) andon
(character(1)
) andcond
(Condition). Lists all (direct) dependency parents of a param, through parameter IDs. Internally created by a call toadd_dep
. Settable, if you want to remove dependencies or perform other changes.values
:: namedlist()
Currently set / fixed parameter values. Settable, and feasibility of values will be checked when you set them. You do not have to set values for all parameters, but only for a subset. When you set values, all previously set values will be unset / removed.trafo
::function(x, param_set)
Transformation function. Settable. User has to pass afunction(x, param_set)
, of the form (namedlist()
, ParamSet) -> namedlist()
. The function is responsible to transform a feasible configuration into another encoding, before potentially evaluating the configuration with the target algorithm. For the output, not many things have to hold. It needs to have unique names, and the target algorithm has to accept the configuration. For convenience, the self-paramset is also passed in, if you need some info from it (e.g. tags). Is NULL by default, and you can set it to NULL to switch the transformation off.has_trafo
::logical(1)
Has the set atrafo
function?
Public methods
ids(class = NULL, is_bounded = NULL, tags = NULL)
(character
,logical(1)
,character()
) ->character()
Retrieves IDs of contained parameters based on some filter criteria selections,NULL
means no restriction.get_values(class = NULL, is_bounded = NULL, tags = NULL)
(character()
,logical(1)
,character()
) -> namedlist()
Retrieves parameter values based on some selections,NULL
means no restriction and is equivalent to$values
.add(param_set)
(Param | ParamSet) ->self
Adds a single param or another set to this set, all params are cloned.subset(ids)
character()
->self
Changes the current set to the set of passed IDs.test(x)
,check(x)
,assert(x)
Three checkmate-like check-functions. Takes a named list. A point x is feasible, if it configures a subset of params, all individual param constraints are satisfied and all dependencies are satisfied. Params for which dependencies are not satisfied should not be part ofx
.add_dep(id, on, cond)
(character(1)
,character(1)
, Condition) ->self
Adds a dependency to this set, so that paramid
now depends on paramon
.
S3 methods and type converters
as.data.table()
Compact representation as datatable. Col types are:id: character
lower, upper: double
levels: list col, with NULL elements
special_vals: list col of list
is_bounded: logical
default: list col, with NULL elements
storage_type: character
tags: list col of character vectors
Examples
# NOT RUN {
ps = ParamSet$new(
params = list(
ParamDbl$new("d", lower = -5, upper = 5, default = 0),
ParamFct$new("f", levels = letters[1:3])
)
)
ps$trafo = function(x, param_set) {
x$d = 2^d
return(x)
}
ps$add(ParamInt$new("i", lower = 0L, upper = 16L))
ps$check(list(d = 2.1, f = "a", i = 3L))
# }