Title: | Mixed Integer Evolution Strategies |
Description: | Evolutionary black box optimization algorithms building on the 'bbotk' package. 'miesmuschel' offers both ready-to-use optimization algorithms, as well as their fundamental building blocks that can be used to manually construct specialized optimization loops. The Mixed Integer Evolution Strategies as described by Li et al. (2013) <doi:10.1162/EVCO_a_00059> can be implemented, as well as the multi-objective optimization algorithms NSGA-II by Deb, Pratap, Agarwal, and Meyarivan (2002) <doi:10.1109/4235.996017>. |
URL: | https://github.com/mlr-org/miesmuschel |
BugReports: | https://github.com/mlr-org/miesmuschel/issues |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
ByteCompile: | yes |
Version: | 0.0.4-3 |
Depends: | paradox (≥ 0.7.1) |
Imports: | mlr3misc (≥ 0.5.0), checkmate (≥ 1.9.0), R6, bbotk (≥ 0.3.0.900), data.table, matrixStats, lgr |
Suggests: | tinytest, mlr3tuning, mlr3, mlr3learners, ranger, xgboost, rpart |
RoxygenNote: | 7.3.2 |
Collate: | 'dictionaries.R' 'MiesOperator.R' 'Filtor.R' 'FiltorMaybe.R' 'FiltorNull.R' 'FiltorProxy.R' 'FiltorSurrogate.R' 'FiltorSurrogateProgressive.R' 'FiltorSurrogateTournament.R' 'Mutator.R' 'MutatorCmpMaybe.R' 'MutatorDiscreteUniform.R' 'MutatorErase.R' 'MutatorGauss.R' 'MutatorMaybe.R' 'MutatorNull.R' 'MutatorProxy.R' 'MutatorSequential.R' 'ParamSetShadow.R' 'OperatorCombination.R' 'Recombinator.R' 'Selector.R' 'mies_methods.R' 'OptimizerMies.R' 'RecombinatorCmpMaybe.R' 'RecombinatorConvex.R' 'RecombinatorConvexPair.R' 'RecombinatorCrossoverNary.R' 'RecombinatorCrossoverUniform.R' 'RecombinatorMaybe.R' 'RecombinatorNull.R' 'RecombinatorProxy.R' 'RecombinatorSequential.R' 'RecombinatorSimulatedBinaryCrossover.R' 'RecombinatorSwap.R' 'Scalor.R' 'ScalorAggregate.R' 'ScalorDomcount.R' 'ScalorFixedProjections.R' 'ScalorHypervolume.R' 'ScalorNondom.R' 'ScalorOne.R' 'ScalorProxy.R' 'ScalorSingleObjective.R' 'SelectorBest.R' 'SelectorMaybe.R' 'SelectorNull.R' 'SelectorProxy.R' 'SelectorRandom.R' 'SelectorSequential.R' 'SelectorTournament.R' 'TerminatorBudget.R' 'TerminatorGenerationPerfReached.R' 'TerminatorGenerationStagnation.R' 'TerminatorGenerations.R' 'TunerMies.R' 'bibentries.R' 'repr.R' 'utils.R' 'utils_mo.R' 'zzz.R' |
NeedsCompilation: | no |
Packaged: | 2025-03-19 17:34:09 UTC; user |
Author: | Martin Binder [aut, cre],
Lennart Schneider |
Maintainer: | Martin Binder <mlr.developer@mb706.com> |
Repository: | CRAN |
Date/Publication: | 2025-03-19 19:10:02 UTC |
miesmuschel: Mixed Integer Evolution Strategies
Description
miesmuschel
offers both an Optimizer
and a Tuner
for general
MIES-optimization, as well as all the building blocks for building a custom optimization algorithm that
is more flexible and can be used for research into novel evolution strategies.
The call-graph of the default algorithm in OptimizerMies
/ TunerMies
is as follows, and is shown
here as an overview over the mies_*
functions, and how they are usually connected. (Note that only the
exported mies_*
functions are shown.) See the help information of these functions for more info.
OptimizerMies$.optimize(inst) |- mies_prime_operators() # prime operators on instance's search_space |- mies_init_population() # sample and evaluate first generation | `- mies_evaluate_offspring() # evaluate sampled individuals | `- inst$eval_batch() # The OptimInst's evaluation method `- repeat # Repeat the following until terminated |- mies_step_fidelity() # Evaluate individuals with changing fidelity | `- inst$eval_batch() # The OptimInst's evaluation method |- mies_generate_offspring() # Sample parents, recombine, mutate | `- mies_select_from_archive() # Use 'Selector' on 'Archive' | `- mies_get_fitnesses() # Get objective values as fitness matrix |- mies_evaluate_offspring() # evaluate sampled individuals | `- inst$eval_batch() # The OptimInst's evaluation method `- mies_survival_plus() / mies_survival_comma() # survival `- mies_select_from_archive() # Use 'Selector' on 'Archive'
Author(s)
Maintainer: Martin Binder mlr.developer@mb706.com
Other contributors:
Lennart Schneider lennart.sch@web.de (ORCID) [contributor]
Susanne Dandl dandl.susanne@googlemail.com (ORCID) [contributor]
Andreas Hofheinz andreas.hofheinz@outlook.com [contributor]
See Also
Useful links:
Filtor Base Class
Description
Base class representing filter operations, inheriting from MiesOperator
.
A Filtor
gets a table of individuals that are to be filtered, as well as a table of individuals that were already evaluated,
along with information on the latter individuals' performance values. Furthermore, the
number of individuals to return is given. The Filtor
returns a vector of unique integers indicating which individuals were selected.
Filter operations are performed in ES algorithms to facilitate concentration towards individuals that likely perform well with regard to the fitness measure, without evaluating the fitness measure, for example through a surrogate model.
Fitness values are always maximized, both in single- and multi-criterion optimization.
Unlike most other operator types inheriting from MiesOperator
, the $operate()
function has four arguments, which are passed on to $.filter()
-
values
::data.frame
Individuals to filter. Must pass the check of theParamSet
given in the last$prime()
call and may not have any missing components. -
known_values
::data.frame
Individuals to use for filtering. Must pass the check of theParamSet
given in the last$prime()
call and may not have any missing components. Note thatknown_values
may be empty. -
fitnesses
::numeric
|matrix
Fitnesses for each individual given inknown_values
. If this is anumeric
, then its length must be equal to the number of rows invalues
. If this is amatrix
, if number of rows must be equal to the number of rows invalues
, and it must have one column when doing single-crit optimization and one column each for each "criterion" when doing multi-crit optimization. -
n_filter
::integer(1)
Number of individuals to select. SomeFiltor
s select individuals with replacement, for which this value may be greater than the number of rows invalues
.
The return value for an operation will be a numeric vector of integer values of ength n_filter
indexing the individuals that were selected. Filtor
must always return unique integers, i.e. select every individual at most once.
Inheriting
Filtor
is an abstract base class and should be inherited from. Inheriting classes should implement the private $.filter()
function. The user of the object calls $operate()
, and the arguments are passed on to private $.filter()
after checking that
the operator is primed, that the values
and known_values
arguments conforms to the primed domain and that other values match.
The private$.needed_input()
function should also be overloaded, it is called by the public $needed_input()
function after initial checks;
see the documentation there.
Typically, the $initialize()
function should also be overloaded, and optionally the $prime()
function; they should call their super
equivalents.
Super class
miesmuschel::MiesOperator
-> Filtor
Active bindings
supported
(
character
)
Optimization supported by thisFiltor
, can be"single-crit"
,"multi-crit"
, or both.
Methods
Public methods
Inherited methods
Method new()
Initialize base class components of the Filtor
.
Usage
Filtor$new( param_classes = c("ParamLgl", "ParamInt", "ParamDbl", "ParamFct"), param_set = ps(), supported = c("single-crit", "multi-crit"), packages = character(0), dict_entry = NULL, own_param_set = quote(self$param_set) )
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.supported
(
character
)
Subset of"single-crit"
and"multi-crit"
, indicating wether single and / or multi-criterion optimization is supported. Default both of them.
The$supported
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.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.
Method needed_input()
Calculate the number of values
that are required to
filter down to output_size
, given the current configuraiton parameter settings.
Usage
Filtor$needed_input(output_size)
Arguments
output_size
(
integer(1)
)
A positive integer indicating the number of individuals for which the needed input size should be calculated.
Returns
integer(1)
: The minimum number of rows required to filter down to output_size
. At least output_size
.
Method clone()
The objects of this class are cloneable with this method.
Usage
Filtor$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other base classes:
FiltorSurrogate
,
MiesOperator
,
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
Scalor
,
Selector
,
SelectorScalar
Other filtors:
FiltorSurrogate
,
dict_filtors_maybe
,
dict_filtors_null
,
dict_filtors_proxy
,
dict_filtors_surprog
,
dict_filtors_surtour
Abstract Surrogate Model Filtering Base Class
Description
Abstract base class for surrogate model filtering.
A surrogate model is a regression model, based on an mlr3::Learner
, which predicts the approximate performance of newly sampled configurations
given the empirical performance of already evaluated configurations. The surrogate model can be used to propose points that have, according to the
surrogate model, a relatively high chance of performing well.
The FiltorSurrogate
base class can be inherited from to create different Filtor
s that filter based on a surrogate model, for example tournament
filtering or progresive filtering.
Configuration Parameters
FiltorSurrogateProgressive
's configuration parameters are the hyperparameters of the surrogate_learner
Learner
, as well as
the configuration parameters of the surrogate_selector
Selector
.
Supported Operand Types
Supported Domain
classes depend on the supported feature types of the surrogate_learner
, as reported
by surrogate_learner$feature_types
: "ParamInt"
requires
"integer"
, "ParamDbl"
requires "numeric"
, "ParamLgl"
requires "logical"
, and "ParamFct"
requires "factor"
.
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Filtor
-> FiltorSurrogate
Active bindings
surrogate_learner
(
mlr3::LearnerRegr
)
Regression learner for the surrogate model filtering algorithm.surrogate_selector
(
Selector
)
Selector
with which to select using surrogate-predicted performance
Methods
Public methods
Inherited methods
Method new()
Initialize the base class components of the FiltorSurrogate
.
Usage
FiltorSurrogate$new( surrogate_learner, surrogate_selector = SelectorBest$new(), param_set = ps(), packages = character(0), dict_entry = NULL )
Arguments
surrogate_learner
(
mlr3::LearnerRegr
)
Regression learner for the surrogate model filtering algorithm.
The$surrogate_learner
field will reflect this value.surrogate_learner
(
mlr3::LearnerRegr
)
Regression learner for the surrogate model filtering algorithm.
The$surrogate_learner
field will reflect this value.surrogate_selector
(
Selector
)Selector
for the surrogate model filtering algorithm.
The$surrogate_selector
field will reflect this value.surrogate_selector
(
Selector
)Selector
for the surrogate model filtering algorithm.
The$surrogate_selector
field will reflect this value.param_set
(
ParamSet
)
ParamSet
of the method implemented in the inheriting class with configuration parameters that go beyond the parameters of thesurrogate_learner
andsurrogate_selector
.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.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_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.
Method prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operator
given to surrogate_selector
during construction.
Usage
FiltorSurrogate$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
FiltorSurrogate$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other base classes:
Filtor
,
MiesOperator
,
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
Scalor
,
Selector
,
SelectorScalar
Other filtors:
Filtor
,
dict_filtors_maybe
,
dict_filtors_null
,
dict_filtors_proxy
,
dict_filtors_surprog
,
dict_filtors_surtour
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
Mutator Base Class
Description
Base class representing mutation operations, inheriting from MiesOperator
.
Mutations get a table of individuals as input and return a table of modified individuals as output. Individuals are acted on as individuals: every line of output corresponds to the same line of input, and presence or absence of other input lines does not affect the result.
Mutation operations are performed in ES algorithms to facilitate exploration of the search space around individuals.
Inheriting
Mutator
is an abstract base class and should be inherited from. Inheriting classes should implement the private $.mutate()
function. The user of the object calls $operate()
, and the arguments are passed on to private $.mutate()
after checking that
the operator is primed, and that the values
argument conforms to the primed domain. Typically, the $initialize()
function
should also be overloaded, and optionally the $prime()
function; they should call their super
equivalents.
In many cases, it is advisable to inherit from one of the abstract subclasses, such as MutatorNumeric
, or MutatorDiscrete
.
Super class
miesmuschel::MiesOperator
-> Mutator
Methods
Public methods
Inherited methods
Method new()
Initialize base class components of the Mutator
.
Usage
Mutator$new( param_classes = c("ParamLgl", "ParamInt", "ParamDbl", "ParamFct"), param_set = ps(), packages = character(0), dict_entry = NULL, own_param_set = quote(self$param_set) )
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.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.
Method clone()
The objects of this class are cloneable with this method.
Usage
Mutator$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other base classes:
Filtor
,
FiltorSurrogate
,
MiesOperator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
Scalor
,
Selector
,
SelectorScalar
Other mutators:
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
dict_mutators_cmpmaybe
,
dict_mutators_erase
,
dict_mutators_gauss
,
dict_mutators_maybe
,
dict_mutators_null
,
dict_mutators_proxy
,
dict_mutators_sequential
,
dict_mutators_unif
Discrete Mutator Base Class
Description
Base class for mutation operations on discrete individuals, inheriting from Mutator
.
MutatorDiscrete
operators perform mutation on discrete (logical and factor valued) individuals. Inheriting
operators implement the private $.mutate_discrete()
function that is called once for each individual
and is given a character vector.
Inheriting
MutatorDiscrete
is an abstract base class and should be inherited from. Inheriting classes should implement the private $.mutate_discrete()
function. During $operate()
, the $.mutate_discrete()
function is called once for each individual, with the parameters values
(the
individual as a single character
vector), and levels
(a list of character
containing the possible values for each element of values
). Typically,
$initialize()
should also be overloaded.
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Mutator
-> MutatorDiscrete
Methods
Public methods
Inherited methods
Method new()
Initialize base class components of the MutatorNumeric
.
Usage
MutatorDiscrete$new( param_classes = c("ParamLgl", "ParamFct"), param_set = ps(), packages = character(0), dict_entry = NULL, own_param_set = quote(self$param_set) )
Arguments
param_classes
(
character
)
Classes of parameters that the operator can handle. May contain any of"ParamLgl"
,"ParamFct"
. Default is both 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.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.
Method clone()
The objects of this class are cloneable with this method.
Usage
MutatorDiscrete$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other base classes:
Filtor
,
FiltorSurrogate
,
MiesOperator
,
Mutator
,
MutatorNumeric
,
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
Scalor
,
Selector
,
SelectorScalar
Other mutators:
Mutator
,
MutatorNumeric
,
OperatorCombination
,
dict_mutators_cmpmaybe
,
dict_mutators_erase
,
dict_mutators_gauss
,
dict_mutators_maybe
,
dict_mutators_null
,
dict_mutators_proxy
,
dict_mutators_sequential
,
dict_mutators_unif
Numeric Mutator Base Class
Description
Base class for mutation operations on numeric and integer valued individuals, inheriting from Mutator
.
MutatorNumeric
operators perform mutation on numeric (integer and real valued) individuals. Inheriting
operators implement the private $.mutate_numeric()
function that is called once for each individual
and is given a numeric vector.
Inheriting
MutatorNumeric
is an abstract base class and should be inherited from. Inheriting classes should implement the private $.mutate_numeric()
function. During $operate()
, the $.mutate_numeric()
function is called once for each individual, with the parameters values
(the
individual as a single numeric
vector), lowers
and uppers
(numeric
vectors, the lower and upper bounds for each component of values
). Typically,
$initialize()
should also be overloaded.
MutatorNumeric
s that perform real-valued operations, such as e.g. MutatorGauss
, operate on integers by widening the lower and upper bounds
of integer components by 0.5, applying their operation, and rounding resulting values to the nearest integer (while always staying inside bounds).
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Mutator
-> MutatorNumeric
Methods
Public methods
Inherited methods
Method new()
Initialize base class components of the MutatorNumeric
.
Usage
MutatorNumeric$new( param_classes = c("ParamInt", "ParamDbl"), param_set = ps(), packages = character(0), dict_entry = NULL, own_param_set = quote(self$param_set) )
Arguments
param_classes
(
character
)
Classes of parameters that the operator can handle. May contain any of"ParamInt"
,"ParamDbl"
. Default is both 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.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.
Method clone()
The objects of this class are cloneable with this method.
Usage
MutatorNumeric$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other base classes:
Filtor
,
FiltorSurrogate
,
MiesOperator
,
Mutator
,
MutatorDiscrete
,
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
Scalor
,
Selector
,
SelectorScalar
Other mutators:
Mutator
,
MutatorDiscrete
,
OperatorCombination
,
dict_mutators_cmpmaybe
,
dict_mutators_erase
,
dict_mutators_gauss
,
dict_mutators_maybe
,
dict_mutators_null
,
dict_mutators_proxy
,
dict_mutators_sequential
,
dict_mutators_unif
Self-Adaptive Operator Combinations
Description
Combines multiple operators and makes operator-configuration parameters self-adaptive.
The OperatorCombination
operators combine operators for different subspaces of individuals by wraping other MiesOperator
s given during construction.
Different MiesOperator
s are assigned to different components or sets of components and operate on them independently of the rest of the components
or the other operators. An operator can be assigned to a single component by giving it in operators
with the name of the component, or to multiple components by
giving it in operators
with the name of a group. Groups are created by the groups
argument, but several default groups that catch components by type
exist.
Details
Operators can be made self-adaptive by coupling their configuration parameter values to values in individuals. This is done by giving functions in adaptions
; these
functions are executed for each individual before an operator is applied, and the result given to a named operator configuration parameter.
OperatorCombination
is the base class from which MutatorCombination
and RecombinatorCombination
inherit. The latter two are to be used for Mutator
and
Recombinator
objects, respectively.
Besides groups created with the groups
construction argument, there are special groups that all unnamed operators fall into based on their Domain
class: "ParamInt"
, "ParamDbl"
, "ParamFct"
, and "ParamLgl"
. A component of an individual that is not named directly in operators
or made part of a group
in groups
is automatically in one of these special groups. There is furthermore a special catch-all group "ParamAny"
, which catches all components that are
are not operated directly, not in a group, and not in another special group that is itself named directly or in a group. I.e., all components that would otherwise
have no assigned operation.
RecombinatorCombination
can only combine operators where $n_indivs_in
and $n_indivs_out
can be combined. This is
currently supported either when $n_indivs_in
and $n_indivs_out
for each operator are the same (but $n_indivs_in
may be unequal $n_indivs_out
in
eacho of them); or when $n_indivs_in
is equal to $n_indivs_out
for each operator and the set of all $n_indivs_in
that occur contains 1
and one more integer.
$n_indivs_in
and $n_indivs_out
for the resulting RecombinatorCombination
operator will be set the maximum of occuring $n_indivs_in
and $n_indivs_out
,
respectively.
Supported Operand Types
Supported Domain
classes are calculated based on the supported classes of the wrapped operators.
They are frequently just the set union of supported classes, unless inference can be drawn from type-specific groups that an operator is assigned to.
If e.g. an operator that supports p_dbl
and p_int
is assigned to group "ParamInt"
, and
an operator that supports p_lgl
is assigned to component "a"
, then the result will support p_lgl
and
p_int
only.
Configuration Parameters
The OperatorCombination
has the configuration parameters of all encapsulated MiesOperator
s, minus the configuration parameters that are named in the adaptions
.
Configuration parameter names are prefixed with the name of the MiesOperator
in the operators
list.
Dictionary
This Mutator
can be created with the short access form mut()
(muts()
to get a list), or through the the dictionary
dict_mutators
in the following way:
# preferred: mut("combine", <operators>, ...) muts("combine", <operators>, ...) # takes vector IDs, returns list of Mutators # long form: dict_mutators$get("combine", <operators>, ...)
This Recombinator
can be created with the short access form rec()
(recs()
to get a list), or through the the dictionary
dict_recombinators
in the following way:
# preferred: rec("combine", <operators>, ...) recs("combine", <operators>, ...) # takes vector IDs, returns list of Recombinators # long form: dict_recombinators$get("combine", <operators>, ...)
Super class
miesmuschel::MiesOperator
-> OperatorCombination
Active bindings
operators
(named
list
ofMiesOperator
)
List of operators to apply to components of individuals, as set during construction. Read-only.groups
(named
list
ofcharacter
)
List of groups that operators can act on, as set during construction. Read-only.adaptions
(named
list
offunction
)
List of functions used for self-adaption of operators, as set during construction. Read-only.binary_fct_as_logical
(
logical(1)
)
Whether to treat binaryp_fct
components ofParamSet
s asp_lgl
with respect to the special groups"ParamLgl"
and"ParamFct"
, as set during construction. Read-only.on_type_not_present
(
character(1)
)
Action to perform during$prime()
when an operator is assigned to a type special group but there is no component available that falls in this group. See the construction argument. Can be changed during the object's lifetime.on_name_not_present
(
character(1)
)
Action to perform during$prime()
when an operator is assigned to a specifically named component, but the component is not present. See the construction argument. Can be changed during the object's lifetime.
Methods
Public methods
Inherited methods
Method new()
Initialize the OperatorCombination
object.
Usage
OperatorCombination$new( operators, groups = list(), adaptions = list(), binary_fct_as_logical = FALSE, on_type_not_present = "warn", on_name_not_present = "stop", granularity = 1, dict_entry = NULL, dict_shortaccess = NULL )
Arguments
operators
(named
list
ofMiesOperator
)
List of operators to apply to components of individuals. Names are either names of individual components, or group names which are either as defined throughgroups
or special groups. Individual components can only be member of either a (non-special) group or named inoperators
, so a name that occurs inoperators
may not be a member of a group as defined ingroups
.
The$operators
field will reflect this value.groups
(named
list
ofcharacter
)
List of groups that operators can act on. Names of this list define new groups. The content of each list element contains the names of components or special groups (aDomain
subclass name or"ParamAny"
) to subsume under the group. Individual components can only be member of either a (non-special) group or named inoperators
, so a name that occurs inoperators
may not be a member of a group as defined ingroups
. The default is the empty list.
The$groups
field will reflect this value.adaptions
(named
list
offunction
)
List of functions used for self-adaption of operators. The names of the list must be names of configuration parameters of wrapped operators, prefixed with the corresponding name in theoperators
list. This is the same name as the configuration parameter would otherwise have if exposed by theOperatorCombination
object. The values in the list must be functions that receive a single input, the individual or individuals being operated on, as adata.table
. It must return a value that is then assigned to the configuration parameter of the operator to which it pertains. Note thatMutatorCombination
adaption functions are always called with adata.table
containing a single row, whileRecombinatorCombination
adaption functions are called withdata.table
s with multiple rows according to$n_indivs_in
. In both cases, the return value must be a scalar. The default is the empty list.
The$adaption
field will reflect this value.binary_fct_as_logical
(
logical(1)
)
Whether to treat binaryp_fct
components ofParamSet
s asp_lgl
with respect to the special groups"ParamLgl"
and"ParamFct"
. This does not perform any conversion, so aMiesOperator
assigned to the"ParamLgl"
special group whenbinary_fct_as_logical
isTRUE
and there are binaryp_fct
s present will receive a factorial value and must also supportp_fct
in this case. This is checked during$prime()
, but not during construction. Default isFALSE
.
The$binary_fct_as_logical
field will reflect this value.on_type_not_present
(
character(1)
)
Action to perform during$prime()
when an operator is assigned to a type special group but there is no component available that falls in this group, either because no components of the respective type are present, or because all these components are also directly named inoperators
or ingroups
. One of"quiet"
(do nothing),"warn"
(give warning, default), or"stop"
(generate an error).
The writable$on_type_not_present
field will reflect this value.on_name_not_present
(
character(1)
)
Action to perform during$prime()
when an operator is assigned to a specifically named component, but the component is not present. One of"quiet"
(do nothing),"warn"
(give warning), or"stop"
(generate an error, default).
The writable$on_name_not_present
field will reflect this value.granularity
(
integer(1)
)
At what granularity to queryadaptions
for sets of individuals. Functions inadaptions
are always called once pergranularity
individuals in inputvalues
, and the function argument in these calls will then havegranularity
number of rows. This is used internally, it is set to 1 forMutatorCombination
, and to$n_indivs_in
forRecombinatorCombination
.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.
Method prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operators
given to operators
during construction. Priming of wrapped operators happens according
to component assignments to wrapped operators.
Usage
OperatorCombination$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
OperatorCombination$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Super classes
miesmuschel::MiesOperator
-> miesmuschel::OperatorCombination
-> MutatorCombination
Methods
Public methods
Inherited methods
Method new()
Initialize the MutatorCombination
object.
Usage
MutatorCombination$new( operators = list(), groups = list(), adaptions = list(), binary_fct_as_logical = FALSE, on_type_not_present = "warn", on_name_not_present = "stop" )
Arguments
operators
see above.
groups
see above.
adaptions
see above.
binary_fct_as_logical
see above.
on_type_not_present
see above.
on_name_not_present
see above.
Method clone()
The objects of this class are cloneable with this method.
Usage
MutatorCombination$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Super classes
miesmuschel::MiesOperator
-> miesmuschel::OperatorCombination
-> RecombinatorCombination
Active bindings
n_indivs_in
(
integer(1)
)
Number of individuals to consider at the same time. When operating, the number of input individuals must be divisible by this number.n_indivs_out
(
integer(1)
)
Number of individuals produced for each group of$n_indivs_in
individuals.
Methods
Public methods
Inherited methods
Method new()
Initialize the RecombinatorCombination
object.
Usage
RecombinatorCombination$new( operators = list(), groups = list(), adaptions = list(), binary_fct_as_logical = FALSE, on_type_not_present = "warn", on_name_not_present = "stop" )
Arguments
operators
see above.
groups
see above.
adaptions
see above.
binary_fct_as_logical
see above.
on_type_not_present
see above.
on_name_not_present
see above.
Method clone()
The objects of this class are cloneable with this method.
Usage
RecombinatorCombination$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other base classes:
Filtor
,
FiltorSurrogate
,
MiesOperator
,
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
Recombinator
,
RecombinatorPair
,
Scalor
,
Selector
,
SelectorScalar
Other mutators:
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
dict_mutators_cmpmaybe
,
dict_mutators_erase
,
dict_mutators_gauss
,
dict_mutators_maybe
,
dict_mutators_null
,
dict_mutators_proxy
,
dict_mutators_sequential
,
dict_mutators_unif
Other mutator wrappers:
dict_mutators_cmpmaybe
,
dict_mutators_maybe
,
dict_mutators_proxy
,
dict_mutators_sequential
Other recombinators:
Recombinator
,
RecombinatorPair
,
dict_recombinators_cmpmaybe
,
dict_recombinators_convex
,
dict_recombinators_cvxpair
,
dict_recombinators_maybe
,
dict_recombinators_null
,
dict_recombinators_proxy
,
dict_recombinators_sbx
,
dict_recombinators_sequential
,
dict_recombinators_swap
,
dict_recombinators_xonary
,
dict_recombinators_xounif
Other recombinator wrappers:
dict_recombinators_cmpmaybe
,
dict_recombinators_maybe
,
dict_recombinators_proxy
,
dict_recombinators_sequential
Examples
set.seed(1)
data = data.frame(x = 0, y = 0, a = TRUE, b = "a",
stringsAsFactors = FALSE) # necessary for R <= 3.6
p = ps(x = p_dbl(-1, 1), y = p_dbl(-1, 1), a = p_lgl(), b = p_fct(c("a", "b")))
# Demo operators:
m0 = mut("null") # no mutation
msmall = mut("gauss", sdev = 0.1) # mutates to small value around 0
mbig = mut("gauss", sdev = 100) # likely mutates to +1 or -1
mflip = mut("unif", can_mutate_to_same = FALSE) # flips TRUE/"a" to FALSE/"b"
# original:
data
# operators by name
op = mut("combine", operators = list(x = msmall, y = mbig, a = m0, b = mflip))
op$prime(p)
op$operate(data)
# operators by type
op = mut("combine",
operators = list(ParamDbl = msmall, ParamLgl = m0, ParamFct = mflip)
)
op$prime(p)
op$operate(data)
# the binary ParamFct 'b' counts as 'ParamLgl' when
# 'binary_fct_as_logical' is set to 'TRUE'.
op = mut("combine",
operators = list(ParamDbl = msmall, ParamLgl = m0),
binary_fct_as_logical = TRUE
)
op$prime(p)
op$operate(data)
# operators by type; groups can be mixed types
op = mut("combine",
operators = list(group1 = m0, group2 = msmall, group3 = mflip),
groups = list(group1 = c("a", "x"), group2 = "y", group3 = "b")
)
op$prime(p)
op$operate(data)
# Special type-groups can be used inside groups.
op = mut("combine",
operators = list(group1 = m0, b = mflip),
groups = list(group1 = c("ParamDbl", "a"))
)
op$prime(p)
op$operate(data)
# Type-groups only capture all parameters that were not caught by name.
# The special 'ParamAny' group captures all that is left.
op = mut("combine",
operators = list(ParamAny = m0, ParamDbl = msmall, x = mbig)
)
op$prime(p)
op$operate(data)
# Configuration parameters are named by names in the 'operators' list.
op$param_set
###
# Self-adaption:
# In this example, the 'ParamDbl''s operation is changed depending on the
# value of 'b'.
op = mut("combine",
operators = list(ParamAny = m0, ParamLgl = mflip, ParamDbl = msmall),
adaptions = list(ParamDbl.sdev = function(x) if (x$a) 100 else 0.1)
)
op$prime(p)
data2 = data[c(1, 1, 1, 1), ]
data2$a = c(TRUE, TRUE, FALSE, FALSE)
data2
# Note the value of x$a gets used line-wise, and that it is used *before*
# being flipped here. So the first two lines get large mutations, even though
# they have 'a' 'FALSE' after the operation.
op$operate(data2)
OptimInstanceMultiCrit Class
Description
bbotk
's OptimInstanceMultiCrit
class.
Re-exported since bbotk
will change the name.
Super classes
bbotk::OptimInstance
-> bbotk::OptimInstanceBatch
-> bbotk::OptimInstanceBatchMultiCrit
-> OptimInstanceMultiCrit
Methods
Public methods
Inherited methods
Method clone()
The objects of this class are cloneable with this method.
Usage
OptimInstanceMultiCrit$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
OptimInstanceSingleCrit Class
Description
bbotk
's OptimInstanceSingleCrit
class.
Re-exported since bbotk
will change the name.
Super classes
bbotk::OptimInstance
-> bbotk::OptimInstanceBatch
-> bbotk::OptimInstanceBatchSingleCrit
-> OptimInstanceSingleCrit
Methods
Public methods
Inherited methods
Method clone()
The objects of this class are cloneable with this method.
Usage
OptimInstanceSingleCrit$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Optimizer Class
Description
bbotk
's Optimizer
class.
Re-exported since bbotk
will change the name.
Super classes
bbotk::Optimizer
-> bbotk::OptimizerBatch
-> Optimizer
Methods
Public methods
Inherited methods
Method clone()
The objects of this class are cloneable with this method.
Usage
Optimizer$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Mixed Integer Evolution Strategies Optimizer
Description
Perform optimization using evolution strategies. OptimizerMies
and TunerMies
implement a standard ES optimization
algorithm, performing initialization first, followed by a loop of performance evaluation, survival selection, parent selection, mutation, and
recombination to generate new individuals to be evaluated. Currently, two different survival modes ("comma" and "plus") are supported.
Multi-fidelity optimization, similar to the "rolling-tide" algorithm described in Fieldsend (2014), is supported.
The modular design and reliance on MiesOperator
objects to perform central parts of the optimization algorithm makes this
Optimizer
highly flexible and configurable. In combination with OperatorCombination
mutators and recombinators, an algorithm
as presented in Li (2013) can easily be implemented.
OptimizerMies
implements a standard evolution strategies loop:
Prime operators, using
mies_prime_operators()
Initialize and evaluate population, using
mies_init_population()
Generate offspring by selecting parents, recombining and mutating them, using
mies_generate_offspring()
Evaluate performance, using
mies_evaluate_offspring()
Select survivors, using either
mies_survival_plus()
ormies_survival_comma()
, depending on thesurvival_strategy
configuration parameterOptionally, evaluate survivors with higher fidelity if the multi-fidelity functionality is being used
Jump to 3.
Terminating
As with all optimizers, Terminator
s are used to end optimization after a specific number of evaluations were performed,
time elapsed, or other conditions are satisfied. Of particular interest is TerminatorGenerations
, which terminates after a number
of generations were evaluated in OptimizerMies
. The initial population counts as generation 1, its offspring as generation 2 etc.;
fidelity refinements (step 6. in the algorithm description above) are always included in their generation, TerminatorGenerations
avoids terminating right before they are evaluated. Other terminators may, however, end the optimization process at any time.
Multi-Fidelity
miesmuschel
provides a simple multi-fidelity optimization mechanism that allows both the refinement of fidelity as the optimization progresses,
as well as fidelity refinement within each generation. When multi_fidelity
is TRUE
, then one search space component of the
OptimInstance
must have the "budget"
tag, which is then optimized as the "budget" component. This means that the value of this component is
determined by the fidelity
/fidelity_offspring
parameters, which are functions that get called whenever individuals get evaluated.
The fidelity
function is evaluated before step 2 and before every occurrence of step 6 in the algorithm, it returns the value of the budget search space component that all individuals
that survive the current generation should be evaluated with. fidelity_offspring
is called before step 4 and determines the fidelity that newly
sampled offspring individuals should be evaluated with; it may be desirable to set this to a lower value than fidelity
to save budget when
preliminarily evaluating newly sampled individuals that may or may not perform well compared to already sampled individuals.
Individuals that survive the generation and are not removed in step 5 will be re-evaluated with the fidelity
-value in step 6 before the next loop
iteration.
fidelity
and fidelity_offspring
must have arguments inst
, budget_id
, last_fidelity
and last_fidelity_offspring
. inst
is the
OptimInstance
bein optimized, the functions can use it to determine the progress of the optimization, e.g. query
the current generation with mies_generation
. budget_id
identifies the search space component being used as budget parameter. last_fidelity
and last_fidelity_offspring
contain the last values given by fidelity
/ fidelity_offspring
. Should the offspring-fidelity (as returned
by fidelity_offspring
always be the same as the parent generation fidelity (as returned by fidelity
), for example, then fidelity_offspring
can be set to a function that just returns last_fidelity
; this is actually the behaviour that fidelity_offspring
is initialized with.
OptimizerMies
avoids re-evaluating individuals if the fidelity parameter does not change. This means that setting fidelity
and fidelity_offspring
to the same value avoids re-evaluating individuals in step 6. When fidelity_monotonic
is TRUE
, re-evaluation is also avoided should the
desired fidelity parameter value decrease. When fidelity_current_gen_only
is TRUE
, then step 6 only re-evaluates individuals that were
created in the current generation (in the previous step 4) and sets the fidelity for individuals that are created in step 6, but it does not
re-evaluate individuals that survived from earlier generations or were already in the OptimInstance
when
optimization started; it is recommended to leave this value at TRUE
which it is initialized with.
Additional Components
The search space over which the optimization is performed is fundamentally tied to the Objective
, and therefore
to the OptimInstance
given to OptimizerMies$optimize()
. However, some advanced Evolution Strategy based
algorithms may need to make use of additional search space components that are independent of the particular objective. An example is
self-adaption as implemented in OperatorCombination
, where one or several components can be used to adjust operator behaviour.
These additional components are supplied to the optimizer through the additional_component_sampler
configuration parameter, which takes
a Sampler
object. This object both has an associated ParamSet
which represents the
additional components that are present, and it provides a method for generating the initial values of these components. The search space
that is seen by the MiesOperator
s is then the union of the OptimInstance
's ParamSet
, and the
Sampler
's ParamSet
.
Configuration Parameters
OptimizerMies
has the configuration parameters of the mutator
, recombinator
, parent_selector
, survival_selector
, init_selector
, and, if given,
elite_selector
operator given during construction, and prefixed according to the name of the argument (mutator
's configuration parameters
are prefixed "mutator."
etc.). When using the construction arguments' default values, they are all "proxy" operators: MutatorProxy
,
RecombinatorProxy
and SelectorProxy
. This means that the respective configuration parameters become mutator.operation
, recombinator.operation
etc.,
so the operators themselves can be set via configuration parameters in this case.
Further configuration parameters are:
-
lambda
::integer(1)
Offspring size: Number of individuals that are created and evaluated anew for each generation. This is equivalent to thelambda
parameter ofmies_generate_offspring()
, see there for more information. Must be set by the user. -
mu
::integer(1)
Population size: Number of individuals that are sampled in the beginning, and which are selected with each survival step. This is equivalent to themu
parameter ofmies_init_population()
, see there for more information. Must be set by the user. -
survival_strategy
::character(1)
May be"plus"
, or, if theelite_selector
construction argument is notNULL
,"comma"
: Choose whethermies_survival_plus()
ormies_survival_comma()
is used for survival selection. Initialized to"plus"
. -
n_elite
::integer(1)
Only if theelite_selector
construction argument is notNULL
, and only valid whensurvival_strategy
is"comma"
: Number of elites, i.e. individuals from the parent generation, to keep during "Comma" survival. This is equivalent to then_elite
parameter ofmies_survival_comma()
, see there for more information. -
initializer
::function
Function that generates the initial population as aDesign
object, with argumentsparam_set
andn
, functioning likeparadox::generate_design_random
orparadox::generate_design_lhs
. This is equivalent to theinitializer
parameter ofmies_init_population()
, see there for more information. Initialized togenerate_design_random()
. -
additional_component_sampler
::Sampler
|NULL
Additional components that may be part of individuals as seen by mutation, recombination, and selectionMiesOperator
s, but that are not part of the search space of theOptimInstance
being optimized. This is equivalent to theadditional_component_sampler
parameter ofmies_init_population()
, see there for more information. Initialized toNULL
(no additional components). -
fidelity
::function
Only if themulti_fidelity
construction argument isTRUE
: Function that determines the value of the "budget" component of surviving individuals being evaluated when doing multi-fidelity optimization. It must have arguments namedinst
,budget_id
,last_fidelity
andlast_fidelity_offspring
, see the "Multi-Fidelity"-section for more details. Its return value is given tomies_init_population()
andmies_step_fidelity()
. When this configuration parameter is present (i.e.multi_fidelity
isTRUE
), then it is initialized to afunction
returning the value 1. -
fidelity_offspring
::function
Only if themulti_fidelity
construction argument isTRUE
: Function that determines the value of the "budget" component of newly sampled offspring individuals being evaluated when doing multi-fidelity optimization. It must have arguments namedinst
,budget_id
,last_fidelity
andlast_fidelity_offspring
, see the "Multi-Fidelity"-section for more details. Its return value is given tomies_evaluate_offspring()
. When this configuration parameter is present (i.e.multi_fidelity
isTRUE
), then it is initialized to afunction
returning the value oflast_fidelity
, i.e. the value returned by the last call to thefidelity
configuration parameter. This is the recommended value when fidelity should not change within a generation, since this means that survivor selection is performed with individuals that were evaluated with the same fidelity (at least iffidelity_current_gen_only
is also set toFALSE
) . -
fidelity_current_gen_only
::logical(1)
Only if themulti_fidelity
construction argument isTRUE
: When doing fidelity refinement inmies_step_fidelity()
, whether to refine all individuals with different budget component, or only individuals created in the current generation. This is equivalent to thecurrent_gen_only
parameter ofmies_step_fidelity()
, see there for more information.
When this configuration parameter is present (i.e.multi_fidelity
isTRUE
), then it is initialized toFALSE
, the recommended value. -
fidelity_monotonic
::logical(1)
Only if themulti_fidelity
construction argument isTRUE
: Whether to only do fidelity refinement inmies_step_fidelity()
for individuals for which the budget component value would increase. This is equivalent to themonotonic
parameter ofmies_step_fidelity()
, see there for more information.
When this configuration parameter is present (i.e.multi_fidelity
isTRUE
), then it is initialized toTRUE
. When optimization is performed on problems that have a categorical "budget" parameter, then this value should be set toFALSE
.
Super classes
bbotk::OptimizerBatch
-> miesmuschel::Optimizer
-> OptimizerMies
Active bindings
mutator
(
Mutator
)
Mutation operation to perform duringmies_generate_offspring()
.recombinator
(
Recombinator
)
Recombination operation to perform duringmies_generate_offspring()
.parent_selector
(
Selector
)
Parent selection operation to perform duringmies_generate_offspring()
.survival_selector
(
Selector
)
Survival selection operation to use inmies_survival_plus()
ormies_survival_comma()
.elite_selector
(
Selector
|NULL
)
Elite selector used inmies_survival_comma()
.init_selector
(
Selector
)
Selection operation to use when there are more thanmu
individuals present at the beginning of the optimization.param_set
(
ParamSet
)
Configuration parameters of the optimization algorithm.
Methods
Public methods
Inherited methods
Method new()
Initialize the OptimizerMies
object.
Usage
OptimizerMies$new( mutator = MutatorProxy$new(), recombinator = RecombinatorProxy$new(), parent_selector = SelectorProxy$new(), survival_selector = SelectorProxy$new(), elite_selector = NULL, init_selector = survival_selector, multi_fidelity = FALSE )
Arguments
mutator
(
Mutator
)
Mutation operation to perform duringmies_generate_offspring()
, see there for more information. Default isMutatorProxy
, which exposes the operation as a configuration parameter of the optimizer itself.
The$mutator
field will reflect this value.recombinator
(
Recombinator
)
Recombination operation to perform duringmies_generate_offspring()
, see there for more information. Default isRecombinatorProxy
, which exposes the operation as a configuration parameter of the optimizer itself. Note: The defaultRecombinatorProxy
has$n_indivs_in
set to 2, so to use recombination operations with more than two inputs, or to use population size of 1, it may be necessary to construct this argument explicitly.
The$recombinator
field will reflect this value.parent_selector
(
Selector
)
Parent selection operation to perform duringmies_generate_offspring()
, see there for more information. Default isSelectorProxy
, which exposes the operation as a configuration parameter of the optimizer itself.
The$parent_selector
field will reflect this value.survival_selector
(
Selector
)
Survival selection operation to use inmies_survival_plus()
ormies_survival_comma()
(depending on thesurvival_strategy
configuration parameter), see there for more information. Default isSelectorProxy
, which exposes the operation as a configuration parameter of the optimizer itself.
The$survival_selector
field will reflect this value.elite_selector
(
Selector
|NULL
)
Elite selector used inmies_survival_comma()
, see there for more information. "Comma" selection is only available when this argument is notNULL
. DefaultNULL
.
The$elite_selector
field will reflect this value.init_selector
(
Selector
)
Survival selection operation to give to thesurvival_selector
argument ofmies_init_population()
; it is used if theOptimInstance
being optimized already contains more (alive) individuals thanmu
. Default is the value given tosurvival_selector
. The$init_selector
field will reflect this value.multi_fidelity
(
logical(1)
)
Whether to enable multi-fidelity optimization. When this isTRUE
, then theOptimInstance
being optimized must contain aDomain
tagged"budget"
, which is then used as the "budget" search space component, determined byfidelity
andfidelity_offspring
instead of by theMiesOperator
s themselves. For multi-fidelity optimization, thefidelity
,fidelity_offspring
,fidelity_current_gen_only
, andfidelity_monotonic
configuration parameters must be given to determine multi-fidelity behaviour. (While the initial values for most of these are probably good for most cases in which more budget implies higher fidelity, at least thefidelity
configuration parameter should be adjusted in most cases). Default isFALSE
.
Method clone()
The objects of this class are cloneable with this method.
Usage
OptimizerMies$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Super classes
mlr3tuning::Tuner
-> mlr3tuning::TunerBatch
-> mlr3tuning::TunerBatchFromOptimizerBatch
-> TunerMies
Methods
Public methods
Inherited methods
Method new()
Initialize the TunerMies
object.
Usage
TunerMies$new( mutator = MutatorProxy$new(), recombinator = RecombinatorProxy$new(), parent_selector = SelectorProxy$new(), survival_selector = SelectorProxy$new(), elite_selector = NULL, init_selector = survival_selector, multi_fidelity = FALSE )
Arguments
Method clone()
The objects of this class are cloneable with this method.
Usage
TunerMies$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
References
Fieldsend, E J, Everson, M R (2014). “The rolling tide evolutionary algorithm: A multiobjective optimizer for noisy optimization problems.” IEEE Transactions on Evolutionary Computation, 19(1), 103–117.
Li, Rui, Emmerich, TM M, Eggermont, Jeroen, B"ack, Thomas, Sch"utz, Martin, Dijkstra, Jouke, Reiber, HC J (2013). “Mixed integer evolution strategies for parameter optimization.” Evolutionary computation, 21(1), 29–64.
Examples
lgr::threshold("warn")
op.m <- mut("gauss", sdev = 0.1)
op.r <- rec("xounif", p = .3)
op.parent <- sel("random")
op.survival <- sel("best")
#####
# Optimizing a Function
#####
library("bbotk")
# Define the objective to optimize
objective <- ObjectiveRFun$new(
fun = function(xs) {
z <- exp(-xs$x^2 - xs$y^2) + 2 * exp(-(2 - xs$x)^2 - (2 - xs$y)^2)
list(Obj = z)
},
domain = ps(x = p_dbl(-2, 4), y = p_dbl(-2, 4)),
codomain = ps(Obj = p_dbl(tags = "maximize"))
)
# Get a new OptimInstance
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 100)
)
# Create OptimizerMies object
mies_opt <- opt("mies", mutator = op.m, recombinator = op.r,
parent_selector = op.parent, survival_selector = op.survival,
mu = 10, lambda = 5)
# mies_opt$optimize performs MIES optimization and returns the optimum
mies_opt$optimize(oi)
#####
# Optimizing a Machine Learning Method
#####
# Note that this is a short example, aiming at clarity and short runtime.
# The settings are not optimal for hyperparameter tuning. The resampling
# in particular should not be "holdout" for small datasets where this gives
# a very noisy estimate of performance.
library("mlr3")
library("mlr3tuning")
# The Learner to optimize
learner = lrn("classif.rpart")
# The hyperparameters to optimize
learner$param_set$values[c("cp", "maxdepth")] = list(to_tune())
# Get a TuningInstance
ti = TuningInstanceSingleCrit$new(
task = tsk("iris"),
learner = learner,
resampling = rsmp("holdout"),
measure = msr("classif.acc"),
terminator = trm("gens", generations = 10)
)
# Create TunerMies object
mies_tune <- tnr("mies", mutator = op.m, recombinator = op.r,
parent_selector = op.parent, survival_selector = op.survival,
mu = 10, lambda = 5)
# mies_tune$optimize performs MIES optimization and returns the optimum
mies_tune$optimize(ti)
ParamSetShadow
Description
Wraps another ParamSet
and shadows out a subset of its Domain
s.
The original ParamSet
can still be accessed through the $origin
field;
otherwise, the ParamSetShadow
behaves like a ParamSet
where the shadowed
Domain
s are not present.
Super class
paradox::ParamSet
-> ParamSetShadow
Active bindings
params
(named
list()
)
Table of rows identifying the containedDomain
sparams_unid
(named
list
ofParam
) List ofParam
that are members of the wrappedParamSet
with the shadowedParam
s removed. This is a field mostly for internal usage that has the$id
s set to invalid values but avoids cloning overhead.
Deprecated by the upcomingparadox
package update and will be removed in the future.deps
(
data.table
)
Table of dependencies, as inParamSet
. The dependencies that are related to shadowed parameters are not exposed. Thisdata.table
should be seen as read-only and not modified in-place; instead, the$origin
's$deps
should be modified.values
(named
list
)
List of values, as inParamSet
, with the shadowed values removed.set_id
(
data.table
)
Id of the wrappedParamSet
. Changing this value will also change the wrappedParamSet
's$set_id
accordingly.origin
(
ParamSet
)
ParamSet
being wrapped. This object can be modified by reference to influence theParamSetShadow
object itself.
Methods
Public methods
Inherited methods
paradox::ParamSet$aggr_internal_tuned_values()
paradox::ParamSet$assert()
paradox::ParamSet$assert_dt()
paradox::ParamSet$check()
paradox::ParamSet$check_dependencies()
paradox::ParamSet$check_dt()
paradox::ParamSet$convert_internal_search_space()
paradox::ParamSet$disable_internal_tuning()
paradox::ParamSet$flatten()
paradox::ParamSet$format()
paradox::ParamSet$get_domain()
paradox::ParamSet$get_values()
paradox::ParamSet$ids()
paradox::ParamSet$print()
paradox::ParamSet$qunif()
paradox::ParamSet$search_space()
paradox::ParamSet$set_values()
paradox::ParamSet$subset()
paradox::ParamSet$subspaces()
paradox::ParamSet$test()
paradox::ParamSet$test_constraint_dt()
paradox::ParamSet$test_dt()
paradox::ParamSet$trafo()
Method new()
Initialize the ParamSetShadow
object.
Usage
ParamSetShadow$new(set, shadowed)
Arguments
Method test_constraint()
Checks underlying ParamSet
's constraint.
It uses the underlying $values
for shadowed values.
Usage
ParamSetShadow$test_constraint(x, ...)
Arguments
x
(named
list
) values to test...
Further arguments passed to
ParamSet
's$test_constraint()
function.
Returns
logical(1)
.
Method add_dep()
Adds a dependency to the unterlying ParamSet
.
Usage
ParamSetShadow$add_dep(id, on, cond, allow_dangling_dependencies = FALSE, ...)
Arguments
Returns
invisible(self)
.
Method clone()
The objects of this class are cloneable with this method.
Usage
ParamSetShadow$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
p1 = ps(x = p_dbl(0, 1), y = p_lgl())
p1$values = list(x = 0.5, y = TRUE)
print(p1)
p2 = ParamSetShadow$new(p1, "x")
print(p2$values)
p2$values$y = FALSE
print(p2)
print(p2$origin$values)
Recombinator Base Class
Description
Base class representing recombination operations, inheriting from MiesOperator
.
Recombinators get a table of individuals as input and return a table of modified individuals as output. Individuals are acted on by
groups: every $n_indivs_out
lines of output corresponds to a group of $n_indivs_in
lines of input, and presence or absence
of other input groups does not affect the result.
Recombination operations are performed in ES algorithms to facilitate exploration of the search space that combine partial solutions.
Inheriting
Recombinator
is an abstract base class and should be inherited from. Inheriting classes should implement the private $.recombine()
function. The user of the object calls $operate()
, which calls $.recombine()
for each $n_indivs_in
sized group of individuals after checking that
the operator is primed, that the values
argument conforms to the primed domain. $.recombine()
should then return a table of
$n_indivs_out
individuals for each call. Typically, the $initialize()
function
should also be overloaded, and optionally the $prime()
function; they should call their super
equivalents.
Super class
miesmuschel::MiesOperator
-> Recombinator
Active bindings
n_indivs_in
(
integer(1)
)
Number of individuals to consider at the same time. When operating, the number of input individuals must be divisible by this number.n_indivs_out
(
integer(1)
)
Number of individuals produced for each group of$n_indivs_in
individuals.
Methods
Public methods
Inherited methods
Method new()
Initialize base class components of the Recombinator
.
Usage
Recombinator$new( param_classes = c("ParamLgl", "ParamInt", "ParamDbl", "ParamFct"), param_set = ps(), n_indivs_in = 2, n_indivs_out = n_indivs_in, packages = character(0), dict_entry = NULL, own_param_set = quote(self$param_set) )
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.n_indivs_in
(
integer(1)
)
Number of individuals to consider at the same time. When operating, the number of input individuals must be divisible by this number. Default 2.
The$n_indivs_in
field will reflect this value.n_indivs_out
(
integer(1)
)
Number of individuals that result for eachn_indivs_in
lines of input. The number of results from the recombinator will benrow(values) / n_indivs_in * n_indivs_out
. Default equal ton_indivs_in
.
The$n_indivs_out
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.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.
Method clone()
The objects of this class are cloneable with this method.
Usage
Recombinator$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other base classes:
Filtor
,
FiltorSurrogate
,
MiesOperator
,
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
RecombinatorPair
,
Scalor
,
Selector
,
SelectorScalar
Other recombinators:
OperatorCombination
,
RecombinatorPair
,
dict_recombinators_cmpmaybe
,
dict_recombinators_convex
,
dict_recombinators_cvxpair
,
dict_recombinators_maybe
,
dict_recombinators_null
,
dict_recombinators_proxy
,
dict_recombinators_sbx
,
dict_recombinators_sequential
,
dict_recombinators_swap
,
dict_recombinators_xonary
,
dict_recombinators_xounif
Pair Recombinator Base Class
Description
Base class for recombination that covers the common case of combining two individuals, where two (typically complementary) child individuals could be taken as the result, such as bitwise crossover or SBX crossover.
This is a relatively lightweight class, it adds the keep_complement
active binding and sets $n_indivs_in
and $n_indivs_out
appropriately.
Inheriting
RecombinatorPair
is an abstract base class and should be inherited from. Inheriting classes should implement the private
$.recombine_pair()
function. During $operate()
, the $.recombine_pair()
function is called with the same input as the $.recombine()
function
of the Recombinator
class. It should return a data.table
of two individuals.
Constructors of inheriting classes should have a keep_complement
argument.
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Recombinator
-> RecombinatorPair
Active bindings
keep_complement
(
logical(1)
)
Whether the operation keeps both resulting individuals of the operation or discards the complement.
Methods
Public methods
Inherited methods
Method new()
Initialize base class components of the RecombinatorPair
.
Usage
RecombinatorPair$new( keep_complement = TRUE, param_classes = c("ParamLgl", "ParamInt", "ParamDbl", "ParamFct"), param_set = ps(), packages = character(0), dict_entry = NULL, own_param_set = quote(self$param_set) )
Arguments
keep_complement
(
logical(1)
)
Whether the operation should keep both resulting individuals (TRUE
), or only the first and discard the complement (FALSE
). DefaultTRUE
. The$keep_complement
field will reflect this value.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.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.
Method clone()
The objects of this class are cloneable with this method.
Usage
RecombinatorPair$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other base classes:
Filtor
,
FiltorSurrogate
,
MiesOperator
,
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
Recombinator
,
Scalor
,
Selector
,
SelectorScalar
Other recombinators:
OperatorCombination
,
Recombinator
,
dict_recombinators_cmpmaybe
,
dict_recombinators_convex
,
dict_recombinators_cvxpair
,
dict_recombinators_maybe
,
dict_recombinators_null
,
dict_recombinators_proxy
,
dict_recombinators_sbx
,
dict_recombinators_sequential
,
dict_recombinators_swap
,
dict_recombinators_xonary
,
dict_recombinators_xounif
Sampler for Projection Weights
Description
Sampler for a single p_uty
that samples weight-matrices
as used by ScalorFixedProjection
.
Super class
paradox::Sampler
-> SamplerRandomWeights
Active bindings
nobjectives
(
numeric(1)
)
Number of objectives for which weights are generated.nweights
(
numeric(1)
)
Number of weight vectors generated for each configuration.weights_component_id
(
numeric(1)
)
search space component identifying the weights by which to scalarize.
Methods
Public methods
Inherited methods
Method new()
Initialize the SamplerRandomWeights
object.
Usage
SamplerRandomWeights$new( nobjectives = 2, nweights = 1, weights_component_id = "scalarization_weights" )
Arguments
nobjectives
(
numeric(1)
)
Number of objectives for which weights are generated.nweights
(
numeric(1)
)
Number of weight vectors generated for each configuration.weights_component_id
(
character(1)
)
Id of thep_uty
. Default is"scalarization_weights"
. Can be changed arbitrarily but should match theScalorFixedProjection
'sweights_component_id
.
Method clone()
The objects of this class are cloneable with this method.
Usage
SamplerRandomWeights$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
set.seed(1)
Scalarizer
Description
Scalarizer
objects are functions taking a fitness-matrix fitnesses
(Nindivs x Nobjectives, with higher values indicating higher desirability)
and a list of weight matrices weights
(Nindivs elements of Nobjectives x Nweights matrices; positive weights indicate a positive contribution
to scale) and returns a matrix of scalarizations (Nindivs x Nweights, with higher values indicating greater desirability).
Any other function conforming to these requirements can also be used in place of a Scalarizer
, but the provided Scalarizer
functions cover
the most common use cases.
Scalarizer
s are constructed from constructor-functions, such as scalarizer_linear()
or scalarizer_chebyshev()
.
See Also
Other Scalarizers:
scalarizer_chebyshev()
,
scalarizer_linear()
Scalor Base Class
Description
Base class representing ranking operations, inheriting from MiesOperator
.
A Scalor
gets a table of individuals as input, along with information on the individuals' performance values
and returns a vector of a possible scalarization of individuals' fitness (or other qualities).
Scalor
s can be used by Selector
s as a basis to select individuals by. This way it is possible to have tournament
selection (SelectorTournament
) or elite selection (SelectorBest
) based on different, configurable qualities of
individuals.
Unlike most other operator types inheriting from MiesOperator
, the $operate()
function has two arguments, which are passed on to $.scale()
-
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. -
fitnesses
::numeric
|matrix
Fitnesses for each individual given invalues
. If this is anumeric
, then its length must be equal to the number of rows invalues
. If this is amatrix
, if number of rows must be equal to the number of rows invalues
, and it must have one column when doing single-crit optimization and one column each for each "criterion" when doing multi-crit optimization.
Note that fitness values are always maximized, both in single- and multi-criterion optimization, so objective output is multiplied with-1
if it is tagged as"minimize"
.
The return value of an operation should be a numeric vector with one finite value for each entry of values
, assigning high values to individuals in
some way more "desirable" than others with low values.
Inheriting
Scalor
is an abstract base class and should be inherited from. Inheriting classes should implement the private $.scale()
function. The user of the object calls $operate()
, and the arguments are passed on to private $.scale()
after checking that
the operator is primed, that the values
argument conforms to the primed domain and that other values match. Typically, the $initialize()
function
should also be overloaded, and optionally the $prime()
function; they should call their super
equivalents.
Super class
miesmuschel::MiesOperator
-> Scalor
Active bindings
supported
(
character
)
Optimization supported by thisScalor
, can be"single-crit"
,"multi-crit"
, or both.
Methods
Public methods
Inherited methods
Method new()
Initialize base class components of the Mutator
.
Usage
Scalor$new( param_classes = c("ParamLgl", "ParamInt", "ParamDbl", "ParamFct"), param_set = ps(), supported = c("single-crit", "multi-crit"), packages = character(0), dict_entry = NULL, own_param_set = quote(self$param_set) )
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.supported
(
character
)
Subset of"single-crit"
and"multi-crit"
, indicating wether single and / or multi-criterion optimization is supported. Default both of them.
The$supported
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.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.
Method clone()
The objects of this class are cloneable with this method.
Usage
Scalor$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other base classes:
Filtor
,
FiltorSurrogate
,
MiesOperator
,
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
Selector
,
SelectorScalar
Other scalors:
dict_scalors_aggregate
,
dict_scalors_domcount
,
dict_scalors_fixedprojection
,
dict_scalors_hypervolume
,
dict_scalors_nondom
,
dict_scalors_one
,
dict_scalors_proxy
,
dict_scalors_single
Selector Base Class
Description
Base class representing selection operations, inheriting from MiesOperator
.
A Selector
gets a table of individuals as input, along with information on the individuals' performance values and the
number of individuals to select, and returns a vector of integers indicating which individuals were selected.
Selection operations are performed in ES algorithms to facilitate concentration towards individuals that perform well with regard to the fitness measure.
Fitness values are always maximized, both in single- and multi-criterion optimization.
Unlike most other operator types inheriting from MiesOperator
, the $operate()
function has three arguments, which are passed on to $.select()
-
values
::data.frame
Individuals to operate on. Must pass the check of theDomain
given in the last$prime()
call and may not have any missing components. -
fitnesses
::numeric
|matrix
Fitnesses for each individual given invalues
. If this is anumeric
, then its length must be equal to the number of rows invalues
. If this is amatrix
, if number of rows must be equal to the number of rows invalues
, and it must have one column when doing single-crit optimization and one column each for each "criterion" when doing multi-crit optimization.
Thefitnesses
-value passed on to$.select()
is always amatrix
. -
n_select
::integer(1)
Number of individuals to select. SomeSelector
s select individuals with replacement, for which this value may be greater than the number of rows invalues
. -
group_size
::integer
Sampling group size hint, indicating that the caller would prefer there to not be any duplicates within this group size, e.g. because theSelector
is called to select individuals to be given to aRecombinator
with a certainn_indivs_in
, or because it is called as asurvival_selector
inmies_survival_comma()
ormies_survival_plus()
. TheSelector
may or may not ignore this value, however. This may possibly happen because of certain configuration parameters, or because the input size is too small.
Must either be a scalar value or sum up ton_select
. Must be non-negative. A scalar value of 0 is interpreted the same as 1.
If not given, this value defaults to 1.
The return value for an operation will be a numeric vector of integer values of length n_select
indexing the individuals that were selected. Some Selector
s
select individuals with replacement, for which the return value may contain indices more than once.
Inheriting
Selector
is an abstract base class and should be inherited from. Inheriting classes should implement the private $.select()
function. The user of the object calls $operate()
, and the arguments are passed on to private $.select()
after checking that
the operator is primed, that the values
argument conforms to the primed domain and that other values match. Typically, the $initialize()
function
should also be overloaded, and optionally the $prime()
function; they should call their super
equivalents.
Super class
miesmuschel::MiesOperator
-> Selector
Active bindings
supported
(
character
)
Optimization supported by thisSelector
, can be"single-crit"
,"multi-crit"
, or both.
Methods
Public methods
Inherited methods
Method new()
Initialize base class components of the Selector
.
Usage
Selector$new( is_deterministic = FALSE, param_classes = c("ParamLgl", "ParamInt", "ParamDbl", "ParamFct"), param_set = ps(), supported = c("single-crit", "multi-crit"), packages = character(0), dict_entry = NULL, own_param_set = quote(self$param_set) )
Arguments
is_deterministic
(
logical(1)
)
Whether theSelector
is deterministic. Setting this toTRUE
adds a configuration parametershuffle_selection
(initialized toTRUE
) that causes the selection to be shuffled.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.supported
(
character
)
Subset of"single-crit"
and"multi-crit"
, indicating wether single and / or multi-criterion optimization is supported. Default both of them.
The$supported
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.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.
Method clone()
The objects of this class are cloneable with this method.
Usage
Selector$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other base classes:
Filtor
,
FiltorSurrogate
,
MiesOperator
,
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
Scalor
,
SelectorScalar
Other selectors:
SelectorScalar
,
dict_selectors_best
,
dict_selectors_maybe
,
dict_selectors_null
,
dict_selectors_proxy
,
dict_selectors_random
,
dict_selectors_sequential
,
dict_selectors_tournament
Selector making use of Scalors
Description
Base class inheriting from Selector
for selection operations that make use of scalar values, generated by Scalor
.
Inheriting
SelectorScaling
is an abstract base class and should be inherited from. Inheriting classes should implement the private $.select_scalar()
function. During $operate()
, the $.select_scalar()
function is called, it should have three arguments, similar to Selector
's $.select()
function.
values
and n_select
are as given to $.select()
of the Selector
. The fitnesses
argument is first scaled by the associated Scalor
and then passed on as a numeric
vector.
Typically, $initialize()
should also be overloaded when inheriting.
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Selector
-> SelectorScalar
Active bindings
Methods
Public methods
Inherited methods
Method new()
Initialize base class components of the SelectorScalar
.
Usage
SelectorScalar$new( scalor = ScalorSingleObjective$new(), is_deterministic = FALSE, param_classes = c("ParamLgl", "ParamInt", "ParamDbl", "ParamFct"), param_set = ps(), supported = scalor$supported, packages = character(0), dict_entry = NULL )
Arguments
scalor
(
Scalor
)
Scalor
to use to generate scalar values from multiple objectives, if multi-objective optimization is performed. Initialized toScalorSingleObjective
: Doing single-objective optimization normally, throwing an error if used in multi-objective setting: In that case, aScalor
needs to be explicitly chosen.is_deterministic
(
logical(1)
)
Whether theSelector
is deterministic. Setting this toTRUE
adds a configuration parametershuffle_selection
(initialized toTRUE
) that causes the selection to be shuffled.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.supported
(
character
)
Subset of"single-crit"
and"multi-crit"
, indicating wether single and / or multi-criterion optimization is supported. Default to the supported set ofscalor
.
The$supported
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.
Method prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operator
given to scalor
during construction.
Usage
SelectorScalar$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
SelectorScalar$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other base classes:
Filtor
,
FiltorSurrogate
,
MiesOperator
,
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
Scalor
,
Selector
Other selectors:
Selector
,
dict_selectors_best
,
dict_selectors_maybe
,
dict_selectors_null
,
dict_selectors_proxy
,
dict_selectors_random
,
dict_selectors_sequential
,
dict_selectors_tournament
TuningInstanceMultiCrit Class
Description
mlr3tuning
's TuningInstanceMultiCrit
class.
Re-exported since mlr3tuning
will change the name.
Super classes
bbotk::OptimInstance
-> bbotk::OptimInstanceBatch
-> bbotk::OptimInstanceBatchMultiCrit
-> mlr3tuning::TuningInstanceBatchMultiCrit
-> TuningInstanceMultiCrit
Methods
Public methods
Inherited methods
Method clone()
The objects of this class are cloneable with this method.
Usage
TuningInstanceMultiCrit$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
TuningInstanceSingleCrit Class
Description
mlr3tuning
's TuningInstanceSingleCrit
class.
Re-exported since mlr3tuning
will change the name.
Super classes
bbotk::OptimInstance
-> bbotk::OptimInstanceBatch
-> bbotk::OptimInstanceBatchSingleCrit
-> mlr3tuning::TuningInstanceBatchSingleCrit
-> TuningInstanceSingleCrit
Methods
Public methods
Inherited methods
Method clone()
The objects of this class are cloneable with this method.
Usage
TuningInstanceSingleCrit$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Set a Function's Environment
Description
Useful to represent functions efficiently within repr()
.
Usage
crate_env(fun, namespace = "R_GlobalEnv", ..., selfref = NULL)
Arguments
fun |
( |
namespace |
( |
... |
( |
selfref |
( |
Value
function
: The given fun
with changed environment.
Examples
identity2 = crate_env(function(x) x, "base")
identical(identity, identity2) # TRUE
y = 1
f1 = mlr3misc::crate(function(x) x + y, y, .parent = .GlobalEnv)
f2 = crate_env(function(x) x + y, "R_GlobalEnv", list(y = 1))
# Note identical() does not apply because both contain (equal, but not
# identical) 'y = 1'-environments
all.equal(f1, f2) # TRUE
f1(10) # 10 + 1 == 11
factorial1 = mlr3misc::crate(
function(x) if (x > 0) x * factorial1(x - 1) else 1,
y, .parent = .GlobalEnv
)
environment(factorial1)$factorial1 = factorial1
factorial2 = crate_env(
function(x) if (x > 0) x * factorial1(x - 1) else 1,
"R_GlobalEnv", list(y = 1), selfref = "factorial1")
# putting 'factorial1' into the list (or repeating function(x) ....)
# would *not* work, since we want:
identical(environment(factorial2)$factorial1, factorial2) # TRUE
all.equal(factorial1, factorial2) # TRUE
g = crate_env(function(x) x + y + z, "miesmuschel",
list(y = 1), list(z = 2), selfref = c(X = 1, Y = 2, Z = 2))
g(0) # 0 + 1 + 2 == 3
identical(environment(g)$X, g)
identical(parent.env(environment(g))$Y, g)
identical(parent.env(environment(g))$Z, g)
identical(
parent.env(parent.env(environment(g))),
loadNamespace("miesmuschel")
)
Dictionary of Filtors
Description
Dictionary of Filtors
Usage
dict_filtors
Format
An object of class DictionaryFiltor
(inherits from DictionaryEx
, Dictionary
, R6
) of length 15.
Methods
Methods inherited from Dictionary
, as well as:
-
help(key, help_type)
(character(1)
,character(1)
)
Displays help for the dictionary entrykey
.help_type
is one of"text"
,"html"
,"pdf"
and given as thehelp_type
argument of R'shelp()
.
See Also
Other dictionaries:
dict_mutators
,
dict_recombinators
,
dict_scalors
,
dict_selectors
,
mut()
Filtor-Combination that Filters According to Two Filtors
Description
Filtor
that wraps two other Filtor
s given during construction and chooses which operation to perform.
Each of the resulting n_filter
individuals is chosen either from $filtor
, or from $filtor_not
.
This makes it possible to implement filter methods such as random interleaving, where only a fraction of p
individuals were filtered and the others were not.
Letting the number of individuals chosen by $filtor
be n_filter_f
, then n_filter_f
is either fixed
set to round(n_filter * p)
, (when random_choise
is FALSE
) or to rbinom(1, n_filter, p)
(when random_choice
is TRUE
).
When random_choice
is FALSE
, then $needed_input()
is calculated directly from $needed_input()
of $filtor
and $filtor_not
,
as well as n_filter_f
and n_filter - n_filter_f
.
When random_choice
is TRUE
, then $needed_input()
is considers the "worst case" from $filtor
and $filtor_not
, and assumes that
$needed_input()
is monotonically increasing in its input argument.
To make the worst case less extreme, the number of individuals chosen with random_choice
set to TRUE
is limited to
qbinom(-20, n_filter, p, log.p = TRUE)
(with lower.tail
FALSE
and TRUE
for $filtor
and $filtor_not
, respectively), which distorts the binomial
distribution with probability 1 - exp(-20)
or about 1 - 0.5e-9
.
Configuration Parameters
This operator has the configuration parameters of the Filtor
s that it wraps: The configuration parameters of the operator given to the filtor
construction argument
are prefixed with "maybe."
, the configuration parameters of the operator given to the filtor_not
construction argument are prefixed with "maybe_not."
.
Additional configuration parameters:
-
p
::numeric(1)
Probability per individual (whenrandom_choise
isTRUE
), or fraction of individuals (whenrandom_choice
isFALSE
), that are chosen from$filtor
instead of$filtor_not
. Must be set by the user. -
random_choice
::logical(1)
Whether to sample the number of individuals chosen by$filtor
according torbinom(1, n_filter, p)
, or to use a fixed fraction. Initialized toFALSE
.
Supported Operand Types
Supported Domain
classes are the set intersection of supported classes of filtor
and filtor_not
.
Dictionary
This Filtor
can be created with the short access form ftr()
(ftrs()
to get a list), or through the the dictionary
dict_filtors
in the following way:
# preferred: ftr("maybe", <filtor> [, <filtor_not>]) ftrs("maybe", <filtor> [, <filtor_not>]) # takes vector IDs, returns list of Filtors # long form: dict_filtors$get("maybe", <filtor> [, <filtor_not>])
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Filtor
-> FiltorMaybe
Active bindings
Methods
Public methods
Inherited methods
Method new()
Initialize the FiltorMaybe
object.
Usage
FiltorMaybe$new(filtor, filtor_not = FiltorNull$new())
Arguments
filtor
(
Filtor
)
Filtor
to wrap. This operator gets run with probabilityp
(Configuration parameter).
The constructed object gets a clone of this argument. The$filtor
field will reflect this value.filtor_not
(
Filtor
)
AnotherFiltor
to wrap. This operator runs whenfiltor
is not chosen. By default, this isFiltorNull
, i.e. no filtering. With this default, theFiltorMaybe
object applies thefiltor
operation with probability / proportionp
, and no operation at all otherwise.
The constructed object gets a clone of this argument. The$filtor_not
field will reflect this value.
Method prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operators
given to filtor
and filtor_not
during construction.
Usage
FiltorMaybe$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
FiltorMaybe$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other filtors:
Filtor
,
FiltorSurrogate
,
dict_filtors_null
,
dict_filtors_proxy
,
dict_filtors_surprog
,
dict_filtors_surtour
Other filtor wrappers:
dict_filtors_proxy
Examples
library("mlr3")
library("mlr3learners")
fm = ftr("maybe", ftr("surprog", lrn("regr.lm"), filter.pool_factor = 2), p = 0.5)
p = ps(x = p_dbl(-5, 5))
known_data = data.frame(x = as.numeric(1:5))
fitnesses = as.numeric(1:5)
new_data = data.frame(x = c(0.5, 1.5, 2.5, 3.5, 4.5))
fm$prime(p)
fm$needed_input(2)
fm$operate(new_data, known_data, fitnesses, 2)
fm$param_set$values$p = 0.33
fm$needed_input(3)
fm$operate(new_data, known_data, fitnesses, 3)
Null-Filtor
Description
Null-filtor that does not perform filtering. Its needed_input()
is always the output_size
, and operate()
selects the first n_filter
values from its input.
Useful in particular with operator-wrappers such as FiltorProxy
, and to make filtering optional.
Configuration Parameters
This operator has no configuration parameters.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Filtor
can be created with the short access form ftr()
(ftrs()
to get a list), or through the the dictionary
dict_filtors
in the following way:
# preferred: ftr("null") ftrs("null") # takes vector IDs, returns list of Filtors # long form: dict_filtors$get("null")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Filtor
-> FiltorNull
Methods
Public methods
Inherited methods
Method new()
Initialize the FiltorNull
object.
Usage
FiltorNull$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
FiltorNull$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other filtors:
Filtor
,
FiltorSurrogate
,
dict_filtors_maybe
,
dict_filtors_proxy
,
dict_filtors_surprog
,
dict_filtors_surtour
Examples
fn = ftr("null")
p = ps(x = p_dbl(-5, 5))
known_data = data.frame(x = as.numeric(1:5))
fitnesses = as.numeric(1:5)
new_data = data.frame(x = c(2.5, 4.5))
fn$prime(p)
fn$needed_input(1)
fn$operate(new_data, known_data, fitnesses, 1)
Proxy-Filtor that Filters According to its Configuration Parameter
Description
Filtor that performs the operation in its operation
configuration parameter. This can be used to make filtor operations fully parametrizable.
Configuration Parameters
-
operation
::Filtor
Operation to perform. Must be set by the user. This is primed when$prime()
ofSelectorProxy
is called, and also when$operate()
is called, to make changing the operation as part of self-adaption possible. However, if the same operation gets used inside multipleSelectorProxy
objects, then it is recommended to$clone(deep = TRUE)
the object before assigning them tooperation
to avoid frequent re-priming.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Selector
can be created with the short access form sel()
(sels()
to get a list), or through the the dictionary
dict_selectors
in the following way:
# preferred: sel("proxy") sels("proxy") # takes vector IDs, returns list of Selectors # long form: dict_selectors$get("proxy")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Filtor
-> FiltorProxy
Methods
Public methods
Inherited methods
Method new()
Initialize the FiltorProxy
object.
Usage
FiltorProxy$new()
Method prime()
See MiesOperator
method. Primes both this operator, as well as the operator given to the operation
configuration parameter.
Note that this modifies the $param_set$values$operation
object.
Usage
FiltorProxy$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
FiltorProxy$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other filtors:
Filtor
,
FiltorSurrogate
,
dict_filtors_maybe
,
dict_filtors_null
,
dict_filtors_surprog
,
dict_filtors_surtour
Other filtor wrappers:
dict_filtors_maybe
Examples
library("mlr3")
library("mlr3learners")
fp = ftr("proxy")
p = ps(x = p_dbl(-5, 5))
known_data = data.frame(x = as.numeric(1:5))
fitnesses = as.numeric(1:5)
new_data = data.frame(x = c(2.5, 4.5))
fp$param_set$values$operation = ftr("null")
fp$prime(p)
fp$operate(new_data, known_data, fitnesses, 1)
fp$param_set$values$operation = ftr("surprog", lrn("regr.lm"), filter.pool_factor = 2)
fp$operate(new_data, known_data, fitnesses, 1)
Progressive Surrogate Model Filtering
Description
Performs progressive surrogate model filtering. A surrogate model is used, as described in the parent class FiltorSurrogate
.
The filtering is "progressive" in that successive values are filtered more agressively.
Algorithm
Given the number n_filter
of of individuals to sample, and the desired pool size at round i
pool_size(i)
, progressive
surrogate model filtering proceeds as follows:
Train the
surrogate_learner
LearnerRegr
on theknown_values
and theirfitnesses
.Take
pool_size(1)
configurations, predict their expected performance using the surrogate model, and put them into a poolP
of configurations to consider.Initialize
i
to 1.Take the individual that is optimal according to predicted performance, remove it from
P
and add it to solution setS
.If the number of solutions in
S
equalsn_filter
, quit.If
pool_size(i + 1)
is larger thanpool_size(i)
, take the nextpool_size(i + 1) - pool_size(i)
configurations, predict their expected performance using the surrogate model, and add them toP
. Otherwise, removepool_size(i) - pool_size(i + 1)
random individuals from the pool. The size ofP
ends up beingpool_size(i + 1) - i
, asi
individuals have also been removed and added toS
.Increment
i
, jump to 4.
(The algorithm presented here is optimized for clarity; the actual implementation does all the surrogate model prediction in one go, but is functionally equivalent).
pool_size(i)
is calculated as round(n_filter * pool_factor * (pool_factor_last / pool_factor) ^ (i / n_filter))
, i.e. a log-linear interpolation from
pool_factor * n_filter
to pool_factor_last * n_filter
.
The pool_factor
and pool_factor_last
configuration parameters of this algorithm determine how agressively the surrogate model is used to
filter out sampled configurations. If the filtering is agressive (large values), then more "exploitation" at the cost of "exploration" is performed.
When pool_factor
is small but pool_factor_last
is large (or vice-versa), then different individuals are filtered with different agressiveness, potentially
leading to a tradeoff between "exploration" and "exploitation".
When pool_factor_last
is set, it defaults to pool_factor
, with no new individuals added and no individuals removed from the filter pool during filtering.
It is equivalent to taking the top n_filter
individuals out of a sample of n_filter * pool_factor
.
Configuration Parameters
FiltorSurrogateProgressive
's configuration parameters are the hyperparameters of the FiltorSurrogate
base class, as well as:
-
filter.pool_factor
::numeric(1)
pool_factor
parameter of the progressive surrogate model filtering algorithm, see the corresponding section. Initialized to 1. Together with the default offilter.pool_factor_last
, this is equivalent to random sampling new individuals. -
filter.pool_factor_last
::numeric(1)
pool_factor_last
parameter of the progressive surrogate model filtering algorithm, see the corresponding section. When not given, it defaults tofilter.pool_factor
, equivalent to taking the topn_filter
fromn_filter * pool_factor
individuals.
Supported Operand Types
See FiltorSurrogate
about supported operand types.
Dictionary
This Filtor
can be created with the short access form ftr()
(ftrs()
to get a list), or through the the dictionary
dict_filtors
in the following way:
# preferred: ftr("surprog", <surrogate_learner> [, <surrogate_selector>]) ftrs("surprog", <surrogate_learner> [, <surrogate_selector>]) # takes vector IDs, returns list of Filtors # long form: dict_filtors$get("surprog", <surrogate_learner> [, <surrogate_selector>])
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Filtor
-> miesmuschel::FiltorSurrogate
-> FiltorSurrogateProgressive
Methods
Public methods
Inherited methods
Method new()
Initialize the FiltorSurrogateProgressive
.
Usage
FiltorSurrogateProgressive$new( surrogate_learner, surrogate_selector = SelectorBest$new() )
Arguments
surrogate_learner
(
mlr3::LearnerRegr
)
Regression learner for the surrogate model filtering algorithm.
The$surrogate_learner
field will reflect this value.surrogate_learner
(
mlr3::LearnerRegr
)
Regression learner for the surrogate model filtering algorithm.
The$surrogate_learner
field will reflect this value.surrogate_selector
(
Selector
)Selector
for the surrogate model filtering algorithm.
The$surrogate_selector
field will reflect this value.surrogate_selector
(
Selector
)Selector
for the surrogate model filtering algorithm.
The$surrogate_selector
field will reflect this value.
Method clone()
The objects of this class are cloneable with this method.
Usage
FiltorSurrogateProgressive$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other filtors:
Filtor
,
FiltorSurrogate
,
dict_filtors_maybe
,
dict_filtors_null
,
dict_filtors_proxy
,
dict_filtors_surtour
Examples
library("mlr3")
library("mlr3learners")
fp = ftr("surprog", lrn("regr.lm"), filter.pool_factor = 2)
p = ps(x = p_dbl(-5, 5))
known_data = data.frame(x = as.numeric(1:5))
fitnesses = as.numeric(1:5)
new_data = data.frame(x = c(2.5, 4.5))
fp$prime(p)
fp$needed_input(1)
fp$operate(new_data, known_data, fitnesses, 1)
Tournament Surrogate Model Filtering
Description
Performs tournament surrogate model filtering. A surrogate model is used, as described in the parent class FiltorSurrogate
.
Algorithm
Selects individuals from a tournament by taking the top per_tournament
individuals, according to surrogate_selector
and
as predicted by surrogate_learner
, from a sample of tournament_size(i)
, where tournament_size(1)
is given by
tournament_size
, tournament_size(ceiling(n_filter / per_tournament))
is given by tournament_size_last
, and
tournament_size(i)
for i
between these values is linearly interpolated on a log scale.
Configuration Parameters
FiltorSurrogateProgressive
's configuration parameters are the hyperparameters of the FiltorSurrogate
base class, as well as:
-
filter.per_tournament
::integer(1)
Number of individuals to select from each tournament. Ifper_tournament
is not a divider ofn_filter
, then the last tournament selects a random subset ofn_filter %% per_tournament
individuals out of the topper_tournament
individuals. Initialized to 1. -
filter.tournament_size
::numeric(1)
Tournament size used for filtering. Iftournament_size_last
is not given, alln_filter
individuals are selected in batches ofper_tournament
from tournaments of this size. If it is given, then the actual tournament size is interpolated betweentournament_size
andtournament_size_last
on a logarithmic scale. Tournaments with tournament size belowper_tournament
selectper_tournament
individuals without tournament, i.e. no filtering. Initialized to 1. -
filter.tournament_size_last
::numeric(1)
Tournament size used for the last tournament, see description oftournament_size
. Defaults totournament_size
when not given, i.e. all tournaments have the same size.
Supported Operand Types
See FiltorSurrogate
about supported operand types.
Dictionary
This Filtor
can be created with the short access form ftr()
(ftrs()
to get a list), or through the the dictionary
dict_filtors
in the following way:
# preferred: ftr("surtour", <surrogate_learner> [, <surrogate_selector>]) ftrs("surtour", <surrogate_learner> [, <surrogate_selector>]) # takes vector IDs, returns list of Filtors # long form: dict_filtors$get("surtour", <surrogate_learner> [, <surrogate_selector>])
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Filtor
-> miesmuschel::FiltorSurrogate
-> FiltorSurrogateTournament
Methods
Public methods
Inherited methods
Method new()
Initialize the FiltorSurrogateTournament
.
Usage
FiltorSurrogateTournament$new( surrogate_learner, surrogate_selector = SelectorBest$new() )
Arguments
surrogate_learner
(
mlr3::LearnerRegr
)
Regression learner for the surrogate model filtering algorithm.
The$surrogate_learner
field will reflect this value.surrogate_learner
(
mlr3::LearnerRegr
)
Regression learner for the surrogate model filtering algorithm.
The$surrogate_learner
field will reflect this value.surrogate_selector
(
Selector
)Selector
for the surrogate model filtering algorithm.
The$surrogate_selector
field will reflect this value.surrogate_selector
(
Selector
)Selector
for the surrogate model filtering algorithm.
The$surrogate_selector
field will reflect this value.
Method clone()
The objects of this class are cloneable with this method.
Usage
FiltorSurrogateTournament$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other filtors:
Filtor
,
FiltorSurrogate
,
dict_filtors_maybe
,
dict_filtors_null
,
dict_filtors_proxy
,
dict_filtors_surprog
Examples
library("mlr3")
library("mlr3learners")
fp = ftr("surtour", lrn("regr.lm"), filter.tournament_size = 2)
p = ps(x = p_dbl(-5, 5))
known_data = data.frame(x = as.numeric(1:5))
fitnesses = as.numeric(1:5)
new_data = data.frame(x = c(2.5, 4.5))
fp$prime(p)
fp$needed_input(1)
fp$operate(new_data, known_data, fitnesses, 1)
Dictionary of Mutators
Description
Dictionary of Mutators
Usage
dict_mutators
Format
An object of class DictionaryMutator
(inherits from DictionaryEx
, Dictionary
, R6
) of length 15.
Methods
Methods inherited from Dictionary
, as well as:
-
help(key, help_type)
(character(1)
,character(1)
)
Displays help for the dictionary entrykey
.help_type
is one of"text"
,"html"
,"pdf"
and given as thehelp_type
argument of R'shelp()
.
See Also
Other dictionaries:
dict_filtors
,
dict_recombinators
,
dict_scalors
,
dict_selectors
,
mut()
Mutator Choosing Action Component-Wise Independently
Description
Mutator
that chooses which operation to perform probabilistically. The Mutator
wraps two other Mutator
s given during construction,
and both of these operators are run. The ultimate result is sampled from the results of these operations independently for each
individuum and component: with probability p
(configuration parameter), the result from the Mutator
given to the mutator
construction argument is used, and with probability p - 1
the one given to mutator_not
is used.
Configuration Parameters
This operator has the configuration parameters of the Mutator
s that it wraps: The configuration parameters of the operator given to the mutator
construction argument
are prefixed with "cmpmaybe."
, the configuration parameters of the operator given to the mutator_not
construction argument are prefixed with "cmpmaybe_not."
.
Additional configuration parameters:
-
p
::numeric(1)
Probability per component with which to apply the operator given to themutator
construction argument. Must be set by the user.
Supported Operand Types
Supported Domain
classes are the set intersection of supported classes of mutator
and mutator_not
.
Dictionary
This Mutator
can be created with the short access form mut()
(muts()
to get a list), or through the the dictionary
dict_mutators
in the following way:
# preferred: mut("cmpmaybe", <mutator> [, <mutator_not>]) muts("cmpmaybe", <mutator> [, <mutator_not>]) # takes vector IDs, returns list of Mutators # long form: dict_mutators$get("cmpmaybe", <mutator> [, <mutator_not>])
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Mutator
-> MutatorCmpMaybe
Active bindings
Methods
Public methods
Inherited methods
Method new()
Initialize the MutatorCmpMaybe
object.
Usage
MutatorCmpMaybe$new(mutator, mutator_not = MutatorNull$new())
Arguments
mutator
(
Mutator
)
Mutator
to wrap. Component-wise results of this operator are used with probabilityp
(Configuration parameter).
The constructed object gets a clone of this argument. The$mutator
field will reflect this value.mutator_not
(
Mutator
)
AnotherMutator
to wrap. Results from this operator are used whenmutator
is not chosen. By default, this isMutatorNull
, i.e. no operation.
With this default, theMutatorCmpMaybe
object applies themutator
operation with probabilityp
, and no operation at all otherwise.
The constructed object gets a clone of this argument. The$mutator_not
field will reflect this value.
Method prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operators
given to mutator
and mutator_not
during construction.
Usage
MutatorCmpMaybe$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
MutatorCmpMaybe$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other mutators:
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
dict_mutators_erase
,
dict_mutators_gauss
,
dict_mutators_maybe
,
dict_mutators_null
,
dict_mutators_proxy
,
dict_mutators_sequential
,
dict_mutators_unif
Other mutator wrappers:
OperatorCombination
,
dict_mutators_maybe
,
dict_mutators_proxy
,
dict_mutators_sequential
Examples
set.seed(1)
mcm = mut("cmpmaybe", mut("gauss", sdev = 5), p = 0.5)
p = ps(x = p_int(-5, 5), y = p_dbl(-5, 5))
data = data.frame(x = rep(0, 5), y = rep(0, 5))
mcm$prime(p)
mcm$operate(data)
mcm$param_set$values$p = 0.2
mcm$operate(data)
mcm2 = mut("cmpmaybe",
mutator = mut("gauss", sdev = 0.01),
mutator_not = mut("gauss", sdev = 10),
p = 0.5
)
mcm2$prime(p)
mcm2$operate(data)
Uniform Sample Mutator
Description
"Mutates" individuals by forgetting the current value and sampling new individuals from scratch.
Since the information loss is very high, this should in most cases be combined with MutatorCmpMaybe
.
Configuration Parameters
-
initializer
::function
Function that generates the initial population as aDesign
object, with argumentsparam_set
andn
, functioning likeparadox::generate_design_random
orparadox::generate_design_lhs
. This is equivalent to theinitializer
parameter ofmies_init_population()
, see there for more information. Initialized togenerate_design_random()
.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Mutator
can be created with the short access form mut()
(muts()
to get a list), or through the the dictionary
dict_mutators
in the following way:
# preferred: mut("erase") muts("erase") # takes vector IDs, returns list of Mutators # long form: dict_mutators$get("erase")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Mutator
-> MutatorErase
Methods
Public methods
Inherited methods
Method new()
Initialize the MutatorErase
object.
Usage
MutatorErase$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
MutatorErase$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other mutators:
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
dict_mutators_cmpmaybe
,
dict_mutators_gauss
,
dict_mutators_maybe
,
dict_mutators_null
,
dict_mutators_proxy
,
dict_mutators_sequential
,
dict_mutators_unif
Examples
set.seed(1)
mer = mut("erase")
p = ps(x = p_lgl(), y = p_fct(c("a", "b", "c")), z = p_dbl(0, 1))
data = data.frame(x = rep(TRUE, 5), y = rep("a", 5),
z = seq(0, 1, length.out = 5),
stringsAsFactors = FALSE) # necessary for R <= 3.6
mer$prime(p)
mer$operate(data)
Gaussian Distribution Mutator
Description
Individuals are mutated with an independent normal random variable on each component.
Configuration Parameters
-
sdev
::numeric
Standard deviation of normal distribuion. This is absolute ifsdev_is_relative
isFALSE
, and multiplied with each individual component's range (upper - lower) ifsdev_is_relative
isTRUE
. This may either be a scalar, in which case it is applied to all input components, or a vector, in which case it must have the length of the input and applies to components in order in which they appear in the primingParamSet
. Must be set by the user. -
sdev_is_relative
::logical(1)
Whethersdev
is absolute (FALSE
) or relative to component range (TRUE
). Initialized toFALSE
. -
truncated_normal
::logical(1)
Whether to draw individuals from a normal distribution that is truncated at the bounds of each component (TRUE
), or to draw from a normal distribution and then restrict to bounds afterwards (FALSE
). The former (TRUE
) will lead to very few to no samples landing on the exact bounds (analytically it would be none almost surely, but this is subject to machine precision), the latter (FALSE
) can lead to a substantial number of samples landing on the exact bounds. Initialized toFALSE
.
Supported Operand Types
Supported Domain
classes are: p_int
('ParamInt'), p_dbl
('ParamDbl')
Dictionary
This Mutator
can be created with the short access form mut()
(muts()
to get a list), or through the the dictionary
dict_mutators
in the following way:
# preferred: mut("gauss") muts("gauss") # takes vector IDs, returns list of Mutators # long form: dict_mutators$get("gauss")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Mutator
-> miesmuschel::MutatorNumeric
-> MutatorGauss
Methods
Public methods
Inherited methods
Method new()
Initialize the MutatorGauss
object.
Usage
MutatorGauss$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
MutatorGauss$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other mutators:
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
dict_mutators_cmpmaybe
,
dict_mutators_erase
,
dict_mutators_maybe
,
dict_mutators_null
,
dict_mutators_proxy
,
dict_mutators_sequential
,
dict_mutators_unif
Examples
set.seed(1)
mg = mut("gauss", sdev = 0.1)
p = ps(x = p_int(-5, 5), y = p_dbl(-5, 5))
data = data.frame(x = rep(0, 5), y = rep(0, 5))
mg$prime(p)
mg$operate(data)
mg$param_set$values$sdev = 100
mg$operate(data)
Mutator Choosing Action Probabilistically
Description
Mutator
that chooses which operation to perform probabilistically. The Mutator
wraps two other Mutator
s given during construction,
and for each individuum, the operation to perform is sampled: with probability p
(configuration parameter), the Mutator
given to the mutator
construction argument is applied, and with probability p - 1
the one given to mutator_not
is applied.
Configuration Parameters
This operator has the configuration parameters of the Mutator
s that it wraps: The configuration parameters of the operator given to the mutator
construction argument
are prefixed with "maybe."
, the configuration parameters of the operator given to the mutator_not
construction argument are prefixed with "maybe_not."
.
Additional configuration parameters:
-
p
::numeric(1)
Probability per individual with which to apply the operator given to themutator
construction argument. Must be set by the user.
Supported Operand Types
Supported Domain
classes are the set intersection of supported classes of mutator
and mutator_not
.
Dictionary
This Mutator
can be created with the short access form mut()
(muts()
to get a list), or through the the dictionary
dict_mutators
in the following way:
# preferred: mut("maybe", <mutator> [, <mutator_not>]) muts("maybe", <mutator> [, <mutator_not>]) # takes vector IDs, returns list of Mutators # long form: dict_mutators$get("maybe", <mutator> [, <mutator_not>])
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Mutator
-> MutatorMaybe
Active bindings
Methods
Public methods
Inherited methods
Method new()
Initialize the MutatorMaybe
object.
Usage
MutatorMaybe$new(mutator, mutator_not = MutatorNull$new())
Arguments
mutator
(
Mutator
)
Mutator
to wrap. This operator gets run with probabilityp
(configuration parameter).
The constructed object gets a clone of this argument.
The$mutator
field will reflect this value.mutator_not
(
Mutator
)
AnotherMutator
to wrap. This operator runs whenmutator
is not chosen. By default, this isMutatorNull
, i.e. no operation. With this default, theMutatorMaybe
object applies themutator
operation with probabilityp
, and no operation at all otherwise.
The constructed object gets a clone of this argument. The$mutator_not
field will reflect this value.
Method prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operators
given to mutator
and mutator_not
during construction.
Usage
MutatorMaybe$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
MutatorMaybe$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other mutators:
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
dict_mutators_cmpmaybe
,
dict_mutators_erase
,
dict_mutators_gauss
,
dict_mutators_null
,
dict_mutators_proxy
,
dict_mutators_sequential
,
dict_mutators_unif
Other mutator wrappers:
OperatorCombination
,
dict_mutators_cmpmaybe
,
dict_mutators_proxy
,
dict_mutators_sequential
Examples
set.seed(1)
mm = mut("maybe", mut("gauss", sdev = 5), p = 0.5)
p = ps(x = p_int(-5, 5), y = p_dbl(-5, 5))
data = data.frame(x = rep(0, 5), y = rep(0, 5))
mm$prime(p)
mm$operate(data)
mm$param_set$values$p = 0.3
mm$operate(data)
mm2 = mut("maybe",
mutator = mut("gauss", sdev = 0.01),
mutator_not = mut("gauss", sdev = 10),
p = 0.5
)
mm2$prime(p)
mm2$operate(data)
Null Mutator
Description
Null-mutator that does not perform any operation on its input. Useful in particular with operator-wrappers such as MutatorMaybe
or MutatorCombination
.
Configuration Parameters
This operator has no configuration parameters.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Mutator
can be created with the short access form mut()
(muts()
to get a list), or through the the dictionary
dict_mutators
in the following way:
# preferred: mut("null") muts("null") # takes vector IDs, returns list of Mutators # long form: dict_mutators$get("null")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Mutator
-> MutatorNull
Methods
Public methods
Inherited methods
Method new()
Initialize the MutatorNull
object.
Usage
MutatorNull$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
MutatorNull$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other mutators:
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
dict_mutators_cmpmaybe
,
dict_mutators_erase
,
dict_mutators_gauss
,
dict_mutators_maybe
,
dict_mutators_proxy
,
dict_mutators_sequential
,
dict_mutators_unif
Examples
mn = mut("null")
p = ps(x = p_int(-5, 5), y = p_dbl(-5, 5), z = p_lgl())
data = data.frame(x = rep(0, 5), y = rep(0, 5), z = rep(TRUE, 5))
mn$prime(p)
mn$operate(data)
Proxy-Mutator that Mutates According to its Configuration parameter
Description
Mutator that performs the operation in its operation
configuration parameter. This is useful, e.g., to make
OptimizerMies
's mutation operation fully parametrizable.
Configuration Parameters
-
operation
::Mutator
Operation to perform. Must be set by the user. This is primed when$prime()
ofMutatorProxy
is called, and also when$operate()
is called, to make changing the operation as part of self-adaption possible. However, if the same operation gets used inside multipleMutatorProxy
objects, then it is recommended to$clone(deep = TRUE)
the object before assigning them tooperation
to avoid frequent re-priming.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Mutator
can be created with the short access form mut()
(muts()
to get a list), or through the the dictionary
dict_mutators
in the following way:
# preferred: mut("proxy") muts("proxy") # takes vector IDs, returns list of Mutators # long form: dict_mutators$get("proxy")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Mutator
-> MutatorProxy
Methods
Public methods
Inherited methods
Method new()
Initialize the MutatorProxy
object.
Usage
MutatorProxy$new()
Method prime()
See MiesOperator
method. Primes both this operator, as well as the operator given to the operation
configuration parameter.
Note that this modifies the $param_set$values$operation
object.
Usage
MutatorProxy$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
MutatorProxy$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other mutators:
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
dict_mutators_cmpmaybe
,
dict_mutators_erase
,
dict_mutators_gauss
,
dict_mutators_maybe
,
dict_mutators_null
,
dict_mutators_sequential
,
dict_mutators_unif
Other mutator wrappers:
OperatorCombination
,
dict_mutators_cmpmaybe
,
dict_mutators_maybe
,
dict_mutators_sequential
Examples
set.seed(1)
mp = mut("proxy", operation = mut("gauss", sdev = 0.1))
p = ps(x = p_int(-5, 5), y = p_dbl(-5, 5))
data = data.frame(x = rep(0, 5), y = rep(0, 5))
mp$prime(p)
mp$operate(data)
mp$param_set$values$operation = mut("null")
mp$operate(data)
Run Multiple Mutator Operations in Sequence
Description
Mutator
that wraps multiple other Mutator
s given during construction and uses them for mutation in sequence.
Configuration Parameters
This operator has the configuration parameters of the Mutator
s that it wraps: The configuration parameters of the operator given to the mutators
construction
argument are prefixed with "mutator_1"
, "mutator_2"
, ... up to "mutator_#"
, where #
is length(mutators)
.
Supported Operand Types
Supported Domain
classes are the set intersection of supported classes of the Mutator
s given in mutators
.
Dictionary
This Mutator
can be created with the short access form mut()
(muts()
to get a list), or through the the dictionary
dict_mutators
in the following way:
# preferred: mut("sequential", <mutators>) muts("sequential", <mutators>) # takes vector IDs, returns list of Mutators # long form: dict_mutators$get("sequential", <mutators>)
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Mutator
-> MutatorSequential
Active bindings
Methods
Public methods
Inherited methods
Method new()
Initialize the MutatorSequential
object.
Usage
MutatorSequential$new(mutators)
Arguments
Method prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operators
given to mutator
and mutator_not
during construction.
Usage
MutatorSequential$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
MutatorSequential$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other mutators:
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
dict_mutators_cmpmaybe
,
dict_mutators_erase
,
dict_mutators_gauss
,
dict_mutators_maybe
,
dict_mutators_null
,
dict_mutators_proxy
,
dict_mutators_unif
Other mutator wrappers:
OperatorCombination
,
dict_mutators_cmpmaybe
,
dict_mutators_maybe
,
dict_mutators_proxy
Examples
set.seed(1)
# dataset:
# - x1 is mutated around +- 10
# - x2 influences sdev of mutation of x1
ds = data.frame(x1 = 0, x2 = c(.01, 0.1, 1))
p = ps(x1 = p_dbl(-10, 10), x2 = p_dbl(0, 10))
# operator that only mutates x1, with sdev given by x2
gauss_x1 = mut("combine",
operators = list(
x1 = mut("gauss", sdev_is_relative = FALSE),
x2 = mut("null")
),
adaptions = list(x1.sdev = function(x) x$x2)
)
gauss_x1$prime(p)
gauss_x1$operate(ds) # see how x1[1] changes little, x1[3] changes a lot
# operator that mutates x1 with sdev given by x2, as well as x2. However,
# the value that x2 takes after mutation does not influence the value that
# the mutator of x1 "sees" -- although x2 is mutated to extreme values,
# mutation of x1 happens as in `gauss_x1`.
gauss_x1_x2 = mut("combine",
operators = list(
x1 = mut("gauss", sdev_is_relative = FALSE),
x2 = mut("gauss", sdev = 100)
),
adaptions = list(x1.sdev = function(x) x$x2)
)
gauss_x1_x2$prime(p)
gauss_x1_x2$operate(ds) # see how x1 changes in similar ways to above
# operator that mutates sequentially: first x2, and then x1 with sdev given
# by x2. The value that x2 takes after mutation *does* influence the value
# that the mutator of x1 "sees": x1 is mutated either to a large degree,
# or not at all.
gauss_x2_then_x1 = mut("sequential", list(
mut("combine",
operators = list(
x1 = mut("null"),
x2 = mut("gauss", sdev = 100)
)
),
mut("combine",
operators = list(
x1 = mut("gauss", sdev_is_relative = FALSE),
x2 = mut("null")
),
adaptions = list(x1.sdev = function(x) x$x2)
)
))
gauss_x2_then_x1$prime(p)
gauss_x2_then_x1$operate(ds)
Uniform Discrete Mutator
Description
Discrete components are mutated by sampling from a uniform distribution, either from all possible values of each component, or from all values except the original value.
Since the information loss is very high, this should in most cases be combined with MutatorCmpMaybe
.
Configuration Parameters
-
can_mutate_to_same
::logical(1)
Whether to sample from entire range of each parameter (TRUE
) or from all values except the current value (FALSE
). Initialized toTRUE
.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_fct
('ParamFct')
Dictionary
This Mutator
can be created with the short access form mut()
(muts()
to get a list), or through the the dictionary
dict_mutators
in the following way:
# preferred: mut("unif") muts("unif") # takes vector IDs, returns list of Mutators # long form: dict_mutators$get("unif")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Mutator
-> miesmuschel::MutatorDiscrete
-> MutatorDiscreteUniform
Methods
Public methods
Inherited methods
Method new()
Initialize the MutatorDiscreteUniform
object.
Usage
MutatorDiscreteUniform$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
MutatorDiscreteUniform$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other mutators:
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
dict_mutators_cmpmaybe
,
dict_mutators_erase
,
dict_mutators_gauss
,
dict_mutators_maybe
,
dict_mutators_null
,
dict_mutators_proxy
,
dict_mutators_sequential
Examples
set.seed(1)
mdu = mut("unif")
p = ps(x = p_lgl(), y = p_fct(c("a", "b", "c")))
data = data.frame(x = rep(TRUE, 5), y = rep("a", 5),
stringsAsFactors = FALSE) # necessary for R <= 3.6
mdu$prime(p)
mdu$operate(data)
mdu$param_set$values$can_mutate_to_same = FALSE
mdu$operate(data)
Dictionary of Recombinators
Description
Dictionary of Recombinators
Usage
dict_recombinators
Format
An object of class DictionaryRecombinator
(inherits from DictionaryEx
, Dictionary
, R6
) of length 15.
Methods
Methods inherited from Dictionary
, as well as:
-
help(key, help_type)
(character(1)
,character(1)
)
Displays help for the dictionary entrykey
.help_type
is one of"text"
,"html"
,"pdf"
and given as thehelp_type
argument of R'shelp()
.
See Also
Other dictionaries:
dict_filtors
,
dict_mutators
,
dict_scalors
,
dict_selectors
,
mut()
Recombinator Choosing Action Component-Wise Independently
Description
Recombinator
that chooses which operation to perform probabilistically and independently for each component.
The Recombinator
wraps two other Recombinator
s given during construction,
and both of these operators are run. The ultimate result is sampled from the results of these operations independently for each individuum
and component: with probability p
(configuration parameter), the result from the Recombinator
given to
the recombinator
construction argument is used, and with probability p - 1
the one given to recombinator_not
is used.
The values of $n_indivs_in
and $n_indivs_out
is set to the corresponding values of the wrapped Recombinator
s. Both recombinator
and recombinator_not
must currently have the same respective $n_indivs_in
and $n_indivs_out
values.
Configuration Parameters
This operator has the configuration parameters of the Recombinator
s that it wraps: The configuration parameters of the operator given to the recombinator
construction argument
are prefixed with "cmpmaybe."
, the configuration parameters of the operator given to the recombinator_not
construction argument are prefixed with "cmpmaybe_not."
.
Additional configuration parameters:
-
p
::numeric(1)
Probability per component with which to use the result of applying the operator given to therecombinator
construction argument. Must be set by the user.
Supported Operand Types
Supported Domain
classes are the set intersection of supported classes of recombinator
and recombinator_not
.
Dictionary
This Recombinator
can be created with the short access form rec()
(recs()
to get a list), or through the the dictionary
dict_recombinators
in the following way:
# preferred: rec("cmpmaybe", <recombinator> [, <recombinator_not>]) recs("cmpmaybe", <recombinator> [, <recombinator_not>]) # takes vector IDs, returns list of Recombinators # long form: dict_recombinators$get("cmpmaybe", <recombinator> [, <recombinator_not>])
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Recombinator
-> RecombinatorCmpMaybe
Active bindings
recombinator
(
Recombinator
)
Recombinator
being wrapped. This operator gets run with probabilityp
(configuration parameter).recombinator_not
(
Recombinator
)
AlternativeRecombinator
being wrapped. This operator gets run with probability1 - p
(configuration parameter).
Methods
Public methods
Inherited methods
Method new()
Initialize the RecombinatorCmpMaybe
object.
Usage
RecombinatorCmpMaybe$new(recombinator, recombinator_not = NULL)
Arguments
recombinator
(
Recombinator
)
Recombinator
to wrap. Component-wise results of this operator are used with probabilityp
(Configuration parameter).
The constructed object gets a clone of this argument. The$recombinator
field will reflect this value.recombinator_not
(
Recombinator
)
AnotherRecombinator
to wrap. Results from this operator are used whenrecombinator
is not chosen. By default, this isRecombinatorNull
, i.e. no operation, with bothn_indivs_in
andn_indivs_out
set to matchrecombinator
. This does not work whenrecombinator
hasn_indivs_in < n_indivs_out
, in which case this argument must be set explicitly.
With this default, theRecombinatorCmpMaybe
object applies therecombinator
operation with probabilityp
, and no operation at all otherwise.
The constructed object gets a clone of this argument. The$recombinator_not
field will reflect this value.
Method prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operators
given to recombinator
and recombinator_not
during construction.
Usage
RecombinatorCmpMaybe$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
RecombinatorCmpMaybe$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other recombinators:
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
dict_recombinators_convex
,
dict_recombinators_cvxpair
,
dict_recombinators_maybe
,
dict_recombinators_null
,
dict_recombinators_proxy
,
dict_recombinators_sbx
,
dict_recombinators_sequential
,
dict_recombinators_swap
,
dict_recombinators_xonary
,
dict_recombinators_xounif
Other recombinator wrappers:
OperatorCombination
,
dict_recombinators_maybe
,
dict_recombinators_proxy
,
dict_recombinators_sequential
Examples
set.seed(1)
rm = rec("cmpmaybe", rec("swap"), p = 0.5)
p = ps(x = p_int(1, 8), y = p_dbl(1, 8), z = p_lgl())
data = data.frame(x = 1:8, y = 1:8, z = rep(TRUE, 4))
rm$prime(p)
rm$operate(data)
rm$param_set$values$p = 0.3
rm$operate(data)
# equivalent to rec("cmpmaybe", rec("swap", keep_complement = FALSE), p = 0.7)
rm2 = rec("cmpmaybe",
recombinator = rec("null", 2, 1),
recombinator_not = rec("swap", keep_complement = FALSE),
p = 0.3
)
rm2$prime(p)
rm2$operate(data)
Convex Combination Recombinator
Description
Numeric Values between various individuals are recombined via component-wise convex combination (or weighted mean). The number of individuals
over which the convex combination is taken must be determined during construction as n_indivs_in
.
The number of output individuals is always 1, i.e. n_indivs_in
are used to create one output value. When using this
recombinator in a typical EA setting, e.g. with mies_generate_offspring
, it is therefore recommended to use a parent-selector
where the expected quality of selected parents does not depend on the number of parents selected when n_indivs_in
is large:
sel("tournament")
is preferred to sel("best")
.
Configuration Parameters
-
lambda
::numeric
|matrix
Combination weights; these are normalized to sum to 1 internally. Must either be a vector of lengthn_indivs_in
, or a matrix withn_indivs_in
rows and as many columns as there are components in the values being operated on. Must be non-negative, at least one value per column must be greater than zero, but it is not necessary that they sum to 1.
Initialized torep(1, n_indivs_in)
, i.e. equal weights to all individuals being operated on.
Supported Operand Types
Supported Domain
classes are: p_dbl
('ParamDbl')
Dictionary
This Recombinator
can be created with the short access form rec()
(recs()
to get a list), or through the the dictionary
dict_recombinators
in the following way:
# preferred: rec("convex") recs("convex") # takes vector IDs, returns list of Recombinators # long form: dict_recombinators$get("convex")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Recombinator
-> RecombinatorConvex
Methods
Public methods
Inherited methods
Method new()
Initialize the RecombinatorConvex
object.
Usage
RecombinatorConvex$new(n_indivs_in = 2)
Arguments
n_indivs_in
(
integer(1)
)
Number of individuals to consider at the same time. When operating, the number of input individuals must be divisible by this number. Default 2.
The$n_indivs_in
field will reflect this value.
Method clone()
The objects of this class are cloneable with this method.
Usage
RecombinatorConvex$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other recombinators:
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
dict_recombinators_cmpmaybe
,
dict_recombinators_cvxpair
,
dict_recombinators_maybe
,
dict_recombinators_null
,
dict_recombinators_proxy
,
dict_recombinators_sbx
,
dict_recombinators_sequential
,
dict_recombinators_swap
,
dict_recombinators_xonary
,
dict_recombinators_xounif
Examples
set.seed(1)
rcvx = rec("convex", n_indivs_in = 3)
p = ps(x = p_dbl(-5, 5), y = p_dbl(-5, 5), z = p_dbl(-5, 5))
data = data.frame(x = 0:5, y = 0:5, z = 0:5)
rcvx$prime(p)
rcvx$operate(data) # mean of groups of 3
rcvx = rec("convex", 3, lambda = c(0, 1, 2))$prime(p)
rcvx$operate(data) # for groups of 3, take 1/3 of 2nd and 2/3 of 3rd row
lambda = matrix(c(0, 1, 2, 1, 1, 1, 1, 0, 0), ncol = 3)
lambda
rcvx = rec("convex", 3, lambda = lambda)$prime(p)
rcvx$operate(data) # componentwise different operation
Convex Combination Recombinator for Pairs
Description
Numeric Values between various individuals are recombined via component-wise convex combination (or weighted mean). Exactly two
individuals are being recombined, and the lambda
configuration parameter determines the relative weight of the first
individual in each pair for the first result, and the relative weight of the second indivudual for the complement, if
initialized with keep_complement
set to TRUE
.
Configuration Parameters
-
lambda
::numeric
Combination weight. Ifkeep_complement
isTRUE
, then two individuals are returned for each pair of input individuals: one corresponding tolambda * <1st individual> + (1-lambda) * <2nd individual>
, and one corresponding to(1-lambda) * <1st individual> + lambda * <2nd individual>
(i.e. the complement). Otherwise, only the first of these two is generated. Must either be a scalar, or a vector with length equal to the number of components in the values being operated on. Must be between 0 and 1.
Initialized to 0.5.
Supported Operand Types
Supported Domain
classes are: p_dbl
('ParamDbl')
Dictionary
This Recombinator
can be created with the short access form rec()
(recs()
to get a list), or through the the dictionary
dict_recombinators
in the following way:
# preferred: rec("convex") recs("convex") # takes vector IDs, returns list of Recombinators # long form: dict_recombinators$get("convex")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Recombinator
-> miesmuschel::RecombinatorPair
-> RecombinatorConvexPair
Methods
Public methods
Inherited methods
Method new()
Initialize the RecombinatorConvexPair
object.
Usage
RecombinatorConvexPair$new(keep_complement = TRUE)
Arguments
keep_complement
(
logical(1)
)
Whether the operation should keep both resulting individuals (TRUE
), or only the first and discard the complement (FALSE
). DefaultTRUE
. The$keep_complement
field will reflect this value.
Method clone()
The objects of this class are cloneable with this method.
Usage
RecombinatorConvexPair$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other recombinators:
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
dict_recombinators_cmpmaybe
,
dict_recombinators_convex
,
dict_recombinators_maybe
,
dict_recombinators_null
,
dict_recombinators_proxy
,
dict_recombinators_sbx
,
dict_recombinators_sequential
,
dict_recombinators_swap
,
dict_recombinators_xonary
,
dict_recombinators_xounif
Examples
set.seed(1)
rcvx = rec("cvxpair")
p = ps(x = p_dbl(-5, 5), y = p_dbl(-5, 5), z = p_dbl(-5, 5))
data = data.frame(x = 0:5, y = 0:5, z = 0:5)
rcvx$prime(p)
rcvx$operate(data) # mean of groups of 2
# with the default value of lambda = 0.5, the default of
# keep_complement = TRUE means that pairs of equal values are generated;
# consider setting keep_complement = FALSE int that case.
rcvx$param_set$values$lambda = 0.1
rcvx$operate(data)
Recombinator Choosing Action Probabilistically
Description
Recombinator
that chooses which operation to perform probabilistically. The Recombinator
wraps two other Recombinator
s given during construction,
and for each group of $n_indivs_in
individuals, the operation to perform is sampled: with probability p
(configuration parameter), the Recombinator
given to
the recombinator
construction argument is applied, and with probability p - 1
the one given to recombinator_not
is applied.
The values of $n_indivs_in
and $n_indivs_out
is set to the corresponding values of the wrapped Recombinator
s. Both recombinator
and recombinator_not
must currently have the same respective $n_indivs_in
and $n_indivs_out
values.
Configuration Parameters
This operator has the configuration parameters of the Recombinator
s that it wraps: The configuration parameters of the operator given to the recombinator
construction argument
are prefixed with "maybe."
, the configuration parameters of the operator given to the recombinator_not
construction argument are prefixed with "maybe_not."
.
Additional configuration parameters:
-
p
::numeric(1)
Probability per group ofn_indivs_in
individuals with which to apply the operator given to therecombinator
construction argument. Must be set by the user.
Supported Operand Types
Supported Domain
classes are the set intersection of supported classes of recombinator
and recombinator_not
.
Dictionary
This Recombinator
can be created with the short access form rec()
(recs()
to get a list), or through the the dictionary
dict_recombinators
in the following way:
# preferred: rec("maybe", <recombinator> [, <recombinator_not>]) recs("maybe", <recombinator> [, <recombinator_not>]) # takes vector IDs, returns list of Recombinators # long form: dict_recombinators$get("maybe", <recombinator> [, <recombinator_not>])
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Recombinator
-> RecombinatorMaybe
Active bindings
recombinator
(
Recombinator
)
Recombinator
being wrapped. This operator gets run with probabilityp
(configuration parameter).recombinator_not
(
Recombinator
)
AlternativeRecombinator
being wrapped. This operator gets run with probability1 - p
(configuration parameter).
Methods
Public methods
Inherited methods
Method new()
Initialize the RecombinatorMaybe
object.
Usage
RecombinatorMaybe$new(recombinator, recombinator_not = NULL)
Arguments
recombinator
(
Recombinator
)
Recombinator
to wrap. This operator gets run with probabilityp
(Configuration parameter).
The constructed object gets a clone of this argument. The$recombinator
field will reflect this value.recombinator_not
(
Recombinator
)
AnotherRecombinator
to wrap. This operator runs whenrecombinator
is not chosen. By default, this isRecombinatorNull
, i.e. no operation, with bothn_indivs_in
andn_indivs_out
set to matchrecombinator
. This does not work whenrecombinator
hasn_indivs_in < n_indivs_out
, in which case this argument must be set explicitly.
With this default, theRecombinatorMaybe
object applies therecombinator
operation with probabilityp
, and no operation at all otherwise.
The constructed object gets a clone of this argument. The$recombinator_not
field will reflect this value.
Method prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operators
given to recombinator
and recombinator_not
during construction.
Usage
RecombinatorMaybe$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
RecombinatorMaybe$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other recombinators:
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
dict_recombinators_cmpmaybe
,
dict_recombinators_convex
,
dict_recombinators_cvxpair
,
dict_recombinators_null
,
dict_recombinators_proxy
,
dict_recombinators_sbx
,
dict_recombinators_sequential
,
dict_recombinators_swap
,
dict_recombinators_xonary
,
dict_recombinators_xounif
Other recombinator wrappers:
OperatorCombination
,
dict_recombinators_cmpmaybe
,
dict_recombinators_proxy
,
dict_recombinators_sequential
Examples
set.seed(1)
rm = rec("maybe", rec("xounif", p = 1), p = 0.5)
p = ps(x = p_int(1, 8), y = p_dbl(1, 8), z = p_lgl())
data = data.frame(x = 1:8, y = 1:8, z = rep(TRUE, 4))
rm$prime(p)
rm$operate(data)
rm$param_set$values$p = 0.3
rm$operate(data)
rm2 = rec("maybe",
recombinator = rec("xounif", p = 1),
recombinator_not = rec("xounif", p = 0.5),
p = 0.5
)
rm2$prime(p)
rm2$operate(data)
Null-Recombinator
Description
Null-recombinator that does not perform any operation on its input. Useful in particular with operator-wrappers such as RecombinatorMaybe
or
RecombinatorCombination
.
n_indivs_in
and n_indivs_out
can be set during construction, where n_indivs_out
must be less or equal n_indivs_in
. If it is strictly less,
then the operation returns only the first n_indivs_out
individuals out of each n_indivs_in
sized group.
Configuration Parameters
This operator has no configuration parameters.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Recombinator
can be created with the short access form rec()
(recs()
to get a list), or through the the dictionary
dict_recombinators
in the following way:
# preferred: rec("null") recs("null") # takes vector IDs, returns list of Recombinators # long form: dict_recombinators$get("null")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Recombinator
-> RecombinatorNull
Methods
Public methods
Inherited methods
Method new()
Initialize base class components of the Recombinator
.
Usage
RecombinatorNull$new(n_indivs_in = 1, n_indivs_out = n_indivs_in)
Arguments
n_indivs_in
(
integer(1)
)
Number of individuals to consider at the same time. When operating, the number of input individuals must be divisible by this number. Setting this number to a number unequal 1 is mostly useful when incorporating this operator in wrappers such asRecombinatorMaybe
orRecombinatorCombination
. Default 1.
The$n_indivs_in
field will reflect this value.n_indivs_out
(
integer(1)
)
Number of individuals that result for eachn_indivs_in
lines of input. Must be at mostn_indivs_in
. If this is less thann_indivs_in
, then only the firstn_indivs_out
individuals out of eachn_indivs_in
sized group are returned by an operation. Setting this number to a number unequal 1 is mostly useful when incorporating this operator in wrappers such asRecombinatorMaybe
orRecombinatorCombination
. Default equal ton_indivs_in
.
The$n_indivs_out
field will reflect this value.
Method clone()
The objects of this class are cloneable with this method.
Usage
RecombinatorNull$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other recombinators:
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
dict_recombinators_cmpmaybe
,
dict_recombinators_convex
,
dict_recombinators_cvxpair
,
dict_recombinators_maybe
,
dict_recombinators_proxy
,
dict_recombinators_sbx
,
dict_recombinators_sequential
,
dict_recombinators_swap
,
dict_recombinators_xonary
,
dict_recombinators_xounif
Examples
rn = rec("null")
p = ps(x = p_int(-5, 5), y = p_dbl(-5, 5), z = p_lgl())
data = data.frame(x = 1:4, y = 0:3, z = rep(TRUE, 4))
rn$prime(p)
rn$operate(data)
rn_half = rec("null", n_indivs_in = 2, n_indivs_out = 1)
rn_half$prime(p)
rn_half$operate(data)
Proxy-Recombinator that Recombines According to its Configuration parameter
Description
Recombinator that performs the operation in its operation
configuration parameter. This is useful, e.g., to make
OptimizerMies
's recombination operation fully parametrizable.
Configuration Parameters
-
operation
::Recombinator
Operation to perform. Must be set by the user. This is primed when$prime()
ofRecombinatorProxy
is called, and also when$operate()
is called, to make changing the operation as part of self-adaption possible. However, if the same operation gets used inside multipleRecombinatorProxy
objects, then it is recommended to$clone(deep = TRUE)
the object before assigning them tooperation
to avoid frequent re-priming.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Recombinator
can be created with the short access form rec()
(recs()
to get a list), or through the the dictionary
dict_recombinators
in the following way:
# preferred: rec("proxy") recs("proxy") # takes vector IDs, returns list of Recombinators # long form: dict_recombinators$get("proxy")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Recombinator
-> RecombinatorProxy
Methods
Public methods
Inherited methods
Method new()
Initialize the RecombinatorProxy
object.
Usage
RecombinatorProxy$new(n_indivs_in = 2, n_indivs_out = n_indivs_in)
Arguments
n_indivs_in
(
integer(1)
)
Number of individuals to consider at the same time. When operating, the number of input individuals must be divisible by this number. Furthermore, theRecombinator
assigned to theoperation
configuration parameter must have ann_indivs_in
that is a divisor of this number. Default 2.
The$n_indivs_in
field will reflect this value.n_indivs_out
(
integer(1)
)
Number of individuals that result for eachn_indivs_in
lines of input. Must be at mostn_indivs_in
. The ratio of$n_indivs_in
to$n_indivs_out
of theRecombinator
assigned to theoperation
configuration parameter must be the same asn_indivs_in
ton_indivs_out
of this object. Default equal ton_indivs_in
.
The$n_indivs_out
field will reflect this value.
Method prime()
See MiesOperator
method. Primes both this operator, as well as the operator given to the operation
configuration parameter.
Note that this modifies the $param_set$values$operation
object.
Usage
RecombinatorProxy$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
RecombinatorProxy$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other recombinators:
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
dict_recombinators_cmpmaybe
,
dict_recombinators_convex
,
dict_recombinators_cvxpair
,
dict_recombinators_maybe
,
dict_recombinators_null
,
dict_recombinators_sbx
,
dict_recombinators_sequential
,
dict_recombinators_swap
,
dict_recombinators_xonary
,
dict_recombinators_xounif
Other recombinator wrappers:
OperatorCombination
,
dict_recombinators_cmpmaybe
,
dict_recombinators_maybe
,
dict_recombinators_sequential
Examples
set.seed(1)
rp = rec("proxy", operation = rec("xounif"))
p = ps(x = p_int(-5, 5), y = p_dbl(-5, 5), z = p_lgl())
data = data.frame(x = 1:4, y = 0:3, z = rep(TRUE, 4))
rp$prime(p)
rp$operate(data) # default operation: null
rp$param_set$values$operation = rec("xounif", p = 0.5)
rp$operate(data)
Simulated Binary Crossover Recombinator
Description
Numeric Values between two individuals are recombined via component-wise independent simulated binary crossover. See Deb (1995) for more details.
This operator is applied to all components; It is common to apply the operator to only some randomly
chosen components, in which case the rec("cmpmaybe")
operator should
be used; see examples.
Configuration Parameters
-
n
::numeric
Non-negative distribution index of the polynomial distribution for each component. Generally spoken, the highern
, the higher the probability of creating near parent values. This may either be a scalar in which case it is applied to all input components, or a vector, in which case it must have the length of the input components and applies to components in order in which they appear in the primingParamSet
. Initialized to 1.
Supported Operand Types
Supported Domain
classes are: p_int
('ParamInt'), p_dbl
('ParamDbl')
Dictionary
This Recombinator
can be created with the short access form rec()
(recs()
to get a list), or through the the dictionary
dict_recombinators
in the following way:
# preferred: rec("sbx") recs("sbx") # takes vector IDs, returns list of Recombinators # long form: dict_recombinators$get("sbx")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Recombinator
-> miesmuschel::RecombinatorPair
-> RecombinatorSimulatedBinaryCrossover
Methods
Public methods
Inherited methods
Method new()
Initialize the RecombinatorSimulatedBinaryCrossover
object.
Usage
RecombinatorSimulatedBinaryCrossover$new(keep_complement = TRUE)
Arguments
keep_complement
(
logical(1)
)
Whether the operation should keep both resulting individuals (TRUE
), or only the first and discard the complement (FALSE
). DefaultTRUE
. The$keep_complement
field will reflect this value.
Method clone()
The objects of this class are cloneable with this method.
Usage
RecombinatorSimulatedBinaryCrossover$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
References
Deb, Kalyanmoy, Agrawal, Bhushan R, others (1995). “Simulated binary crossover for continuous search space.” Complex systems, 9(2), 115–148.
See Also
Other recombinators:
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
dict_recombinators_cmpmaybe
,
dict_recombinators_convex
,
dict_recombinators_cvxpair
,
dict_recombinators_maybe
,
dict_recombinators_null
,
dict_recombinators_proxy
,
dict_recombinators_sequential
,
dict_recombinators_swap
,
dict_recombinators_xonary
,
dict_recombinators_xounif
Examples
set.seed(1)
rsbx = rec("cmpmaybe", rec("sbx"), p = 0.5)
p = ps(x = p_dbl(-5, 5), y = p_dbl(-5, 5), z = p_dbl(-5, 5))
data = data.frame(x = 0:5, y = 0:5, z = 0:5)
rsbx$prime(p)
rsbx$operate(data)
rsbx = rec("sbx", n = c(0.5, 1, 10))
rsbx$prime(p)
rsbx$operate(data)
Run Multiple Recombinator Operations in Sequence
Description
Recombinator
that wraps multiple other Recombinator
s given during construction and uses them for mutation in sequence.
When subsequent Recombinator
s have mismatching n_indivs_out
/ n_indivs_in
, then RecombinatorSequential
tries to
match them by running them multiple times. If e.g. recombinators[[1]]$n_indivs_out
is 2 and recombinators[[2]]$n_indivs_in
is 1, then
recombinators[[2]]
is run twice, once for each output of recombinators[[1]]
.
When the allow_lcm_packing
argument is FALSE
, then an error is given if neither n_indivs_out
of a Recombinator
divides n_indivs_in
of the
following Recombinator
, nor n_indivs_in
of the latter divides n_indivs_out
of the former even when considering that the former is run multiple times.
If allow_lcm_packing
is TRUE
, then both recombinators are run multiple times, according to the lowest common multiple ("lcm")
of the two.
However, allow_lcm_packing
can lead to very large values of n_indivs_in
/ n_indivs_out
, so it may instead be preferred to add RecombinatorNull
objects
with fitting n_indivs_in
/ n_indivs_out
values to match subsequent recombinators.
Configuration Parameters
This operator has the configuration parameters of the Recombinator
s that it wraps: The configuration parameters of the operator given to the recombinators
construction
argument are prefixed with "recombinator_1"
, "recombinator_2"
, ... up to "recombinator_#"
, where #
is length(recombinators)
.
Additional configuration parameters:
-
shuffle_between
::logical(1)
Whether to reordervalues
between invocations of recombinators. Initialized toTRUE
.
Supported Operand Types
Supported Domain
classes are the set intersection of supported classes of the Recombinator
s given in recombinators
.
Dictionary
This Recombinator
can be created with the short access form rec()
(recs()
to get a list), or through the the dictionary
dict_recombinators
in the following way:
# preferred: rec("sequential", <recombinators>) recs("sequential", <recombinators>) # takes vector IDs, returns list of Recombinators # long form: dict_recombinators$get("sequential", <recombinators>)
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Recombinator
-> RecombinatorSequential
Active bindings
recombinators
(
list
ofRecombinator
)
Recombinator
s being wrapped. These operators get run sequentially in order.allow_lcm_packing
(
logical(1)
)
Whether to allow lowest common multiple packing.
Methods
Public methods
Inherited methods
Method new()
Initialize the RecombinatorSequential
object.
Usage
RecombinatorSequential$new(recombinators, allow_lcm_packing = FALSE)
Arguments
recombinators
(
list
ofRecombinator
)
Recombinator
s to wrap. The operations are run in order given torecombinators
. The constructed object gets a clone of this argument. The$recombinators
field will reflect this value.allow_lcm_packing
(
logical(1)
)
Whether to allow lowest common multiple packing. DefaultFALSE
. The$allow_lcm_packing
field will reflect this value.
Method prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operators
given to recombinator
and recombinator_not
during construction.
Usage
RecombinatorSequential$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
RecombinatorSequential$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other recombinators:
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
dict_recombinators_cmpmaybe
,
dict_recombinators_convex
,
dict_recombinators_cvxpair
,
dict_recombinators_maybe
,
dict_recombinators_null
,
dict_recombinators_proxy
,
dict_recombinators_sbx
,
dict_recombinators_swap
,
dict_recombinators_xonary
,
dict_recombinators_xounif
Other recombinator wrappers:
OperatorCombination
,
dict_recombinators_cmpmaybe
,
dict_recombinators_maybe
,
dict_recombinators_proxy
Examples
set.seed(1)
ds = data.frame(a = c(0, 1), b = c(0, 1))
p = ps(a = p_dbl(0, 1), b = p_dbl(0, 1))
convex = rec("cvxpair", lambda = 0.7)
swap = rec("swap")
convex_then_swap = rec("sequential", list(convex, swap))
ds
convex$prime(p)$operate(ds)
swap$prime(p)$operate(ds)
convex_then_swap$prime(p)$operate(ds)
Swap Recombinator
Description
Values between two individuals are exchanged. This is relatively useless as an operator by itself, but is used
in combination with RecombinatorCmpMaybe
to get a recombinator that is crossing over individuals
uniformly at random. Because this is such a frequently-used operation, the RecombinatorCrossoverUniform
pseudo-class
exists as a shortcut.
Configuration Parameters
None.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Recombinator
can be created with the short access form rec()
(recs()
to get a list), or through the the dictionary
dict_recombinators
in the following way:
# preferred: rec("swap") recs("swap") # takes vector IDs, returns list of Recombinators # long form: dict_recombinators$get("swap")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Recombinator
-> miesmuschel::RecombinatorPair
-> RecombinatorSwap
Methods
Public methods
Inherited methods
Method new()
Initialize the RecombinatorCrossoverSwap
object.
Usage
RecombinatorSwap$new(keep_complement = TRUE)
Arguments
keep_complement
(
logical(1)
)
Whether the operation should keep both resulting individuals (TRUE
), or only the first and discard the complement (FALSE
). DefaultTRUE
. The$keep_complement
field will reflect this value.
Method clone()
The objects of this class are cloneable with this method.
Usage
RecombinatorSwap$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other recombinators:
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
dict_recombinators_cmpmaybe
,
dict_recombinators_convex
,
dict_recombinators_cvxpair
,
dict_recombinators_maybe
,
dict_recombinators_null
,
dict_recombinators_proxy
,
dict_recombinators_sbx
,
dict_recombinators_sequential
,
dict_recombinators_xonary
,
dict_recombinators_xounif
Examples
set.seed(1)
rs = rec("swap")
p = ps(x = p_int(-5, 5), y = p_dbl(-5, 5), z = p_dbl(-5, 5))
data = data.frame(x = 0:5, y = 0:5, z = 0:5)
rs$prime(p)
rs$operate(data)
rx = rec("cmpmaybe", rec("swap"), p = 0.5) # the same as 'rec("xounif")'
rx$prime(p)
rx$operate(data)
N-ary Crossover Recombinator
Description
Values are chosen componentwise independently at random from multiple individuals.
The number of individuals must be determined during construction as n_indivs_in
.
The number of output individuals is always 1, i.e. n_indivs_in
are used to create one output value. When using this
recombinator in a typical EA setting, e.g. with mies_generate_offspring
, it is therefore recommended to use a parent-selector
where the expected quality of selected parents does not depend on the number of parents selected when n_indivs_in
is large:
sel("tournament")
is preferred to sel("best")
.
Configuration Parameters
-
p
::numeric
|matrix
Sampling weights these are normalized to sum to 1 internally. Must either be a vector of lengthn_indivs_in
, or a matrix withn_indivs_in
rows and as many columns as there are components in the values being operated on. Must be non-negative, at least one value per column must be greater than zero, but it is not necessary that they sum to 1.
Initialized torep(1, n_indivs_in)
, i.e. uniform sampling from all individuals being operated on.
Supported Operand Types
Supported Domain
classes are: p_dbl
('ParamDbl')
Dictionary
This Recombinator
can be created with the short access form rec()
(recs()
to get a list), or through the the dictionary
dict_recombinators
in the following way:
# preferred: rec("convex") recs("convex") # takes vector IDs, returns list of Recombinators # long form: dict_recombinators$get("convex")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Recombinator
-> RecombinatorCrossoverNary
Methods
Public methods
Inherited methods
Method new()
Initialize the RecombinatorConvex
object.
Usage
RecombinatorCrossoverNary$new(n_indivs_in = 2)
Arguments
n_indivs_in
(
integer(1)
)
Number of individuals to consider at the same time. When operating, the number of input individuals must be divisible by this number. Default 2.
The$n_indivs_in
field will reflect this value.
Method clone()
The objects of this class are cloneable with this method.
Usage
RecombinatorCrossoverNary$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other recombinators:
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
dict_recombinators_cmpmaybe
,
dict_recombinators_convex
,
dict_recombinators_cvxpair
,
dict_recombinators_maybe
,
dict_recombinators_null
,
dict_recombinators_proxy
,
dict_recombinators_sbx
,
dict_recombinators_sequential
,
dict_recombinators_swap
,
dict_recombinators_xounif
Examples
set.seed(1)
rxon = rec("xonary", n_indivs_in = 3)
p = ps(x = p_dbl(-5, 5), y = p_dbl(-5, 5), z = p_dbl(-5, 5))
data = data.frame(x = 0:5, y = 0:5, z = 0:5)
rxon$prime(p)
rxon$operate(data) # uniform sampling from groups of 3
rxon = rec("xonary", 3, p = c(0, 1, 2))$prime(p)
# for groups of 3, take with probability 1/3 from 2nd and with probability 2/3 from 3rd row
rxon$operate(data)
pmat = matrix(c(0, 1, 2, 1, 1, 1, 1, 0, 0), ncol = 3)
pmat
rxon = rec("xonary", 3, p = pmat)$prime(p)
rxon$operate(data) # componentwise different operation
Crossover Recombinator
Description
Values between two individuals are exchanged with component-wise independent probability.
This is a pseudo-class: It does not create a single R6-object of a class;
instead, it creates the object rec("cmpmaybe", rec("swap"), p = 0.5)
,
making use of the RecombinatorCmpMaybe
and RecombinatorSwap
operators.
Usage
RecombinatorCrossoverUniform(keep_complement = TRUE)
Arguments
keep_complement |
( |
Value
an object of class Recombinator
: rec("cmpmaybe", rec("swap"))
.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Recombinator
can be created with the short access form rec()
(recs()
to get a list), or through the the dictionary
dict_recombinators
in the following way:
# preferred: rec("xounif") recs("xounif") # takes vector IDs, returns list of Recombinators # long form: dict_recombinators$get("xounif")
See Also
Other recombinators:
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
dict_recombinators_cmpmaybe
,
dict_recombinators_convex
,
dict_recombinators_cvxpair
,
dict_recombinators_maybe
,
dict_recombinators_null
,
dict_recombinators_proxy
,
dict_recombinators_sbx
,
dict_recombinators_sequential
,
dict_recombinators_swap
,
dict_recombinators_xonary
Examples
set.seed(1)
rx = rec("xounif")
print(rx)
p = ps(x = p_int(-5, 5), y = p_dbl(-5, 5), z = p_dbl(-5, 5))
data = data.frame(x = 0:5, y = 0:5, z = 0:5)
rx$prime(p)
rx$operate(data)
rx$param_set$values$p = 0.3
rx$operate(data)
Dictionary of Scalors
Description
Dictionary of Scalors
Usage
dict_scalors
Format
An object of class DictionaryScalor
(inherits from DictionaryEx
, Dictionary
, R6
) of length 15.
Methods
Methods inherited from Dictionary
, as well as:
-
help(key, help_type)
(character(1)
,character(1)
)
Displays help for the dictionary entrykey
.help_type
is one of"text"
,"html"
,"pdf"
and given as thehelp_type
argument of R'shelp()
.
See Also
Other dictionaries:
dict_filtors
,
dict_mutators
,
dict_recombinators
,
dict_selectors
,
mut()
Scalor giving Weighted Sum of Multiple Scalors
Description
Scalor
that applies multiple other Scalor
s and calculates their weighted sum.
Configuration Parameters
This operation has the configuration parameters of the Scalor
s that it wraps: The configuration
parameters of the operator given to the scalors
construction argument are prefixed with "scalor_1"
,
"scalor_2"
, ... up to "scalor_#"
, where #
is length(scalors)
.
Additional configuration parameters:
-
weight_1
,weight_2
, ... ::numeric(1)
Weight factors ofscalors[[1]]
,scalors[[2]]
, etc. Depending onscaling
, the outputs ofscalors
is multiplied with this (whenscaling
is"linear"
or"rank"
), or ties between ranks are broken with it (whenscaling
is"tiebreak"
). Initialized to 1. -
scaling
::character(1)
How to calculate output values, one of"linear"
,"rank"
or"tiebreak"
. Whenscaling
is"linear"
, then the output is calculated as the weighted sum of the outputs ofscalors
, weighted byweight_1
,weight_2
etc. Whenscaling
is"rank"
, then the output is calculated as the weighted sum of therank()
ofscalors
, weighted byweight_1
,weight_2
etc., with ties broken by average. Whenscaling
is"tiebreak"
, then the output is calculated as the averagedrank()
of thescalors
with the highestweight_#
, with ties broken by the averagerank()
of the second highestweight_#
, with remaining ties broken byscalors
with third highestweight_#
etc. Initialized to"linear"
. -
scale_output
::logical(1)
Whether to scale the output to lie between 0 and 1. Initialized toFALSE
.
Dictionary
This Scalor
can be created with the short access form scl()
(scls()
to get a list), or through the the dictionary
dict_scalors
in the following way:
# preferred: scl("aggregate", <scalors>) scls("aggregate", <scalors>) # takes vector IDs, returns list of Scalors # long form: dict_scalors$get("aggregate", <scalors>)
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Scalor
-> ScalorAggregate
Active bindings
Methods
Public methods
Inherited methods
Method new()
Initialize the ScalorAggregate
object.
Usage
ScalorAggregate$new(scalors)
Arguments
Method prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operators
given to scalors
during construction.
Usage
ScalorAggregate$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
ScalorAggregate$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other scalors:
Scalor
,
dict_scalors_domcount
,
dict_scalors_fixedprojection
,
dict_scalors_hypervolume
,
dict_scalors_nondom
,
dict_scalors_one
,
dict_scalors_proxy
,
dict_scalors_single
Other scalor wrappers:
dict_scalors_fixedprojection
,
dict_scalors_proxy
Examples
p = ps(x = p_dbl(-5, 5))
data = data.frame(x = rep(0, 5))
sa = scl("aggregate", list(
scl("one", objective = 1),
scl("one", objective = 2)
))
sa$prime(p)
(fitnesses = matrix(c(1, 5, 2, 3, 0, 3, 1, 0, 10, 8), ncol = 2))
# to see the fitness matrix, use:
## plot(fitnesses, pch = as.character(1:5))
# default weight 1 -- sum of both objectives
sa$operate(data, fitnesses)
# only first objective
sa$param_set$values[c("weight_1", "weight_2")] = c(1, 0)
sa$operate(data, fitnesses)
# only 2 * second objective
sa$param_set$values[c("weight_1", "weight_2")] = c(0, 2)
sa$operate(data, fitnesses)
Scalor Counting Dominating Individuals
Description
Scalor
that returns a the number of (weakly, epsilon-) dominated or dominating individuals for each individuum.
Configuration Parameters
-
output
::character(1)
What to count: individuals that are being dominated by the point under consideration("count_dominated"
), or individuals that do not dominate the point under consideration ("count_not_dominating"
). In both cases, a larger output means the individual is "better", in some way, according to the fitness values. Initialized with"count_not_dominating"
. -
epsilon
::numeric
Epsilon-value for non-dominance, as used byrank_nondominated
. Initialized to0
. -
jitter
::logical(1)
Whether to add random jitter to points, with magnitudesqrt(.Machine$double.eps)
relative to fitness values. This is used to effectively break ties. -
scale_output
::logical(1)
Whether to scale output by the total numberof individuals, giving output between0
and1
(inclusive) whenTRUE
or integer outputs ranging from 0 andnrow(fitnesses)
(inclusive) whenFALSE
. Initialized toTRUE
.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Scalor
can be created with the short access form scl()
(scls()
to get a list), or through the the dictionary
dict_scalors
in the following way:
# preferred: scl("domcount") scls("domcount") # takes vector IDs, returns list of Scalors # long form: dict_scalors$get("domcount")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Scalor
-> ScalorDomcount
Methods
Public methods
Inherited methods
Method new()
Initialize the ScalorNondom
object.
Usage
ScalorDomcount$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
ScalorDomcount$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other scalors:
Scalor
,
dict_scalors_aggregate
,
dict_scalors_fixedprojection
,
dict_scalors_hypervolume
,
dict_scalors_nondom
,
dict_scalors_one
,
dict_scalors_proxy
,
dict_scalors_single
Examples
p = ps(x = p_dbl(-5, 5))
data = data.frame(x = rep(0, 5))
sd = scl("domcount")
sd$prime(p)
(fitnesses = matrix(c(1, 5, 2, 3, 0, 3, 1, 0, 10, 8), ncol = 2))
# to see the fitness matrix, use:
## plot(fitnesses, pch = as.character(1:5))
# note that for both 2 and 4, all points do not dominate them
# their value is therefore 1
sd$operate(data, fitnesses)
sd$param_set$values$scale_output = FALSE
sd$operate(data, fitnesses)
sd$param_set$values$output = "count_dominated"
# point 4 dominates three other points, point 2 only one other point.
sd$operate(data, fitnesses)
Multi-Objective Fixed Projection Scalor
Description
Scalor
that returns the maximum of a set of projections.
Priming PS must contain a "scalarization_weights"
tagged p_uty
that contains
weight matrices (Nobjectives x Nweights) or vectors (if Nweights is 1).
Configuration Parameters
-
scalarization
::function
Function taking a fitness-matrixfitnesses
(Nindivs x Nobjectives, with higher values indicating higher desirability) and a list of weight matricesweights
(Nindivs elements of Nobjectives x Nweights matrices; positive weights should indicate a positive contribution to scale) and returns a matrix of scalarizations (Nindivs x Nweights, with higher values indicating greater desirability).
While custom functions can be used, it is recommended to use aScalarizer
, such asscalarizer_linear()
, orscalarizer_chebyshev()
.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Scalor
can be created with the short access form scl()
(scls()
to get a list), or through the the dictionary
dict_scalors
in the following way:
# preferred: scl("fixedprojection") scls("fixedprojection") # takes vector IDs, returns list of Scalors # long form: dict_scalors$get("fixedprojection")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Scalor
-> ScalorFixedProjection
Active bindings
weights_component_id
(
numeric(1)
)
search space component identifying the weights by which to scalarize.
Methods
Public methods
Inherited methods
Method new()
Initialize the ScalorFixedProjection
object.
Usage
ScalorFixedProjection$new(weights_component_id = "scalarization_weights")
Arguments
weights_component_id
(
character(1)
)
Id of the search space component identifying the weights by which to scalarize. Default"scalarization_weights"
.
Method prime()
See MiesOperator
method. Primes both this operator, as well as the operator given to the operation
configuration parameter.
Note that this modifies the $param_set$values$operation
object.
Usage
ScalorFixedProjection$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
ScalorFixedProjection$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other scalors:
Scalor
,
dict_scalors_aggregate
,
dict_scalors_domcount
,
dict_scalors_hypervolume
,
dict_scalors_nondom
,
dict_scalors_one
,
dict_scalors_proxy
,
dict_scalors_single
Other scalor wrappers:
dict_scalors_aggregate
,
dict_scalors_proxy
Examples
set.seed(1)
Hypervolume Scalor
Description
Scalor
that returns the hypervolume of each individual, relative to nadir
and as a contribution over baseline
.
The returned scalar value is the measure of all points that have fitnesses that are
greater than the respective value in
nadir
in all dimensions, andsmaller than the respective value in the given point in all dimensions, and
greater than all points in
baseline
in at least one dimension.
baseline
should probably be a paradox::ContextPV
and generate fitness values from the Archive
in the context using mies_get_fitnesses
.
Configuration Parameters
-
scale_output
::logical(1)
Whether to scale output to lie between 0 and 1. -
nadir
::numeric
Nadir of fitness values relative to which hypervolume ution is calculated. -
baseline
::matrix
Fitness-matrix with one column per objective, giving a population over which the hypervolume improvement should be calculated.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Scalor
can be created with the short access form scl()
(scls()
to get a list), or through the the dictionary
dict_scalors
in the following way:
# preferred: scl("hypervolume") scls("hypervolume") # takes vector IDs, returns list of Scalors # long form: dict_scalors$get("hypervolume")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Scalor
-> ScalorHypervolume
Methods
Public methods
Inherited methods
Method new()
Initialize the ScalorHypervolume
object.
Usage
ScalorHypervolume$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
ScalorHypervolume$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other scalors:
Scalor
,
dict_scalors_aggregate
,
dict_scalors_domcount
,
dict_scalors_fixedprojection
,
dict_scalors_nondom
,
dict_scalors_one
,
dict_scalors_proxy
,
dict_scalors_single
Examples
sv = scl("hypervolume")
p = ps(x = p_dbl(-5, 5))
# dummy data; note that ScalorHV does not depend on data content
data = data.frame(x = rep(0, 5))
fitnesses = matrix(c(1, 5, 2, 3, 0, 3, 1, 0, 10, 8), ncol = 2)
sv$param_set$values$baseline = matrix(c(1, 1), ncol = 2)
sv$param_set$values$nadir = c(0, -1)
sv$prime(p)
sv$operate(data, fitnesses)
Nondominated Sorting Scalor
Description
Scalor
that returns a the rank of the pareto-front in nondominated sorting as scale. Higher ranks
indocate higher fitnesses and therefore "better" individuals.
Configuration Parameters
-
epsilon
-
nadir
-
jitter
-
scale_output
-
tiebreak
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Scalor
can be created with the short access form scl()
(scls()
to get a list), or through the the dictionary
dict_scalors
in the following way:
# preferred: scl("nondom") scls("nondom") # takes vector IDs, returns list of Scalors # long form: dict_scalors$get("nondom")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Scalor
-> ScalorNondom
Methods
Public methods
Inherited methods
Method new()
Initialize the ScalorNondom
object.
Usage
ScalorNondom$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
ScalorNondom$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other scalors:
Scalor
,
dict_scalors_aggregate
,
dict_scalors_domcount
,
dict_scalors_fixedprojection
,
dict_scalors_hypervolume
,
dict_scalors_one
,
dict_scalors_proxy
,
dict_scalors_single
Examples
so = scl("nondom")
p = ps(x = p_dbl(-5, 5))
# dummy data; note that ScalorNondom does not depend on data content
data = data.frame(x = rep(0, 5))
fitnesses = matrix(c(1, 5, 2, 3, 0, 3, 1, 0, 10, 8), ncol = 2)
so$prime(p)
so$operate(data, fitnesses)
Single Dimension Scalor
Description
Scalor
that returns a the fitness value of a single objective dimension as scale.
Configuration Parameters
-
objective
::integer(1)
objective to return as scale, ranges from 1 (the default, first objective) to the number of objectives of the function being optimized.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Scalor
can be created with the short access form scl()
(scls()
to get a list), or through the the dictionary
dict_scalors
in the following way:
# preferred: scl("one") scls("one") # takes vector IDs, returns list of Scalors # long form: dict_scalors$get("one")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Scalor
-> ScalorOne
Methods
Public methods
Inherited methods
Method new()
Initialize the ScalorOne
object.
Usage
ScalorOne$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
ScalorOne$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other scalors:
Scalor
,
dict_scalors_aggregate
,
dict_scalors_domcount
,
dict_scalors_fixedprojection
,
dict_scalors_hypervolume
,
dict_scalors_nondom
,
dict_scalors_proxy
,
dict_scalors_single
Examples
so = scl("one")
p = ps(x = p_dbl(-5, 5))
# dummy data; note that ScalorOne does not depend on data content
data = data.frame(x = rep(0, 5))
fitnesses = matrix(c(1, 5, 2, 3, 0, 3, 1, 0, 10, 8), ncol = 2)
so$prime(p)
so$operate(data, fitnesses)
so$param_set$values$objective = 2
so$operate(data, fitnesses)
Proxy-Scalor that Scales According to its Configuration parameter
Description
Scalor
that performs the operation in its operation
configuration parameter. This is useful, e.g., to make
SelectorBest
's operation fully parametrizable.
Configuration Parameters
-
operation
::Scalor
Operation to perform. Initialized toScalorSingleObjective
. This is primed when$prime()
ofScalorProxy
is called, and also when$operate()
is called, to make changing the operation as part of self-adaption possible. However, if the same operation gets used inside multipleScalorProxy
objects, then it is recommended to$clone(deep = TRUE)
the object before assigning them tooperation
to avoid frequent re-priming.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Scalor
can be created with the short access form scl()
(scls()
to get a list), or through the the dictionary
dict_scalors
in the following way:
# preferred: scl("proxy") scls("proxy") # takes vector IDs, returns list of Scalors # long form: dict_scalors$get("proxy")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Scalor
-> ScalorProxy
Methods
Public methods
Inherited methods
Method new()
Initialize the ScalorProxy
object.
Usage
ScalorProxy$new()
Method prime()
See MiesOperator
method. Primes both this operator, as well as the operator given to the operation
configuration parameter.
Note that this modifies the $param_set$values$operation
object.
Usage
ScalorProxy$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
ScalorProxy$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other scalors:
Scalor
,
dict_scalors_aggregate
,
dict_scalors_domcount
,
dict_scalors_fixedprojection
,
dict_scalors_hypervolume
,
dict_scalors_nondom
,
dict_scalors_one
,
dict_scalors_single
Other scalor wrappers:
dict_scalors_aggregate
,
dict_scalors_fixedprojection
Examples
set.seed(1)
sp = scl("proxy")
p = ps(x = p_dbl(-5, 5))
# dummy data; note that ScalorOne does not depend on data content
data = data.frame(x = rep(0, 5))
fitnesses = c(1, 5, 2, 3, 0)
sp$param_set$values$operation = scl("one")
sp$prime(p)
sp$operate(data, fitnesses)
Single Objective Scalor
Description
Scalor
that uses a single given objective, throwing an error in case it is used in a multi-objective problem.
In contrast to ScalorOne
, this Scalor
throws an error when more than one objective is present. When
this Scalor
gets used as the default value, e.g. for a Selector
, then it
forces the user to make an explicit decision about what Scalor
to use in a multi-objective setting.
Configuration Parameters
No configuration parameters.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Scalor
can be created with the short access form scl()
(scls()
to get a list), or through the the dictionary
dict_scalors
in the following way:
# preferred: scl("single") scls("single") # takes vector IDs, returns list of Scalors # long form: dict_scalors$get("single")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Scalor
-> ScalorSingleObjective
Methods
Public methods
Inherited methods
Method new()
Initialize the ScalorSingleObjective
object.
Usage
ScalorSingleObjective$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
ScalorSingleObjective$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other scalors:
Scalor
,
dict_scalors_aggregate
,
dict_scalors_domcount
,
dict_scalors_fixedprojection
,
dict_scalors_hypervolume
,
dict_scalors_nondom
,
dict_scalors_one
,
dict_scalors_proxy
Examples
ss = scl("single")
p = ps(x = p_dbl(-5, 5))
# dummy data; note that ScalorOne does not depend on data content
data = data.frame(x = rep(0, 5))
fitnesses_so = c(1, 5, 2, 3, 0)
fitnesses_mo = matrix(c(1, 5, 2, 3, 0, 3, 1, 0, 10, 8), ncol = 2)
ss$prime(p)
ss$operate(data, fitnesses_so)
try(ss$operate(data, fitnesses_mo))
Dictionary of Selectors
Description
Dictionary of Selectors
Usage
dict_selectors
Format
An object of class DictionarySelector
(inherits from DictionaryEx
, Dictionary
, R6
) of length 15.
Methods
Methods inherited from Dictionary
, as well as:
-
help(key, help_type)
(character(1)
,character(1)
)
Displays help for the dictionary entrykey
.help_type
is one of"text"
,"html"
,"pdf"
and given as thehelp_type
argument of R'shelp()
.
See Also
Other dictionaries:
dict_filtors
,
dict_mutators
,
dict_recombinators
,
dict_scalors
,
mut()
Best Value Selector
Description
Selector
that selects the top n_select
individuals based on the fitness value, breaking ties randomly. When n_select
is larger than the number
of individuals, the selection wraps around: All nrow(values)
individuals are selected at least floor(nrow(values) / n_select)
times, with the top nrow(values) %% n_select
individuals being selected one more time.
Configuration Parameters
-
shuffle_selection
::logical(1)
Whether to shuffle the selected output. When this isTRUE
, selected individuals are returned in random order, so when this operator is e.g. used inmies_generate_offspring()
, then subsequent recombination operators effectively operate on pairs (or larger groups) of random individuals. Otherwise they are returned in order, and recombination operates on the first batch ofn_indivs_in
returned individuals first, then the second batch etc. in order. Initialized toTRUE
(recommended).
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Selector
can be created with the short access form sel()
(sels()
to get a list), or through the the dictionary
dict_selectors
in the following way:
# preferred: sel("best") sels("best") # takes vector IDs, returns list of Selectors # long form: dict_selectors$get("best")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Selector
-> miesmuschel::SelectorScalar
-> SelectorBest
Methods
Public methods
Inherited methods
Method new()
Initialize the SelectorBest
object.
Usage
SelectorBest$new(scalor = ScalorSingleObjective$new())
Arguments
scalor
(
Scalor
)
Scalor
to use to generate scalar values from multiple objectives, if multi-objective optimization is performed. Initialized toScalorSingleObjective
: Doing single-objective optimization normally, throwing an error if used in multi-objective setting: In that case, aScalor
needs to be explicitly chosen.
Method clone()
The objects of this class are cloneable with this method.
Usage
SelectorBest$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other selectors:
Selector
,
SelectorScalar
,
dict_selectors_maybe
,
dict_selectors_null
,
dict_selectors_proxy
,
dict_selectors_random
,
dict_selectors_sequential
,
dict_selectors_tournament
Examples
sb = sel("best")
p = ps(x = p_dbl(-5, 5))
# dummy data; note that SelectorBest does not depend on data content
data = data.frame(x = rep(0, 5))
fitnesses = c(1, 5, 2, 3, 0)
sb$prime(p)
sb$operate(data, fitnesses, 2)
sb$param_set$values$shuffle_selection = FALSE
sb$operate(data, fitnesses, 4)
Selector-Combination that Selects According to Two Selectors
Description
Selector
that wraps two other Selector
s given during construction and uses both for selection proportionally.
Each of the resulting n_select
individuals is chosen either from $selector
, or from $selector_not
.
This makes it possible to implement selection methods such as random interleaving, where only a fraction of p
individuals were selected by a criterion, while the others are taken randomly.
Algorithm
To perform selection, n_selector_in
rows of values
are given to $selector
, and the remaining
nrow(values) - n_selector_in
rows are given to $selector_not
. Both selectors are used to generate
a subset of selected individuals: $selector
generates n_selector_out
individuals, and $selector_not
generates
n_select - n_selector_out
individuals.
n_selector_in
is either set to
round(nrow(values) * p_in)
when proportion_in
is "exact"
, or to rbinom(1, nrow(values), p_in)
when proportion_in
is "random"
.
n_selector_out
is set to round(n_select * p_out)
when proportion_out
is "exact"
, or to rbinom(1, n_select, p_out)
when proportion_out
is "random"
.
When odds_correction
is TRUE
, then p_out
is adjusted depending on the used n_selector_in
value before being applied. Let odds(p) = p/(1-p)
.
Then the effective p_out
is set such that odds(effective p_out) = odds(p_out) * n_selector_in / (nrow(values) - n_selector_in) / odds(p_in)
.
This corrects for the discrepancy between the chosen p_in
and the effective proportion of n_selector_in / nrow(values)
caused either by rounding
errors or when proportion_in
is "random"
.
When p_in
is exactly 1 or exactly 0, and p_out
is not equal to p_in
, then an error is given.
If nrow(values)
is 1, then this individuum is returned and $selector
/ $selector_not
are not called.
If try_unique
is TRUE
, then n_selector_out
is set to at most n_selector_in
and at least n_select - nrow(values) + n_selector_in
,
and an error is generated when nrow(values)
is less than n_select
.
If try_unique
is FALSE
and odds_correction
is TRUE
and n_selector_in
is either 0 or nrow(values)
, then $p_out
is set to either 0 or 1, respectively.
If try_unique
is FALSE
and odds_correction
is FALSE
and n_selector_in
is either 0 or nrow(values)
, and n_selector_out
is not equal
to 0 or n_select
, respectively, then
n_selector_in
is increased / decreased by 1 to give $selector_not
/ $selector
at least one individuum to choose from. While this behaviour
may seem pathological, it is to ensure continuity with sampled values of n_selector_in
that are close to 0 or n_select
.
If n_selector_out
is n_select
or 0, or if n_selector_in
is nrows(values) - 1
or 1,
then only $selector
/ $selector_not
is executed, respectively; possibly with a subset
of values
if n_selector_in
differs from nrow(values)
/ 0.
Configuration Parameters
This operator has the configuration parameters of the Selector
s that it wraps: The configuration parameters of the operator given to the selector
construction argument
are prefixed with "maybe."
, the configuration parameters of the operator given to the selector_not
construction argument are prefixed with "maybe_not."
.
Additional configuration parameters:
-
p_in
::numeric(1)
Probability per individual (whenrandom_choise
isTRUE
), or fraction of individuals (whenrandom_choice
isFALSE
), that are given to$selector
instead of$selector_not
. This may be overriden whentry_unique
isTRUE
, in which case at least as many rows are given to$selector
and$selector_not
as they are generating output values respectively. When this is exactly 1 or exactly 0, thenp_out
must be equal top_in
. Must be set by the user. -
p_out
::numeric(1)
Probability per output value (whenrandom_choise
isTRUE
), or fraction of output values (whenrandom_choice
isFALSE
), that are generated by$selector
instead of$selector_not
. When this values is not given, it defaults top_in
. -
shuffle_input
::logical(1)
Whether to distribute input values randomly to$selector
/$selector_not
. IfFALSE
, then the first part ofvalues
is given to$selector
. This only randomizes which lines ofvalues
are given to$selector
/$selector_not
, but it does not necessarily reorder the lines of values given to each. In particular, ifp_out
is 0 or 1, then no shuffling takes place. Initialized toTRUE
. -
proportion_in
::character(1)
When set to"random"
, sample the number of individuals given to$selector
according torbinom(1, nrow(values), p_in)
. When set to"exact"
, give$selector
round(nrow(values) * p_in)
individuals. Initialized to"exact"
. -
proportion_out
::character(1)
When set to"random"
, sample the number of individuals generated by$selector
according torbinom(1, n_select, p_out)
. When set to"exact"
, have$selector
generateround(n_select * p_out)
individuals. -
odds_correction
::logical(1)
When set, the effectively used value ofp_out
is set to1 / (1 + ((nrow(values) - n_selector_in) * p_in * (1 - p_out)) / (n_selector_in * p_out * (1 - p_in)))
, see the Algorithm section. Initialized toFALSE
. -
try_unique
::logical(1)
Whether to give at least as many rows ofvalues
to each of$selector
and$selector_not
as they are generating output values. This should be set toTRUE
wheneverSelectorMaybe
is used to select unique values, and can be set toFALSE
when selecting values multiple times is acceptable. When this isTRUE
, then havingn_select > nrow(values)
generates an error. Initialized toTRUE
.
Supported Operand Types
Supported Domain
classes are the set intersection of supported classes of selector
and selector_not
.
Dictionary
This Filtor
can be created with the short access form ftr()
(ftrs()
to get a list), or through the the dictionary
dict_filtors
in the following way:
# preferred: ftr("maybe", <selector> [, <selector_not>]) ftrs("maybe", <selector> [, <selector_not>]) # takes vector IDs, returns list of Filtors # long form: dict_filtors$get("maybe", <selector> [, <selector_not>])
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Selector
-> SelectorMaybe
Active bindings
selector
(
Selector
)
Selector
being wrapped. This operator gets run with probability / proportionp_in
and generates output with probability / proportionp_out
(configuration parameters).selector_not
(
Selector
)
AlternativeSelector
being wrapped. This operator gets run with probability / proportion1 - p_in
and generates output with probability / proportion1 - p_out
(configuration parameters).
Methods
Public methods
Inherited methods
Method new()
Initialize the SelectorMaybe
object.
Usage
SelectorMaybe$new(selector, selector_not = SelectorRandom$new())
Arguments
selector
(
Selector
)
Selector
to wrap. This operator gets run with probability / fractionp_in
(Configuration parameter).
The constructed object gets a clone of this argument. The$selector
field will reflect this value.selector_not
(
Selector
)
AnotherSelector
to wrap. This operator runs whenselector
is not chosen. By default, this isSelectorRandom
, i.e. selecting randomly.
The constructed object gets a clone of this argument. The$selector_not
field will reflect this value.
Method prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operators
given to selector
and selector_not
during construction.
Usage
SelectorMaybe$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
SelectorMaybe$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other selectors:
Selector
,
SelectorScalar
,
dict_selectors_best
,
dict_selectors_null
,
dict_selectors_proxy
,
dict_selectors_random
,
dict_selectors_sequential
,
dict_selectors_tournament
Other selector wrappers:
dict_selectors_proxy
,
dict_selectors_sequential
Null Selector
Description
Selector
that disregards fitness and individual values and selects individuals by order in which they are given.
Configuration Parameters
-
shuffle_selection
::logical(1)
Whether to shuffle the selected output. When this isTRUE
, selected individuals are returned in random order, so when this operator is e.g. used inmies_generate_offspring()
, then subsequent recombination operators effectively operate on pairs (or larger groups) of random individuals. Otherwise they are returned in order, and recombination operates on the first batch ofn_indivs_in
returned individuals first, then the second batch etc. in order. Initialized toTRUE
(recommended).
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Selector
can be created with the short access form sel()
(sels()
to get a list), or through the the dictionary
dict_selectors
in the following way:
# preferred: sel("null") sels("null") # takes vector IDs, returns list of Selectors # long form: dict_selectors$get("null")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Selector
-> SelectorNull
Methods
Public methods
Inherited methods
Method new()
Initialize the SelectorNull
object.
Usage
SelectorNull$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
SelectorNull$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other selectors:
Selector
,
SelectorScalar
,
dict_selectors_best
,
dict_selectors_maybe
,
dict_selectors_proxy
,
dict_selectors_random
,
dict_selectors_sequential
,
dict_selectors_tournament
Examples
sn = sel("null")
p = ps(x = p_dbl(-5, 5))
# dummy data; note that SelectorNull does not depend on data content
data = data.frame(x = rep(0, 5))
fitnesses = c(1, 5, 2, 3, 0)
sn$prime(p)
sn$operate(data, fitnesses, 2)
sn$operate(data, fitnesses, 4)
sn$operate(data, fitnesses, 6)
Proxy-Selector that Selects According to its Configuration Parameter
Description
Selector
that performs the operation in its operation
configuration parameter. This is useful, e.g., to make
OptimizerMies
's selection operations fully parametrizable.
Configuration Parameters
-
operation
::Selector
Operation to perform. Initialized toSelectorBest
. This is primed when$prime()
ofSelectorProxy
is called, and also when$operate()
is called, to make changing the operation as part of self-adaption possible. However, if the same operation gets used inside multipleSelectorProxy
objects, then it is recommended to$clone(deep = TRUE)
the object before assigning them tooperation
to avoid frequent re-priming.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Selector
can be created with the short access form sel()
(sels()
to get a list), or through the the dictionary
dict_selectors
in the following way:
# preferred: sel("proxy") sels("proxy") # takes vector IDs, returns list of Selectors # long form: dict_selectors$get("proxy")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Selector
-> SelectorProxy
Methods
Public methods
Inherited methods
Method new()
Initialize the SelectorProxy
object.
Usage
SelectorProxy$new()
Method prime()
See MiesOperator
method. Primes both this operator, as well as the operator given to the operation
configuration parameter.
Note that this modifies the $param_set$values$operation
object.
Usage
SelectorProxy$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
SelectorProxy$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other selectors:
Selector
,
SelectorScalar
,
dict_selectors_best
,
dict_selectors_maybe
,
dict_selectors_null
,
dict_selectors_random
,
dict_selectors_sequential
,
dict_selectors_tournament
Other selector wrappers:
dict_selectors_maybe
,
dict_selectors_sequential
Examples
set.seed(1)
sp = sel("proxy")
p = ps(x = p_dbl(-5, 5))
# dummy data; note that SelectorBest does not depend on data content
data = data.frame(x = rep(0, 5))
fitnesses = c(1, 5, 2, 3, 0)
sp$param_set$values$operation = sel("random")
sp$prime(p)
sp$operate(data, fitnesses, 2)
sp$param_set$values$operation = sel("best")
sp$operate(data, fitnesses, 2)
Random Selector
Description
Random selector that disregards fitness and individual values and selects individuals randomly. Depending on the configuration parameter replace
,
it samples with or without replacement.
Configuration Parameters
-
sample_unique
::character(1)
Whether to sample individuals globally unique ("global"
), unique within groups ("groups"
), or not unique at all ("no"
, sample with replacement). This is done with best effort; ifgroup_size
(whensample_unique
is"groups"
) orn_select
(whensample_unique
is"global"
) is greater thannrow(values)
, then individuals are selected with as few repeats as possible. Initialized to"groups"
.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Selector
can be created with the short access form sel()
(sels()
to get a list), or through the the dictionary
dict_selectors
in the following way:
# preferred: sel("random") sels("random") # takes vector IDs, returns list of Selectors # long form: dict_selectors$get("random")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Selector
-> SelectorRandom
Methods
Public methods
Inherited methods
Method new()
Initialize the SelectorRandom
object.
Usage
SelectorRandom$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
SelectorRandom$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other selectors:
Selector
,
SelectorScalar
,
dict_selectors_best
,
dict_selectors_maybe
,
dict_selectors_null
,
dict_selectors_proxy
,
dict_selectors_sequential
,
dict_selectors_tournament
Examples
set.seed(1)
sr = sel("random")
p = ps(x = p_dbl(-5, 5))
# dummy data; note that SelectorRandom does not depend on data content
data = data.frame(x = rep(0, 5))
fitnesses = c(1, 5, 2, 3, 0)
sr$prime(p)
sr$operate(data, fitnesses, 2)
sr$operate(data, fitnesses, 2)
sr$operate(data, fitnesses, 2)
sr$operate(data, fitnesses, 4)
sr$operate(data, fitnesses, 4)
sr$operate(data, fitnesses, 4)
Run Multiple Selection Operations in Sequence
Description
Selector
that wraps multiple other Selector
s given during construction and uses them for selection in sequence.
This makes it possible for one Selector
to discard a few individuals, followed by a second Selector
to
discard more, etc., until n_select
individuals are remaining.
Algorithm
Given that there are nrow(values)
input individuals in an operation, and n_select
individuals requested to be selected,
the operation calls selector_i
for i
in 1 ... length(selectors)
to reduce the number of individuals in this pipeline.
The relative quantity by which the number of individuals is reduced in each step is determined by the configuration parameters
reduction_1
, reduction_2
, etc., and also dependent on the sum of these values, in the following denoted, with a slight abuse of notation, by sum[reduction_#]
.
Let the number of individuals passed to step i
be denoted by n_values[i]
, and the number of individuals requested to be
selected by that step be denoted as n_select_[i]
. In particular, n_values[1] == nrow(values)
, and n_select_[length(selectors)] == n_select
.
When reduction_by_factor
is TRUE
, then the reduction at step i
is done by a factor, meaning that n_values[i] / n_select_[i]
is set (up to rounding).
This factor is (nrow(values) / n_select) ^ (reduction_i / sum[reduction_#])
.
When reduction_by_factor
is FALSE
, then the reduction at step i
is done by absolute differences, meaning that n_values[i] - n_select_[i]
is set (up to rounding).
This difference is (nrow(values) - n_select) * (reduction_i / sum[reduction_#])
, with sum[reduction_#]
as above.
In particular, this means that when all reduction_#
values are the same and reduction_by_factor
is TRUE
, then each operation reduces the number of
individuals in the pipeline by the same factor. When reduction_by_factor
is FALSE
, then each operation removes the same absolute number of individuals.
While the illustrations are done with the assumption that nrow(values) >= n_select
, they hold equivalently with nrow(values) < n_select
.
All except the last Selector
s are called with group_size
set to their n_select
value; the last Selector
is called with the group_size
value
given as input.
Configuration Parameters
This operator has the configuration parameters of the Selector
s that it wraps: The configuration parameters of the operator given to the selectors
construction
argument are prefixed with "selector_1"
, "selector_2"
, ... up to "selector_#"
, where #
is length(selectors)
.
Additional configuration parameters:
-
reduction_1
,reduction_2
, ... ::numeric(1)
Relative reduction done byselector_1
,selector_2
, ..., as described in the section Algorithm. The values are all initialized to 1, meaning the same factor (whenreduction_by_factor
isTRUE
) or absolute number (otherwise) of reduction by each operation. -
reduction_by_factor
::logical(1)
Whether to do reduction by factor (TRUE
) or absolute number (FALSE
), as described in Algorithm. Initialized toTRUE
.
Supported Operand Types
Supported Domain
classes are the set intersection of supported classes of the Selector
s given in selectors
.
Dictionary
This Selector
can be created with the short access form sel()
(sels()
to get a list), or through the the dictionary
dict_selectors
in the following way:
# preferred: sel("sequential", <selectors>) sels("sequential", <selectors>) # takes vector IDs, returns list of Selectors # long form: dict_selectors$get("sequential", <selectors>)
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Selector
-> SelectorSequential
Active bindings
Methods
Public methods
Inherited methods
Method new()
Initialize the SelectorSequential
object.
Usage
SelectorSequential$new(selectors)
Arguments
Method prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operators
given to selectors
during construction.
Usage
SelectorSequential$prime(param_set)
Arguments
param_set
(
ParamSet
)
Passed toMiesOperator
$prime()
.
Returns
invisible self
.
Method clone()
The objects of this class are cloneable with this method.
Usage
SelectorSequential$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other selectors:
Selector
,
SelectorScalar
,
dict_selectors_best
,
dict_selectors_maybe
,
dict_selectors_null
,
dict_selectors_proxy
,
dict_selectors_random
,
dict_selectors_tournament
Other selector wrappers:
dict_selectors_maybe
,
dict_selectors_proxy
Tournament Selector
Description
Selector
that repeatedly samples k
individuals and selects the best ouf of these.
Configuration Parameters
-
k
::integer(1)
Tournament size. Must be set by the user. -
choose_per_tournament
:: Number of individuals to choose in each tournament. Must be smaller thank
. The special value0
sets this to thegroup_size
hint given to the$operate()
-call (but at mostk
). This is equal ton_select
when used as survival-selector inmies_survival_plus()
/mies_survival_comma()
, and equal ton_indivs_in
of aRecombinator
used inmies_generate_offspring()
.
Initialized to 1. -
sample_unique
::character(1)
Whether to sample individuals globally unique ("global"
, selected individuals are removed from the population after each tournament), unique within groups ("groups"
, individuals are replaced whengroup_size
individuals were sampled), unique per tournament ("tournament"
, individuals are replaced after each tournament), or not unique at all ("no"
, individuals are sampled with replacement within tournaments). This is done with best effort; ifgroup_size
(whensample_unique
is"groups"
) orn_select
(whensample_unique
is"global"
) is greater thannrow(values)
, then the firstnrow(values) * floor(group_size / nrow(values))
ornrow(values) * floor(n_select / nrow(values))
individuals are chosen deterministically by selecting every individual with the same frequency, followed by tournament selection for the remaining required individuals. Initialized to"groups"
.
Supported Operand Types
Supported Domain
classes are: p_lgl
('ParamLgl'), p_int
('ParamInt'), p_dbl
('ParamDbl'), p_fct
('ParamFct')
Dictionary
This Selector
can be created with the short access form sel()
(sels()
to get a list), or through the the dictionary
dict_selectors
in the following way:
# preferred: sel("tournament") sels("tournament") # takes vector IDs, returns list of Selectors # long form: dict_selectors$get("tournament")
Super classes
miesmuschel::MiesOperator
-> miesmuschel::Selector
-> miesmuschel::SelectorScalar
-> SelectorTournament
Methods
Public methods
Inherited methods
Method new()
Initialize the SelectorTournament
object.
Usage
SelectorTournament$new(scalor = ScalorSingleObjective$new())
Arguments
scalor
(
Scalor
)
Scalor
to use to generate scalar values from multiple objectives, if multi-objective optimization is performed. Initialized toScalorSingleObjective
: Doing single-objective optimization normally, throwing an error if used in multi-objective setting: In that case, aScalor
needs to be explicitly chosen.
Method clone()
The objects of this class are cloneable with this method.
Usage
SelectorTournament$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other selectors:
Selector
,
SelectorScalar
,
dict_selectors_best
,
dict_selectors_maybe
,
dict_selectors_null
,
dict_selectors_proxy
,
dict_selectors_random
,
dict_selectors_sequential
Examples
sb = sel("tournament", k = 4)
p = ps(x = p_dbl(-5, 5))
# dummy data; note that SelectorBest does not depend on data content
data = data.frame(x = rep(0, 7))
fitnesses = c(1, 5, 2, 3, 0, 4, 6)
sb$prime(p)
sb$operate(data, fitnesses, 2)
sb$operate(data, fitnesses, 4, group_size = 2)
Calculate Crowding Distance
Description
Takes a matrix
of fitness values and calculates the crowding distance for individuals in that matrix
.
Individuals that are minimal or maximal with respect to at least one dimension are assigned infinite crowding distance.
Individuals are assumed to be in a (epsilon-) nondominated front.
Usage
dist_crowding(fitnesses)
Arguments
fitnesses |
( |
Value
numeric
: Vector of crowding distances.
Calculate Dominated Hypervolume
Description
Use Chan's algorithm (Chan, M T (2013). “Klee's measure problem made easy.” In 2013 IEEE 54th annual symposium on foundations of computer science, 410–419. IEEE.) to calculate dominated hypervolume.
Usage
domhv(fitnesses, nadir = 0, prefilter = TRUE, on_worse_than_nadir = "warn")
Arguments
fitnesses |
( |
nadir |
( |
prefilter |
( |
on_worse_than_nadir |
( |
Value
numeric(1)
: The dominated hypervolume of individuals in fitnesses
.
Examples
(fitnesses = matrix(c(1, 5, 2, 3, 0, 3, 1, 0, 10, 8), ncol = 2))
# to see the fitness matrix, use:
## plot(fitnesses, pch = as.character(1:5))
domhv(fitnesses)
Calculate Hypervolume Contribution
Description
Takes a matrix
of fitness values and calculates the hypervolume contributions of individuals in that matrix
.
Hypervolume contribution of an individual I is the difference between the dominated hypervolume of a set of
individuals including I, where the fitness of I is increased by epsilon
, and the dominated hypervolume of
the same set but excluding I.
Individuals that are less than another individual more than epsilon
in any dimension have hypervolume contribution
of 0.
Usage
domhv_contribution(fitnesses, nadir = 0, epsilon = 0)
Arguments
fitnesses |
( |
nadir |
( |
epsilon |
( |
Value
numeric
: The vector of dominated hypervolume contributions for each individual in fitnesses
.
Examples
(fitnesses = matrix(c(1, 5, 2, 3, 0, 3, 1, 0, 10, 8), ncol = 2))
# to see the fitness matrix, use:
## plot(fitnesses, pch = as.character(1:5))
domhv_contribution(fitnesses)
Calculate Hypervolume Improvement
Description
Takes a matrix
of fitness values and calculates the hypervolume improvement of individuals in that matrix
, one by one,
over the baseline
individuals.
The hypervolume improvement for each point is the measure of all points that have fitnesses that are
greater than the respective value in
nadir
in all dimensions, andsmaller than the respective value in the given point in all dimensions, and
greater than all points in
baseline
in at least one dimension.
Individuals in fitnesses
are considered independently of each other. A possible speedup is achieved because
baseline
individuals only need to be pre-filtered once.
Usage
domhv_improvement(fitnesses, baseline = NULL, nadir = 0)
Arguments
fitnesses |
( |
baseline |
( |
nadir |
( |
Value
numeric
: The vector of dominated hypervolume contributions for each individual in fitnesses
.
Examples
(fitnesses = matrix(c(1, 5, 2, 3, 0, 3, 1, 0, 10, 8), ncol = 2))
# to see the fitness matrix, use:
## plot(fitnesses, pch = as.character(1:5))
domhv_improvement(fitnesses)
domhv_improvement(fitnesses, fitnesses[1, , drop = FALSE])
Get Aggregated Performance Values by Generation
Description
Get evaluated performance values from an OptimInstance
aggregated for each generation.
This may either concern all individuals that were alive at the end of a given generation (survivors_only
TRUE
)
or at any point during a generation (survivors_only
FALSE
).
The result is a single data.table
object with a dob
column indicating the
generation, as well as one column for each aggregations
entry crossed with each objective of inst
.
See mies_generation_apply()
on how to apply functions to entire fitness-matrices, not only individual objectives.
Usage
mies_aggregate_generations(
inst,
objectives = inst$archive$codomain$ids(),
aggregations = list(min = min, mean = mean, max = max, median = stats::median, size =
length),
as_fitnesses = TRUE,
survivors_only = TRUE,
condition_on_budget_id = NULL
)
Arguments
inst |
( |
objectives |
( |
aggregations |
(named |
as_fitnesses |
( |
survivors_only |
( |
condition_on_budget_id |
( |
Value
a data.table
with the column "dob"
, indicating the generation, as well as further
columns named by the items in aggregations
. There is more on element in objectives
(or more than one element not being minimized/maximized when as_fitnesses
is TRUE
), then columns are named <aggregations element name>.<objective name>
.
Otherwise, they are named by <aggregations element name>
only. To get a guarantee that elements are only named after elements in aggregations
, set objectives
to a length 1 character
.
See Also
Other aggregation methods:
mies_aggregate_single_generation()
,
mies_get_generation_results()
Examples
library("bbotk")
lgr::threshold("warn")
# Define the objective to optimize
objective <- ObjectiveRFun$new(
fun = function(xs) {
z <- 10 - exp(-xs$x^2 - xs$y^2) + 2 * exp(-(2 - xs$x)^2 - (2 - xs$y)^2)
list(Obj = z)
},
domain = ps(x = p_dbl(-2, 4), y = p_dbl(-2, 4)),
codomain = ps(Obj = p_dbl(tags = "minimize"))
)
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 6)
)
op <- opt("mies",
lambda = 2, mu = 2,
mutator = mut("gauss", sdev = 0.1),
recombinator = rec("xounif"),
parent_selector = sel("best")
)
set.seed(1)
op$optimize(oi)
# negates objectives that are minimized:
mies_aggregate_generations(oi)
# silly aggregation: first element
mies_aggregate_generations(oi, aggregations = list(first = function(x) x[1]))
# real objective values:
mies_aggregate_generations(oi, as_fitnesses = FALSE)
# Individuals that died are included:
mies_aggregate_generations(oi, survivors_only = FALSE)
Aggregate a Value for a given Generation
Description
Applies a fitness_aggregator
function to the values that were alive in the archive at a given generation.
The function is supplied with the fitness values, and optionally other data, of all individuals that are alive at that point.
Usage
mies_aggregate_single_generation(
archive,
fitness_aggregator,
generation = NA,
include_previous_generations = FALSE
)
Arguments
archive |
( |
fitness_aggregator |
( |
generation |
( |
include_previous_generations |
( |
Details
The fitness_aggregator
function may have any of the following arguments, which will be given the following information when
fitness_aggregator
is called:
-
fitnesses
::matrix
Will contain fitnesses for each alive individual. This value has one column when doing single-crit optimization and one column for each "criterion" when doing multi-crit optimization. Fitnesses are always being maximized, so if an objective is being minimized, thefitness_aggregator
function is given the objective values * -1. -
objectives_unscaled
::matrix
The objective values as given tofitnesses
, but not multiplied by -1 if they are being minimized. It is recommended that thecodomain
argument is queried for"maximize"
or"minimize"
tags whenobjectives_unscaled
is used. -
budget
::scalar
If multi-fidelity evaluation is being performed, then this is the "budget" value of each individual. Otherwise it is a vector containing the value 1 for each individual. -
xdt
::data.table
The configurations that were evaluated for the alive individuals. Rows are in the same order as the values given tofitnesses
orobjectives_unscaled
. -
search_space
::ParamSet
The search space of theArchive
under evaluation. -
codomain
::ParamSet
The codomain of theArchive
under evaluation. This is particularly useful when usingobjectives_unscaled
to determine minimization or maximization.
Not all of these arguments need to present, but at least one of fitnesses
, objectives_unscaled
, or xdt
must be.
fitness_aggregator
will never be called for an empty generation.
Value
The value returned by fitness_aggregator
when applied to individuals alive at generation generation
. If no
individuals of the requested generation are present, fitness_aggregator
is not called
and mies_aggregate_single_generation()
returns NULL
instead.
See Also
Other aggregation methods:
mies_aggregate_generations()
,
mies_get_generation_results()
Examples
library("bbotk")
lgr::threshold("warn")
objective <- ObjectiveRFun$new(
fun = function(xs) {
list(y1 = xs$x1, y2 = xs$x2)
},
domain = ps(x1 = p_dbl(0, 1), x2 = p_dbl(-1, 0)),
codomain = ps(y1 = p_dbl(0, 1, tags = "maximize"),
y2 = p_dbl(-1, 0, tags = "minimize"))
)
oi <- OptimInstanceMultiCrit$new(objective, terminator = trm("none"))
try(mies_aggregate_single_generation(oi$archive, identity), silent = TRUE)
mies_aggregate_single_generation(oi$archive, function(fitnesses) fitnesses)
mies_init_population(oi, 2, budget_id = "x1", fidelity = .5)
oi$archive$data
mies_aggregate_single_generation(oi$archive, function(fitnesses) fitnesses)
# Notice how fitnesses are positive, since x2 is scaled with -1.
# To get the original objective-values, use objectives_unscaled:
mies_aggregate_single_generation(oi$archive,
function(objectives_unscaled) objectives_unscaled)
# When `...` is used, all information is passed:
mies_aggregate_single_generation(oi$archive, function(...) names(list(...)))
# Generation 10 is not present, but individuals with eol `NA` are still
# considered alive:
mies_aggregate_single_generation(oi$archive, function(fitnesses) fitnesses,
generation = 10)
# Re-evaluating points with higher "fidelity" (x1)
mies_step_fidelity(oi, budget_id = "x1", fidelity = 0.7)
oi$archive$data
# Lower-fidelity values are considered dead now, even for generation 1:
mies_aggregate_single_generation(oi$archive, function(fitnesses) fitnesses,
generation = 1)
# This adds two new alive individuals at generation 2.
# Also the individuals from gen 1 are reevaluated with fidelity 0.8
mies_evaluate_offspring(oi, offspring = data.frame(x2 = c(-0.1, -0.2)),
budget_id = "x1", fidelity = 0.9, reevaluate_fidelity = 0.8)
oi$archive$data
mies_aggregate_single_generation(oi$archive, function(budget, ...) budget)
mies_aggregate_single_generation(oi$archive, function(fitnesses) fitnesses,
generation = 1)
mies_aggregate_single_generation(oi$archive, function(fitnesses) fitnesses,
generation = 2)
# No individuals were killed, but some were fidelity-reevaluated.
# These are not present with include_previous_generations:
mies_aggregate_single_generation(oi$archive, function(fitnesses) fitnesses,
generation = 2, include_previous_generations = TRUE)
# Typical use-case: get dominated hypervolume
mies_aggregate_single_generation(oi$archive, function(fitnesses) domhv(fitnesses))
# Get generation-wise mean fitness values
mies_aggregate_single_generation(oi$archive, function(fitnesses) {
apply(fitnesses, 2, mean)
})
Evaluate Proposed Configurations Generated in a MIES Iteration
Description
Calls $eval_batch
of a given OptimInstance
on a set
of configurations as part of a MIES operation. The dob
extra-info in the archive
is also set properly to indicate a progressed generation.
This function can be used directly, but it is easier to use it within the OptimizerMies
class if standard GA operation is desired.
Multifidelity evaluation is supported as described in vignette("mies-multifid")
. For this,
an extra component named after budget_id
is appended to each individual, chosen from
the fidelity
argument and depending on the value of survivor_budget
. budget_id
should
have the same values as given to the other mies_*
functions.
Usage
mies_evaluate_offspring(
inst,
offspring,
budget_id = NULL,
fidelity = NULL,
reevaluate_fidelity = NULL,
fidelity_monotonic = TRUE
)
Arguments
inst |
( |
offspring |
( |
budget_id |
( |
fidelity |
( |
reevaluate_fidelity |
( |
fidelity_monotonic |
( |
Value
invisible data.table
: the performance values returned when evaluating the offspring
values
through eval_batch
.
See Also
Other mies building blocks:
mies_generate_offspring()
,
mies_get_fitnesses()
,
mies_init_population()
,
mies_select_from_archive()
,
mies_step_fidelity()
,
mies_survival_comma()
,
mies_survival_plus()
Examples
library("bbotk")
lgr::threshold("warn")
# Define the objective to optimize
objective <- ObjectiveRFun$new(
fun = function(xs) {
z <- exp(-xs$x^2 - xs$y^2) + 2 * exp(-(2 - xs$x)^2 - (2 - xs$y)^2)
list(Obj = z)
},
domain = ps(x = p_dbl(-2, 4), y = p_dbl(-2, 4)),
codomain = ps(Obj = p_dbl(tags = "maximize"))
)
# Get a new OptimInstance
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 100)
)
mies_init_population(inst = oi, mu = 3)
# Initial state:
oi$archive
# 'offspring' is just a data.frame of values to evaluate.
# In general it should be created using 'mies_generate_offspring()'.
offspring = data.frame(x = 1:2, y = 2:1)
mies_evaluate_offspring(oi, offspring = offspring)
# This evaluated the given points and assigned them 'dob' 2.
oi$archive
# Note that at this point one would ordinarily call a 'mies_survival_*()'
# function.
###
# Advanced demo, making use of additional components and doing multi-fidelity
##
# declare 'y' the budget parameter. It will not be in the 'offspring'
# table any more.
budget_id = "y"
# but: offspring may contain any other value that is appended to 'oi'. These
# are ignored by the objective.
offspring = data.frame(x = 0:1, z = 3)
mies_evaluate_offspring(oi, offspring = offspring, budget_id = budget_id,
fidelity = 1)
# This now has the additional column 'z'. Values of y for the new evaluations
# are 1.
oi$archive
offspring = data.frame(x = 2, z = 3)
# Increasing the fidelity will not cause re-evaluation of existing individuals
# when `reevaluate_fidelity` is not given.
mies_evaluate_offspring(oi, offspring = offspring, budget_id = budget_id,
fidelity = 2)
oi$archive
offspring = data.frame(x = 3, z = 3)
# Depending on the effect of fidelity, this may however have a biasing effect,
# so it may be desirable to re-evaluate surviving individuals from previous
# generations. The 'reevaluate_fidelity' may even be different from 'fidelity'
mies_evaluate_offspring(oi, offspring = offspring, budget_id = budget_id,
fidelity = 3, reevaluate_fidelity = 2)
# In this example, only individuals with 'y = 1' were re-evaluated, since
# 'fidelity_monotonic' is TRUE.
oi$archive
Filter Offspring
Description
Uses a Filtor
to extract a subset of individuals from a given set. The individuals are either returned directly (when get_indivs
is TRUE
)
or in form of an index into the given individuals (when get_indivs
is FALSE
).
Filtor
s must always select individuals without replacement, so selected individual indices are unique.
Usage
mies_filter_offspring(
inst,
individuals,
lambda,
filtor = NULL,
budget_id = NULL,
fidelity = NULL,
get_indivs = TRUE
)
Arguments
inst |
( |
individuals |
( |
lambda |
( |
filtor |
( |
budget_id |
( |
fidelity |
( |
get_indivs |
( |
Value
If get_indivs
is TRUE
: a data.frame
or data.table
(depending on the input type of individuals
) of filtered configurations.
If get_indivs
is FALSE
: an integer
vector indexing the filtered individuals.
Generate Offspring Through Mutation and Recombination
Description
Generate new proposal individuals to be evaluated using mies_evaluate_offspring()
.
Parent individuals are selected using parent_selector
, then mutated using mutator
, and thend
recombined using recombinator
. If only a subset of these operations is desired, then
it is possible to set mutator
or recombinator
to the respective "null"-operators.
Usage
mies_generate_offspring(
inst,
lambda,
parent_selector = NULL,
mutator = NULL,
recombinator = NULL,
budget_id = NULL
)
Arguments
inst |
( |
lambda |
( |
parent_selector |
( |
mutator |
( |
recombinator |
( |
budget_id |
( |
Value
data.table
: A table of configurations proposed as offspring to be evaluated
using mies_evaluate_offspring()
.
See Also
Other mies building blocks:
mies_evaluate_offspring()
,
mies_get_fitnesses()
,
mies_init_population()
,
mies_select_from_archive()
,
mies_step_fidelity()
,
mies_survival_comma()
,
mies_survival_plus()
Examples
set.seed(1)
library("bbotk")
lgr::threshold("warn")
# Define the objective to optimize
objective <- ObjectiveRFun$new(
fun = function(xs) {
z <- exp(-xs$x^2 - xs$y^2) + 2 * exp(-(2 - xs$x)^2 - (2 - xs$y)^2)
list(Obj = z)
},
domain = ps(x = p_dbl(-2, 4), y = p_dbl(-2, 4)),
codomain = ps(Obj = p_dbl(tags = "maximize"))
)
# Get a new OptimInstance
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 100)
)
# Demo operators
m = mut("gauss", sdev = 0.1)
r = rec("xounif")
s = sel("random")
# Operators must be primed
mies_prime_operators(objective$domain, list(m), list(r), list(s))
# We would normally call mies_init_population, but for reproducibility
# we are going to evaluate three given points
oi$eval_batch(data.table::data.table(x = 0:2, y = 2:0, dob = 1, eol = NA_real_))
# Evaluated points:
oi$archive
# Use default operators: no mutation, no recombination, parent_selctor is
# sel("best") --> get one individual, the one with highest performance in the
# archive (x = 1, y = 1).
# (Note 'mies_generate_offspring()' does not modify 'oi')
mies_generate_offspring(oi, lambda = 1)
# Mutate the selected individual after selection. 'm' has 'sdev' set to 0.1,
# so the (x = 1, y = 1) is slightly permuted.
mies_generate_offspring(oi, lambda = 1, mutator = m)
# Recombination, then mutation.
# Even though lambda is 1, there will be two individuals selected with
# sel("best") and recombined, because rec("xounif") needs two parents. One
# of the crossover results is discarded (respecting that 'lambda' is 1),
# the other is mutated and returned.
mies_generate_offspring(oi, lambda = 1, mutator = m, recombinator = r)
# General application: select, recombine, then mutate.
mies_generate_offspring(oi, lambda = 5, parent_selector = s, mutator = m, recombinator = r)
Get the Last Generation that was Evaluated
Description
Gets the last generation that was evaluated as counted by the "dob"
column in the OptimInstance
's Archive
.
This accepts OptimInstance
s that were not evaluated with miesmuschel
and are therefore missing the "dob"
column, returning
a value of 0. However, if the "dob"
column is invalid (the inferred generation is not integer numeric or not non-negative), an error is thrown.
Usage
mies_generation(inst)
Arguments
inst |
( |
Value
a scalar integer value indicating the last generation that was evaluated in inst
. It is 0 when inst
is empty, and also typically 0 if all evaluations
in inst
so far were performed outside of miesmuschel
. Every call of mies_init_population
that actually performs evaluations, as well as each call to
mies_evaluate_offspring
with non-empty offspring
, increases the generation by 1.
Examples
library("bbotk")
lgr::threshold("warn")
# Define the objective to optimize
objective <- ObjectiveRFun$new(
fun = function(xs) {
z <- 10 - exp(-xs$x^2 - xs$y^2) + 2 * exp(-(2 - xs$x)^2 - (2 - xs$y)^2)
list(Obj = z)
},
domain = ps(x = p_dbl(-2, 4), y = p_dbl(-2, 4)),
codomain = ps(Obj = p_dbl(tags = "minimize"))
)
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 6)
)
op <- opt("mies",
lambda = 2, mu = 2,
mutator = mut("gauss", sdev = 0.1),
recombinator = rec("xounif"),
parent_selector = sel("best")
)
set.seed(1)
mies_generation(oi)
op$optimize(oi)
mies_generation(oi)
oi$terminator = trm("evals", n_evals = 10)
op$optimize(oi)
mies_generation(oi)
Aggregate Values for All Generations Present
Description
Applies a fitness_aggregator
function to the values that were alive in the archive at at any generation.
mies_aggregate_single_generation()
is used, see there for more information about fitness_aggregator
.
Generations for which fitness_aggregator
returns NULL
, or which are not present in any dob
in the archive,
or which contain no alive individuals (e.g. because eol
is smaller or equal dob
for all of them) are ignored.
as.list()
is applied to the values returned by fitness_aggregator
, and data.table::rbindlist()
is called on
the list of resulting values. If the first non-NULL
-value returned by fitness_aggregator
, then data.table::rbindlist()
is called with fill = TRUE
and use.names = TRUE
.
If no non-empty generations are present, or fitness_aggregator
returns NULL
on every call, then the return value
is data.table(dob = numeric(0))
.
In contrast with mies_aggregate_generations()
, mies_generate_apply()
can construct aggregated values for
entire fitness matrices, not only individual objectives (see examples). However, mies_aggregate_generations()
is simpler
if per-objective aggregates are desired.
Usage
mies_generation_apply(
archive,
fitness_aggregator,
include_previous_generations = FALSE
)
Arguments
archive |
( |
fitness_aggregator |
( |
include_previous_generations |
( |
Value
data.table
with columns dob
, next to the columns constructed from the return values of fitness_aggregator
.
Examples
set.seed(1)
library("bbotk")
lgr::threshold("warn")
objective <- ObjectiveRFun$new(
fun = function(xs) {
list(y1 = xs$x1, y2 = xs$x2)
},
domain = ps(x1 = p_dbl(0, 1), x2 = p_dbl(-1, 0)),
codomain = ps(y1 = p_dbl(0, 1, tags = "maximize"),
y2 = p_dbl(-1, 0, tags = "minimize"))
)
oi <- OptimInstanceMultiCrit$new(objective,
terminator = trm("evals", n_evals = 40))
op <- opt("mies",
lambda = 4, mu = 4,
mutator = mut("gauss", sdev = 0.1),
recombinator = rec("xounif"),
parent_selector = sel("random"),
survival_selector = sel("best", scl("hypervolume"))
)
op$optimize(oi)
# Aggregated hypervolume of individuals alive in each gen:
mies_generation_apply(oi$archive, function(fitnesses) {
domhv(fitnesses)
})
# Aggregated hypervolume of all points evaluated up to each gen
# (may be slightly more, since the domhv of more points is evaluated).
# This would be the dominated hypervolume of the result set at each
# generation:
mies_generation_apply(oi$archive, function(fitnesses) {
domhv(fitnesses)
}, include_previous_generations = TRUE)
# The following are simpler with mies_aggregate_single_generations():
mies_generation_apply(oi$archive, function(fitnesses) {
apply(fitnesses, 2, mean)
})
# Compare:
mies_aggregate_generations(oi, aggregations = list(mean = mean))
mies_generation_apply(oi$archive, function(objectives_unscaled) {
apply(objectives_unscaled, 2, mean)
})
# Compare:
mies_aggregate_generations(oi, aggregations = list(mean = mean),
as_fitnesses = FALSE)
Get Fitness Values from OptimInstance
Description
Get fitness values in the correct form as used by Selector
operators from an
OptimInstance
.
This works for both single-criterion and multi-criterion optimization, and entails multiplying
objectives with -1 if they are being minimized, since Selector
tries to maximize fitness.
Usage
mies_get_fitnesses(inst, rows)
Arguments
inst |
( |
rows |
optional ( |
Value
numeric
matrix
with length(rows)
(if rows
is given, otherwise nrow(inst$archive$data)
) rows
and one column for each objective: fitnesses to be maximized.
See Also
Other mies building blocks:
mies_evaluate_offspring()
,
mies_generate_offspring()
,
mies_init_population()
,
mies_select_from_archive()
,
mies_step_fidelity()
,
mies_survival_comma()
,
mies_survival_plus()
Examples
set.seed(1)
library("bbotk")
lgr::threshold("warn")
# Define the objective to optimize
objective <- ObjectiveRFun$new(
fun = function(xs) {
z <- exp(-xs$x^2 - xs$y^2) + 2 * exp(-(2 - xs$x)^2 - (2 - xs$y)^2)
list(Obj = z)
},
domain = ps(x = p_dbl(-2, 4), y = p_dbl(-2, 4)),
codomain = ps(Obj = p_dbl(tags = "maximize"))
)
# Get a new OptimInstance
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 100)
)
mies_init_population(inst = oi, mu = 3)
oi$archive
mies_get_fitnesses(oi, c(2, 3))
###
# Multi-objective, and automatic maximization:
objective2 <- ObjectiveRFun$new(
fun = function(xs) list(Obj1 = xs$x^2, Obj2 = -xs$y^2),
domain = ps(x = p_dbl(-2, 4), y = p_dbl(-2, 4)),
codomain = ps(
Obj1 = p_dbl(tags = "minimize"),
Obj2 = p_dbl(tags = "maximize")
)
)
# Using MultiCrit!
oi <- OptimInstanceMultiCrit$new(objective2,
terminator = trm("evals", n_evals = 100)
)
mies_init_population(inst = oi, mu = 3)
oi$archive
# Note Obj1 has a different sign than in the archive.
mies_get_fitnesses(oi, c(2, 3))
Get Performance Values by Generation
Description
Get evaluated performance values from an OptimInstance
for all individuals that were alive
at a given generation. Depending on survivors_only
, all individuals alive at the end of a generation are returned,
or all individuals alive at any point during a generation.
The resulting data.table
object is formatted for easy manipulation to get relevant
information about optimization progress. To get aggregated values per generation, use by = "dob"
.
Usage
mies_get_generation_results(
inst,
as_fitnesses = TRUE,
survivors_only = TRUE,
condition_on_budget_id = NULL
)
Arguments
inst |
( |
as_fitnesses |
( |
survivors_only |
( |
condition_on_budget_id |
( |
Value
a data.table
with the column "dob"
, indicating the generation, as well as further
columns named by the OptimInstance
's objectives.
See Also
Other aggregation methods:
mies_aggregate_generations()
,
mies_aggregate_single_generation()
Examples
library("bbotk")
lgr::threshold("warn")
# Define the objective to optimize
objective <- ObjectiveRFun$new(
fun = function(xs) {
z <- 10 - exp(-xs$x^2 - xs$y^2) + 2 * exp(-(2 - xs$x)^2 - (2 - xs$y)^2)
list(Obj = z)
},
domain = ps(x = p_dbl(-2, 4), y = p_dbl(-2, 4)),
codomain = ps(Obj = p_dbl(tags = "minimize"))
)
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 6)
)
op <- opt("mies",
lambda = 2, mu = 2,
mutator = mut("gauss", sdev = 0.1),
recombinator = rec("xounif"),
parent_selector = sel("best")
)
set.seed(1)
op$optimize(oi)
# negates objectives that are minimized:
mies_get_generation_results(oi)
# real objective values:
mies_get_generation_results(oi, as_fitnesses = FALSE)
# Individuals that died are included:
mies_get_generation_results(oi, survivors_only = FALSE)
Initialize MIES Optimization
Description
Set up an OptimInstance
for MIES optimization.
This adds the dob
and eol
columns to the instance's archive, and makes sure there are at least mu
survivors
(i.e. entries with eol
set to NA
) present. If there are already >= mu
prior evaluations present, then the last
mu
of these remain alive (the other's eol
set to 0); otherwise, up to mu
new randomly sampled configurations
are evaluated and added to the archive and have eol
set to NA
.
Usage
mies_init_population(
inst,
mu,
initializer = generate_design_random,
survival_selector = SelectorBest$new()$prime(inst$search_space),
budget_id = NULL,
fidelity = NULL,
fidelity_new_individuals_only = FALSE,
fidelity_monotonic = TRUE,
additional_component_sampler = NULL
)
Arguments
inst |
( |
mu |
( |
initializer |
( |
survival_selector |
( |
budget_id |
( |
fidelity |
( |
fidelity_new_individuals_only |
( |
fidelity_monotonic |
( |
additional_component_sampler |
( |
Value
invisible OptimInstance
: the input
instance, modified by-reference.
See Also
Other mies building blocks:
mies_evaluate_offspring()
,
mies_generate_offspring()
,
mies_get_fitnesses()
,
mies_select_from_archive()
,
mies_step_fidelity()
,
mies_survival_comma()
,
mies_survival_plus()
Examples
library("bbotk")
lgr::threshold("warn")
# Define the objective to optimize
objective <- ObjectiveRFun$new(
fun = function(xs) {
z <- exp(-xs$x^2 - xs$y^2) + 2 * exp(-(2 - xs$x)^2 - (2 - xs$y)^2)
list(Obj = z)
},
domain = ps(x = p_dbl(-2, 4), y = p_dbl(-2, 4)),
codomain = ps(Obj = p_dbl(tags = "maximize"))
)
# Get a new OptimInstance
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 100)
)
mies_init_population(inst = oi, mu = 3)
# 3 evaluations, archive contains 'dob' and 'eol'
oi$archive
###
# Advanced demo, making use of additional components and fidelity
##
# Get a new OptimInstance
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 100)
)
mies_init_population(inst = oi, mu = 3, budget_id = "y", fidelity = 2,
additional_component_sampler = Sampler1DRfun$new(
param = ps(additional = p_dbl(-1, 1)), rfun = function(n) rep(-1, n)
)
)
# 3 evaluations. We also have 'additional', sampled from rfun (always -1),
# which is ignored by the objective. Besides, we have "y", which is 2,
# according to 'fidelity'.
oi$archive
Prime MIES Operators
Description
Prime the given MiesOperator
s for an optimization run with the given search space.
In its simplest form, MIES optimization only optimizes the search space of the Objective
to be optimized. However,
more advanced optimization may handle a "budget" parameter for multi-fidelity optimization differently: It is still selected by Selector
s,
but not mutated or recombined and instead handled separately. It is also possible to add additional components to the search space that are
not evaluated by the objective function, but that are used for self-adaption by other operators.
The mies_prime_operators()
function uses the information that the user usually has readily at hand – the Objective
s search space, the budget parameter, and additional components -- and primes [
Mutator], [
Recombinator], and [
Selector'] objects in the right way:
-
Selector
s are primed on a union ofsearch_space
andadditional_components
-
Mutator
s andRecombinator
s are primed on theSelector
's space with thebudget_id
Domain
removed.
mies_prime_operators()
is called with an arbitrary number of MiesOperator
arguments; typically one Mutator
, one Recombinator
and
at least two Selector
: one for survival selection, and one parent selection. Supplied MiesOperator
s are primed by-reference, but
they are also returned as invisible list
.
If neither additional components nor multi-fidelity optimization is used, it is also possible to use the $prime()
function of hte MiesOperator
s
directly, although using mies_prime_operators()
gives flexibility for future extension.
Usage
mies_prime_operators(
search_space,
mutators = list(),
recombinators = list(),
selectors = list(),
filtors = list(),
...,
additional_components = NULL,
budget_id = NULL
)
Arguments
search_space |
( |
mutators |
( |
recombinators |
( |
selectors |
( |
filtors |
( |
... |
(any) |
additional_components |
( |
budget_id |
( |
Value
invisible
named list
with entries $mutators
(list
of Mutator
, primed mutators
), $recombinators
(list
of Recombinator
, primed recombinators
),
and $selectors
(list
of Selector
, primed selectors
).
Examples
# Search space of a potential TuningInstance for optimization:
search_space = ps(x = p_dbl(), y = p_dbl())
# Additoinal search space components that are not part of the TuningInstance
additional_components = ps(z = p_dbl())
# Budget parameter not subject to mutation or recombination
budget_id = "y"
m = mut("gauss")
r = rec("xounif")
s1 = sel("best")
s2 = sel("random")
f = ftr("null")
mies_prime_operators(search_space, mutators = list(m),
recombinators = list(r), selectors = list(s1, s2), filtors = list(f),
additional_components = additional_components, budget_id = budget_id
)
# contain search_space without budget parameter, with additional_components
m$primed_ps
r$primed_ps
# contain also the budget parameter
s1$primed_ps
s2$primed_ps
f$primed_ps
Select Individuals from an OptimInstance
Description
Apply a Selector
operator to a subset of configurations inside
an OptimInstance
and return the index within the archive (when get_indivs
FALSE
) or the configurations themselves
(when get_indivs
is TRUE
).
It is not strictly necessary for the selector to select unique individuals / individuals without replacement.
Individuals are selected independently of whether they are "alive" or not. To select only from alive individuals,
set rows
to inst$archive$data[, which(is.na(eol))]
.
Usage
mies_select_from_archive(
inst,
n_select,
rows,
selector = SelectorBest$new()$prime(inst$search_space),
group_size = 1,
get_indivs = TRUE
)
Arguments
inst |
( |
n_select |
( |
rows |
optional ( |
selector |
( |
group_size |
( |
get_indivs |
( |
Value
integer
| data.table
: Selected individuals, either index into inst
or subset of archive table,
depending on get_indivs
.
See Also
Other mies building blocks:
mies_evaluate_offspring()
,
mies_generate_offspring()
,
mies_get_fitnesses()
,
mies_init_population()
,
mies_step_fidelity()
,
mies_survival_comma()
,
mies_survival_plus()
Examples
set.seed(1)
library("bbotk")
lgr::threshold("warn")
# Define the objective to optimize
objective <- ObjectiveRFun$new(
fun = function(xs) {
z <- exp(-xs$x^2 - xs$y^2) + 2 * exp(-(2 - xs$x)^2 - (2 - xs$y)^2)
list(Obj = z)
},
domain = ps(x = p_dbl(-2, 4), y = p_dbl(-2, 4)),
codomain = ps(Obj = p_dbl(tags = "maximize"))
)
# Get a new OptimInstance
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 100)
)
s = sel("best")
s$prime(oi$search_space)
mies_init_population(inst = oi, mu = 6)
oi$archive
# Default: get individuals
mies_select_from_archive(oi, n_select = 2, rows = 1:6, selector = s)
# Alternatively: get rows within archive
mies_select_from_archive(oi, n_select = 2, rows = 1:6, selector = s,
get_indivs = FALSE)
# Rows gotten from archive are relative from *all* rows, not from archive[rows]:
mies_select_from_archive(oi, n_select = 2, rows = 3:6, selector = s,
get_indivs = FALSE)
##
# When using additional components: mies_select_from_archive learns about
# additional components from primed selector.
# Get a new OptimInstance
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 100)
)
mies_init_population(inst = oi, mu = 6,
additional_component_sampler = Sampler1DRfun$new(
param = ps(additional = p_dbl(-1, 1)), rfun = function(n) -1
)
)
oi$archive
# Wrong: using selector primed only on search space. The resulting
# individuals do not have the additional component.
mies_select_from_archive(oi, n_select = 2, rows = 1:6, selector = s)
# Correct: selector must be primed on search space + additional component
mies_prime_operators(oi$search_space, selectors = list(s),
additional_components = ps(additional = p_dbl(-1, 1)))
mies_select_from_archive(oi, n_select = 2, rows = 1:6, selector = s)
Re-Evaluate Existing Configurations with Higher Fidelity
Description
As part of the "rolling-tide" multifidelity-setup, do reevaluation of configurations with
higher fidelity that have survived lower-fidelity selection. The evaluations are done as part of the
current generation, so the dob
value is not increased.
This function should only be called when doing rolling-tide multifidelity, and should not be part of the MIES cycle otherwise.
Usage
mies_step_fidelity(
inst,
budget_id,
fidelity,
current_gen_only = FALSE,
fidelity_monotonic = TRUE,
additional_components = NULL
)
Arguments
inst |
( |
budget_id |
( |
fidelity |
( |
current_gen_only |
( |
fidelity_monotonic |
( |
additional_components |
( |
Value
invisible data.table
: the performance values returned when evaluating the offspring
values
through eval_batch
.
See Also
Other mies building blocks:
mies_evaluate_offspring()
,
mies_generate_offspring()
,
mies_get_fitnesses()
,
mies_init_population()
,
mies_select_from_archive()
,
mies_survival_comma()
,
mies_survival_plus()
Examples
library("bbotk")
lgr::threshold("warn")
# Define the objective to optimize
objective <- ObjectiveRFun$new(
fun = function(xs) {
z <- exp(-xs$x^2 - xs$y^2) + 2 * exp(-(2 - xs$x)^2 - (2 - xs$y)^2)
list(Obj = z)
},
domain = ps(x = p_dbl(-2, 4), y = p_dbl(-2, 4)),
codomain = ps(Obj = p_dbl(tags = "maximize"))
)
# Get a new OptimInstance
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 100)
)
budget_id = "y"
# Create an initial population with fidelity ("y") value 1
mies_init_population(oi, mu = 2, budget_id = budget_id, fidelity = 1)
oi$archive
# Re-evaluate these individuals with higher fidelity
mies_step_fidelity(oi, budget_id = budget_id, fidelity = 2)
oi$archive
# The following creates a new generation without killing the initial
# generation
offspring = data.frame(x = 0:1)
mies_evaluate_offspring(oi, offspring = offspring, budget_id = budget_id,
fidelity = 3)
oi$archive
# Re-evaluate only individuals from last generation by setting current_gen_only
mies_step_fidelity(oi, budget_id = budget_id, fidelity = 4,
current_gen_only = TRUE)
oi$archive
# Default: Re-evaluate all that *increase* fidelity: Only the initial
# population is re-evaluated here.
mies_step_fidelity(oi, budget_id = budget_id, fidelity = 3)
oi$archive
# To also re-evaluate individuals with *higher* fidelity, use
# 'fidelity_monotonic = FALSE'. This does not re-evaluate the points that already have
# the requested fidelity, however.
mies_step_fidelity(oi, budget_id = budget_id, fidelity = 3, fidelity_monotonic = FALSE)
oi$archive
Choose Survivors According to the "Mu , Lambda" ("Comma") Strategy
Description
Choose survivors during a MIES iteration using the "Comma" survival strategy, i.e.
selecting survivors from the latest generation only, using a Selector
operator, and choosing
"elites" from survivors from previous generations using a different Selector
operator.
When n_elite
is greater than the number of alive individuals from previous generations,
then all these individuals from previous generations survive. In this case, it is
possible that more than mu - n_elite
individuals from the current generation survive.
Similarly, when mu
is greater
than the number of alive individuals from the last generation, then all these individuals survive.
Usage
mies_survival_comma(inst, mu, survival_selector, n_elite, elite_selector, ...)
Arguments
inst |
( |
mu |
( |
survival_selector |
( |
n_elite |
( |
elite_selector |
( |
... |
(any) |
Value
invisible data.table
: The value of inst$archive$data
, changed
in-place with eol
set to the current generation for non-survivors.
See Also
Other mies building blocks:
mies_evaluate_offspring()
,
mies_generate_offspring()
,
mies_get_fitnesses()
,
mies_init_population()
,
mies_select_from_archive()
,
mies_step_fidelity()
,
mies_survival_plus()
Examples
set.seed(1)
library("bbotk")
lgr::threshold("warn")
# Define the objective to optimize
objective <- ObjectiveRFun$new(
fun = function(xs) {
z <- exp(-xs$x^2 - xs$y^2) + 2 * exp(-(2 - xs$x)^2 - (2 - xs$y)^2)
list(Obj = z)
},
domain = ps(x = p_dbl(-2, 4), y = p_dbl(-2, 4)),
codomain = ps(Obj = p_dbl(tags = "maximize"))
)
# Get a new OptimInstance
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 100)
)
mies_init_population(inst = oi, mu = 3)
# Usually the offspring is generated using mies_generate_offspring()
# Here shorter for demonstration purposes.
offspring = generate_design_random(oi$search_space, 3)$data
mies_evaluate_offspring(oi, offspring = offspring)
# State before: different generations of individuals. Alive individuals have
# 'eol' set to 'NA'.
oi$archive
s = sel("best")
s$prime(oi$search_space)
mies_survival_comma(oi, mu = 3, survival_selector = s,
n_elite = 2, elite_selector = s)
# sel("best") lets only the best individuals survive.
# mies_survival_comma selects from new individuals (generation 2 in this case)
# and old individuals (all others) separately: n_elite = 2 from old,
# mu - n_elite = 1 from new.
# The surviving individuals have 'eol' set to 'NA'
oi$archive
Choose Survivors According to the "Mu + Lambda" ("Plus") Strategy
Description
Choose survivors during a MIES iteration using the "Plus" survival strategy, i.e.
combining all alive individuals from the latest and from prior generations indiscriminately and
choosing survivors using a survival Selector
operator.
When mu
is greater than the number of alive individuals, then all individuals survive.
Usage
mies_survival_plus(inst, mu, survival_selector, ...)
Arguments
inst |
( |
mu |
( |
survival_selector |
( |
... |
(any) |
Value
invisible data.table
: The value of inst$archive$data
, changed
in-place with eol
set to the current generation for non-survivors.
See Also
Other mies building blocks:
mies_evaluate_offspring()
,
mies_generate_offspring()
,
mies_get_fitnesses()
,
mies_init_population()
,
mies_select_from_archive()
,
mies_step_fidelity()
,
mies_survival_comma()
Examples
set.seed(1)
library("bbotk")
lgr::threshold("warn")
# Define the objective to optimize
objective <- ObjectiveRFun$new(
fun = function(xs) {
z <- exp(-xs$x^2 - xs$y^2) + 2 * exp(-(2 - xs$x)^2 - (2 - xs$y)^2)
list(Obj = z)
},
domain = ps(x = p_dbl(-2, 4), y = p_dbl(-2, 4)),
codomain = ps(Obj = p_dbl(tags = "maximize"))
)
# Get a new OptimInstance
oi <- OptimInstanceSingleCrit$new(objective,
terminator = trm("evals", n_evals = 100)
)
mies_init_population(inst = oi, mu = 3)
offspring = generate_design_random(oi$search_space, 2)$data
mies_evaluate_offspring(oi, offspring = offspring)
# State before: different generations of individuals. Alive individuals have
# 'eol' set to 'NA'.
oi$archive
s = sel("best")
s$prime(oi$search_space)
mies_survival_plus(oi, mu = 3, survival_selector = s)
# sel("best") lets only the three best individuals survive.
# The others have 'eol = 2' (the current generation).
oi$archive
Terminator that Limits Total Budget Component Evaluation
Description
Terminator
that terminates after the sum (or similar aggregate) of a given "budget" search space component croses a threshold.
Dictionary
This Terminator
can be created with the short access form trm()
(trms()
to get a list),
or through the dictionary mlr_terminators
in the following way:
# preferred trm("budget") trms("budget") # takes vector IDs, returns list of Terminators # long form mlr_terminators$get("budget")
Configuration Parameters
-
budget
::numeric(1)
Total budget available, after which to stop. Not initialized and should be set to the desired value during construction. -
aggregate
::function
Function taking a vector of values of the budget search space component, returning a scalar value to be compared to thebudget
configuration parameter. If this function returns a value greater or equal tobudget
the termination criterion is matched. Calling this function withNULL
must return the lower bound of the budget value; percentage progress is reported as the progress from this lower bound to the value ofbudget
. Initialized tosum()
.
Super class
bbotk::Terminator
-> TerminatorBudget
Methods
Public methods
Inherited methods
Method new()
Initialize the TerminatorBudget
object.
Usage
TerminatorBudget$new()
Method is_terminated()
Is TRUE
if when the termination criterion is matched, FALSE
otherwise.
Usage
TerminatorBudget$is_terminated(archive)
Arguments
archive
Archive
Archive to check.
Returns
logical(1)
: Whether to terminate.
Method clone()
The objects of this class are cloneable with this method.
Usage
TerminatorBudget$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
library("bbotk")
# Evaluate until sum of budget component of evaluated configs is >= 100
trm("budget", budget = 100)
# Evaluate until sum of two to the power of budget component is >= 100
trm("budget", budget = 1024, aggregate = function(x) sum(2 ^ x))
Terminator That Stops When a Generation-Wise Aggregated Value Reaches a Target
Description
Terminator
that terminates when a value, aggregated over generations, reaches a target value.
The user-supplied fitness_aggregator
function is called whenever the archive of evaluated configurations contains a new generation.
The function is supplied with the fitness values, and optionally other data, of all individuals that are alive at that point
(include_previous_generations = FALSE
) or at any point (include_previous_generations = TRUE
).
Its result is saved inside the $data_extra
field of the Archive
object.
Termination is then signaled when the aggregated value meets or exceeds level
.
The mies_aggregate_single_generation()
function is used, see the documentation there for the functioning of fitness_aggregator
.
The fitness_aggregator
functions used for termination must return a scalar value or NULL
, if a generation should be ignored.
The value returned by fitness_aggregator
should be increasing for better performance, even if the underlying objective is being minimized.
Multi-Fidelity Optimization
Multi-fidelity optimization can introduce a few edge-cases because the individuals inside the generation(s) being aggregated may have been evaluated with different fidelity values, which can give biased results.
When OptimizerMies
is constructed with multi_fidelity
set to TRUE
, it typically evaluates some configurations multiple times,
at first with a lower fidelity, followed by an evaluation at "full" fidelity.
fitness_aggregator
will only be called for generations containing entirely full-fidelity-evaluations will be aggregated.
This is achieved by caching aggregated fitness values in the $data_extra
field of the Archive
and only ever calling
fitness_aggregator
for a generation that does not have a cached value. Since mies_step_fidelity()
will
count low-fidelity evaluations as part of the "previous" generation, fitness_aggregator
will not see them.
Note, however that if fitness_aggregator
returns NULL
, it will be called again should a second evaluation occur in the same generation,
since NULL
is not cached and instead treated as absent.
It is possible for fitness_aggregator
to see fitness values that were evaluated with different fidelities when using OptimizerMies
,
and
-
fidelity_monotonic
is set toTRUE
and fidelity decreases (unlikely setup), or if
fidelity_current_gen_only
is set toFALSE
(advanced usage), orThe value returned by the
fidelity
configuration parameter (notfidelity_offspring
) changes over the course of optimization andinclude_previous_generations
ofTerminatorGenerationStagnation
is set toTRUE
.
(1) and (2) only need consideration in advanced scenarios, but (3) may be a common, e.g. when doing multi-fidelity optimization
and stopping on reaching an overall dominated hypervolume target. In this case, it may be necessary to inspect the budget
value given to fitness_aggregator
and to remove all individuals evaluated with a different than the current fidelity.
When using a custom-written optimization loop, case (1) relates to fidelity_monotonic
argument of mies_step_fidelity()
and mies_init_population()
,
and case (2) relates to the current_gen_only
argument of mies_step_fidelity()
and the fidelity_new_individuals_only
argument of mies_init_population()
.
Case (3) relates to changing the fidelity given to mies_step_fidelity()
if that function is used, or to changing the fidelity given to mies_evaluate_offspring()
if
mies_step_fidelity()
is not used.
Dictionary
This Terminator
can be created with the short access form trm()
(trms()
to get a list),
or through the dictionary mlr_terminators
in the following way:
# preferred trm("genperfreached") trms("genperfreached") # takes vector IDs, returns list of Terminators # long form mlr_terminators$get("genperfreached")
Configuration Parameters
-
fitness_aggregator
::function
Aggregation function, called with information about alive individuals of each generation. This argument is passed tomies_aggregate_single_generation()
, see there for more details. The aggregated values returned byfitness_aggregator
should be maximized, so a larger value must be returned to indicate improvement in a generation, even if an underlying objective is being minimized. The return value must be a scalarnumeric(1)
. -
include_previous_generations
::logical(1)
Whether to aggregate over all individuals that were evaluated (TRUE
), or only the individuals alive in the current generation (FALSE
). If multi-fidelity optimization is being performed and individuals were re-evaluated with a different fidelity, theirx_id
will be the same and only the last fidelity-reevaluation will be given tofitness_aggregator
. However, individuals from different generations may still have been evaluated with different fidelity and it may be necessary to inspect thebudget
value given tofitness_aggregator
ifinclude_previous_generations
isTRUE
in a multi-fidelity-setting. See the "Multi-Fidelity Optimization" section for more. -
level
::numeric(1)
Minimum aggregated value for which to terminate.
Super class
bbotk::Terminator
-> TerminatorGenerationPerfReached
Methods
Public methods
Inherited methods
Method new()
Initialize the TerminatorGenerationPerfReached
object.
Usage
TerminatorGenerationPerfReached$new()
Method is_terminated()
Is TRUE
if when the termination criterion is matched, FALSE
otherwise.
Usage
TerminatorGenerationPerfReached$is_terminated(archive)
Arguments
archive
Archive
Archive to check.
Returns
logical(1)
: Whether to terminate.
Method clone()
The objects of this class are cloneable with this method.
Usage
TerminatorGenerationPerfReached$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
set.seed(1)
library("bbotk")
lgr::threshold("warn")
# Terminate when hypervolume with nadir `c(0, 0, ...)`
# does not improve for 3 generations by at least 0.1:
tg <- trm("genperfreached",
fitness_aggregator = function(fitnesses) domhv(fitnesses),
include_previous_generations = TRUE,
level = 1
)
set.seed(1)
objective <- ObjectiveRFun$new(
fun = function(xs) {
list(y1 = xs$x1, y2 = xs$x2)
},
domain = ps(x1 = p_dbl(0, 1), x2 = p_dbl(-1, 0)),
codomain = ps(y1 = p_dbl(0, 1, tags = "maximize"),
y2 = p_dbl(-1, 0, tags = "minimize"))
)
oi <- OptimInstanceMultiCrit$new(objective, terminator = tg)
op <- opt("mies",
lambda = 4, mu = 4,
mutator = mut("gauss", sdev = 0.1),
recombinator = rec("xounif"),
parent_selector = sel("random"),
survival_selector = sel("best", scl("hypervolume"))
)
op$optimize(oi)
# the observed aggregated values:
oi$archive$data_extra$TerminatorGenerationPerfReached
# ... or as calculated by mies_generation_apply
mies_generation_apply(oi$archive, function(fitnesses) {
domhv(fitnesses)
}, include_previous_generations = TRUE)
#' @export
Terminator that Counts OptimizerMies Generations
Description
Terminator
that terminates after a given number of generations have passed in OptimizerMies
.
If OptimizerMies
is started on an archive that already has evaluated configurations, these evaluations count as
generation 0. If an initial, randomly sampled generation is generated by OptimizerMies
, it has generation number 1.
Setting generation
to 1 therefore terminates after the evaluation of the initial sample, unless no initial sample is
generated by OptimizerMies
and instead found in the archive. generation
set to 0 avoids any evaluation within OptimizerMies
(but is ignored if no dob
column is in the archive).
When doing multi-fidelity optimization, and fidelity of a configuration is increased because of a step in the fidelity schedule, or because they were sampled new and survived, then this fidelity refinement happens as part of an already started generation. This means termination at this fidelity refinement step is avoided.
Dictionary
This Terminator
can be created with the short access form trm()
(trms()
to get a list),
or through the dictionary mlr_terminators
in the following way:
# preferred trm("gens") trms("gens") # takes vector IDs, returns list of Terminators # long form mlr_terminators$get("gens")
Configuration Parameters
-
generations
::integer(1)
Number of generations to evaluate, after which to stop. Not initialized and should be set to the desired value during construction.
Super class
bbotk::Terminator
-> TerminatorGenerations
Methods
Public methods
Inherited methods
Method new()
Initialize the TerminatorGenerations
object.
Usage
TerminatorGenerations$new()
Method is_terminated()
Is TRUE
if when the termination criterion is matched, FALSE
otherwise.
Usage
TerminatorGenerations$is_terminated(archive)
Arguments
archive
Archive
Archive to check.
Returns
logical(1)
: Whether to terminate.
Method clone()
The objects of this class are cloneable with this method.
Usage
TerminatorGenerations$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
library("bbotk")
trm("gens", generations = 10)
Terminator That Stops When a Generation-Wise Aggregated Value Stagnates
Description
Terminator
that terminates when a value, aggregated over generations, stagnates.
The user-supplied fitness_aggregator
function is called whenever the archive of evaluated configurations contains a new generation.
The function is supplied with the fitness values, and optionally other data, of all individuals that are alive at that point
(include_previous_generations = FALSE
) or at any point (include_previous_generations = TRUE
).
Its result is saved inside the $data_extra
field of the Archive
object.
Termination is then signaled when the aggregated value has stagnated, or not improved enough, for a given number of generations.
The mies_aggregate_single_generation()
function is used, see the documentation there for the functioning of fitness_aggregator
.
The fitness_aggregator
functions used for termination must return a scalar value or NULL
, if a generation should be ignored.
The value returned by fitness_aggregator
should be increasing for better performance, even if the underlying objective is being minimized.
Termination is triggered in generation i
when the aggregated value, returned by fitness_aggregator
, of generation i - patience
is not greater than the maximum of all later generations (i - patience + 1
.. i
) by at least min_delta
.
If the aggregated value for generation i - patience
is not known, for example because fewer than patience + 1
generations
have been evaluated so far, because fitness_aggregator
returned NULL
, or because previous generations were evaluated
when TerminatorGenerationStagnation
was not used, then termination is not triggered, regardless of whether values are known
for generations before generation i - patience
.
Multi-Fidelity Optimization
Multi-fidelity optimization can introduce a few edge-cases, for one because the individuals inside the generation(s) being aggregated may have been evaluated with different fidelity values, which can give biased results. Besides that, it may also be problematic that increase of fidelity could lead to "worse" aggregated results (e.g. because of reduced noise making max-aggregation worse), triggering an undesired termination.
Termination from fidelity changes
Higher fidelity values can sometimes lead to worse aggregated fitness values, which can trigger undesired termination.
However, in many multi-fidelity-setups, terminating before the last fidelity increase, controlled e.g. by the fidelity
configuration parameter of OptimizerMies
, may be undesirable to begin with.
If the fidelity increase follows a fixed schedule based on evaluations or generations, one solution may be to use a
TerminatorCombo
together with a TerminatorEvals
or TerminatorGenerations
that prevents premature termination. Termination should happen at least patience
generations after the last switch to the
highest fidelity if termination from biased values because of fidelity changes should be avoided.
Otherwise it may be necessary to check whether the budget
value given to fitness_aggregator
reached the desired level,
and to prevent comparisons by letting fitness_aggregator
return NULL
if not.
In both cases one may still have a problem with biased aggregations within an aggregated set of individuals if include_previous_generations
is TRUE
.
Biases within aggregated generation(s)
When OptimizerMies
is constructed with multi_fidelity
set to TRUE
, it typically evaluates some configurations multiple times,
at first with a lower fidelity, followed by an evaluation at "full" fidelity.
fitness_aggregator
will only be called for generations containing entirely full-fidelity-evaluations will be aggregated.
This is achieved by caching aggregated fitness values in the $data_extra
field of the Archive
and only ever calling
fitness_aggregator
for a generation that does not have a cached value. Since mies_step_fidelity()
will
count low-fidelity evaluations as part of the "previous" generation, fitness_aggregator
will not see them.
Note, however that if fitness_aggregator
returns NULL
, it will be called again should a second evaluation occur in the same generation,
since NULL
is not cached and instead treated as absent.
It is possible for fitness_aggregator
to see fitness values that were evaluated with different fidelities when using OptimizerMies
,
and
-
fidelity_monotonic
is set toTRUE
and fidelity decreases (unlikely setup), or if
fidelity_current_gen_only
is set toFALSE
(advanced usage), orThe value returned by the
fidelity
configuration parameter (notfidelity_offspring
) changes over the course of optimization andinclude_previous_generations
ofTerminatorGenerationStagnation
is set toTRUE
.
(1) and (2) only need consideration in advanced scenarios, but (3) may be a common, e.g. when doing multi-fidelity optimization
and stopping on overall dominated hypervolume stagnation. In this case, it may be necessary to inspect the budget
value given to fitness_aggregator
and to remove all individuals evaluated with a different than the current fidelity.
When using a custom-written optimization loop, case (1) relates to fidelity_monotonic
argument of mies_step_fidelity()
and mies_init_population()
,
and case (2) relates to the current_gen_only
argument of mies_step_fidelity()
and the fidelity_new_individuals_only
argument of mies_init_population()
.
Case (3) relates to changing the fidelity given to mies_step_fidelity()
if that function is used, or to changing the fidelity given to mies_evaluate_offspring()
if
mies_step_fidelity()
is not used.
Dictionary
This Terminator
can be created with the short access form trm()
(trms()
to get a list),
or through the dictionary mlr_terminators
in the following way:
# preferred trm("genstag") trms("genstag") # takes vector IDs, returns list of Terminators # long form mlr_terminators$get("genstag")
Configuration Parameters
-
fitness_aggregator
::function
Aggregation function, called with information about alive individuals of each generation. This argument is passed tomies_aggregate_single_generation()
, see there for more details. The aggregated values returned byfitness_aggregator
should be maximized, so a larger value must be returned to indicate improvement in a generation, even if an underlying objective is being minimized. The return value must be a scalarnumeric(1)
. -
include_previous_generations
::logical(1)
Whether to aggregate over all individuals that were evaluated (TRUE
), or only the individuals alive in the current generation (FALSE
). If multi-fidelity optimization is being performed and individuals were re-evaluated with a different fidelity, theirx_id
will be the same and only the last fidelity-reevaluation will be given tofitness_aggregator
. However, individuals from different generations may still have been evaluated with different fidelity and it may be necessary to inspect thebudget
value given tofitness_aggregator
ifinclude_previous_generations
isTRUE
in a multi-fidelity-setting. See the "Multi-Fidelity Optimization" section for more. -
min_delta
::numeric(1)
Minimum positive change of aggregated value to count as improvement. This value may also be negative, resulting in termination only when aggregated value decreases by at least the given amount. However, depending on the survival setup, or oninclude_previous_generations
, it is possible that aggregate values never decrease; in this case, settingmin_delta
to a negative value may never trigger termination. Initialized to 0. -
patience
::integer(1)
Number of generations with no improvement better thanmin_delta
after which to terminate. Initialized to 1.
Super class
bbotk::Terminator
-> TerminatorGenerationStagnation
Methods
Public methods
Inherited methods
Method new()
Initialize the TerminatorGenerationStagnation
object.
Usage
TerminatorGenerationStagnation$new()
Method is_terminated()
Is TRUE
if when the termination criterion is matched, FALSE
otherwise.
Usage
TerminatorGenerationStagnation$is_terminated(archive)
Arguments
archive
Archive
Archive to check.
Returns
logical(1)
: Whether to terminate.
Method clone()
The objects of this class are cloneable with this method.
Usage
TerminatorGenerationStagnation$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
set.seed(1)
library("bbotk")
lgr::threshold("warn")
# Terminate when hypervolume with nadir `c(0, 0, ...)`
# does not improve for 3 generations by at least 0.1:
tg <- trm("genstag",
fitness_aggregator = function(fitnesses) domhv(fitnesses),
include_previous_generations = TRUE,
min_delta = 0.1,
patience = 3
)
set.seed(1)
objective <- ObjectiveRFun$new(
fun = function(xs) {
list(y1 = xs$x1, y2 = xs$x2)
},
domain = ps(x1 = p_dbl(0, 1), x2 = p_dbl(-1, 0)),
codomain = ps(y1 = p_dbl(0, 1, tags = "maximize"),
y2 = p_dbl(-1, 0, tags = "minimize"))
)
oi <- OptimInstanceMultiCrit$new(objective, terminator = tg)
op <- opt("mies",
lambda = 4, mu = 4,
mutator = mut("gauss", sdev = 0.1),
recombinator = rec("xounif"),
parent_selector = sel("random"),
survival_selector = sel("best", scl("hypervolume"))
)
op$optimize(oi)
# the observed aggregated values:
oi$archive$data_extra$TerminatorGenerationStagnation
# ... or as calculated by mies_generation_apply
mies_generation_apply(oi$archive, function(fitnesses) {
domhv(fitnesses)
}, include_previous_generations = TRUE)
#' @export
Short Access Forms for Operators
Description
These functions complement dict_mutators, dict_recombinators, dict_selectors with functions in the spirit of mlr3::mlr_sugar.
Usage
mut(.key, ...)
muts(.keys, ...)
rec(.key, ...)
recs(.key, ...)
sel(.key, ...)
sels(.key, ...)
scl(.key, ...)
scls(.key, ...)
ftr(.key, ...)
ftrs(.key, ...)
Arguments
.key |
( |
... |
(any) |
.keys |
( |
Value
-
Mutator
formut()
list of
Mutator
formuts()
-
Recombinator
forrec()
. list of
Recombinator
forrecs()
.-
Selector
forsel()
. list of
Selector
forsels()
.-
Scalor
forscl()
. list of
Scalor
forscls()
.
See Also
Other dictionaries:
dict_filtors
,
dict_mutators
,
dict_recombinators
,
dict_scalors
,
dict_selectors
Examples
mut("gauss", sdev = 0.5)
rec("xounif")
sel("random")
scl("nondom")
Perform Nondominated Sorting
Description
Assign elements of fitnesses
to nondominated fronts.
The first nondominated front is the set of individuals that is not dominated by any other individual with respect to any fitness dimension, i.e. where no other individual exists that has all fitness values greater or equal, with at least one fitness value strictly greater.
The n'th nondominated front is the set of individuals that is not dominated by any other individual that is not in any nondominated front with smaller n.
Fitnesses are maximized, so the individuals in lower numbered nondominated fronts tend to have higher fitness values.
Usage
rank_nondominated(fitnesses, epsilon = 0)
Arguments
fitnesses |
( |
epsilon |
( |
Value
list
: $front
: Vector assigning each individual in fitnesses
its nondominated front.
$domcount
: Length N vector counting the number of individuals that dominate the given individual.
Create a 'call' Object Representation
Description
repr()
creates a call
object representing obj
, if possible.
Evaluating the call should come close to recreating the original object.
In the most trivial cases, it should be possible to recreate objects from their
representation by evaluating them using eval()
. Important exceptions
are:
Functions are represented by their source code, if available, and by their AST if not. This drops the context from their environments and recreated objects will not work if they contain functions that depend on specific environments
-
environment
s are not represented. -
R6
objects are only represented if they have a$repr()
function. This function may have arbitrary arguments, and should have a...
argument to capture ignored arguments.
Objects that can not be represented are currently mapped to the call stop("<###>")
, where
###
is a short description of the non-representable object.
Usage
repr(obj, ...)
Arguments
obj |
(any) |
... |
(any) |
Value
call
: A call that, when evaluated, tries to re-create the object.
Chebyshev Scalarizer
Description
Constructs a Scalarizer
that does Chebyshev scalarization, as employed in ParEGO by Knowles (2006).
The Chebyshev scalarization for a single individual with
fitness values f
and given weight vector w
is
min(w * f) + rho * sum(w * f)
, where rho
is a hyperparameter
given during construction.
Usage
scalarizer_chebyshev(rho = 0.05)
Arguments
rho |
( |
Value
a Scalarizer
object.
References
Knowles, Joshua (2006). “ParEGO: A hybrid algorithm with on-line landscape approximation for expensive multiobjective optimization problems.” IEEE Transactions on Evolutionary Computation, 10(1), 50–66.
See Also
Other Scalarizers:
Scalarizer
,
scalarizer_linear()
Examples
# fitnesses: three rows (i.e. thee indivs) with two objective values each
fitnesses <- matrix(0:5, ncol = 2)
# weights: contains one matrix for each row of 'fitnesses' (i.e. each indiv)
# which get multiplied with their respective row.
weights <- list(
matrix(c(1, 0, 0, 1), ncol = 2),
matrix(c(1, 2, 0, 0), ncol = 2),
matrix(c(0, 1, 0, 1), ncol = 2)
)
sc <- scalarizer_chebyshev()
# The resulting row-vectors are the different scalarizations according to the
# columns in the 'weights' matrices.
sc(fitnesses, weights)
sc <- scalarizer_chebyshev(rho = 0.1)
sc(fitnesses, weights)
Linear Scalarizer
Description
Constructs a linear Scalarizer
, which performs linear scalarization for ScalorFixedProjection
.
Usage
scalarizer_linear()
Value
a Scalarizer
object.
See Also
Other Scalarizers:
Scalarizer
,
scalarizer_chebyshev()
Examples
# fitnesses: three rows (i.e. thee indivs) with two objective values each
fitnesses <- matrix(0:5, ncol = 2)
# weights: contains one matrix for each row of 'fitnesses' (i.e. each indiv)
# which get multiplied with their respective row.
weights <- list(
matrix(c(1, 0, 0, 1), ncol = 2),
matrix(c(1, 2, 0, 0), ncol = 2),
matrix(c(0, 1, 0, 1), ncol = 2)
)
sc <- scalarizer_linear()
# The resulting row-vectors are the different scalarizations according to the
# columns in the 'weights' matrices.
sc(fitnesses, weights)
Get the Numger of Generations that a Terminator Allows
Description
Get the number of generations of a TerminatorGenerations
. When the TerminatorGenerations
is wrapped in a TerminatorCombo
, then the minimum number of generations
allowed by it are retrieved. This is the minimum of all terminator_get_generations
if $any
is set
to TRUE
, and the maximum if $any
is set to FALSE
.
The number of generations allowed by other Terminator
s is infinity.
Usage
terminator_get_generations(x)
Arguments
x |
( |
Value
numeric(1)
: The theoretical maximum number of generations allowed by the Terminator
.