| MiesOperator {miesmuschel} | R Documentation |
Operator Base Class
Description
Base class representing MIES-operators: Recombinator, Mutator, and Selector.
Operators perform a specific function within ES algorithms, and by exchanging them, the character of ES
algorithms can be modified. Operators operate on collections of individuals and return
modified individuals (mutated or recombined) or indices of selected individuals. Operators can be combined using
MutatorCombination / RecombinatorCombination and other operators wrappers.
Before applying operators, they have to be primed for the domain of the individuals which they are operating on;
this is done using the $prime() function. Afterwards, the $operate() function may be called with a data.frame
of individuals that fall into this domain. $operate() may be called multiple times after priming, and a once
primed operator can be primed again for a different domain by calling $prime() agian (which forgets the old priming).
Inheriting
MiesOperator is an abstract base class and should be inherited from. Inheriting classes should implement the
private $.operate() function. The user of the object calls $operate(), and the arguments are passed on to
private $.operate() after checking that the operator is primed, and that the values argument conforms to the
primed domain. Typically, the $initialize() and $prime() functions are also overloaded, but should call their
super equivalents.
In most cases, the MiesOperator class should not be inherited from, directly; instead, the operator classes
(Recombinator, Mutator, Selector) or their subclasses should be inherited.
Active bindings
param_set(
ParamSet)
Configuration parameters of theMiesOperatorobject. Read-only.param_classes(
character)
Classes of parameters that the operator can handle, contains any of"ParamLgl","ParamInt","ParamDbl","ParamFct". Read-only.packages(
character)
Packages needed for the operator. Read-only.dict_entry(
character(1)|NULL)
Key of this class in its respectiveDictionary. IsNULLif this class it not (known to be) in aDictionary. Read-only.dict_shortaccess(
character(1)|NULL)
Name ofDictionaryshort-access function where an object of this class can be retrieved. IsNULLif this class is not (known to be) in aDictionarywith a short-access function. Read-only.endomorphism(
logical(1))
Whether the output of$operate()is adata.frame/data.tablein the same domain as its input. Read-only.primed_ps(
ParamSet|NULL)
ParamSeton which theMiesOperatoris primed. IsNULLif it has not been primed. Writing to this acrive binding calls$prime().is_primed(
logical(1))
Whether theMiesOperatorwas primed before. IsFALSEexactly when$primed_psisNULL. Read-only.man(
character(1))
Name of this class, in the form<package>::<classname>. Used by the$help()method.
Methods
Public methods
Method new()
Initialize base class components of the MiesOperator.
Usage
MiesOperator$new(
param_classes = c("ParamLgl", "ParamInt", "ParamDbl", "ParamFct"),
param_set = ps(),
packages = character(0),
dict_entry = NULL,
dict_shortaccess = NULL,
own_param_set = quote(self$param_set),
endomorphism = TRUE
)Arguments
param_classes(
character)
Classes of parameters that the operator can handle. May contain any of"ParamLgl","ParamInt","ParamDbl","ParamFct". Default is all of them.
The$param_classesfield will reflect this value.param_set(
ParamSet|listofexpression)
Strategy parameters of the operator. This should be created by the subclass and given tosuper$initialize(). If this is aParamSet, it is used as theMiesOperator'sParamSetdirectly. Otherwise it must be alistof expressions e.g. created byalist()that evaluate toParamSets, possibly referencingselfandprivate. TheseParamSetare then combined using aParamSetCollection. Default is the emptyParamSet.
The$param_setfield will reflect this value.packages(
character) Packages that need to be loaded for the operator to function. This should be declared so these packages can be loaded when operators run on parallel instances. Default ischaracter(0).
The$packagesfield will reflect this values.dict_entry(
character(1)|NULL)
Key of the class inside theDictionary(usually one ofdict_mutators,dict_recombinators,dict_selectors), where it can be retrieved using a short access function. May beNULLif the operator is not entered in a dictionary.
The$dict_entryfield will reflect this value.dict_shortaccess(
character(1)|NULL)
Name of theDictionaryshort access function in which the operator is registered. This is used to inform the user about how to construct a given object. Should ordinarily be one of"mut","rec","sel".
The$dict_shortaccessfield will reflect this value.own_param_set(
language)
An expression that evaluates to aParamSetindicating the configuration parameters that are entirely owned by this operator class (and not proxied from a construction argument object). This should bequote(self$param_set)(the default) when theparam_setargument is not a list of expressions.endomorphism(
logical(1))
Whether the private$.operate()operation creates adata.tablewith the same columns as the input (i.e. conforming to the primedParamSet). If this isTRUE(default), then the return value of$.operate()is checked for this and columns are put in the correct order.
The$endomorphsimfield will reflect this value.
Method repr()
Create a call object representing this operator.
Usage
MiesOperator$repr( skip_defaults = TRUE, show_params = TRUE, show_constructor_args = TRUE, ... )
Arguments
skip_defaults(
logical(1))
Whether to skip construction arguments that have their default value. DefaultTRUE.show_params(
logical(1))
Whether to showParamSetvalues. DefaultTRUE.show_constructor_args(
logical(1))
Whether to show construction args that are notParamSetvalues. DefaultTRUE....(any)
Ignored.
Method print()
Print this operator.
Usage
MiesOperator$print(verbose = FALSE, ...)
Arguments
verbose(
logical(1))
Whether to show all construction arguments, even the ones at default values. DefaultFALSE....(any)
Ignored.
Method prime()
Prepare the MiesOperator to function on the given ParamSet. This must be called before
$operate(). It may be called multiple times in the lifecycle of the MiesOperator object, and prior primings are
forgotten when priming on a new ParamSet. The ParamSet on which
the MiesOperator was last primed can be read from $primed_ps.
Usage
MiesOperator$prime(param_set)
Arguments
Returns
invisible self.
Method operate()
Operate on the given individuals. This calls private $.operate(), which must be overloaded by an inheriting class,
passing through all function arguments after performing some checks.
Usage
MiesOperator$operate(values, ...)
Arguments
values(
data.frame)
Individuals to operate on. Must pass the check of theParamSetgiven in the last$prime()call and may not have any missing components....(any)
Depending on the concrete class, passed on to$.operate().
Returns
data.frame: the result of the operation. If the input was a data.table instead of
a data.frame, the output is also data.table.
Method help()
Run utils::help() for this object.
Usage
MiesOperator$help(help_type = getOption("help_type"))Arguments
help_type(
character(1))
One of"text","html", or"pdf": The type of help page to open. Defaults to the"help_type"option.
Returns
help_files_with_dopic object, which opens the help page.
Method clone()
The objects of this class are cloneable with this method.
Usage
MiesOperator$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other base classes:
Filtor,
FiltorSurrogate,
Mutator,
MutatorDiscrete,
MutatorNumeric,
OperatorCombination,
Recombinator,
RecombinatorPair,
Scalor,
Selector,
SelectorScalar