Example #1
0
def test_population(params=None, gen_no=0):
    if params is None:
        from utils import StatusUpdateTool
        params = StatusUpdateTool.get_init_params()
        gen_no = 20
    pop = Population(params, gen_no)
    pop.initialize()
    print(pop)
Example #2
0
def test_individual(params=None, indi_no=2):
    if params is None:
        from utils import StatusUpdateTool
        params = StatusUpdateTool.get_init_params()
    ind = Individual(params, indi_no)
    ind.initialize()
    print(ind)
    print(ind.uuid())
Example #3
0
        self.fitness_evaluate()
        Log.info('EVOLVE[%d-gen]-Finish the evaluation' % (gen_no))

        gen_no += 1
        for curr_gen in range(gen_no, max_gen):
            self.params['gen_no'] = curr_gen
            # step 3
            # .1 交叉变异 .2 估计适应度 .3 筛选
            Log.info('EVOLVE[%d-gen]-Begin to crossover and mutation' %
                     (curr_gen))
            self.crossover_and_mutation()
            Log.info('EVOLVE[%d-gen]-Finish crossover and mutation' %
                     (curr_gen))

            Log.info('EVOLVE[%d-gen]-Begin to evaluate the fitness' %
                     (curr_gen))
            self.fitness_evaluate()
            Log.info('EVOLVE[%d-gen]-Finish the evaluation' % (curr_gen))

            self.environment_selection()
            Log.info('EVOLVE[%d-gen]-Finish the environment selection' %
                     (curr_gen))

        StatusUpdateTool.end_evolution()


if __name__ == '__main__':
    params = StatusUpdateTool.get_init_params()
    evoCNN = EvolveCNN(params)
    evoCNN.do_work(max_gen=5)