├── B22080228徐基恒数据结构与算法设计报告.doc ├── README.md ├── data └── 图片1.png ├── src ├── 题目1_优化版.cpp └── 题目1_基础版.cpp ├── 优化版遗传算法求解.exe └── 基础版暴力求解.exe /B22080228徐基恒数据结构与算法设计报告.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/njuptlogic/shortest-path-data-structure-algorithm-design-/475ddd6ec20a171ab29c77773d619975b9976618/B22080228徐基恒数据结构与算法设计报告.doc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 环形 TSP 问题的遗传算法求解 2 | 3 | 此程序基于遗传算法求解 **环形旅行商问题(TSP)**,用户可以输入城市数目、起始城市以及城市间的路径长度,程序将通过模拟遗传算法,找到一个路径长度最短的环形路径。 4 | 5 | ## 功能说明 6 | 7 | 1. **用户输入城市和路径数据** 8 | - 用户输入城市数量 `n` 和起始城市 `k`。 9 | - 输入所有城市间的路径长度和两端城市编号。 10 | 11 | 2. **遗传算法求解** 12 | - 初始化种群,保证路径从指定起始城市出发。 13 | - 通过遗传算法进行多代迭代,寻找最优的环形路径。 14 | - 包括以下遗传算法步骤: 15 | - **选择**:基于路径长度评估适应度,选择较优个体。 16 | - **交叉**:对父代进行部分基因交叉生成子代。 17 | - **变异**:对一定概率的个体进行随机变异。 18 | - 程序将输出最优路径和最短路径长度。 19 | 20 | 3. **环形路径计算** 21 | - 路径是一个闭环,从起始城市出发,经过其他城市后返回起始城市。 22 | - 使用邻接矩阵存储城市间的路径长度。 23 | 24 | 25 | -------------------------------------------------------------------------------- /data/图片1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/njuptlogic/shortest-path-data-structure-algorithm-design-/475ddd6ec20a171ab29c77773d619975b9976618/data/图片1.png -------------------------------------------------------------------------------- /src/题目1_优化版.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/njuptlogic/shortest-path-data-structure-algorithm-design-/475ddd6ec20a171ab29c77773d619975b9976618/src/题目1_优化版.cpp -------------------------------------------------------------------------------- /src/题目1_基础版.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/njuptlogic/shortest-path-data-structure-algorithm-design-/475ddd6ec20a171ab29c77773d619975b9976618/src/题目1_基础版.cpp -------------------------------------------------------------------------------- /优化版遗传算法求解.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/njuptlogic/shortest-path-data-structure-algorithm-design-/475ddd6ec20a171ab29c77773d619975b9976618/优化版遗传算法求解.exe -------------------------------------------------------------------------------- /基础版暴力求解.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/njuptlogic/shortest-path-data-structure-algorithm-design-/475ddd6ec20a171ab29c77773d619975b9976618/基础版暴力求解.exe --------------------------------------------------------------------------------