Hide Comments
Hide Comments

Comments (0)

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.

noteNote

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

expandingInheritance Hierarchy

TCollectionItem
  RSGeneticBase.TRSIndividual
    RSGenerics.GeneticProgramming.TRSGPIndividual<T>
 

expandingSyntax

Delphi

type
  TRSGPIndividual<T> = class(TRSIndividual)
  end; 
 

Type Parameters

T

expandingConstructors

 

Name

Description

public constructor

Create(TCollection)

Initializes a new instance of the TRSGPIndividual<T> class. (Overrides RSGeneticBase.TRSIndividual.Create(TCollection).)

public destructor

Destroy

Represents the destructor of the TRSGPIndividual<T> class. (Overrides RSGeneticBase.TRSIndividual.Destroy.)

Top

expandingProperties

 

Name

Description

public property

AdjustedFitness

Represents property AdjustedFitness. (Inherited from RSGeneticBase.TRSIndividual.)

public property

Collection

Returns the population that this individual belongs to.
 

public property

DNA

Represents the genetic code of the individual, its DNA as a program tree of functions, constants, and variables.

public property

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).
 

protected property

FlattenedDNA

Represents property FlattenedDNA.

published property

Name

Allows you to provide a descriptive name for the individual. The genetics components do not use this property. (Inherited from RSGeneticBase.TRSIndividual.)

protected property

NeedFitness

Represents property NeedFitness. (Inherited from RSGeneticBase.TRSIndividual.)

public property

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.)

public property

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.)

public property

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

expandingMethods

 

Name

Description

public method

Assign(TPersistent)

Overloaded. Represents method Assign(TPersistent). (Overrides RSGeneticBase.TRSIndividual.Assign(TPersistent).)

public method

AssignDNA(TNode)

Replaces the current   DNA tree with the aDNA parameter. The old DNA tree is deleted and freed.

public method

Clone

Returns an exact copy of the current individual. (Inherited from RSGeneticBase.TRSIndividual.)

protected method

CreateDNA

Represents method CreateDNA.

public method

Crossover(TNode,TRSGPIndividual<T>,TNode)

Represents method Crossover(TNode,TRSGPIndividual<T>,TNode).

protected method

DoSelectNode(TNodeList,TGAFloat)

Overloaded. Represents method DoSelectNode(TNodeList,TGAFloat).

public method

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.

public method

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

public method

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.

protected method

GetDisplayName

Represents method GetDisplayName. (Inherited from RSGeneticBase.TRSIndividual.)

public method

Graft(TNode,TNode)

Replaces old node with the new node. The old node and its children are NOT deleted or freed

public method

LoadFromXML(IXMLIndividualType)

Overloaded. Reads the individual from the XML node, including   DNA

public method

LoadFromXML(IXMLNode)

Overloaded. Reads the individual's data from the XML node (Overrides RSGeneticBase.TRSIndividual.LoadFromXML(IXMLNode).)

public method

Modified

Informs the object that you have modified it so that its Fitness must be reevaluated (Inherited from RSGeneticBase.TRSIndividual.)

public method

SaveToXML(IXMLIndividualType)

Overloaded. Saves the individual to the XML node, including   DNA

public method

SaveToXML(IXMLNode)

Overloaded. Writes the individual's data to the XML node (Overrides RSGeneticBase.TRSIndividual.SaveToXML(IXMLNode).)

public method

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.

public method

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)

public method

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)

public method

ToString

Returns a string representation of the individual, including its   DNA

Top

expandingFields

 

Name

Description

protected field

FFitness

Represents field FFitness. (Inherited from RSGeneticBase.TRSIndividual.)

Top

expandingSee Also

Comments (0)