def save_file(self, formatting):
     options = dict(defaultextension='.csv',\
                    filetypes=[('CSV files', '*.csv'), \
                               ('Text files', '*.txt')])
     filename = tkFileDialog.asksaveasfilename(**options)
     self.save_filename.set(filename)
     self.update_idletasks()
     if formatting == 'people':
         write_people_to_csv(self.solution, self.save_filename.get())
     else:
         write_tables_to_csv(self.solution, self.save_filename.get())
Exemple #2
0
    best_solution = deepcopy(init_solution)
    print_init_cost(init_solution.cost)

    if config.anneal:
        for (solution, T) in anneal(init_solution):
            print_progress(solution, T)
            yield solution, T
    else:
        yield best_solution, None


if __name__ == "__main__":
    parser = create_parser()
    args = parser.parse_args()
    input_data = InputData(args.people_file, args.tables_file)

    if not config.test_cost:
        for (best_solution, T) in main(input_data):
            if best_solution.cost == "Baseline cost":
                print "Average cost of random solutions: " + str(best_solution.baseline_cost)
            else:
                print_progress(best_solution, T)

        print_final_metrics(best_solution)
        write_people_to_csv(best_solution, args.output_people_filename)
        write_tables_to_csv(best_solution, args.output_tables_filename)

    if config.test_cost:
        for i in range(0, 500):
            print main(input_data).next()[0].cost