本文整理汇总了Python中GPopulation.GPopulation.printStats方法的典型用法代码示例。如果您正苦于以下问题:Python GPopulation.printStats方法的具体用法?Python GPopulation.printStats怎么用?Python GPopulation.printStats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GPopulation.GPopulation
的用法示例。
在下文中一共展示了GPopulation.printStats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: your_func
# 需要导入模块: from GPopulation import GPopulation [as 别名]
# 或者: from GPopulation.GPopulation import printStats [as 别名]
#.........这里部分代码省略.........
sister = random.choice([genomeMom, genomeDad])
sister = sister.clone()
sister.mutate(pmut=self.pMutation, ga_engine=self)
newPop.internalPop.append(sister)
logging.debug("Evaluating the new created population.")
newPop.evaluate()
if self.elitism:
logging.debug("Doing elitism.")
if self.getMinimax() == Consts.minimaxType["maximize"]:
for i in xrange(self.nElitismReplacement):
#re-evaluate before being sure this is the best
self.internalPop.bestRaw(i).evaluate()
if self.internalPop.bestRaw(i).score > newPop.bestRaw(i).score:
newPop[len(newPop)-1-i] = self.internalPop.bestRaw(i)
elif self.getMinimax() == Consts.minimaxType["minimize"]:
for i in xrange(self.nElitismReplacement):
#re-evaluate before being sure this is the best
self.internalPop.bestRaw(i).evaluate()
if self.internalPop.bestRaw(i).score < newPop.bestRaw(i).score:
newPop[len(newPop)-1-i] = self.internalPop.bestRaw(i)
self.internalPop = newPop
self.internalPop.sort()
logging.debug("The generation %d was finished.", self.currentGeneration)
self.currentGeneration += 1
return (self.currentGeneration == self.nGenerations)
def printStats(self):
""" Print generation statistics
:rtype: the printed statistics as string
.. versionchanged:: 0.6
The return of *printStats* method.
"""
percent = self.currentGeneration * 100 / float(self.nGenerations)
message = "Gen. %d (%.2f%%):" % (self.currentGeneration, percent)
logging.info(message)
print message,
sys_stdout.flush()
self.internalPop.statistics()
stat_ret = self.internalPop.printStats()
return message + stat_ret
def printTimeElapsed(self):
""" Shows the time elapsed since the begin of evolution """
total_time = time()-self.time_init
print "Total time elapsed: %.3f seconds." % total_time
return total_time
def dumpStatsDB(self):
""" Dumps the current statistics to database adapter """
logging.debug("Dumping stats to the DB Adapter")
self.internalPop.statistics()
self.dbAdapter.insert(self)
def evolve(self, freq_stats=0):
""" Do all the generations until the termination criteria, accepts
the freq_stats (default is 0) to dump statistics at n-generation