Example #1
0
 def initialize(self):
     do('rm -f %s/*' % config.config['main']['populationPath'])
     do('mkdir %s' % config.config['main']['populationPath'])
     do('echo > %s' % config.config['main']['logPath'])
     for i in range(0, config.config['ga']['populationSize']):
         genome = self.genomeType()
         genome.create()
         self.genomes.append(genome)
     log.info('initialized population of %d genomes' % config.config['ga']['populationSize'])
Example #2
0
        result = 0 if result.wasSuccessful() else 1
        exit(result)

    cfg = read_config(args.config)
    logger = init_logger()

    renderer = DistributedRenderer()
    qualifier = DistributedQualifier()
    base_image_path = cfg['main']['populationPath'] + basename(cfg['main']['baseImage'])
    fitnessMachine = MeshFitnessMachine(base_image_path, renderer, qualifier)
    population = Population(MeshGenome, fitnessMachine)
    population.generation = int(db.get('generation', default=0))

    accuracy.register(population)
    monitor.register(population)

    if args.command == 'reset' or not population.generation:
        population.initialize()
    else:
        population.load()
    do('cp -v %s %s' % (cfg['main']['baseImage'], base_image_path))

    try:
        population.evolve()
    except KeyboardInterrupt as ki:
        pass

    best = population.get_best_genome()
    print(best.serial, best.fitness)