def test_1(): protogenes = protogene_factory(IntGene, 'x', 50, min_value=0, max_value=10) protogenome = ProtoGenome(protogenes, mutation_probability = 0.1) algo = MultiGeneticAlgorithm(protogenome, fitness_function, population_size = 60, optimization_mode = 'min', num_parents = 2, crossover_method = single_point_crossover, selection_method = select_from_top, termination_criteria=[raw_score_stop], termination_criteria_options=[{'stop_score':0}]) #main evolution cycle algo.evolve(debug=True) bi = algo.best_individual() print bi.score print bi.dict_value()
def test_5(): num_letters = len("genepi") protogenes = protogene_factory(CharGene, 'x', num_letters) protogenome = ProtoGenome(protogenes, mutation_probability = 0.05) algo = GeneticAlgorithm(protogenome, findname, population_size = 200, optimization_mode = 'min', num_parents = 8, #elitism = False, crossover_method = single_point_crossover, crossover_probability = 0.5, selection_method = select_from_top, termination_criteria = raw_score_stop, termination_criteria_options={'stop_score':0} ) algo.evolve(debug=True) bi = algo.best_individual() print bi.score print "".join(bi.list_value())