本文整理匯總了Python中system.System.latestVersion方法的典型用法代碼示例。如果您正苦於以下問題:Python System.latestVersion方法的具體用法?Python System.latestVersion怎麽用?Python System.latestVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類system.System
的用法示例。
在下文中一共展示了System.latestVersion方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run_simulation
# 需要導入模塊: from system import System [as 別名]
# 或者: from system.System import latestVersion [as 別名]
def run_simulation(repo_path, gen_max):
logger.info("Running simulation with: REPO_PATH={}, GENERATION_MAX={}"
.format(repo_path, gen_max))
# Init base system
sys=System(repo_path=repo_path)
sys.setLowestVersions()
sys.dump()
# Init goal (latest version)
goal=System.latestVersion(sys)
goal.dump()
# Init population
pop=Population(DEFAULT_POP_SIZE, sys, goal)
# Init dataframe for storing results
## TODO
logger.info("Starting simulation...")
for i in range(gen_max):
'''
For each generation we need to go through all the genomes
and evolve them (mutate/crossover/rebel) and test. The more
successful a genome is (more programs installed/tests), the
more likely it is to create offspring for the next generation
'''
logger.info("Generation #{}".format(i))
for genome in pop.getGenomes():
# TODO some evaluation, score, record
logger.info("\t{}".format(genome))
#Check if objective has been met yet
if pop.isGoalMet():
# TODO
logger.info("Goal configuration has been found!")
break
pop=pop.nextGeneration()
logger.debug("System state at end of this generation")
pop.sys.dump()
#TODO do some final reporting
logger.info("Final configuration after {} generations looks like:".format(i))
pop.sys.dump()