def save_matrices(self): """ saves the matrices so these can be used to cluster in the gmm etc. :return: """ save_pickle('/home/ghost/PycharmProjects/bayesian_prolo/scheduling_env/', self.matrices, str(self.num_schedules) + 'test_matrices.pkl') return self.matrices
def save_performance_results(self, top1, top3, special_string): """ saves performance of top1 and top3 :return: """ print('top1_mean for ', self.alpha, ' is : ', np.mean(top1)) data = {'top1_mean': np.mean(top1), 'top3_mean': np.mean(top3), 'top1_stderr': np.std(top1) / np.sqrt(len(top1)), 'top3_stderr': np.std(top3) / np.sqrt(len(top3))} save_pickle(file=data, file_location=self.home_dir + '/saved_models/pairwise_saved_models/', special_string=special_string)
def save_performance_results(self, top1): """ saves performance of top1 and top3 :return: """ print('top1_mean for ', self.alpha, ' is : ', np.mean(top1)) data = { 'top1_mean': np.mean(top1), 'top1_stderr': np.std(top1) / np.sqrt(len(top1)), 'embedding': self.bayesian_embedding_dim } save_pickle(file=data, file_location=self.home_dir + '/saved_models/naive_saved_models/', special_string=str(self.bayesian_embedding_dim) + 'baydim_naivetest.pkl')
def save_performance_results(top1, top3, special_string): """ saves performance of top1 and top3 :return: """ print('top1_mean: ', np.mean(top1)) data = { 'top1_mean': np.mean(top1), 'top3_mean': np.mean(top3), 'top1_stderr': np.std(top1) / np.sqrt(len(top1)), 'top3_stderr': np.std(top3) / np.sqrt(len(top3)) } save_pickle( file=data, file_location= '/home/ghost/PycharmProjects/bayesian_prolo/saved_models/pairwise_saved_models/', special_string=special_string)
def main(str_for_naive, str_for_pickle): """ entry point of the file :return: """ total_schedule = [] total_schedule_pairwise = [] n = 0 num_scheds = 1500 test = False if test: np.random.seed(50) random.seed(50) else: np.random.seed(150) random.seed(150) while n < num_scheds: world = World(num_scheds, n) # 2 cases this breaks, either t > max duration, or 19 tasks are scheduled. while not world.data_done_generating: is_feasible = world.update_floyd_warshall_and_all_vectors() world.print_all_features() if is_feasible == False: print('constraint was infeasible') break for counter, agent in enumerate(world.agents): world.compute_task_to_schedule(counter) is_feasible = world.update_floyd_warshall_and_all_vectors() world.add_constraints_based_on_task() world.check_if_schedule_finished() print('current finish times', world.agents[0].getFinishTime(), world.agents[1].getFinishTime()) # Next Time Step world.t += 1 print('current time is ', world.t) world.update_based_on_time() if world.did_schedule_fail: pass else: # temp = [] # temp_pairwise = [] # with open(world.filepath, 'r') as csvfile: # data = (csv.reader(csvfile)) # for row in data: # temp.append(row) # # with open(world.second_file_path, 'r') as csvfile: # data = (csv.reader(csvfile)) # for row in data: # temp_pairwise.append(row) total_schedule.append(world.naive_total_data) total_schedule_pairwise.append(world.pairwise_total_data) n += 1 print('on schedule ', n) if n == 100: save_pickle( file_location= '/home/ghost/PycharmProjects/bayesian_prolo/scheduling_env', file=total_schedule, special_string=str(100) + str_for_naive + '.pkl') save_pickle( file_location= '/home/ghost/PycharmProjects/bayesian_prolo/scheduling_env', file=total_schedule_pairwise, special_string=str(100) + str_for_pickle + '.pkl') if n == 250: save_pickle( file_location= '/home/ghost/PycharmProjects/bayesian_prolo/scheduling_env', file=total_schedule, special_string=str(250) + str_for_naive + '.pkl') save_pickle( file_location= '/home/ghost/PycharmProjects/bayesian_prolo/scheduling_env', file=total_schedule_pairwise, special_string=str(250) + str_for_pickle + '.pkl') if n == 500: save_pickle( file_location= '/home/ghost/PycharmProjects/bayesian_prolo/scheduling_env', file=total_schedule, special_string=str(500) + str_for_naive + '.pkl') save_pickle( file_location= '/home/ghost/PycharmProjects/bayesian_prolo/scheduling_env', file=total_schedule_pairwise, special_string=str(500) + str_for_pickle + '.pkl') if n == 1500: save_pickle( file_location= '/home/ghost/PycharmProjects/bayesian_prolo/scheduling_env', file=total_schedule, special_string=str(1500) + str_for_naive + '.pkl') save_pickle( file_location= '/home/ghost/PycharmProjects/bayesian_prolo/scheduling_env', file=total_schedule_pairwise, special_string=str(1500) + str_for_pickle + '.pkl') save_pickle(file_location= '/home/ghost/PycharmProjects/bayesian_prolo/scheduling_env', file=total_schedule, special_string=str(num_scheds) + str_for_naive + '.pkl') save_pickle(file_location= '/home/ghost/PycharmProjects/bayesian_prolo/scheduling_env', file=total_schedule_pairwise, special_string=str(num_scheds) + str_for_pickle + '.pkl')