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).
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.
Other base classes:
Filtor
,
FiltorSurrogate
,
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
Scalor
,
Selector
,
SelectorScalar
param_set
(ParamSet
)
Configuration parameters of the MiesOperator
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 respective Dictionary
.
Is NULL
if this class it not (known to be) in a Dictionary
. Read-only.
dict_shortaccess
(character(1)
| NULL
)
Name of Dictionary
short-access function where an object of this class can be retrieved.
Is NULL
if this class is not (known to be) in a Dictionary
with a short-access function. Read-only.
endomorphism
(logical(1)
)
Whether the output of $operate()
is a data.frame
/ data.table
in the same domain as its input. Read-only.
primed_ps
(ParamSet
| NULL
)ParamSet
on which the MiesOperator
is primed. Is NULL
if it has not been primed.
Writing to this acrive binding calls $prime()
.
is_primed
(logical(1)
)
Whether the MiesOperator
was primed before. Is FALSE
exactly when $primed_ps
is NULL
. Read-only.
man
(character(1)
)
Name of this class, in the form <package>::<classname>
. Used by the $help()
method.
new()
Initialize base class components of the MiesOperator
.
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
)
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
of expression
)
Strategy parameters of the operator. This should be created by the subclass and given to super$initialize()
.
If this is a ParamSet
, it is used as the MiesOperator
's ParamSet
directly. Otherwise it must be a list
of expressions e.g. created by alist()
that evaluate to ParamSet
s,
possibly referencing self
and private
.
These ParamSet
are then combined using a ParamSetCollection
.
Default is the empty ParamSet
.
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 is character(0)
.
The $packages
field will reflect this values.
dict_entry
(character(1)
| NULL
)
Key of the class inside the Dictionary
(usually one of
dict_mutators
, dict_recombinators
, dict_selectors
), where it can
be retrieved using a short access function. May be NULL
if the operator
is not entered in a dictionary.
The $dict_entry
field will reflect this value.
dict_shortaccess
(character(1)
| NULL
)
Name of the Dictionary
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 a ParamSet
indicating the configuration parameters that are entirely owned by
this operator class (and not proxied from a construction argument object). This should be quote(self$param_set)
(the default) when
the param_set
argument is not a list of expressions.
endomorphism
(logical(1)
)
Whether the private $.operate()
operation creates a data.table
with the same columns as the input
(i.e. conforming to the primed ParamSet
). If this is TRUE
(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.
repr()
Create a call
object representing this operator.
MiesOperator$repr(
skip_defaults = TRUE,
show_params = TRUE,
show_constructor_args = TRUE,
...
)
skip_defaults
(logical(1)
)
Whether to skip construction arguments that have their default value. Default TRUE
.
show_params
(logical(1)
)
Whether to show ParamSet
values. Default TRUE
.
show_constructor_args
(logical(1)
)
Whether to show construction args that are not ParamSet
values. Default TRUE
.
...
(any)
Ignored.
print()
Print this operator.
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
.
invisible self
.
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.
values
(data.frame
)
Individuals to operate on. Must pass the check of the Param
given in the last $prime()
call
and may not have any missing components.
...
(any)
Depending on the concrete class, passed on to $.operate()
.
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
.
help()
Run utils::help()
for this object.
MiesOperator$help(help_type = getOption("help_type"))