C# 클래스 AForge.Genetic.Population

Population of chromosomes.

The class represents population - collection of individuals (chromosomes) and provides functionality for common population's life cycle - population growing with help of genetic operators and selection of chromosomes to new generation with help of selection algorithm. The class may work with any type of chromosomes implementing IChromosome interface, use any type of fitness functions implementing IFitnessFunction interface and use any type of selection algorithms implementing ISelectionMethod interface.

파일 보기 프로젝트 열기: holisticware-admin/MonoVersal.AForgeNET 1 사용 예제들

공개 메소드들

메소드 설명
AddChromosome ( IChromosome chromosome ) : void

Add chromosome to the population.

The method adds specified chromosome to the current population. Manual adding of chromosome maybe useful, when it is required to add some initialized chromosomes instead of random.

Adding chromosome manually should be done very carefully, since it may break the population. The manually added chromosome must have the same type and initialization parameters as the ancestor passed to constructor.

Crossover ( ) : void

Do crossover in the population.

The method walks through the population and performs crossover operator taking each two chromosomes in the order of their presence in the population. The total amount of paired chromosomes is determined by crossover rate.

Migrate ( Population anotherPopulation, int numberOfMigrants, ISelectionMethod migrantsSelector ) : void

Perform migration between two populations.

The method performs migration between two populations - current and the specified one. During migration specified number of chromosomes is choosen from each population using specified selection algorithms and put into another population replacing worst members there.

Mutate ( ) : void

Do mutation in the population.

The method walks through the population and performs mutation operator taking each chromosome one by one. The total amount of mutated chromosomes is determined by mutation rate.

Population ( int size, IChromosome ancestor, IFitnessFunction fitnessFunction, ISelectionMethod selectionMethod ) : System

Initializes a new instance of the Population class.

Creates new population of specified size. The specified ancestor becomes first member of the population and is used to create other members with same parameters, which were used for ancestor's creation.

Regenerate ( ) : void

Regenerate population.

The method regenerates population filling it with random chromosomes.

Resize ( int newPopulationSize ) : void

Resize population to the new specified size.

The method does resizing of population. In the case if population should grow, it just adds missing number of random members. In the case if population should get smaller, the population's selection method is used to reduce the population.

Resize ( int newPopulationSize, ISelectionMethod membersSelector ) : void

Resize population to the new specified size.

The method does resizing of population. In the case if population should grow, it just adds missing number of random members. In the case if population should get smaller, the specified selection method is used to reduce the population.

RunEpoch ( ) : void

Run one epoch of the population.

The method runs one epoch of the population, doing crossover, mutation and selection by calling Crossover, Mutate and Selection.

Selection ( ) : void

Do selection.

The method applies selection operator to the current population. Using specified selection algorithm it selects members to the new generation from current generates and adds certain amount of random members, if is required (see RandomSelectionPortion).

Shuffle ( ) : void

Shuffle randomly current population.

Population shuffling may be useful in cases when selection operator results in not random order of chromosomes (for example, after elite selection population may be ordered in ascending/descending order).

this ( int index ) : IChromosome

Get chromosome with specified index.

Allows to access individuals of the population.

비공개 메소드들

메소드 설명
FindBestChromosome ( ) : void

메소드 상세

AddChromosome() 공개 메소드

Add chromosome to the population.

The method adds specified chromosome to the current population. Manual adding of chromosome maybe useful, when it is required to add some initialized chromosomes instead of random.

Adding chromosome manually should be done very carefully, since it may break the population. The manually added chromosome must have the same type and initialization parameters as the ancestor passed to constructor.

public AddChromosome ( IChromosome chromosome ) : void
chromosome IChromosome Chromosome to add to the population.
리턴 void

Crossover() 공개 메소드

Do crossover in the population.
The method walks through the population and performs crossover operator taking each two chromosomes in the order of their presence in the population. The total amount of paired chromosomes is determined by crossover rate.
public Crossover ( ) : void
리턴 void

Migrate() 공개 메소드

Perform migration between two populations.

The method performs migration between two populations - current and the specified one. During migration specified number of chromosomes is choosen from each population using specified selection algorithms and put into another population replacing worst members there.

public Migrate ( Population anotherPopulation, int numberOfMigrants, ISelectionMethod migrantsSelector ) : void
anotherPopulation Population Population to do migration with.
numberOfMigrants int Number of chromosomes from each population to migrate.
migrantsSelector ISelectionMethod Selection algorithm used to select chromosomes to migrate.
리턴 void

Mutate() 공개 메소드

Do mutation in the population.
The method walks through the population and performs mutation operator taking each chromosome one by one. The total amount of mutated chromosomes is determined by mutation rate.
public Mutate ( ) : void
리턴 void

Population() 공개 메소드

Initializes a new instance of the Population class.
Creates new population of specified size. The specified ancestor becomes first member of the population and is used to create other members with same parameters, which were used for ancestor's creation.
Too small population's size was specified. The /// exception is thrown in the case if is smaller than 2.
public Population ( int size, IChromosome ancestor, IFitnessFunction fitnessFunction, ISelectionMethod selectionMethod ) : System
size int Initial size of population.
ancestor IChromosome Ancestor chromosome to use for population creatioin.
fitnessFunction IFitnessFunction Fitness function to use for calculating /// chromosome's fitness values.
selectionMethod ISelectionMethod Selection algorithm to use for selection /// chromosome's to new generation.
리턴 System

Regenerate() 공개 메소드

Regenerate population.
The method regenerates population filling it with random chromosomes.
public Regenerate ( ) : void
리턴 void

Resize() 공개 메소드

Resize population to the new specified size.

The method does resizing of population. In the case if population should grow, it just adds missing number of random members. In the case if population should get smaller, the population's selection method is used to reduce the population.

Too small population's size was specified. The /// exception is thrown in the case if is smaller than 2.
public Resize ( int newPopulationSize ) : void
newPopulationSize int New size of population.
리턴 void

Resize() 공개 메소드

Resize population to the new specified size.

The method does resizing of population. In the case if population should grow, it just adds missing number of random members. In the case if population should get smaller, the specified selection method is used to reduce the population.

Too small population's size was specified. The /// exception is thrown in the case if is smaller than 2.
public Resize ( int newPopulationSize, ISelectionMethod membersSelector ) : void
newPopulationSize int New size of population.
membersSelector ISelectionMethod Selection algorithm to use in the case /// if population should get smaller.
리턴 void

RunEpoch() 공개 메소드

Run one epoch of the population.
The method runs one epoch of the population, doing crossover, mutation and selection by calling Crossover, Mutate and Selection.
public RunEpoch ( ) : void
리턴 void

Selection() 공개 메소드

Do selection.
The method applies selection operator to the current population. Using specified selection algorithm it selects members to the new generation from current generates and adds certain amount of random members, if is required (see RandomSelectionPortion).
public Selection ( ) : void
리턴 void

Shuffle() 공개 메소드

Shuffle randomly current population.

Population shuffling may be useful in cases when selection operator results in not random order of chromosomes (for example, after elite selection population may be ordered in ascending/descending order).

public Shuffle ( ) : void
리턴 void

this() 공개 메소드

Get chromosome with specified index.
Allows to access individuals of the population.
public this ( int index ) : IChromosome
index int Chromosome's index to retrieve.
리턴 IChromosome