Hide Comments
Hide Comments

Comments (0)

The TRSCustomGeneticProgramming component is the base class for including genetic programming (GP) in your programs that use floating point values. It instantiates the RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T> generics class using TGAFloat and ensures the correct TRSGPInstruction<T> and TRSGPNode<T> classes are created for it. This class creates nodes and instructions with arbitrary number of child nodes (arity > 0). If your problem requires at most functions of arity = 2, it is recommended to use the RSGeneticProgramming.TRSCustomBinaryGeneticProgramming class as it is slightly faster and uses slightly less memory.

Genetic programming is a computer science method, inspired by evolutionary biology, for automatically solving problems, without having to know or define the form or structure of the optimum problem structure beforehand. You define the basic building blocks (functions, constants, and variables) of the problem and then the component does the rest. Genetic programming solves problems by evolving a group or population of candidate individuals through successive generations, selecting fitter (or better) child individuals for each generation, until a solution is found. It uses evolutionary biology techniques such as inheritance, mutation, selection, and crossover (also called recombination).

The TRSCustomGeneticProgramming class contains a population of individuals (TRSGPPopulation<TGAFloat>), which contain genetic program trees as DNA. These DNA are used to represent the solution to the search problem. They represent the functions, constants, and variables of each candidate solution (or individual), represented by a TRSGPIndividual<TGAFloat> class.

After setting up the    Instructions that your genetic programs can use, you set the InitialPopulation , define a fitness function ( OnEvaluateFitness event) to properly "score" each individual, and then Evolve your solution.
 

alert_noteNotes to Implementers

The TRSCustomGeneticProgramming class redeclares the Instructions property and OnConstantMutation event to use instantiated generics types that look like non-generic types. Unfortunately, when a published property contains a generic, even an instantiated one (e.g., TRSGPInstructions<TGAFloat>), Delphi will not publish the property and make it available at design-time.

Namespace: RSGeneticProgramming

expandingInheritance Hierarchy

TComponent
  RSGeneticBase.TRSCustomGeneticComponent
    RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>
      RSGeneticProgramming.TRSCustomGeneticProgramming
        RSGeneticProgramming.TRSGeneticProgramming
 

expandingSyntax

Delphi

type
  TRSCustomGeneticProgramming = class(TRSCustomGeneticProgramming<TGAFloat>)
  end; 
 

expandingConstructors

 

Name

Description

public constructor

Create(TComponent)

Initializes a new instance of the TRSCustomGeneticProgramming<T> class. (Overrides RSGeneticBase.TRSCustomGeneticComponent.Create(TComponent).)

Top

expandingProperties

 

Name

Description

public property

AvgFitness

