From 5ea43c019d6bc47d0d28f9768c38be635e846a36 Mon Sep 17 00:00:00 2001 From: JonZhao <1044264932@qq.com> Date: Fri, 24 May 2019 16:21:44 +0800 Subject: 1. 增加初始化信息素的函数 2. 增加更新rho、q0的函数 3. 修复cost的计算部分 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vrptw_base.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'vrptw_base.py') 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 -- cgit v1.2.3