Represents one individual, or candidate solution, in the Population of solutions in a genetic programming problem. In genetic programming ( RSGenerics.GeneticProgramming.TRSCustomGeneticProgramming<T> component), there is a population of individuals (TRSGPPopulation<T>), which contain tree-based DNA programs. Each candidate individual (represented by a TRSGPIndividual<T> class) has "DNA", which contains one program containing functions and terminals (constants and variables)
Genetic Programming works by evolving your population towards the solution of the problem. Parents are selected from the current generation to reproduce the children of the next generation. Evolving a new generation involves:
• | Selecting 2 parents (Individuals) to reproduce |
• | Splicing the DNA program trees of the 2 parents together to make a child (the child inherits the parents trees or sub-trees) |
• | Optionally Mutating and Inverting the DNA trees of the child to provide randomness |
• | Repeating the above steps until the population of the new generation has been produced. |
Note
|
This is a generics-based implementation of a genetic programming population. For the RSGeneticProgramming|TRSGeneticProgramming class, the generics class is instantiated as floating point values. However, you can define your own genetic programming component using whatever type you want.
|
Namespace: RSGenerics.GeneticProgramming
Type Parameters
T
|
Name
|
Description
|
|
AdjustedFitness
|
Represents property AdjustedFitness. (Inherited from RSGeneticBase.TRSIndividual.)
|
|
Collection
|
Returns the population that this individual belongs to.
|
|
DNA
|
Represents the genetic code of the individual, its DNA as a program tree of functions, constants, and variables.
|
|
Fitness
|
The Fitness property is a floating point value that specifies the correctness of the individual DNA. Fitness is used by the genetic components to decide which individuals are better than others. Fitness is a score you define for every individual using an OnEvaluateFitness event handler. It may be any floating point number. However, fitness must have relative meaning among the entire range of assigned fitness numbers, e.g., a fitness of -10 must be worse than a fitness of -3 which must be worse than a fitness of 5, etc (or vice versa, the FitnessMethod property tells the genetic component whether lower or higher numbers are desirable). The NormalizedFitness value is the fitness of the individual normalized over the entire population's fitness values so that it is a value between 0 and 1 (where 0 will be the individual with the lowest fitness and 1 will be the individual with the highest fitness).
Using each individual's calculated fitness and the FitnessMethod, 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).
|
|
FlattenedDNA
|
Represents property FlattenedDNA.
|
|
Name
|
Allows you to provide a descriptive name for the individual. The genetics components do not use this property. (Inherited from RSGeneticBase.TRSIndividual.)
|
|
NeedFitness
|
Represents property NeedFitness. (Inherited from RSGeneticBase.TRSIndividual.)
|
|
NormalizedFitness
|
Returns the Fitness of the individual normalized over the entire population's fitness values so that it is a value between 0 and 1 (where 0 will be the individual with the lowest fitness and 1 will be the individual with the highest fitness).
(Inherited from RSGeneticBase.TRSIndividual.)
|
|
NormalizedWeigthedFitness
|
Returns the WeightedFitness of the individual normalized over the entire population's weighted fitness values so that it is a value between 0 and 1 (where 0 will be the individual with the lowest weighted fitness and 1 will be the individual with the highest weighted fitness). (Inherited from RSGeneticBase.TRSIndividual.)
|
|
WeightedFitness
|
Returns the Fitness value weighted by some function. Use the RSGeneticBase.TRSCustomGeneticComponent.OnEvaluateWeightedFitness event to specify the weighting.
The genetic components can guide the search for the best individual by using the weighted fitness instead of the regular fitness. The weighted fitness allows optimization for something other than the pure fitness. For example, with genetic programming, the weighted fitness can be used to weight the fitness for smaller programs. The FitnessMethod specifies whether the Fitness or the WeightedFitness is used in the search.
Note that the Fitness is always used for determining if we have found the "best" individual for termination purposes.
|
Top
|
|
Name
|
Description
|
|
Assign(TPersistent)
|
Overloaded. Represents method Assign(TPersistent). (Overrides RSGeneticBase.TRSIndividual.Assign(TPersistent).)
|
|
AssignDNA(TNode)
|
Replaces the current DNA tree with the aDNA parameter. The old DNA tree is deleted and freed.
|
|
Clone
|
Returns an exact copy of the current individual. (Inherited from RSGeneticBase.TRSIndividual.)
|
|
CreateDNA
|
Represents method CreateDNA.
|
|
Crossover(TNode,TRSGPIndividual<T>,TNode)
|
Represents method Crossover(TNode,TRSGPIndividual<T>,TNode).
|
|
DoSelectNode(TNodeList,TGAFloat)
|
Overloaded. Represents method DoSelectNode(TNodeList,TGAFloat).
|
|
EvaluateFitness
|
Evaluates the Fitness of the individual. The fitness function is supplied in the RSGeneticBase.TRSCustomGeneticComponent.OnEvaluateFitness event.
Normally, the Fitness is only evaluated if the individual is modified. This function forces evaluation.
|
|
Execute(TRSGPContext<T>)
|
Executes the individual's genetic program ( DNA) using the specified context. The Context provides program state information (including variable values).
The function returns a value of type T
|
|
FlattenDNA
|
Flattens the DNA tree into a list of nodes. Used by the genetic programming component for various uses, such as selecting a node
You should not have to call the FlattenDNA method yourself.
|
|
GetDisplayName
|
Represents method GetDisplayName. (Inherited from RSGeneticBase.TRSIndividual.)
|
|
Graft(TNode,TNode)
|
Replaces old node with the new node. The old node and its children are NOT deleted or freed
|
|
LoadFromXML(IXMLIndividualType)
|
Overloaded. Reads the individual from the XML node, including DNA
|
|
LoadFromXML(IXMLNode)
|
Overloaded. Reads the individual's data from the XML node (Overrides RSGeneticBase.TRSIndividual.LoadFromXML(IXMLNode).)
|
|
Modified
|
Informs the object that you have modified it so that its Fitness must be reevaluated (Inherited from RSGeneticBase.TRSIndividual.)
|
|
SaveToXML(IXMLIndividualType)
|
Overloaded. Saves the individual to the XML node, including DNA
|
|
SaveToXML(IXMLNode)
|
Overloaded. Writes the individual's data to the XML node (Overrides RSGeneticBase.TRSIndividual.SaveToXML(IXMLNode).)
|
|
SelectNode(Integer,Boolean)
|
Overloaded. Selects a random node from the DNA program tree that does not exceed the Size or Depth limit (specified by the Limit parameter). The IsSizeLimit parameter controls which limit is used.
|
|
SelectNode(TGAFloat)
|
Overloaded. Selects a random node from the DNA program tree. The FunctionProbability parameter controls how much to prefer non-terminals (functions) over terminals (constants, variables, and functions with arity=0)
|
|
SelectNode(TGAFloat,TGPGeneticInstructions)
|
Overloaded. Selects a random node from the DNA program tree that is of the same instruction types as in the Instructions parameter. The FunctionProbability parameter controls how much to prefer non-terminals (functions) over terminals (constants, variables, and functions with arity=0)
|
|
ToString
|
Returns a string representation of the individual, including its DNA
|
Top
|
Reference
• | RSGeneticProgramming|TRSCustomGeneticProgramming |
|