def one_run(evaluator, config, frequencies): ''' Performs a single run of the given configuration. Returns a dictionary containing results. Parameters: - ``evaluator``: An object with the function get_fitness that takes an individual and returns its fitness value - ``config``: A dictionary containing all of the configuration information required to perform a experimental run, including: - All information required to initialize an individual. - All information required to run ``evolution.generate``. - ``verbose``: Boolean value for if extra runtime information should be displayed. - ``max_evals``: The maximum number of evaluations allowed before termination. - ``max_fitness``: The fitness required to cause a "successful" termination. - ``frequencies``: Dictionary used to return information about how often individuals of different lengths are evolved. ''' best = Individual(**config) last_improved = -1 generator = enumerate(generate(config, frequencies)) for evals, individual in generator: individual.fitness = evaluator.get_fitness(individual) if best < individual: best = individual last_improved = evals if config['verbose']: print '\t', last_improved, best.fitness, len(best.active) if (evals >= config['max_evals'] or best.fitness >= config['max_fitness']): break if config['verbose']: print "Best Found" best.show_active() return { 'fitness': best.fitness, 'evals': evals, 'success': best.fitness >= config['max_fitness'], 'phenotype': len(best.active) }
def one_run(evaluator, config, frequencies): ''' Performs a single run of the given configuration. Returns a dictionary containing results. Parameters: - ``evaluator``: An object with the function get_fitness that takes an individual and returns its fitness value - ``config``: A dictionary containing all of the configuration information required to perform a experimental run, including: - All information required to initialize an individual. - All information required to run ``evolution.generate``. - ``verbose``: Boolean value for if extra runtime information should be displayed. - ``max_evals``: The maximum number of evaluations allowed before termination. - ``max_fitness``: The fitness required to cause a "successful" termination. - ``frequencies``: Dictionary used to return information about how often individuals of different lengths are evolved. ''' best = Individual(**config) last_improved = -1 generator = enumerate(generate(config, frequencies)) for evals, individual in generator: individual.fitness = evaluator.get_fitness(individual) if best < individual: best = individual last_improved = evals if config['verbose']: print '\t', last_improved, best.fitness, len(best.active) if (evals >= config['max_evals'] or best.fitness >= config['max_fitness']): break if config['verbose']: print "Best Found" best.show_active() return {'fitness': best.fitness, 'evals': evals, 'success': best.fitness >= config['max_fitness'], 'phenotype': len(best.active)}
def one_run(evaluator, config): ''' Performs a single run of the given configuration. Returns a dictionary containing results. Parameters: - ``evaluator``: An object with the function get_fitness that takes an individual and returns its fitness value - ``config``: A dictionary containing all of the configuration information required to perform a experimental run, including: - All information required to initialize an individual. - All information required to run ``evolution.generate``. - ``verbose``: Boolean value for if extra runtime information should be displayed. - ``max_evals``: The maximum number of evaluations allowed before termination. - ``max_fitness``: The fitness required to cause a "successful" termination. ''' best = Individual(**config) output = {} for evals, individual in enumerate(generate(config, output)): individual.fitness = evaluator.get_fitness(individual) if best < individual: best = individual if config['verbose']: print '\t', evals, best.fitness, len(best.active) if (evals >= config['max_evals'] or best.fitness >= config['max_fitness']): break if config['verbose']: print "Best Found" best.show_active() output.update({'fitness': best.fitness, 'evals': evals, 'success': best.fitness >= config['max_fitness'], 'phenotype': len(best.active), # When running 'Skip' this will correctly give the number # of evaluations required by 'Normal'. Otherwise its junk. 'normal': output['skipped'] + evals}) return output
control_group = None for filename in sys.argv[1:]: base = path.basename(filename) try: # Determine the settings from the filename problem, dup, ordering, nodes, mut, seed = base.split('_') with open_file_method(filename)(filename, 'r') as f: data = json.load(f) version = dup, ordering, nodes, mut if (dup, ordering) == ('skip', 'normal'): control_group = version statify[version].append(data[1]['evals']) active[version].append(data[1]['phenotype']) best = data[1]['bests'][-1] test = data[1]['test_inputs'] individual = Individual.reconstruct_individual(best, test) simplified = individual.new(Individual.simplify) reduced[version].append(len(simplified.active)) filecount += 1 except ValueError: print filename, "FAILED" # Kruskal's requires a rectangular matrix rect = make_rectangular(statify.values(), 10000001) print 'Files Successfully Loaded', filecount print 'Kruskal Wallis', kruskalwallis(rect) for version, data in statify.iteritems(): print '--------- %s ---------' % str(version) print "MES, MAD", median_deviation(data) print 'Active', median_deviation(active[version])
control_group = None for filename in sys.argv[1:]: base = path.basename(filename) try: # Determine the settings from the filename problem, dup, ordering, nodes, mut, seed = base.split('_') with open_file_method(filename)(filename, 'r') as f: data = json.load(f) version = dup, ordering, nodes, mut if (dup, ordering) == ('skip', 'normal'): control_group = version statify[version].append(data[1]['evals']) active[version].append(data[1]['phenotype']) best = data[1]['bests'][-1] test = data[1]['test_inputs'] individual = Individual.reconstruct_individual(best, test) simplified = individual.new(Individual.simplify) reduced[version].append(len(simplified.active)) filecount += 1 except ValueError: print(filename, "FAILED") # Kruskal's requires a rectangular matrix rect = make_rectangular(list(statify.values()), 10000001) print('Files Successfully Loaded', filecount) print('Kruskal Wallis', kruskalwallis(rect)) for version, data in statify.items(): print('--------- %s ---------' % str(version)) print("MES, MAD", median_deviation(data)) print('Active', median_deviation(active[version]))