diff options
| author | JonZhao <[email protected]> | 2019-06-04 09:51:17 +0800 |
|---|---|---|
| committer | JonZhao <[email protected]> | 2019-06-04 09:51:17 +0800 |
| commit | 6c95eeebca7c843a3b9a775a4215836af2f5ab42 (patch) | |
| tree | 935163bcea413e091f6b0139d6a821f5f407f9bb | |
| parent | 11e7a1a71de69813ec7a7ef7469e8cf40ca60df3 (diff) | |
| download | VRPTW-ACO-python-6c95eeebca7c843a3b9a775a4215836af2f5ab42.tar.gz VRPTW-ACO-python-6c95eeebca7c843a3b9a775a4215836af2f5ab42.tar.bz2 VRPTW-ACO-python-6c95eeebca7c843a3b9a775a4215836af2f5ab42.zip | |
显示在given_time的时间内没有得到更好的解
| -rw-r--r-- | multiple_ant_colony_system.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/multiple_ant_colony_system.py b/multiple_ant_colony_system.py index 0ef14da..3a47ff1 100644 --- a/multiple_ant_colony_system.py +++ b/multiple_ant_colony_system.py @@ -123,6 +123,7 @@ class MultipleAntColonySystem: # 如果走完所有的点了,需要回到depot if ant.index_to_visit_empty(): + ant.graph.local_update_pheromone(ant.current_index, 0) ant.move_to_next_index(0) # 对未访问的点进行插入,保证path是可行的 @@ -371,11 +372,15 @@ class MultipleAntColonySystem: while acs_vehicle_thread.is_alive() and acs_time_thread.is_alive(): # 如果在指定时间内没有搜索到更好的结果,则退出程序 - if time.time() - start_time_found_improved_solution > 60 * 5: + given_time = 5 + if time.time() - start_time_found_improved_solution > 60 * given_time: stop_event.set() print('*' * 50) - print('time is up: cannot find a better solution in given time') + print('time is up: cannot find a better solution in given time(%d minutes)' % given_time) print('it takes %0.3f second from multiple_ant_colony_system running' % (time.time()-start_time_total)) + print('the best path have found is:') + print(self.best_path) + print('best path distance is %f, best vehicle_num is %d' % (self.best_path_distance, self.best_vehicle_num)) print('*' * 50) return |
