def best_job(self, jobs): best_job = jobs[0] best_data = job_data(best_job) best_avg = average(best_data['fitness']) for run in jobs: run_data = job_data(run) run_avg = average(run_data['fitness']) if run_avg < best_avg: best_job = run best_data = run_data best_avg = run_avg return best_job, best_data
def compare(self, jobs): 'Runs and compares the results of two jobs.' results_jobs = self.launch(jobs) def adjust(stats_list): 'Transforms the list found in stats to a plottable list.' return [fit[0] for fit in stats_list[0]] plt.figure() for job in results_jobs: data = job_data(job) size = len(data['stats'][0]['min'][0]) # # Plotting individual runs: # for d in data['stats']: # d = adjust(d['min']) # plt.plot(d, color_run + '--') # Plotting average: plt.plot( [ average([adjust(d['min'])[i] for d in data['stats']]) for i in xrange(size) ], # color_avg + '-', # linewidth=2.0, label=job['operators']['name'], ) plt.xlabel('Generations') plt.ylabel('Fitness') plt.legend() plt.show()
def compare(self, jobs): 'Runs and compares the results of two jobs.' results_jobs = self.launch(jobs) def adjust(stats_list): 'Transforms the list found in stats to a plottable list.' return [fit[0] for fit in stats_list[0]] plt.figure() for job in results_jobs: data = job_data(job) size = len(data['stats'][0]['min'][0]) # # Plotting individual runs: # for d in data['stats']: # d = adjust(d['min']) # plt.plot(d, color_run + '--') # Plotting average: plt.plot( [average([adjust(d['min'])[i] for d in data['stats']]) for i in xrange(size)], # color_avg + '-', # linewidth=2.0, label=job['operators']['name'], ) plt.xlabel('Generations') plt.ylabel('Fitness') plt.legend() plt.show()