def test_1(self): file_location = "data/fl_3_1" with open(file_location, "r") as input_data_file: input_data = input_data_file.read() facilities, customers = parse_input(input_data) solution, obj = facility_location(facilities, customers) self.assertEqual(obj, 2545.771137048475)
def test_1(self): file_location = "data/tsp_5_1" with open(file_location, "r") as input_data_file: input_data = input_data_file.read() data = parse_input(input_data) route_distance, path = tsp(data) self.assertEqual(route_distance, 4.0)
def test_1(self): file_location = "data/gc_4_1" with open(file_location, "r") as input_data_file: input_data = input_data_file.read() node_count, edges = parse_input(input_data) solution, k = find_minimum_colors(node_count, edges) self.assertEqual(k, 2)
def test_homemade(self): file_location = "data/ks_4_0" with open(file_location, "r") as input_data_file: input_data = input_data_file.read() items, capacity = parse_input(input_data) value, taken = maximum_value(items, capacity) self.assertEqual(value, 19) self.assertEqual(taken, [0, 0, 1, 1])
import solver # f_name = 'sample.in' # f_name = 'A-small-attempt0.in' f_name = 'A-large.in' f_out_name = f_name[:-2] + 'out' with open(f_name) as f_in, open(f_out_name, 'w') as f_out: T = int(f_in.readline()) for i in xrange(T): test = solver.parse_input(f_in.readline()) out = solver.solve(test) f_out.write('Case #{0}: {1}\n'.format(i + 1, out))