Default settings for genetic operators used in the GA package.

gaControl(...)

Arguments

...

no arguments, a single character vector, or a named list with components.

Details

If the function is called with no arguments returns the current default settings, i.e., a list with the following default components:

binary

  • population = "gabin_Population"

  • selection = "gabin_lrSelection"

  • crossover = "gabin_spCrossover"

  • mutation = "gabin_raMutation"

real-valued

  • population = "gareal_Population"

  • selection = "gareal_lsSelection"

  • crossover = "gareal_laCrossover"

  • mutation = "gareal_raMutation"

permutation

  • population = "gaperm_Population"

  • selection = "gaperm_lrSelection"

  • crossover = "gaperm_oxCrossover"

  • mutation = "gaperm_simMutation"

eps

the tolerance value used by the package functions. By default set at sqrt(.Machine$double.eps).

useRcpp

a logical specifying if a faster C++ implementation of genetic operators should be used (TRUE by default), or an R implementation.

The function may be called with a single string specifying the name of the component. In this case the function returns the current default settings.

To change the default values, a named component must be followed by a single value (in case of eps or useRcpp) or a list of component(s) specifying the name of the function for a genetic operator. See the Examples section.

Value

If the argument list is empty the function returns the current list of values. If the argument list is not empty, the returned list is invisible.

Note

The parameter values set via a call to this function will remain in effect for the rest of the session, affecting the subsequent behaviour of the functions for which the given parameters are relevant.

Author

Luca Scrucca

See also

Examples

# get and save defaults
defaultControl <- gaControl()
print(defaultControl)
#> $binary
#> $binary$population
#> [1] "gabin_Population"
#> 
#> $binary$selection
#> [1] "gabin_lrSelection"
#> 
#> $binary$crossover
#> [1] "gabin_spCrossover"
#> 
#> $binary$mutation
#> [1] "gabin_raMutation"
#> 
#> 
#> $`real-valued`
#> $`real-valued`$population
#> [1] "gareal_Population"
#> 
#> $`real-valued`$selection
#> [1] "gareal_lsSelection"
#> 
#> $`real-valued`$crossover
#> [1] "gareal_laCrossover"
#> 
#> $`real-valued`$mutation
#> [1] "gareal_raMutation"
#> 
#> 
#> $permutation
#> $permutation$population
#> [1] "gaperm_Population"
#> 
#> $permutation$selection
#> [1] "gaperm_lrSelection"
#> 
#> $permutation$crossover
#> [1] "gaperm_oxCrossover"
#> 
#> $permutation$mutation
#> [1] "gaperm_simMutation"
#> 
#> 
#> $eps
#> [1] 1.490116e-08
#> 
#> $useRcpp
#> [1] TRUE
#> 
# get current defaults only for binary search
gaControl("binary")
#> $population
#> [1] "gabin_Population"
#> 
#> $selection
#> [1] "gabin_lrSelection"
#> 
#> $crossover
#> [1] "gabin_spCrossover"
#> 
#> $mutation
#> [1] "gabin_raMutation"
#> 
# set defaults for selection operator of binary search
gaControl("binary" = list(selection = "gabin_tourSelection"))
gaControl("binary")
#> $population
#> [1] "gabin_Population"
#> 
#> $selection
#> [1] "gabin_lrSelection"
#> 
#> $crossover
#> [1] "gabin_spCrossover"
#> 
#> $mutation
#> [1] "gabin_raMutation"
#> 
# set defaults for selection and crossover operators of binary search
gaControl("binary" = list(selection = "ga_rwSelection", 
                          crossover = "gabin_uCrossover"))
gaControl("binary")
#> $population
#> [1] "gabin_Population"
#> 
#> $selection
#> [1] "gabin_lrSelection"
#> 
#> $crossover
#> [1] "gabin_spCrossover"
#> 
#> $mutation
#> [1] "gabin_raMutation"
#> 
# restore defaults
gaControl(defaultControl)
gaControl()
#> $binary
#> $binary$population
#> [1] "gabin_Population"
#> 
#> $binary$selection
#> [1] "gabin_lrSelection"
#> 
#> $binary$crossover
#> [1] "gabin_spCrossover"
#> 
#> $binary$mutation
#> [1] "gabin_raMutation"
#> 
#> 
#> $`real-valued`
#> $`real-valued`$population
#> [1] "gareal_Population"
#> 
#> $`real-valued`$selection
#> [1] "gareal_lsSelection"
#> 
#> $`real-valued`$crossover
#> [1] "gareal_laCrossover"
#> 
#> $`real-valued`$mutation
#> [1] "gareal_raMutation"
#> 
#> 
#> $permutation
#> $permutation$population
#> [1] "gaperm_Population"
#> 
#> $permutation$selection
#> [1] "gaperm_lrSelection"
#> 
#> $permutation$crossover
#> [1] "gaperm_oxCrossover"
#> 
#> $permutation$mutation
#> [1] "gaperm_simMutation"
#> 
#> 
#> $eps
#> [1] 1.490116e-08
#> 
#> $useRcpp
#> [1] TRUE
#>