diff options
| author | JonZhao <[email protected]> | 2019-06-04 15:16:50 +0800 |
|---|---|---|
| committer | JonZhao <[email protected]> | 2019-06-04 15:16:50 +0800 |
| commit | 8bef8ced7954900eb39d01a818173c469adc80d1 (patch) | |
| tree | cba30ad3277d0c91958412cd99eb503d28792981 /multiple_ant_colony_system.py | |
| parent | 2af7b7905705d4ebc774e3f9a95850bd042fe0e3 (diff) | |
| download | VRPTW-ACO-python-8bef8ced7954900eb39d01a818173c469adc80d1.tar.gz VRPTW-ACO-python-8bef8ced7954900eb39d01a818173c469adc80d1.tar.bz2 VRPTW-ACO-python-8bef8ced7954900eb39d01a818173c469adc80d1.zip | |
update and fix error in local_search_procedure
Diffstat (limited to 'multiple_ant_colony_system.py')
| -rw-r--r-- | multiple_ant_colony_system.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/multiple_ant_colony_system.py b/multiple_ant_colony_system.py index c0fc3c8..b4e6f92 100644 --- a/multiple_ant_colony_system.py +++ b/multiple_ant_colony_system.py @@ -388,8 +388,9 @@ class MultipleAntColonySystem: if self.whether_or_not_to_show_figure: path_queue_for_figure.put(PathMessage(None, None)) - file_to_write.flush() - file_to_write.close() + if file_to_write is not None: + file_to_write.flush() + file_to_write.close() return if path_found_queue.empty(): @@ -417,7 +418,8 @@ class MultipleAntColonySystem: self.print_and_write_in_file(file_to_write, '[macs]: distance of found path (%f) better than best path\'s (%f)' % (found_path_distance, self.best_path_distance)) self.print_and_write_in_file(file_to_write, 'it takes %0.3f second from multiple_ant_colony_system running' % (time.time()-start_time_total)) self.print_and_write_in_file(file_to_write, '*' * 50) - file_to_write.flush() + if file_to_write is not None: + file_to_write.flush() self.best_path = found_path self.best_vehicle_num = found_path_used_vehicle_num @@ -442,7 +444,8 @@ class MultipleAntColonySystem: % (found_path_used_vehicle_num, best_vehicle_num, found_path_distance)) self.print_and_write_in_file(file_to_write, 'it takes %0.3f second multiple_ant_colony_system running' % (time.time() - start_time_total)) self.print_and_write_in_file(file_to_write, '*' * 50) - file_to_write.flush() + if file_to_write is not None: + file_to_write.flush() self.best_path = found_path self.best_vehicle_num = found_path_used_vehicle_num |
