Class: GP

GP

new GP(params)

Genetic Programming evolutionary search heuristic. Parameters are: - Population size -- Size of the population - Solution size -- Max size of the nodes which represents an individual solution - Max depth -- Max depth of a tree, this is a function of the solution size - Generations -- Number of iterations of the search loop - Elite size -- Number of individuals preserved between generations - Crossover probability -- Probability of crossing over two solutions - Mutation probability -- Probability of mutating a solution - Fitness function -- Method used to evaluate fitness - Symbols -- The symbols that a GP tree can be built from
Parameters:
Name Type Description
params object GP parameters
Source:

Methods

crossover(crossoverProbability, population) → {Array}

The individuals are created by selecting two random nodes from two parents and swapping the subtrees. Checks that the nodes are compatible for crossover, to prevent too large trees. Loops over the entire population.
Parameters:
Name Type Description
crossoverProbability number Probability to crossover individuals
population array List of individuals
Source:
Returns:
List of crossed over individuals
Type
Array

evaluateFitness(population) → {array}

Evaluate the population according to the fitness function.
Parameters:
Name Type Description
population array List of individual solutions
Source:
Returns:
Evaluated population
Type
array

initializePopulation() → {Array}

Ramped half-half initialization. The individuals in the population are initialized using the grow or the full method for each depth value (ramped) up to max_depth.
Source:
Returns:
Population of individual solutions
Type
Array

mutation(mutationProbability, individuals, maxDepth, symbols) → {Array}

Mutate an individual by randomly picking a node and growing a new subtree from it. Loops over the entire population.
Parameters:
Name Type Description
mutationProbability number Probability to mutate an individual
individuals array List of individuals
maxDepth number Max depth of individual
symbols Symbols Symbols used to label nodes with
Source:
Returns:
List of mutated individuals
Type
Array

printStats(generation, population) → {Individual}

Print the statistics for the generation and population.
Parameters:
Name Type Description
generation number Generation number
population array List of individuals
Source:
Returns:
Best solution of the generation
Type
Individual

searchLoop(population) → {Individual}

Return the best individual from the evolutionary search loop. Starting from an initial population.
Parameters:
Name Type Description
population array Initial population
Source:
Returns:
Best individual solution (model)
Type
Individual

tournamentSelection(tournamentSize, population) → {Array}

Return individuals from a population by drawing `tournamentSize` competitors randomly and selecting the best of the competitors. `population_size` number of tournaments are held.
Parameters:
Name Type Description
tournamentSize number Number of competitors in each tournament
population array List of individuals
Source:
Returns:
List of winners from each tournament
Type
Array