Exemple #1
0
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()