diff options
| author | JonZhao <[email protected]> | 2019-05-27 22:45:10 +0800 |
|---|---|---|
| committer | JonZhao <[email protected]> | 2019-05-27 22:45:10 +0800 |
| commit | 1b2e26d831e075770baa8c2c27ef965b1c7743b2 (patch) | |
| tree | b7c49d4b88681aaeec820f9598c0284bbe567def /vrptw_base.py | |
| parent | 943114101b05f5cb3d4f149c2de4b360f33cb0a7 (diff) | |
| download | VRPTW-ACO-python-1b2e26d831e075770baa8c2c27ef965b1c7743b2.tar.gz VRPTW-ACO-python-1b2e26d831e075770baa8c2c27ef965b1c7743b2.tar.bz2 VRPTW-ACO-python-1b2e26d831e075770baa8c2c27ef965b1c7743b2.zip | |
移除复制多个depot的graph创建方法,使用更加原始的,如果没有可以达到的下一个客户结点,则回到depot,取得了不错的效果,带接下来继续测试
Diffstat (limited to 'vrptw_base.py')
| -rw-r--r-- | vrptw_base.py | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/vrptw_base.py b/vrptw_base.py index 0ce20d9..ba86128 100644 --- a/vrptw_base.py +++ b/vrptw_base.py @@ -39,25 +39,9 @@ class VrptwGraph: # 启发式信息矩阵 self.heuristic_info_mat = 1 / self.node_dist_mat - def construct_graph_with_duplicated_depot(self, vehicle_num, init_pheromone_val): + def copy(self, init_pheromone_val): new_graph = copy.deepcopy(self) - new_graph.node_num += vehicle_num-1 - for i in range(vehicle_num-1): - new_graph.nodes.insert(0, copy.deepcopy(new_graph.nodes[0])) - - # 从新计算距离 - new_graph.node_dist_mat = np.zeros((new_graph.node_num, new_graph.node_num)) - for i in range(new_graph.node_num): - original_i = max(0, i - vehicle_num + 1) - - for j in range(i + 1, new_graph.node_num): - original_j = max(0, j - vehicle_num + 1) - new_graph.node_dist_mat[i][j] = self.node_dist_mat[original_i][original_j] - new_graph.node_dist_mat[j][i] = new_graph.node_dist_mat[i][j] - - # 启发式信息 - new_graph.heuristic_info_mat = 1 / new_graph.node_dist_mat # 信息素 new_graph.init_pheromone_val = init_pheromone_val new_graph.pheromone_mat = np.ones((new_graph.node_num, new_graph.node_num)) * init_pheromone_val |
