summaryrefslogtreecommitdiffstats
path: root/vrptw_base.py
diff options
context:
space:
mode:
authorJonZhao <[email protected]>2019-05-24 16:21:44 +0800
committerJonZhao <[email protected]>2019-05-24 16:21:44 +0800
commit5ea43c019d6bc47d0d28f9768c38be635e846a36 (patch)
treeccdbd884c295c0a6a1f09cc05b5f6d94e20b2106 /vrptw_base.py
parent3068981c81c2d7ca40eecf6c3a1091dd2f7d1350 (diff)
downloadVRPTW-ACO-python-5ea43c019d6bc47d0d28f9768c38be635e846a36.tar.gz
VRPTW-ACO-python-5ea43c019d6bc47d0d28f9768c38be635e846a36.tar.bz2
VRPTW-ACO-python-5ea43c019d6bc47d0d28f9768c38be635e846a36.zip
1. 增加初始化信息素的函数
2. 增加更新rho、q0的函数 3. 修复cost的计算部分
Diffstat (limited to 'vrptw_base.py')
-rw-r--r--vrptw_base.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/vrptw_base.py b/vrptw_base.py
index 798ffc7..2541842 100644
--- a/vrptw_base.py
+++ b/vrptw_base.py
@@ -87,4 +87,17 @@ class Ant:
self.current_index = next_index
def index_to_visit_empty(self):
- return len(self.index_to_visit) == 0 \ No newline at end of file
+ return len(self.index_to_visit) == 0
+
+ def calculate_path_distance(self, graph: VPRTW_Graph):
+ """
+ 计算所有蚂蚁的行走路径的长度
+ :param paths:
+ :return:
+ """
+ distance = 0
+ current_index = self.travel_path[0]
+ for index in self.travel_path[1:]:
+ distance += graph.node_dist_mat[current_index][index]
+ current_index = index
+ return distance