ecr {ecr}R Documentation

Interface to ecr similar to the optim function.


The most flexible way to setup evolutionary algorithms with ecr is by explicitely writing the evolutionary loop utilizing various ecr utlity functions. However, in everyday life R users frequently need to optimize a single-objective R function. The ecr function thus provides a more R like interface for single objective optimization similar to the interface of the optim function.


ecr(, minimize = NULL, n.objectives = NULL, n.dim = NULL,
  lower = NULL, upper = NULL, n.bits, representation, mu, lambda,
  perm = NULL, p.recomb = 0.7, p.mut = 0.3, survival.strategy = "plus",
  n.elite = 0L, custom.constants = list(), log.stats = list(fitness =
  list("min", "mean", "max")), log.pop = FALSE, monitor = NULL, = NULL, parent.selector = NULL,
  survival.selector = NULL, mutator = NULL, recombinator = NULL,
  terminators = list(stopOnIters(100L)), ...)


The fitness function.


Logical vector with ith entry TRUE if the ith objective of shall be minimized. If a single logical is passed, it is assumed to be valid for each objective.


Number of objectives of Optional if is a benchmark function from package smoof.


Dimension of the decision space.


Vector of minimal values for each parameter of the decision space in case of float or permutation encoding. Optional if is a benchmark function from package smoof.


Vector of maximal values for each parameter of the decision space in case of float or permutation encoding. Optional if is a benchmark function from package smoof.


Number of bits to use for binary representation.


Genotype representation of the parameters. Available are “binary”, “float”, “permutation” and “custom”.


Number of individuals in the population.


Number of individuals generated in each generation.


[integer(1) | vector]
Either a single integer number. In this case the set is assumed to be 1:perm. Alternatively, a set, i.e., a vector of elements can be passed which should form each individual.


Probability of two parents to perform crossover. Default is 0.7.


Probability to apply mutation to a child. Default is 0.1.


Determines the survival strategy used by the EA. Possible are “plus” for a classical (mu + lambda) strategy and “comma” for (mu, lambda). Default is “plus”.


Number of fittest individuals of the current generation that shall be copied to the next generation without changing. Keep in mind, that the algorithm does not care about this option if the survival.strategy is set to 'plus'. Default is 0.


Additional constants which should be available to all generators and operators. Defaults to empty list.


(Named) list of scalar functions to compute statistics on the fitness values in each generation. See initLogger for more information. Default is to log fitness minimum, mean and maximum values.


Shall the entire population be saved in each generation? Default is FALSE.


Monitoring function. Default is NULL, i.e. no monitoring.

List of individuals which should be placed in the initial population. If the number of passed individuals is lower than mu, the population will be filled up by individuals generated by the corresponding generator. Default is NULL, i.e., the entire population is generated by the population generator.


Selection operator which implements a procedure to copy individuals from a given population to the mating pool, i. e., allow them to become parents.


Selection operator which implements a procedurce to extract individuals from a given set, which should survive and set up the next generation.


Mutation operator of type ecr_mutator.


Recombination operator of type ecr_recombinator.


List of stopping conditions of type “ecr_terminator”. Default is to stop after 100 iterations.


Further arguments passed down to




fn = function(x) {
lower = c(-5, -5); upper = c(5, 5)
res = ecr(fn, n.dim = 2L, n.objectives = 1L, lower = lower, upper = lower,
 representation = "float", mu = 20L, lambda = 10L,
  mutator = setup(mutGauss, lower = lower, upper = upper))

[Package ecr version 2.1.0 Index]