Learn R Programming

rgp (version 0.4-1)

geneticProgramming: Standard typed and untyped genetic programming

Description

Perform a standard genetic programming (GP) run. Use geneticProgramming for untyped genetic programming or typedGeneticProgramming for typed genetic programming runs. The required argument fitnessFunction must be supplied with an objective function that assigns a numerical fitness value to an R function. Fitness values are minimized, i.e. smaller values denote higher/better fitness. If a multi-objective selectionFunction is used, fitnessFunction return a numerical vector of fitness values. The result of the GP run is a GP result object containing a GP population of R functions. summary.geneticProgrammingResult can be used to create summary views of a GP result object. During the run, restarts are triggered by the restartCondition. When a restart is triggered, the restartStrategy is executed, which returns a new population to replace the current one as well as a list of elite individuals. These are added to the runs elite list, where fitter individuals replace individuals with lesser fittness. The runs elite list is always sorted by fitness in ascending order. Only the first component of a multi-criterial fitness counts in this sorting. After a GP run, the population is inserted into the elite list. The elite list is returned as part of the GP result object.

Usage

geneticProgramming(fitnessFunction, stopCondition = makeTimeStopCondition(5), population = NULL, populationSize = 100, eliteSize = ceiling(0.1 * populationSize), elite = list(), functionSet = mathFunctionSet, inputVariables = inputVariableSet("x"), constantSet = numericConstantSet, crossoverFunction = crossover, mutationFunction = NULL, restartCondition = makeEmptyRestartCondition(), restartStrategy = makeLocalRestartStrategy(), searchHeuristic = makeAgeFitnessComplexityParetoGpSearchHeuristic(lambda = ceiling(0.5 * populationSize)), breedingFitness = function(individual) TRUE, breedingTries = 50, extinctionPrevention = FALSE, archive = FALSE, progressMonitor = NULL, verbose = TRUE)
typedGeneticProgramming(fitnessFunction, type, stopCondition = makeTimeStopCondition(5), population = NULL, populationSize = 100, eliteSize = ceiling(0.1 * populationSize), elite = list(), functionSet, inputVariables, constantSet, crossoverFunction = crossoverTyped, mutationFunction = NULL, restartCondition = makeEmptyRestartCondition(), restartStrategy = makeLocalRestartStrategy(populationType = type), searchHeuristic = makeAgeFitnessComplexityParetoGpSearchHeuristic(), breedingFitness = function(individual) TRUE, breedingTries = 50, extinctionPrevention = FALSE, archive = FALSE, progressMonitor = NULL, verbose = TRUE)

Arguments

fitnessFunction
In case of a single-objective selection function, fitnessFunction must be a single function that assigns a numerical fitness value to a GP individual represented as a R function. Smaller fitness values mean higher/better fitness. If a multi-objective selection function is used, fitnessFunction must return a numerical vector of fitness values.
type
The range type of the individual functions. This parameter only applies to typedGeneticProgramming.
stopCondition
The stop condition for the evolution main loop. See code makeStepsStopCondition for details.
population
The GP population to start the run with. If this parameter is missing, a new GP population of size populationSize is created through random growth.
populationSize
The number of individuals if a population is to be created.
eliteSize
The number of elite individuals to keep. Defaults to ceiling(0.1 * populationSize).
elite
The elite list, must be alist of individuals sorted in ascending order by their first fitness component.
functionSet
The function set.
inputVariables
The input variable set.
constantSet
The set of constant factory functions.
crossoverFunction
The crossover function.
mutationFunction
The mutation function.
restartCondition
The restart condition for the evolution main loop. See makeEmptyRestartCondition for details.
restartStrategy
The strategy for doing restarts. See makeLocalRestartStrategy for details.
searchHeuristic
The search-heuristic (i.e. optimization algorithm) to use in the search of solutions. See the documentation for searchHeuristics for available algorithms.
breedingFitness
A "breeding" function. This function is applied after every stochastic operation Op that creates or modifies an individal (typically, Op is a initialization, mutation, or crossover operation). If the breeding function returns TRUE on the given individual, Op is considered a success. If the breeding function returns FALSE, Op is retried a maximum of breedingTries times. If this maximum number of retries is exceeded, the result of the last try is considered as the result of Op. In the case the breeding function returns a numeric value, the breeding is repeated breedingTries times and the individual with the lowest breeding fitness is considered the result of Op.
breedingTries
In case of a boolean breedingFitness function, the maximum number of retries. In case of a numerical breedingFitness function, the number of breeding steps. Also see the documentation for the breedingFitness parameter. Defaults to 50.
extinctionPrevention
When set to TRUE, the initialization and selection steps will try to prevent duplicate individuals from occurring in the population. Defaults to FALSE, as this operation might be expensive with larger population sizes.
archive
If set to TRUE, all GP individuals evaluated are stored in an archive list archiveList that is returned as part of the result of this function.
progressMonitor
A function of signature function(population, objectiveVectors, fitnessFunction, stepNumber, evaluationNumber, bestFitness, timeElapsed, ...) to be called with each evolution step. Seach heuristics may pass additional information via the ... parameter.
verbose
Whether to print progress messages.

Value

A genetic programming result object that contains a GP population in the field population, as well as metadata describing the run parameters.

See Also

summary.geneticProgrammingResult, symbolicRegression