python DEAP学习4(遗传算法)函数使用

本文介绍了DEAP库中的遗传算法工具箱,该工具箱提供了一系列用于选择、变异和迁移个体的操作算子,并包含了增强算法的实用工具。此外,文章还列举了多种初始化、交叉、变异等遗传操作的具体实现。

Evolutionary Tools

The tools module contains the operators for evolutionary algorithms. They are used to modify, select and move the individuals in their environment. The set of operators it contains are readily usable in the Toolbox. In addition to the basic operators this module also contains utility tools to enhance the basic algorithms with StatisticsHallOfFame, and History.

tools模块中toolbox里面包含遗传算法的操作算子,可以用来选择个体、使个体发生变异或者直接删除个体,另外还有一些基本操作在Statistics、HallOfFame和History里面。

Operators

The operator set does the minimum job for transforming or selecting individuals. This means, for example, that providing two individuals to the crossover will transform those individuals in-place. The responsibility of making offspring(s) independent of their parent(s) and invalidating the fitness is left to the user and is generally fulfilled in the algorithms by calling toolbox.clone() on an individual to duplicate it and del on the values attribute of the individual’s fitness to invalidate it.

Here is a list of the implemented operators in DEAP,

下面是DEAP里面内的操作算子,看起来很强大...怎么用还是慢慢摸索吧....

Initialization Crossover Mutation Selection Migration
initRepeat()cxOnePoint()mutGaussian()selTournament()migRing()
initIterate()cxTwoPoint()mutShuffleIndexes()selRoulette() 
initCycle()cxUniform()mutFlipBit()selNSGA2() 
 cxPartialyMatched()mutPolynomialBounded()selSPEA2() 
 cxUniformPartialyMatched()mutUniformInt()selRandom() 
 cxOrdered()mutESLogNormal()selBest() 
 cxBlend() selWorst() 
 cxESBlend() selTournamentDCD() 
 cxESTwoPoint() selDoubleTournament() 
 cxSimulatedBinary() selStochasticUniversalSampling() 
 cxSimulatedBinaryBounded() selLexicase() 
 cxMessyOnePoint() selEpsilonLexicase() 
   selAutomaticEpsilonLexicase()

and genetic programming specific operators.

Initialization Crossover Mutation Bloat control
genFull()cxOnePoint()mutShrink()staticLimit()
genGrow()cxOnePointLeafBiased()mutUniform()selDoubleTournament()
genHalfAndHalf() mutNodeReplacement() 
  mutEphemeral() 
  mutInsert()

Initialization

deap.tools. initRepeat ( containerfuncn )

Call the function container with a generator function corresponding to the calling n times the function func.

Parameters:
  • container – The type to put in the data from func.
  • func – The function that will be called n times to fill the container.
  • n – The number of times to repeat func.
Returns:

An instance of the container filled with data from func.

This helper function can can be used in conjunction with a Toolbox to register a generator of filled containers, as individuals or population.

初始化函数,包括三个参数:容器、函数、重复次数,如以下函数,容器是list,函数是random.random,重复两次

>>> initRepeat(list, random.random, 2) 
...                                    
[0.4761..., 0.6302...]

deap.tools. initIterate ( containergenerator )

Call the function container with an iterable as its only argument. The iterable must be returned by the method or the object generator.

Parameters:
  • container – The type to put in the data from func.
  • generator – A function returning an iterable (list, tuple, ...), the content of this iterable will fill the container.
Returns:

An instance of the container filled with data from the generator.

This helper function can can be used in conjunction with a Toolbox to register a generator of filled containers, as individuals or population.



看一天累了....未完待续....










评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值