The GA engine core
GeneticAlgorithm
Type Parameters
| Name | Description |
|---|---|
Chr |
01 Syntax
Microsoft.VisualBasic.MachineLearning.Darwinism.GAF.GeneticAlgorithm`1
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| .ctor | 1 | |
| Evolve | 1 | 完成一次种群的迭代进化 |
| evolIterate | 1 | 并行化过程之中的单个迭代 |
| GetFitness | 1 | 调用这个函数的代码应该是非并行的 |
| UpdateMutationRate | 1 | 更新种群中的每一个个体的突变变异程度 |
| Clear | 1 | Clear the internal cache |
| GetRawFitnessModel | 1 |
03 Properties
| Name | Overloads | Summary |
|---|---|---|
| population | 1 | 因为在迭代的过程中,旧的种群会被新的种群所替代 所以在这里不可以加readonly修饰 |
| ParentChromosomesSurviveCount | 1 | Number of parental chromosomes, which survive (and move to new population) |
| popStrategy | 1 | |
| Best | 1 | |
| Worst | 1 |
04 Members
#ctor(Population(Of `0), Fitness(Of `0), Strategies,
IRandomSeeds, Int32, PopulationCollectionCreator(Of `0))Remarks
Just put the model that implements the Fitness, the FitnessPool will be created automatically in this constructor function.
Parameters
| Name | Type | Description |
|---|---|---|
population | Population(Of `0) | - |
fitnessFunc | Fitness(Of `0) | Calculates the fitness of the mutated chromesome in population |
seeds | Strategies | The random number generator. |
cacheSize | IRandomSeeds | -1 means no cache |
replacementStrategy | Int32 | Strategy for new population replace the old population. |
createPopulation | PopulationCollectionCreator(Of `0) | By default is create with PopulationList |
Evolve
完成一次种群的迭代进化
evolIterate(
Int32)并行化过程之中的单个迭代
Remarks
进化发生的契机是个体的突变,这体现在
- 个体的基因组的变异,可能产生错误率更低的新个体
- 突变体和其他个体随机杂交,可能会产生错误率更低的新个体
在这个函数中,需要完成的就是这两种突变的发生
Parameters
| Name | Type | Description |
|---|---|---|
i | Int32 | 种群之中的个体的序号,也就是即将发生的目标个体 |
GetFitness(
`0)调用这个函数的代码应该是非并行的
Parameters
| Name | Type | Description |
|---|---|---|
chromosome | `0 | - |
UpdateMutationRate(
Double)更新种群中的每一个个体的突变变异程度
Parameters
| Name | Type | Description |
|---|---|---|
newRate | Double | - |
Clear
Clear the internal cache
population
因为在迭代的过程中,旧的种群会被新的种群所替代 所以在这里不可以加readonly修饰
ParentChromosomesSurviveCount
Number of parental chromosomes, which survive (and move to new population)
popStrategy
Best
Worst
GetRawFitnessModel()