Returns the average fitness level of the   Population.
 (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

AvgProgramDepth

Returns the average program depth of the current   Population (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

AvgProgramSize

Returns the average program size of the current   Population (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

AvgWeightedFitness

Returns the average weighted fitness level of the   Population.
 (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

BloatLimit

Specifies the bloat limit. The meaning of this property depends on the   BloatStrategy. When the bloat strategy specifies limiting the depth, the BloatLimit specifies the maximum depth. Similarly, when the bloat strategy specifies limiting the tree size, the BloatLimit specifies the maximum size. (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

BloatStrategy

Specifies the strategy to deal with bloat in the genetic program trees.

Bloat, or uncontrolled growth of genetic programs, is a common problem in genetic programming. After a certain number of generations, genetic program trees tend to start gaining in size and depth rapidly, slowing execution and often leading to no convergence on a solution.

The BloatStrategy property specifies the anti-bloating strategy to attempt to control excessive tree growth. Unfortunately, the bloat strategies are often problem dependent so you may have to tinker with bloat strategies to see which works for your problem.

The     BloatLimit property is used with the BloatStrategy to specify when limits are exceeded. The     ParsimonyCoefficient property is used with parsimony-type anti-bloat strategies. The     TarpeianProbability property is used with the Tarpeian anti-bloat strategies.

alert_noteTip

You can implement your own anti-bloat strategy by hooking into the OnReproduction event

public property

CrossoverMethod

Specifies the crossover method to use. Currently, there is only one choice. cmSubtree, which specifies that crossover involves grafting a subtree from one parent into a subtree of another parent to create the new child's DNA.

The chance of crossover occurring depends on the CrossoverProbability property.

public property

CrossoverProbability

Controls the likelihood that crossover (also known as recombination) will occur when 2 parents are selected to create a new child. When crossover occurs, the 2 parents genes or DNA are combined to make the child. The crossover probability is checked for each new child (e.g., if there are 100 children created each generation, the CrossoverProbability will be tested 100 times).

The Operations property controls whether crossover occurs at all during evolution.

noteNote

If crossover does not occur, the child is a duplicate of the first parent (but may be mutated or inverted).

protected property

CumNormFitnesses

Contains the cumulative normalized fitnesses of the current generation (   Population) (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

Diversity

Returns the genetic diversity of the current Population, which is the   AvgFitness /   MaxFitness. In other words, how different (based upon fitness) are the individuals in the population from each other? If the population is not diverse enough, it is hard to breed a solution as everyone is alike. The genetic component can use the Diversity with the   DiversityLimit to automatically abort evolution if the diversity indicates we are in an evolutionary dead-end.
 (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

DiversityLimit

Specifies the minimum diversity the population must have in order to be considered viable. If the Diversity of the Population falls below this limit, the     Evolve method will abort evolution.

Note the     UseDiversityLimit property must be True to use the diversity limit.
 

public property

ElitistPct

Controls the percentage of "elite" parents used every generation for evolution. 0 means 0% of the population, 0.5 means 50% of the population, and 1 means 100% of the population. The ElitistPct property is used when the   SelectionMethod is smElitist.
 (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

FitnessCutoff

Specifies the Fitness level desired for the evolutionary search. If the     FittestIndividual of the     Population has a fitness greater than or less than (depending on the     FitnessMethod) the fitness cutoff, the     Evolve method will abort evolution.

Note the     UseFitnessCutoff property must be True to use the fitness cutoff.
 
 

public property

FitnessMethod

Controls how the genetic component evolves: should it seek to maximize fitness or minimize fitness (or weighted fitness) (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected property

FitnessSum

Contains the sum of all fitness values for the entire population (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

FittestIndividual

Returns the fittest individual in the Population. The individual is chosen based on the FitnessMethod and the Fitness evaluations of all the individuals in the population. The FittestIndividual is chosen every time the population is evolved.
 

This property is nil if the component is not  Initialized.

public property

FunctionsCount

Returns the number of   Instructions that are not terminals (i.e., functions of arity > 0) (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

Functions[Integer]

Returns a non-terminal function (Instructions that are functions of arity > 0) in the list of functions (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

Generation

Returns the current generation number of population. When the   Initialize method is called, the Generation is reset to 0. Every time the   Evolve method creates a new generation, this property is incremented.
 (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

GenerationLimit

Specifies the maximum number of generations to breed before quitting
 
Note the   UseGenerationLimit property must be True to use the generation limit.
 (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

Halt

Controls   Evolve method execution. Set Halt to true to stop evolution (useful for multi-threading) (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

InitialDuplicatesRetries

Specifies the number of times to retry generating an individual on initialization if it is a duplicate

noteNote

The InitialDuplicatesRetries property works differently for genetic algorithms and genetic programming. In genetic algorithms, this property is the maximum number of times to retry generation before giving up for the entire initial population. For genetic programming, this property specifies how many times we attempt to create a unique individual per individual. If all of these retry attempts fail, the initialization depth is incremented to try and make a unique individual at the new depth.

alert_noteTip

With genetic algorithms, this property is not very important as generating unique individuals is easy and duplicates will not occur very often. However, for genetic programming, initialization duplicates will almost certainly occur. Having duplicate individuals in the initial population is a waste of processing power as it limits the pool of truly available individuals (though having duplicates in later generations is a feature not a bug as fitter individuals will tend to be selected and reproduces more as we evolve our solution). It is highly recommended to avoid duplicates in the initialization phase.

public property

InitializationDepth

Specifies the initial maximum depth that an individual's genetic program tree. The initial maximum depth is a minimum of 2. However, if InitializationDepth is set to 0, then the genetic component will choose an initial depth based on number of operations.

The actual depth could be less if using a ramped or grow RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.InitializationMethod . Conversely, the actual depth could also be more than the maximum if the InitialDuplicatesRetries requires expanding the depth to avoid duplicates.

public property

InitializationMethod

Defines the initialization method to use for initializing an individuals genetic program tree, i.e., how are the initial GP trees formed.

The Full method creates trees that all equal the     InitializationDepth (think full, bushy trees). There are not necessarily all the same size (number of nodes) as they depends on the arity of the instructions, but the same initial depth. The Full method creates trees by selecting only functions with arity greater than 0 until the initialization depth is reached; after which only terminals are selected.

The Grow method creates a wider variety of shapes and sizes. In the Grow method, nodes for the trees are selected from the full set of primitives (functions, constants, and variables) until the initialization depth is reached. Since an early node could select a terminal (constant, variable, or function of arity = 0), that node's subtree stops growing before the initialization depth.

The literature suggests that the shape of trees can impact which types of problems a genetic programming component will solve. Koza, in his original book "Genetic Programming," actually suggests using a method called ramped half and half, which involves using both the Full and Grow method and varying the desired depth of the trees. The depth limit is ramped from 2 to the full initialization depth limit, i.e., first individual has a depth limit of 2, second individual has a depth limit of 3, etc up to the full initialization depth limit. The depth limits are evenly divided amongst the population, e.g., if there are 100 individuals and a full initialization depth limit of 10, approximately 11 individuals will have a depth limit of 2, 11 will have a depth limit of 3, etc.

public property

Initialized

Returns true if the genetic component has been initialized (and initial population has been created and evaluated for fitness) (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

InitialPopulation

Specifies the initial number of individuals to make in the   Population before attempting to solve your solution. Use this property to quickly and easily define the population size. The InitialPopulation property specifies the minimum initial population.

alert_noteTip

Your population size has a substantial bearing on whether the genetic component can find a solution, too small a population may be unable to evolve towards a solution, too large a population wastes processing power.

public property

Instructions

Specifies the set of instructions allowed in a genetic program, including all functions, variables and constants. When the genetic programming component is evolving the population of genetic programs, it uses this collection to select a function, variable or constant.

public property

InversionProbability

Controls the likelihood that inversion will occur in a child's DNA or chromosome, e.g., whether a portion of the child's chromosome will be flipped. The probability is between 0 (no chance) and 1 (always). When 2 parents reproduce and create a new child, their chromosomes are combined using Crossover and then the child's chromosome may be mutated and/or inverted. The InversionProbability is checked once per child.

The Operations property controls whether inversion occurs at all during evolution.
 

noteNote

In genetic programming, inversion is actually a point mutation (i.e., a node in an individual's GP tree may be flipped and become a different instruction of the same arity and type). You can either 0 out the probability here and handle it all in the mutation phase or leave it in.

public property

MaxFitness

Returns the highest fitness level of the   Population.
 
 (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

MaxProgramDepth

Returns the maximum program depth of the current   Population (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

MaxProgramSize

Returns the maximum program size of the current   Population (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

MaxWeightedFitness

Returns the highest weighted fitness level of the   Population.
 (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

MinFitness

Returns the lowest fitness level of the   Population.
 (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

MinProgramDepth

Returns the minimum program depth of the current   Population (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

MinProgramSize

Returns the minimum program size of the current   Population (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

MinWeightedFitness

Returns the lowest weighted fitness level of the   Population.
 (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

MutateConstantWeight

Defines the weight or probability that the subtree mutation method will be chosen over the other genetic programming mutation methods. When mutation is selected to occur (see MutationProbability ), the genetic programming component chooses a mutation method using the weights you supply.

Constant mutation replaces the value of a constant instruction with a different value (see     OnConstantMutation)
 

public property

MutateHoistWeight

Defines the weight or probability that the subtree mutation method will be chosen over the other genetic programming mutation methods. When mutation is selected to occur (see MutationProbability ), the genetic programming component chooses a mutation method using the weights you supply.

Hoist mutation replaces the entire child program tree with a subtree from the child (the subtree becomes the root node). This has the effect of reducing the complexity of the child.
 

public property

MutatePointWeight

Defines the weight or probability that the subtree mutation method will be chosen over the other genetic programming mutation methods. When mutation is selected to occur (see MutationProbability ), the genetic programming component chooses a mutation method using the weights you supply.

Point mutation replaces a node of the child with a node of the same type (e.g., arity and TRSGPInstruction<T>). The     PointMutationMethod and     PointMutationProbability control how the point mutation occurs.

public property

MutateReplacementWeight

Defines the weight or probability that the subtree mutation method will be chosen over the other genetic programming mutation methods. When mutation is selected to occur (see MutationProbability ), the genetic programming component chooses a mutation method using the weights you supply.

Replacement mutation is similar to Subtree mutation. It replaces a node of child with a node of the same type (e.g., arity and TRSGPGeneticInstruction<T>) and then grows a new subtree.
 

public property

MutateShrinkWeight

Defines the weight or probability that the subtree mutation method will be chosen over the other genetic programming mutation methods. When mutation is selected to occur (see MutationProbability ), the genetic programming component chooses a mutation method using the weights you supply.

Shrink mutation replaces a subtree of the child with a terminal. This has the effect of reducing the complexity of the child.
 

public property

MutateSubtreeWeight

Defines the weight or probability that the subtree mutation method will be chosen over the other genetic programming mutation methods. When mutation is selected to occur (see MutationProbability ), the genetic programming component chooses a mutation method using the weights you supply.

Subtree mutation replaces a randomly selected subtree of the child with a newly genereated subtree. The old subtree is deleted and a new subtree is grown in its place. The new subtree can be of a different type than the one being replaced, e.g., a constant is replaced with a function and its children.

public property

MutationProbability

Controls the likelihood that a child's chromosomes will be mutated.

For genetic algorithms, this is the likelihood that each bit of a child's chromosome will be mutated (flipped) between 0 (no chance) and 1 (always). When 2 parents reproduce and create a new child, their chromosomes are combined using Crossover and then the child's chromosome may be mutated. Because this probability is used for each bit of a child's chromosome, its value should be set very low (like 0.01). As a general rule, the probability that a chromosome will be flipped should be no more than 1 bit per individual. Any more bits flipping will keep the genetic algorithms from finding a solution.

For genetic programs, this is the likelihood that one mutation will occur in the genetic program tree, so its value should be higher than for genetic algorithms. Genetic programming has a whole suite of mutations (subtree, point, constant, etc) that can occur; which mutation occurs depends on their MutationWeights.
 
The     Operations property controls whether mutation occurs at all during evolution.
 
 

public property

MutationWeights

Defines the weights or probabilities that particular mutation methods will be chosen over the other genetic programming mutation methods. When mutation is selected to occur (see MutationProbability ), the genetic programming component chooses a mutation method using the weights you supply. (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected property

MutationWeightSum

Returns the sum of all the   MutationWeights (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

OnEvolve

Occurs each time the   Evolve method is called. The OnEvolve event handler is called once at the end of the Evolve method. Use the OnEvolve event handler to take action when the Population evolves. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected property

Operations

Returns a list of the   Instructions that are functions with arity > 0 (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

ParsimonyCoefficient

Specifies the parsimony coefficient to use when trying to control bloat using bsSizeParsimonyPressure and bsDepthParsimonyPressure.

When generating the  WeightedFitness of an individual, the  Fitness is reduced by the size or depth its genetic program multiplied by the ParsimonyCoefficient. This has the effect for evolving for smaller genetic programs over larger genetic programs.

noteNote

bsCovariantSizeParsimonyPressure and bsCovariantDepthParsimonyPressure also use the ParsimonyCoefficient when evaluating the WeightedFitness. However, these two methods recalculate the ParsimonyCoefficient themselves every generation using the formula CoVariance(ProgramData, FitnessData) / Variance(ProgramData).

public property

PointMutationMethod

Specifies how point mutation is performed on an individual's genetic program when point mutation is selected. Point mutation could occur once over the entire tree or there could be a chance of point mutation for every node in the tree. The   PointMutationProbability property controls the chance of point mutation occurring on a node (note that this is after the MutationProbability check has occurred and point mutation has been chosen from the set of mutation methods). (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

PointMutationProbability

The   PointMutationProbability property controls the chance of point mutation occurring on a node. When point mutation is going to occur, every node of the genetic program is checked against this probability to see if point mutation occurs. If point mutation is found to occur, what happens next depends on the   PointMutationMethod property. (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

Population

Represents the entire population of candidate individuals (TRSIndividual) in the current Generation, including the     FittestIndividual. The TRSCustomGeneticProgramming<T> component seeks to solve your optimization or search problems by evolving a group or population of candidate individuals through successive generations, selecting fitter (or better) child individuals for each generation, until a solution is found.

After every call to  Evolve, the Population property contains the next generation of individuals (the children), with the     PreviousGeneration property holding the previous generation (the parents, what was the Population before the Evolve call).
 

public property

PreviousGeneration

Contains the parents of the current generation, which is represented by the   Population property. After every call to  Evolve, the Population property contains the next generation of individuals (the children), with the PreviousGeneration property holding the previous generation (the parents, what was the Population before the Evolve call).
 (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected property

PriorityQueue

Returns the population sorted by fitness (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected property

RouletteIndex

Index of the individual next up in Elitist selection method or index of winner of roulette wheel selection method (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

SelectionMethod

Specifies how the genetic component selects individuals from the current generation to be used as parents of the next generation. The genetic component provides some built-in methods and allows you to write your own by using the   OnSelection event.
 (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public property

SelectionNonTerminalsProbability

Specifies the probability that a non-terminal (function) should be preferentially selected in a genetic program tree over a terminal (constant, variable, or function of arity = 0).

With genetic programming, it is preferable to select non-terminals over terminals for genetic operations. Changing an entire subtree's meaning is a stronger change than just changing a constant at the edges of a genetric program. Used in crossover, mutation, and inversion.

public property

TarpeianProbability

Specifies the probability that an individual's  Fitness will be set to UnfitFitness when its genetic program     Size or     Depth exceeds the average size or depth. The Tarpeian anti-bloat strategy has the advantage that the individual is judged before evaluating fitness which can significantly reduce computation.

This property is used when the BloatStrategy is bsTarpeianDepth or bsTarpeianSize.

protected property

Terminals

Returns a list of the   Instructions that are terminals: constants, variables, and functions of arity 0. (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

TerminalsCount

Returns the number of   Instructions that are terminals (i.e., constants, variables, and functions of arity = 0) (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

Terminal[Integer]

Returns a terminal (   Instructions that are constants, variables or functions of arity = 0) in the list of terminals (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

TournamentField

Represents property TournamentField. (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public property

UseDiversityLimit

Controls whether the genetic component attempts to abort evolution when the     Population's diversity falls below the     DiversityLimit. The DiversityLimit property aborts the evolutionary process when the diversity of the children falls below the DiversityLimit, e.g., all the children are too alike to go any further.

The Evolve method starts "breeding" the population towards your goal. The Evolve method may be called with the number of generations to execute. You can use the DiversityLimit, GenerationLimit and the FitnessCutoff as three properties to automatically abort evolution when they are exceeded. If the UseDiversityLimit is false, the     DiversityLimit will not abort evolution.
 
 

public property

UseFitnessCutoff

Controls whether the genetic component attempts to abort evolution when the     FitnessCutoff is exceeded. The FitnessCutoff property aborts the evolutionary process if the     FittestIndividual of the Population has a fitness greater than or less than (depending on the     FitnessMethod) the fitness cutoff, the     Evolve method will abort evolution.

The Evolve method starts "breeding" the population towards your goal. The Evolve method may be called with the number of generations to execute. You can use the DiversityLimit, GenerationLimit and the FitnessCutoff as three properties to automatically abort evolution when they are exceeded. If the     UseFitnessCutoff is false, the FitnessCutoff will not abort evolution.
 
 

public property

UseGenerationLimit

Controls whether the genetic component attempts to abort evolution when the maximum number of generations is exceeded. If     Generation exceeds     GenerationLimit, the     Evolve method will abort evolution.

The Evolve method starts "breeding" the population towards your goal. The Evolve method may be called with the number of generations to execute. You can use the DiversityLimit, GenerationLimit and the FitnessCutoff as three properties to automatically abort evolution when they are exceeded. If the     UseGenerationLimit is false, the GenerationLimit will not abort evolution.
 
 

protected property

WeightedFitnessSum

Contains the sum of all weighted fitness values for the entire population (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

Top

expandingMethods

 

Name

Description

public method

Assign(TPersistent)

Represents method Assign(TPersistent). (Overrides RSGeneticBase.TRSCustomGeneticComponent.Assign(TPersistent).)

public method

AssignAll(TPersistent)

Represents method AssignAll(TPersistent). (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected method

CalculateCumulativeNormalizedFitnesses

Calculates the cumulative normalized fitness values of the   Population (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public method

CompareFitness(TRSIndividual,TRSIndividual,Boolean)

Compares the two individuals and returns an evaluation of who is fitter. If the result is -1, Parent1 is fitter. If the result is 1, Parent2 is fitter. If the two individuals are equally fit, the function returns 0.

The function uses the RSGeneticBase.TRSIndividual.Fitness property or RSGeneticBase.TRSIndividual.WeightedFitness to determine which parent is fitter. The     FitnessMethod controls the interpretation of the fitness.

The UsePureFitness parameter tells the function if it should ignore WeightedFitness or not.

public method

CreateInstructions(TCollectionItemClass)

Creates the instructions collection (Overrides RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.CreateInstructions(TCollectionItemClass).)

public method

CreateNode(TRSGPInstruction<TGAFloat>,TRSGPNode<TGAFloat>)

Represents method CreateNode(TRSGPInstruction<TGAFloat>,TRSGPNode<TGAFloat>).

protected method

CreatePopulation(TRSIndividualClass)

Creates the population collection (Overrides RSGeneticBase.TRSCustomGeneticComponent.CreatePopulation(TRSIndividualClass).)

public method

Crossover(TRSIndividual,TRSIndividual,TRSIndividual)

Overloaded.  Combines the DNA of the two parents to make the DNA of the children. Note that crossover is not guaranteed to occur but is dependent on the     CrossoverProbability. The function calls the     OnCrossover event and then  DoCrossover method.

The Crossover method is called by the     Reproduce method. The function returns true if crossover occurred.
 

public method

Crossover(TRSIndividual,TRSIndividual,TRSIndividual,TRSIndividual)

Overloaded.  Combines the DNA of the two parents to make the DNA of the children. Note that crossover is not guaranteed to occur but is dependent on the     CrossoverProbability. The function calls the     OnCrossover event and then  DoCrossover method.

The Crossover method is called by the     Reproduce method. The function returns true if crossover occurred.
 

protected method

DefineProperties(TFiler)

Represents method DefineProperties(TFiler). (Overrides RSGeneticBase.TRSCustomGeneticComponent.DefineProperties(TFiler).)

public method

Describe(TStrings,String)

Provides a description of the genetic programming component and its important properties. The description is added to the Strings parameter. The TabStr parameter specifies the indentation to use when adding sub-strings. (Overrides RSGeneticBase.TRSCustomGeneticComponent.Describe(TStrings,String).)

protected method

DoAntiBloating(TRSIndividual,TRSIndividual,TRSIndividual,Boolean)

Performs the actual anti-bloating strategy after the new child has been created. The IsChildModified parameter indicates if the child was mutated or inverted

noteNote

Not all anti-bloating strategies occur in this method

protected method

DoCalculateFitnessStatistics

Calculates the fitness statistics (max, min, avg) for one generation. The method accesses each individual's Fitness property which may force a fitness evaulation to occur. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected method

DoCalculateWeightedFitnessStatistics

Calculates the weighted fitness statistics (max, min, avg) for one generation. The method accesses each individual's WeightedFitness property which may force a fitness evaulation to occur. (Overrides RSGeneticBase.TRSCustomGeneticComponent.DoCalculateWeightedFitnessStatistics.)

protected method

DoConstantMutation(TIndividual)

Performs a constant mutation (changes the constant of a tree node) (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected method

DoCrossover(TRSIndividual,TRSIndividual,TRSIndividual,TRSIndividual)

Performs the actual crossover operation. The decision to crossover has already been decided by the time this method is called. (Overrides RSGeneticBase.TRSCustomGeneticComponent.DoCrossover(TRSIndividual,TRSIndividual,TRSIndividual,TRSIndividual).)

protected method

DoEvaluateWeightedFitness(TRSIndividual)

Calls the OnEvaluateWeightedFitness event and returns the result. If the event handler has not been defined, this method returns the regular fitness (Overrides RSGeneticBase.TRSCustomGeneticComponent.DoEvaluateWeightedFitness(TRSIndividual).)

protected method

DoEvolve

Performs the actual evolve for one generation with each new pair of children being created in sequence (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected method

DoEvolveOneStep(Integer)

Performs the actual evolve for one pair of children (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected method

DoFairCrossover(TRSIndividual,TRSIndividual,TRSIndividual)

Represents method DoFairCrossover(TRSIndividual,TRSIndividual,TRSIndividual). (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected method

DoFinishEvolve

Performs final steps for one evolution phase. Called by DoEvolve. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected method

DoHoistMutation(TIndividual)

Performs a hoist mutation. Hoist mutation replaces the entire child program tree with a subtree from the child (the subtree becomes the root node). This has the effect of reducing the complexity of the child. (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected method

DoInitialize

Performs the actual initialization of the Population before evolution occurs.

The method returns number of duplicates fixed.

protected method

DoInitializeFull(TNode,Integer,Integer)

Initializes a genetic program tree to the full depth.

The Full method creates trees that all equal the     InitializationDepth (think full, bushy trees). There are not necessarily all the same size (number of nodes) as they depends on the arity of the instructions, but the same initial depth. The Full method creates trees by selecting only functions with arity greater than 0 until the initialization depth is reached; after which only terminals are selected.
 

protected method

DoInitializeGrow(TNode,Integer,Integer)

Initializes a genetic program tree by growing to the depth indicated.

The Grow method creates trees of a wider variety of shapes and sizes than the full method. In the Grow method, nodes for the trees are selected from the full set of primitives (functions, constants, and variables) until the initialization depth is reached. Since an early node could select a terminal (constant, variable, or function of arity = 0), that node's subtree stops growing before the initialization depth.
 

protected method

DoInvert(TRSIndividual)

Performs the actual inversion of the individual. The decision to invert the individual has already been made before calling this method. (Overrides RSGeneticBase.TRSCustomGeneticComponent.DoInvert(TRSIndividual).)

protected method

DoMutate(TRSIndividual)

Performs the actual mutation of the individual. The decision to mutat the individual has already been made before calling this method. (Overrides RSGeneticBase.TRSCustomGeneticComponent.DoMutate(TRSIndividual).)

protected method

DoParallelEvolveOneStep(Integer)

Performs the actual evolve for one pair of children (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected method

DoPointMutation(TIndividual)

Overloaded. Performs point mutation. A random node is selected and the primitive
stored there is replaced with a different random primitive of the same arity taken from the primitive set
 (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected method

DoPointMutation(TIndividual,TNode)

Overloaded.  Performs point mutation on the tree. A random node is selected and the primitive stored there is replaced with a different random primitive of the same arity taken from the primitive set

Returns true if a point mutation occurred. Point mutation can occur more than once based on     PointMutationMethod.
 

protected method

DoReplacementMutation(TIndividual)

Performs a replacement mutation (replace a subtree of the individual with another subtree that starts with the same arity) (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected method

DoReproduce(TRSIndividual,TRSIndividual,TRSIndividual)

Performs the actual reproduction operation by combining the two parents to make the new Child. The Child must already exist but may be uninitialized. (Overrides RSGeneticBase.TRSCustomGeneticComponent.DoReproduce(TRSIndividual,TRSIndividual,TRSIndividual).)

protected method

DoReproduce(TRSIndividual,TRSIndividual,TRSIndividual,TRSIndividual)

Performs the actual reproduction operation by combining the two parents to make two new children. The children must already exist but may be uninitialized. (Overrides RSGeneticBase.TRSCustomGeneticComponent.DoReproduce(TRSIndividual,TRSIndividual,TRSIndividual,TRSIndividual).)

protected method

DoSelectionPreparation

Performs any steps necessary for selecting parents in the newly evolved Population.

This method is called when evaluating fitness for everyone.
 

protected method

DoSelectParent(TRSPopulation)

Performs the selection of a parent from the Population. This method is only called if the   SelectionMethod is Custom. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected method

DoShrinkMutation(TIndividual)

Performs a shrink mutation. Shrink mutation replaces a subtree of the child with a terminal. This has the effect of reducing the complexity of the child. (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected method

DoStartEvolve

Performs initial steps for one evolution phase. Called by DoEvolve. (Overrides RSGeneticBase.TRSCustomGeneticComponent.DoStartEvolve.)

protected method

DoSubtreeMutation(TIndividual)

Performs a subtree mutation (replace a subtree of the individual with another subtree) (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public method

EvaluateFitness

Overloaded.  Evaluates the fitness for every individual of the Population (and calculates the     MaxFitness,     MinFitness, and     AvgFitness). It calculates a fitness estimation for every RSGeneticBase.TRSIndividual by calling the overloaded     EvaluateFitness method. It uses your     OnEvaluateFitness event handler to calculate values. After every individual is evaluated, it sets the MaxFitness, MinFitness, and AvgFitness values and sets the     FittestIndividual property.

Defining your fitness function is a highly important part of defining a genetic algorithm or genetic program. The fitness function returns a floating point value that specifies the correctness of the individual solution. The fitness function needs to be able to allow the genetic component to decide which solution is better than another. The genetic component will seek to either maximize the solution (e.g., keep evolving for individuals whose fitness are greater than other individuals in the population) or to minimize the solution (e.g., find the individuals whose fitness are less than other individuals). Note you can specify which direction to evolve towards with the     FitnessMethod property.
 

public method

EvaluateFitness(TRSIndividual,Boolean)

Returns a fitness estimation of the passed in RSGeneticBase.TRSIndividual . It uses your     OnEvaluateFitness event handler to return the value.

Defining your fitness function is a highly important part of defining a genetic algorithm or genetic program. The fitness function returns a floating point value that specifies the correctness of the individual solution. The fitness function needs to be able to allow the genetic component to decide which solution is better than another. The genetic component will seek to either maximize the solution (e.g., keep evolving for individuals whose fitness are greater than other individuals in the population) or to minimize the solution (e.g., find the individuals whose fitness are less than other individuals). Note you can specify which direction to evolve towards with the     FitnessMethod property.

The overloaded     EvaluateFitness method evaluates the fitness for every individual of the Population (and calculates the     MaxFitness,     MinFitness, and     AvgFitness).
 

public method

Evolve

Overloaded.  The Evolve method is the heart of the genetic component. The Evolve method is responsible for "breeding" the     Population towards an answer for your goal. Each generation, the Evolve method selects parents and then     Reproduces children for the new generation by using the genetic operations: first crossover, then mutation, and finally inversion. Each call to Evolve with breed one new generation. If you want to evolve many new generations at once (perhaps with a cutoff using the     FitnessCutoff,     GenerationLimit and     DiversityLimit properties), use the overloaded Evolve method. Successive calls to the Evolve method continues the evolutionary process from where the Evolve method stopped (use     Initialize to reset the process). If this is your first call to Evolve, it automatically calls the Initialize method.

Specify the     Operations to control which operations are performed while evolving: crossover, mutation, and inversion operations. You can also specify the chances of each operation occurring every generation using the     CrossoverProbability,     MutationProbability, and     InversionProbability properties.

The     SelectionMethod property (or     OnSelection event) specifies how the genetic component selects individuals from the current generation to be used as parents of the next generation.

The FitnessCutoff property aborts the evolutionary process when any child meets or exceeds (if FitnessMethod is fmMaximize) or is less than (if FitnessMethod is fmMinimize) the cutoff value. The     UseFitnessCutoff property must be true to use the fitness cutoff.

The DiversityLimit property aborts the evolutionary process when the diversity of the children falls below the DiversityLimit, e.g., all the children are too alike to go any further. The     UseDiversityLimit property must be true to use the diversity limit.

The GenerationLimit property aborts the evolutionary process when the required number of generations have been evolved. The     UseGenerationLimit property must be true to use the generation limit.
 
 

public method

Evolve(Integer)

Overloaded.  The Evolve method is the heart of the genetic component. The Evolve method is responsible for "breeding" the     Population towards an answer for your goal. Each generation, the Evolve method selects parents and then     Reproduces children for the new generation by using the genetic operations: first crossover, then mutation, and finally inversion. You can specify the number of generations to evolve or use the     FitnessCutoff,     GenerationLimit and     DiversityLimit properties to automatically stop the genetic process. Successive calls to the Evolve method continues the evolutionary process from where the Evolve method stopped (use     Initialize to reset the process). If this is your first call to Evolve, it automatically calls the Initialize method.

Specify the     Operations to control which operations are performed while evolving: crossover, mutation, and inversion operations. You can also specify the chances of each operation occurring every generation using the     CrossoverProbability,     MutationProbability, and     InversionProbability properties.

The     SelectionMethod property (or     OnSelection event) specifies how the genetic component selects individuals from the current generation to be used as parents of the next generation.

The FitnessCutoff property aborts the evolutionary process when any child meets or exceeds (if FitnessMethod is fmMaximize) or is less than (if FitnessMethod is fmMinimize) the cutoff value. The     UseFitnessCutoff property must be true to use the fitness cutoff.

The DiversityLimit property aborts the evolutionary process when the diversity of the children falls below the DiversityLimit, e.g., all the children are too alike to go any further. The     UseDiversityLimit property must be true to use the diversity limit.

The GenerationLimit property aborts the evolutionary process when the required number of generations have been evolved. The     UseGenerationLimit property must be true to use the generation limit.
 
 
 

public method

Fittest(TRSIndividual,TRSIndividual,Boolean)

Returns the "fitter" of the two parent individuals. It compares the Fitness properties (or WeightedFitness) of both individuals, and, based on the FitnessMethod, selects the better individual. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected method

GetAdjustedFitness(TGAFitness)

Calculates the adjusted fitness, a value between 0 and 1, where a bigger value (closer to 1) represents better individuals.

The adjusted fitness equals 1/(1 + StandardizedFitness) when minimizing, and 1/(1+(MaxFitness - StandardizedFitness)) when maximizing.
 

protected method

GetNode(TNode,Integer)

Overloaded. Creates and returns a node for the specified parent node. The node may be a function, constant, or variable node (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected method

GetNode(TNode,TNode,Integer)

Overloaded. Creates and returns a node for the specified parent node. The node is similar (of the same type and arity of the Similar node parameter) (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected method

GetNormalizedFitness(TGAFitness)

Calculates the normalized fitness, a value between 0 and 1.

The normalized fitness equals Fitness / Sum of All Fitness

protected method

GetNormalizedWeightedFitness(TGAFitness)

Calculates the normalized weighted fitness, a value between 0 and 1.

The normalized fitness equals Fitness / Sum of All Weighted Fitness

protected method

GetOperationNode(TNode,Integer)

Creates and returns a function node for the specified parent node from the list of   Operations (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected method

GetSimilarInstruction(TInstruction)

Returns an instruction that is similar (of same type and arity) (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected method

GetTerminalNode(TNode,Integer)

Creates and returns a terminal (constants, variables, and functions of arity=0) node for the specified parent node from the list of   Terminals (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public method

Initialize

Prepares the genetic component for evolution (or resets the genetic population to start over). On calling the Initialization method, the Population is set to the   InitialPopulation size. The   OnInitialization method is called. Then, the Population's DNA are randomized and each individual's fitness is evaluated. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected method

InitializeChild(TRSIndividual,TRSIndividual,TRSIndividual)

Initializes the Child with the two parents (usually just a copy of the first parent) (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected method

InstructionNotify(TInstruction,Classes)

Called when an instruction is added or removed from the   Instructions (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected method

InstructionOperationUpdate(TInstruction)

Called when an instruction's Operation is changed (i.e., it changes from a function to a constant or a variable to a function, etc) (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected method

InstructionUpdate(TInstruction)

Called when an instruction is changed (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public method

Invert(TRSIndividual)

Inverts the DNA of the individual. Inversion for genetic algorithms means flipping the bits of the chromosome. For genetic programs, inversion means a point mutation (replacing a node with another node of the same arity in the tree).

Note that inversion is not guaranteed to occur but is dependent on the     InversionProbability. The function calls the     OnInversion event and then DoInvert method.
 
The Invert method is called by the     Reproduce method. The function returns true if inversion occurred.
 

protected method

IsCustomSelection

Returns true if   SelectionMethod is custom (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public method

IsFinished

Returns true if the evolution process is complete. The process is complete if the Fitness meets the   FitnessCutoff (if   UseFitnessCutoff is true) or the population diversity meets the   DiversityLimit (if   UseDiversityLimit is true) or the   Generation exceeds the   GenerationLimit (if   UseGenerationLimit is true). (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public method

LoadFromFile(string)

Loads the entire genetic component from the XML file specified by the Filename parameter, including the Genes (genetic algorithms) or Instructions (genetic programming) and the Population. Use the LoadFromFile and SaveToFile methods to stream in and out the genetic component in XML format. The format of the XML is defined in the GeneticAlgorithm.xsd and GeneticProgramming.xsd schema files. (Overrides RSGeneticBase.TRSCustomGeneticComponent.LoadFromFile(string).)

public method

LoadFromStream(TStream)

Loads the entire genetic component from the XML stream specified by the stream parameter, including the Genes (genetic algorithms) or Instructions (genetic programming) and the Population. Use the LoadFromStream and SaveToStream methods to stream in and out the genetic component in XML format. The format of the XML is defined in the GeneticAlgorithm.xsd and GeneticProgramming.xsd schema files. (Overrides RSGeneticBase.TRSCustomGeneticComponent.LoadFromStream(TStream).)

public method

LoadFromXML(IXMLGeneticProgram)

Overloaded. Load the entire genetic programming scenario from the XML

alert_cautionWarning

The component reads and writes the metadata about instructions (i.e., name, arity, comment) but does not actually read or write the OnExecute code. After reading a genetic programming scenario, you need to add OnExecute event handlers to instructions.

alert_cautionImportant Note

When reading a genetic programming scenario, the component will attempt to match currently existing instructions to instruction names in the scenario. IF an instruction is found, the instruction will be preserved (including its OnExecute event).

After reading the scenario, any previous instructions not found in the scenario will be deleted.

public method

LoadFromXML(IXMLGPDomainType)

Overloaded. Load the genetic programming domain ( instructions, fittest individual, population) from the XML

alert_cautionWarning

The component reads and writes the metadata about instructions (i.e., name, arity, comment) but does not actually read or write the OnExecute code. After reading a genetic programming scenario, you need to add OnExecute event handlers to instructions.

alert_cautionImportant Note

When reading a genetic programming scenario, the component will attempt to match currently existing instructions to instruction names in the scenario. IF an instruction is found, the instruction will be preserved (including its OnExecute event).

After reading the scenario, any previous instructions not found in the scenario will be deleted.

public method

LoadFromXML(IXMLGPInstructions)

Overloaded. Load the genetic programming instructions from the XML

alert_cautionWarning

The component reads and writes the metadata about instructions (i.e., name, arity, comment) but does not actually read or write the OnExecute code. After reading a genetic programming scenario, you need to add OnExecute event handlers to instructions.

alert_cautionImportant Note

When reading a genetic programming scenario, the component will attempt to match currently existing instructions to instruction names in the scenario. IF an instruction is found, the instruction will be preserved (including its OnExecute event).

After reading the scenario, any previous instructions not found in the scenario will be deleted.

public method

MaxNodeArity

Returns the maximum number of children and node ( RSGenerics.GeneticProgramEngine.TRSGPNode<T> ) in the component can accept (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public method

Mutate(TIndividual,TGPMutationMethod)

Overloaded.  Mutates the DNA of the individual using the Mutation method. The mutation method controls how the genetic program tree is modified.

This method is called by the overloaded Mutate method when mutation is found to have occurred by its probability.
 

protected method

PopulationNotify(TRSIndividual,TCollectionNotification)

Called when an individual is added or removed from the   Population (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected method

PopulationUpdate(TRSIndividual)

Called when an individual has changed (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected method

PrioritizePopulation

Prioritizes or sorts the population based on Fitness or WeightedFitness and the   FitnessMethod. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public method

Reproduce(TRSIndividual,TRSIndividual,TRSIndividual)

Overloaded.  The Reproduce method takes the two Parents and "mates" them to create the new Children. The Child parameters must exist but all of their information will be overwritten by the Parents. The New Child is copied from its first parent and then     Crossover,     Mutate, and     Invert are called according to the Operations property and the respective probability of the operation. Finally, an     OnReproduction event occurs.

The Evolve method calls the Reproduce methods.
 

public method

Reproduce(TRSIndividual,TRSIndividual,TRSIndividual,TRSIndividual)

Overloaded.  The Reproduce method takes the two Parents and "mates" them to create the new Children. The Child parameters must exist but all of their information will be overwritten by the Parents. Child1 is copied from the first parent and Child2 is copied from the second parent, and then     Crossover,     Mutate, and     Invert are called according to the Operations property and the respective probability of the operation. Finally, an     OnReproduction event occurs.

The Evolve method calls the Reproduce methods.
 

public method

SaveToFile(string)

Saves the entire genetic component to the XML file specified by the Filename parameter, including the Genes (genetic algorithms) or Instructions (genetic programming) and the Population. Use the LoadFromFile and SaveToFile methods to stream in and out the genetic component in XML format. The format of the XML is defined in the GeneticAlgorithm.xsd and GeneticProgramming.xsd schema files. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public method

SaveToStream(TStream)

Saves the entire genetic component to the XML stream specified by the stream parameter, including the Genes (genetic algorithms) or Instructions (genetic programming) and the Population. Use the LoadFromFile and SaveToFile methods to stream in and out the genetic component in XML format. The format of the XML is defined in the GeneticAlgorithm.xsd and GeneticProgramming.xsd schema files. (Overrides RSGeneticBase.TRSCustomGeneticComponent.SaveToStream(TStream).)

public method

SaveToXML(IXMLGeneticDocumentType)

Overloaded. Saves the entire genetic component to the XML specified by the parameter, including the Genes (genetic algorithms) or Instructions (genetic programming) and the Population. Use the LoadFromFile and SaveToFile methods to stream in and out the genetic component in XML format. The format of the XML is defined in the GeneticAlgorithm.xsd and GeneticProgramming.xsd schema files. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public method

SaveToXML(IXMLGeneticProgram)

Overloaded. Saves the genetic programming scenario to XML

alert_cautionWarning

The component writes the metadata about instructions (i.e., name, arity, comment) but does not actually write the OnExecute code.

public method

SaveToXML(IXMLGPDomainType)

Overloaded. Saves the genetic programming domain ( instructions, fittest individual, population) to XML

alert_cautionWarning

The component writes the metadata about instructions (i.e., name, arity, comment) but does not actually write the OnExecute code.

public method

SaveToXML(IXMLGPInstructions)

Overloaded. Saves the genetic programming instructions to XML

alert_cautionWarning

The component writes the metadata about instructions (i.e., name, arity, comment) but does not actually write the OnExecute code.

public method

SearchSpaceSize(Cardinal)

Returns the size of size of the total set of trees from one level of nodes up to a maximum size identified by the variable level. This space contains every combination of the functions and terminals, and the arity of each function arity for every tree of depth 1 up to the stated maximum depth. This number is useful for getting an idea of the size of the search space and may encourage you to reduce the number of functions, terminals, or arity of functions. (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

protected method

SelectElitist(TObject,TRSPopulation,TRSIndividual)

Selected a Parent individual from the Population using the Elitist method.

The top nth percentile parents are chosen (and re-chosen) using this method. Elitist is a heavy-weight selection algorithm (in our implementation at least) because we must figure out the top nth percentile population first
 

public method

SelectParent(TRSPopulation)

Selects a parent for the new generation using the   SelectionMethod or the   OnSelection event. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected method

SelectRandom(TObject,TRSPopulation,TRSIndividual)

Selected a Parent individual from the Population at random.
 (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

protected method

SelectRoulette(TObject,TRSPopulation,TRSIndividual)

Selected a Parent individual from the Population using the Roulette Wheel (fitness proportional) method.

The better "fit" parents are more likely to be chosen (and re-chosen), e.g., the probability of selection is proportional to the fitness of the parent. Also known as fitness proportionate selection.
 

protected method

SelectStochasticTournament(TObject,TRSPopulation,TRSIndividual)

Selected a Parent individual from the Population using the Elitist method.

Select "best" (in this case using roulette wheel) parents from a tournament field (size of tournament field is determined by the     TournamentField property), e.g., select the best parent by selecting better fit individuals proportionally TournamentField times and then choosing the "winner" of the tournament. Note: for speed purposes, this selection method does not ensure that the same individual cannot be picked twice
 

protected method

SelectTournament(TObject,TRSPopulation,TRSIndividual)

Selected a Parent individual from the Population using the Tournament method.

Select "best" parents from a tournament field (size of tournament field is determined by the     TournamentField property), e.g., select the best parent from randomly selecting individuals TournamentField times and then choosing the "winner" of the tournament. Note: for speed purposes, this selection method does not ensure that the same individual cannot be picked twice
 

protected method

SumOfWeights(TGPMutationMethodWeights)

Calculates the sum of all the   MutationWeights (Inherited from RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T>.)

public method

SwapGenerations

Swaps the Population and PreviousGeneration collections in preparation for evolving a new generation. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public method

ToString

Provides a strings description of the genetic programming component and its important properties. The function uses the  Describe method to build the string. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public method

UnfitFitness

Returns a value that represents extreme unfitness. Useful for breeding out an individual by settings its fitness to this value (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

Top

expandingEvents

 

Name

Description

public event

OnConstantMutation

Occurs when constant mutation is selected. Use this event to supply a new constant value for a genetic program node

public event

OnCrossover

Occurs when two parents ( RSGeneticBase.TRSIndividual) have reproduced to create new children and some portion of the their DNA are about to be combined from the parents. The DoMutation parameter controls whether the crossover will occur. It has already been set based on the   CrossoverProbability (and so sometimes will be True and sometimes will be False). Set the DoMutation parameter either to force the crossover to occur or to prohibit it from occuring. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public event

OnEvaluateFitness

Occurs when the     EvaluateFitness method is called. Use the OnEvaluateFitness event to define your fitness function for the genetic algorithm. Defining your fitness function is another highly important part of defining a genetic algorithm. The fitness function returns a floating point value that specifies the correctness of the individual solution. The fitness function needs to be able to allow the genetic component to decide which solution is better than another. The genetic component will seek to either maximize the solution (e.g., keep evolving for individuals whose fitness are greater than other individuals in the population) or to minimize the solution (e.g., find the individuals whose fitness are less than other individuals). Note you can specify which direction to evolve towards with the     FitnessMethod property.

Use the OnEvaluateFitness event to calculate each TRSIndividual's fitness level. Without an OnEvaluateFitness event handler all individuals in the population will have a default Fitness of 0. Every generation, when the Evolve method is called, the OnEvaluateFitness event will occur Population.Count number of times.
 

public event

OnEvaluateWeightedFitness

Occurs when the genetic component needs to evaluate weighted fitness for an individual.

Weighted Fitness allows weighting the fitness for searching the solution space to guide the search. Fitness still evaluates if an individual solves the problem, but the weighted fitness can help constrain the search. For example, genetic programs can weight the fitness by reducing the fitness by the size of the program (limiting growth).

alert_cautionImportant Note

Do not repeat your RSGeneticBase.TRSCustomGeneticComponent.OnEvaluateFitness event code here (this is just wasteful) Rather, weight the Individual.Fitness by some function.

public event

OnInitialization

Occurs when the   Initialize method is called. Use the OnInitialization event to react to the initialization of the genetic algorithm problem or to pre-seed the   Population with specific individuals. The OnInitialization event occurs after the Population is created but before their DNA are randomized and their fitness evaluated. Set the Initialized variable to True to prevent the Initialize method from randomizing the Population's DNA. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public event

OnInitializeChild

Occurs when the two Parent parameters are reproducing to create the new Child (Reproduce method). The OnInitializeChild event occurs after the Child has been created and been copied from the first Parent and before the genetic Operations are performed. Use the OnInitializeChild event to react to the creation of the new Child or to modify the Child. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public event

OnInversion

Occurs when two parents (TRSIndividual) have reproduced to create a new child and some portion of the child's DNA is about to be inverted. The DoMutation parameter controls whether the inversion will occur. It has already been set based on the   InversionProbability (and so sometimes will be True and sometimes will be False). Set the DoMutation parameter either to force the inversion to occur or to prohibit it from occurring. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public event

OnMutation

Occurs when two parents (TRSIndividual) have reproduced to create a new child and some portion of the child's DNA is about to be mutated. The DoMutation parameter controls whether the mutation will occur. It has already been set based on the   MutationProbability (and so sometimes will be True and sometimes will be False). Set the DoMutation parameter either to force the mutation to occur or to prohibit it from occurring. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public event

OnReproduction

Occurs when two parent individuals (TRSIndividual)   Reproduce to create a new child. The OnReproduction event occurs after the child has been created and then its DNA possibly combined, mutated, and inverted. Use the OnReproduction event to perform some action after reproduction has occurred. The OnReproduction event can also be useful for validation, to verify the various   Operations haven't produced an invalid child. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

public event

OnSelection

Occurs when the genetic component needs to select parents for Reproduction. The OnSelection event is only called if the   SelectionMethod is smCustom. Use the OnSelection event to write your own selection method. (Inherited from RSGeneticBase.TRSCustomGeneticComponent.)

Top

expandingRemarks

When creating instructions or nodes to use with this class, always use the  CreateInstructions and  CreateNode methods as they ensure you create an instruction or node of the correct type.

expandingSee Also

Comments (0)