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 theMiesOperator
object. 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
. IsNULL
if this class it not (known to be) in aDictionary
. Read-only.dict_shortaccess
(
character(1)
|NULL
)
Name ofDictionary
short-access function where an object of this class can be retrieved. IsNULL
if this class is not (known to be) in aDictionary
with a short-access function. Read-only.endomorphism
(
logical(1)
)
Whether the output of$operate()
is adata.frame
/data.table
in the same domain as its input. Read-only.primed_ps
(
ParamSet
|NULL
)
ParamSet
on which theMiesOperator
is primed. IsNULL
if it has not been primed. Writing to this acrive binding calls$prime()
.is_primed
(
logical(1)
)
Whether theMiesOperator
was primed before. IsFALSE
exactly when$primed_ps
isNULL
. 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_classes
field will reflect this value.param_set
(
ParamSet
|list
ofexpression
)
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
'sParamSet
directly. Otherwise it must be alist
of expressions e.g. created byalist()
that evaluate toParamSet
s, possibly referencingself
andprivate
. TheseParamSet
are then combined using aParamSetCollection
. Default is the emptyParamSet
.
The$param_set
field 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$packages
field 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 beNULL
if the operator is not entered in a dictionary.
The$dict_entry
field will reflect this value.dict_shortaccess
(
character(1)
|NULL
)
Name of theDictionary
short 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_shortaccess
field will reflect this value.own_param_set
(
language
)
An expression that evaluates to aParamSet
indicating 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_set
argument is not a list of expressions.endomorphism
(
logical(1)
)
Whether the private$.operate()
operation creates adata.table
with 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$endomorphsim
field 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 showParamSet
values. DefaultTRUE
.show_constructor_args
(
logical(1)
)
Whether to show construction args that are notParamSet
values. 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 theParamSet
given 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
deep
Whether to make a deep clone.
See Also
Other base classes:
Filtor
,
FiltorSurrogate
,
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
Scalor
,
Selector
,
SelectorScalar