本文整理匯總了Python中GPopulation.GPopulation.iteratePop方法的典型用法代碼示例。如果您正苦於以下問題:Python GPopulation.iteratePop方法的具體用法?Python GPopulation.iteratePop怎麽用?Python GPopulation.iteratePop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GPopulation.GPopulation
的用法示例。
在下文中一共展示了GPopulation.iteratePop方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: your_func
# 需要導入模塊: from GPopulation import GPopulation [as 別名]
# 或者: from GPopulation.GPopulation import iteratePop [as 別名]
#.........這裏部分代碼省略.........
self.internalPop.create(minimax=self.minimax)
self.internalPop.initialize(ga_engine=self)
logging.debug("The GA Engine was initialized !")
def getPopulation(self):
""" Return the internal population of GA Engine
:rtype: the population (:class:`GPopulation.GPopulation`)
"""
return self.internalPop
def getStatistics(self):
""" Gets the Statistics class instance of current generation
:rtype: the statistics instance (:class:`Statistics.Statistics`)
"""
return self.internalPop.getStatistics()
def getMaxList(self):
return self.max_list
def getAvgList(self):
return self.avg_list
def clear(self):
""" Petrowski's Clearing Method """
def step(self):
""" Just do one step in evolution, one generation """
print "Generation ", self.currentGeneration
self.internalPop.iteratePop()
print "\n"
genomeMom = None
genomeDad = None
newPop = GPopulation(self.internalPop)
logging.debug("Population was cloned.")
size_iterate = len(self.internalPop)
# Odd population size
if size_iterate % 2 != 0: size_iterate -= 1
crossover_empty = self.select(popID=self.currentGeneration).crossover.isEmpty()
for i in xrange(0, size_iterate, 2):
genomeMom = self.select(popID=self.currentGeneration)
genomeDad = self.select(popID=self.currentGeneration)
if not crossover_empty and self.pCrossover >= 1.0:
for it in genomeMom.crossover.applyFunctions(mom=genomeMom, dad=genomeDad, count=2):
(sister, brother) = it
else:
if not crossover_empty and Util.randomFlipCoin(self.pCrossover):
for it in genomeMom.crossover.applyFunctions(mom=genomeMom, dad=genomeDad, count=2):
(sister, brother) = it
else:
sister = genomeMom.clone()
brother = genomeDad.clone()
sister.mutate(pmut=self.pMutation, ga_engine=self)
brother.mutate(pmut=self.pMutation, ga_engine=self)