dict_recombinators_swap {miesmuschel}R Documentation

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 Param classes are: ParamLgl, ParamInt, ParamDbl, 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). Default TRUE. 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, RecombinatorPair, 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_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)


[Package miesmuschel version 0.0.3 Index]