Skip to content

ITISummer/TSP-Genetic_Algorithm_Solution_Scala

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

前言

这个程序是复写的别人的代码,为了熟悉遗传算法的的一些操作,快速入门遗传算法。 参考:遗传算法解决旅行商问题(详细解释+代码分析)-知乎

遗传算法是什么?

遗传算法是一种计算智能技术,模拟了自然界中生物进化的过程,通过模拟生物进化的方式寻找最优解或者接近最优解的解决方案。

遗传算法的基本思想是通过模拟自然进化的过程,将问题的解表示为一个基因型(染色体),然后通过选择、交叉和变异等遗传操作,生成新的解,逐步优化求解。

具体来说,遗传算法通常包括以下步骤:

  1. 初始化种群:随机生成一组初始解(染色体)作为种群。

  2. 适应度评估:对每个染色体进行适应度评估,以确定其质量。

  3. 选择操作:按照适应度大小选择一定数量的染色体作为“父代”,用于生成新的解。

  4. 交叉操作:将选定的染色体按照一定的规则进行“交叉”,生成新的解。

  5. 变异操作:对新生成的解进行一定的概率性变异操作,增加种群的多样性。

  6. 重复执行上述步骤,直到达到预设的停止条件(如达到最大迭代次数、找到最优解等)。

遗传算法在优化问题、机器学习、模式识别等领域得到了广泛应用,特别是对于那些复杂、高维、非线性的问题,遗传算法通常可以找到比传统优化方法更好的解。

TSP 问题

TSP (Traveling Salesman Problem) 是指旅行商问题,它是一类著名的组合优化问题。在TSP问题中,假设有一个旅行商要在给定的一组城市之间旅行,他必须恰好访问每个城市一次,最后回到起始城市。问题的目标是找到一条路径,使得旅行商的总旅行距离最小。

TSP问题属于NP困难问题,意味着随着问题规模的增加,解决问题所需的计算时间呈指数级增长。由于其广泛的应用领域和复杂性,TSP问题一直受到学术界和工业界的关注。

TSP问题有许多变体和扩展,例如带有时间窗口限制的TSP、多旅行商问题、对称TSP和非对称TSP等。解决TSP问题的方法包括贪心算法、动态规划、回溯算法、遗传算法和蚁群算法等。

结果

        epoch: 200
        notImproveEpoch: 7
        最好适应度为:1.8242754693298288E-6
        当前最优路线为:Array(74, 106, 62, 70, 38, 24, 34, 45, 36, 15, 60, 12, 123, 120, 100, 72, 102, 78, 83, 1, 67, 26, 68, 116, 27, 44, 5, 95, 37, 88, 28, 66, 65, 11, 76, 19, 40, 104, 6, 29, 31, 71, 124, 118, 57, 73, 79, 84, 33, 3, 10, 13, 7, 14, 112, 90, 89, 91, 48, 101, 125, 30, 80, 105, 55, 97, 96, 53, 17, 61, 63, 9, 115, 49, 4, 109, 82, 46, 2, 113, 47, 51, 16, 114, 121, 75, 52, 42, 85, 69, 21, 86, 108, 58, 87, 77, 122, 50, 107, 23, 99, 25, 93, 126, 92, 110, 111, 56, 54, 103, 18, 59, 81, 32, 0, 35, 64, 98, 117, 39, 41, 94, 20, 119, 8, 43, 22)
        当前最优路线距离为:548162.8278252094

        epoch: 400
        notImproveEpoch: 197
        最好适应度为:1.843666736553183E-6
        当前最优路线为:Array(14, 70, 22, 95, 13, 110, 102, 28, 50, 68, 98, 90, 63, 115, 108, 121, 39, 2, 124, 113, 43, 27, 106, 126, 9, 18, 96, 116, 8, 32, 74, 7, 94, 93, 53, 33, 118, 56, 104, 119, 109, 60, 19, 0, 37, 4, 82, 81, 15, 36, 34, 71, 55, 64, 84, 6, 10, 80, 125, 30, 120, 44, 58, 52, 45, 31, 65, 97, 69, 59, 103, 20, 72, 21, 114, 41, 83, 67, 12, 112, 123, 51, 40, 61, 11, 57, 88, 92, 17, 76, 16, 3, 23, 5, 1, 26, 49, 47, 42, 105, 117, 111, 46, 54, 91, 38, 73, 79, 66, 86, 62, 85, 24, 75, 77, 48, 122, 99, 35, 100, 78, 107, 89, 87, 101, 25, 29)
        当前最优路线距离为:542397.3759322384

        epoch: 600
        notImproveEpoch: 49
        最好适应度为:1.856532121721292E-6
        当前最优路线为:Array(70, 115, 113, 24, 12, 110, 124, 46, 48, 1, 55, 91, 49, 120, 50, 52, 93, 33, 9, 45, 96, 8, 30, 11, 36, 40, 125, 116, 27, 94, 102, 62, 84, 32, 28, 80, 29, 59, 90, 3, 121, 123, 79, 86, 7, 31, 104, 35, 111, 126, 106, 67, 89, 85, 18, 88, 65, 63, 99, 39, 87, 108, 95, 53, 103, 6, 43, 119, 42, 19, 101, 97, 44, 107, 13, 10, 64, 58, 2, 83, 71, 23, 112, 114, 61, 26, 41, 5, 37, 81, 68, 77, 66, 34, 75, 16, 4, 98, 57, 20, 78, 122, 56, 47, 82, 76, 92, 15, 60, 21, 105, 100, 54, 69, 72, 73, 109, 38, 51, 118, 25, 14, 117, 22, 17, 0, 74)
        当前最优路线距离为:538638.6738479082

        epoch: 800
        notImproveEpoch: 249
        最好适应度为:1.856532121721292E-6
        当前最优路线为:Array(70, 115, 113, 24, 12, 110, 124, 46, 48, 1, 55, 91, 49, 120, 50, 52, 93, 33, 9, 45, 96, 8, 30, 11, 36, 40, 125, 116, 27, 94, 102, 62, 84, 32, 28, 80, 29, 59, 90, 3, 121, 123, 79, 86, 7, 31, 104, 35, 111, 126, 106, 67, 89, 85, 18, 88, 65, 63, 99, 39, 87, 108, 95, 53, 103, 6, 43, 119, 42, 19, 101, 97, 44, 107, 13, 10, 64, 58, 2, 83, 71, 23, 112, 114, 61, 26, 41, 5, 37, 81, 68, 77, 66, 34, 75, 16, 4, 98, 57, 20, 78, 122, 56, 47, 82, 76, 92, 15, 60, 21, 105, 100, 54, 69, 72, 73, 109, 38, 51, 118, 25, 14, 117, 22, 17, 0, 74)
        当前最优路线距离为:538638.6738479082

        epoch: 1000
        notImproveEpoch: 449
        最好适应度为:1.856532121721292E-6
        当前最优路线为:Array(70, 115, 113, 24, 12, 110, 124, 46, 48, 1, 55, 91, 49, 120, 50, 52, 93, 33, 9, 45, 96, 8, 30, 11, 36, 40, 125, 116, 27, 94, 102, 62, 84, 32, 28, 80, 29, 59, 90, 3, 121, 123, 79, 86, 7, 31, 104, 35, 111, 126, 106, 67, 89, 85, 18, 88, 65, 63, 99, 39, 87, 108, 95, 53, 103, 6, 43, 119, 42, 19, 101, 97, 44, 107, 13, 10, 64, 58, 2, 83, 71, 23, 112, 114, 61, 26, 41, 5, 37, 81, 68, 77, 66, 34, 75, 16, 4, 98, 57, 20, 78, 122, 56, 47, 82, 76, 92, 15, 60, 21, 105, 100, 54, 69, 72, 73, 109, 38, 51, 118, 25, 14, 117, 22, 17, 0, 74)
        当前最优路线距离为:538638.6738479082

        epoch: 1200
        notImproveEpoch: 649
        最好适应度为:1.856532121721292E-6
        当前最优路线为:Array(70, 115, 113, 24, 12, 110, 124, 46, 48, 1, 55, 91, 49, 120, 50, 52, 93, 33, 9, 45, 96, 8, 30, 11, 36, 40, 125, 116, 27, 94, 102, 62, 84, 32, 28, 80, 29, 59, 90, 3, 121, 123, 79, 86, 7, 31, 104, 35, 111, 126, 106, 67, 89, 85, 18, 88, 65, 63, 99, 39, 87, 108, 95, 53, 103, 6, 43, 119, 42, 19, 101, 97, 44, 107, 13, 10, 64, 58, 2, 83, 71, 23, 112, 114, 61, 26, 41, 5, 37, 81, 68, 77, 66, 34, 75, 16, 4, 98, 57, 20, 78, 122, 56, 47, 82, 76, 92, 15, 60, 21, 105, 100, 54, 69, 72, 73, 109, 38, 51, 118, 25, 14, 117, 22, 17, 0, 74)
        当前最优路线距离为:538638.6738479082

        epoch: 1400
        notImproveEpoch: 849
        最好适应度为:1.856532121721292E-6
        当前最优路线为:Array(70, 115, 113, 24, 12, 110, 124, 46, 48, 1, 55, 91, 49, 120, 50, 52, 93, 33, 9, 45, 96, 8, 30, 11, 36, 40, 125, 116, 27, 94, 102, 62, 84, 32, 28, 80, 29, 59, 90, 3, 121, 123, 79, 86, 7, 31, 104, 35, 111, 126, 106, 67, 89, 85, 18, 88, 65, 63, 99, 39, 87, 108, 95, 53, 103, 6, 43, 119, 42, 19, 101, 97, 44, 107, 13, 10, 64, 58, 2, 83, 71, 23, 112, 114, 61, 26, 41, 5, 37, 81, 68, 77, 66, 34, 75, 16, 4, 98, 57, 20, 78, 122, 56, 47, 82, 76, 92, 15, 60, 21, 105, 100, 54, 69, 72, 73, 109, 38, 51, 118, 25, 14, 117, 22, 17, 0, 74)
        当前最优路线距离为:538638.6738479082

        epoch: 1600
        notImproveEpoch: 107
        最好适应度为:1.8645650842171889E-6
        当前最优路线为:Array(105, 116, 110, 104, 55, 45, 51, 54, 14, 5, 21, 98, 111, 47, 28, 48, 58, 93, 97, 67, 9, 22, 103, 113, 12, 52, 44, 68, 41, 126, 61, 11, 82, 120, 114, 0, 15, 79, 20, 122, 101, 66, 72, 115, 109, 87, 30, 13, 84, 73, 57, 117, 29, 46, 70, 80, 88, 91, 36, 6, 34, 26, 92, 106, 59, 23, 16, 31, 63, 56, 37, 33, 10, 53, 49, 64, 107, 121, 89, 8, 119, 2, 100, 4, 40, 71, 76, 43, 7, 74, 125, 96, 81, 95, 62, 69, 123, 102, 65, 90, 124, 75, 83, 32, 38, 108, 118, 42, 60, 99, 112, 85, 86, 78, 1, 27, 94, 25, 3, 50, 77, 19, 17, 18, 39, 35, 24)
        当前最优路线距离为:536318.0982335276

        epoch: 1800
        notImproveEpoch: 307
        最好适应度为:1.8645650842171889E-6
        当前最优路线为:Array(105, 116, 110, 104, 55, 45, 51, 54, 14, 5, 21, 98, 111, 47, 28, 48, 58, 93, 97, 67, 9, 22, 103, 113, 12, 52, 44, 68, 41, 126, 61, 11, 82, 120, 114, 0, 15, 79, 20, 122, 101, 66, 72, 115, 109, 87, 30, 13, 84, 73, 57, 117, 29, 46, 70, 80, 88, 91, 36, 6, 34, 26, 92, 106, 59, 23, 16, 31, 63, 56, 37, 33, 10, 53, 49, 64, 107, 121, 89, 8, 119, 2, 100, 4, 40, 71, 76, 43, 7, 74, 125, 96, 81, 95, 62, 69, 123, 102, 65, 90, 124, 75, 83, 32, 38, 108, 118, 42, 60, 99, 112, 85, 86, 78, 1, 27, 94, 25, 3, 50, 77, 19, 17, 18, 39, 35, 24)
        当前最优路线距离为:536318.0982335276

        epoch: 2000
        notImproveEpoch: 507
        最好适应度为:1.8645650842171889E-6
        当前最优路线为:Array(105, 116, 110, 104, 55, 45, 51, 54, 14, 5, 21, 98, 111, 47, 28, 48, 58, 93, 97, 67, 9, 22, 103, 113, 12, 52, 44, 68, 41, 126, 61, 11, 82, 120, 114, 0, 15, 79, 20, 122, 101, 66, 72, 115, 109, 87, 30, 13, 84, 73, 57, 117, 29, 46, 70, 80, 88, 91, 36, 6, 34, 26, 92, 106, 59, 23, 16, 31, 63, 56, 37, 33, 10, 53, 49, 64, 107, 121, 89, 8, 119, 2, 100, 4, 40, 71, 76, 43, 7, 74, 125, 96, 81, 95, 62, 69, 123, 102, 65, 90, 124, 75, 83, 32, 38, 108, 118, 42, 60, 99, 112, 85, 86, 78, 1, 27, 94, 25, 3, 50, 77, 19, 17, 18, 39, 35, 24)
        当前最优路线距离为:536318.0982335276

        epoch: 2200
        notImproveEpoch: 18
        最好适应度为:1.8713498520665035E-6
        当前最优路线为:Array(15, 28, 83, 37, 92, 12, 56, 20, 82, 100, 70, 18, 42, 85, 47, 3, 10, 38, 126, 53, 107, 11, 27, 109, 1, 58, 17, 99, 88, 22, 16, 32, 101, 68, 35, 123, 24, 40, 113, 59, 44, 9, 51, 93, 96, 46, 33, 61, 91, 4, 124, 55, 89, 25, 79, 111, 45, 122, 23, 78, 102, 6, 54, 8, 104, 41, 106, 34, 121, 39, 65, 57, 117, 52, 26, 119, 21, 0, 29, 80, 7, 116, 66, 86, 74, 62, 118, 115, 13, 67, 30, 31, 125, 81, 97, 95, 112, 77, 71, 105, 90, 72, 76, 73, 19, 69, 84, 87, 75, 5, 36, 64, 114, 49, 43, 98, 63, 48, 14, 2, 50, 120, 103, 94, 60, 108, 110)
        当前最优路线距离为:534373.6228133478

        epoch: 2400
        notImproveEpoch: 218
        最好适应度为:1.8713498520665035E-6
        当前最优路线为:Array(15, 28, 83, 37, 92, 12, 56, 20, 82, 100, 70, 18, 42, 85, 47, 3, 10, 38, 126, 53, 107, 11, 27, 109, 1, 58, 17, 99, 88, 22, 16, 32, 101, 68, 35, 123, 24, 40, 113, 59, 44, 9, 51, 93, 96, 46, 33, 61, 91, 4, 124, 55, 89, 25, 79, 111, 45, 122, 23, 78, 102, 6, 54, 8, 104, 41, 106, 34, 121, 39, 65, 57, 117, 52, 26, 119, 21, 0, 29, 80, 7, 116, 66, 86, 74, 62, 118, 115, 13, 67, 30, 31, 125, 81, 97, 95, 112, 77, 71, 105, 90, 72, 76, 73, 19, 69, 84, 87, 75, 5, 36, 64, 114, 49, 43, 98, 63, 48, 14, 2, 50, 120, 103, 94, 60, 108, 110)
        当前最优路线距离为:534373.6228133478

        epoch: 2600
        notImproveEpoch: 418
        最好适应度为:1.8713498520665035E-6
        当前最优路线为:Array(15, 28, 83, 37, 92, 12, 56, 20, 82, 100, 70, 18, 42, 85, 47, 3, 10, 38, 126, 53, 107, 11, 27, 109, 1, 58, 17, 99, 88, 22, 16, 32, 101, 68, 35, 123, 24, 40, 113, 59, 44, 9, 51, 93, 96, 46, 33, 61, 91, 4, 124, 55, 89, 25, 79, 111, 45, 122, 23, 78, 102, 6, 54, 8, 104, 41, 106, 34, 121, 39, 65, 57, 117, 52, 26, 119, 21, 0, 29, 80, 7, 116, 66, 86, 74, 62, 118, 115, 13, 67, 30, 31, 125, 81, 97, 95, 112, 77, 71, 105, 90, 72, 76, 73, 19, 69, 84, 87, 75, 5, 36, 64, 114, 49, 43, 98, 63, 48, 14, 2, 50, 120, 103, 94, 60, 108, 110)
        当前最优路线距离为:534373.6228133478

        epoch: 2800
        notImproveEpoch: 618
        最好适应度为:1.8713498520665035E-6
        当前最优路线为:Array(15, 28, 83, 37, 92, 12, 56, 20, 82, 100, 70, 18, 42, 85, 47, 3, 10, 38, 126, 53, 107, 11, 27, 109, 1, 58, 17, 99, 88, 22, 16, 32, 101, 68, 35, 123, 24, 40, 113, 59, 44, 9, 51, 93, 96, 46, 33, 61, 91, 4, 124, 55, 89, 25, 79, 111, 45, 122, 23, 78, 102, 6, 54, 8, 104, 41, 106, 34, 121, 39, 65, 57, 117, 52, 26, 119, 21, 0, 29, 80, 7, 116, 66, 86, 74, 62, 118, 115, 13, 67, 30, 31, 125, 81, 97, 95, 112, 77, 71, 105, 90, 72, 76, 73, 19, 69, 84, 87, 75, 5, 36, 64, 114, 49, 43, 98, 63, 48, 14, 2, 50, 120, 103, 94, 60, 108, 110)
        当前最优路线距离为:534373.6228133478

        epoch: 3000
        notImproveEpoch: 138
        最好适应度为:1.8961464729342093E-6
        当前最优路线为:Array(113, 96, 54, 103, 90, 89, 0, 7, 65, 91, 49, 109, 87, 95, 14, 2, 80, 23, 22, 79, 19, 30, 76, 8, 60, 3, 120, 126, 106, 94, 74, 68, 88, 59, 71, 58, 34, 20, 11, 117, 75, 115, 57, 124, 50, 1, 78, 97, 110, 12, 107, 61, 85, 86, 25, 44, 42, 114, 46, 104, 18, 28, 17, 111, 92, 33, 29, 116, 45, 43, 84, 108, 83, 73, 35, 52, 112, 98, 16, 82, 66, 67, 77, 64, 6, 38, 40, 69, 15, 81, 118, 70, 4, 13, 47, 53, 99, 119, 62, 37, 55, 21, 100, 26, 31, 27, 105, 121, 32, 36, 56, 51, 5, 122, 125, 10, 39, 93, 123, 9, 63, 102, 101, 48, 72, 24, 41)
        当前最优路线距离为:527385.4178852232

        epoch: 3200
        notImproveEpoch: 338
        最好适应度为:1.8961464729342093E-6
        当前最优路线为:Array(113, 96, 54, 103, 90, 89, 0, 7, 65, 91, 49, 109, 87, 95, 14, 2, 80, 23, 22, 79, 19, 30, 76, 8, 60, 3, 120, 126, 106, 94, 74, 68, 88, 59, 71, 58, 34, 20, 11, 117, 75, 115, 57, 124, 50, 1, 78, 97, 110, 12, 107, 61, 85, 86, 25, 44, 42, 114, 46, 104, 18, 28, 17, 111, 92, 33, 29, 116, 45, 43, 84, 108, 83, 73, 35, 52, 112, 98, 16, 82, 66, 67, 77, 64, 6, 38, 40, 69, 15, 81, 118, 70, 4, 13, 47, 53, 99, 119, 62, 37, 55, 21, 100, 26, 31, 27, 105, 121, 32, 36, 56, 51, 5, 122, 125, 10, 39, 93, 123, 9, 63, 102, 101, 48, 72, 24, 41)
        当前最优路线距离为:527385.4178852232

        epoch: 3400
        notImproveEpoch: 538
        最好适应度为:1.8961464729342093E-6
        当前最优路线为:Array(113, 96, 54, 103, 90, 89, 0, 7, 65, 91, 49, 109, 87, 95, 14, 2, 80, 23, 22, 79, 19, 30, 76, 8, 60, 3, 120, 126, 106, 94, 74, 68, 88, 59, 71, 58, 34, 20, 11, 117, 75, 115, 57, 124, 50, 1, 78, 97, 110, 12, 107, 61, 85, 86, 25, 44, 42, 114, 46, 104, 18, 28, 17, 111, 92, 33, 29, 116, 45, 43, 84, 108, 83, 73, 35, 52, 112, 98, 16, 82, 66, 67, 77, 64, 6, 38, 40, 69, 15, 81, 118, 70, 4, 13, 47, 53, 99, 119, 62, 37, 55, 21, 100, 26, 31, 27, 105, 121, 32, 36, 56, 51, 5, 122, 125, 10, 39, 93, 123, 9, 63, 102, 101, 48, 72, 24, 41)
        当前最优路线距离为:527385.4178852232

        epoch: 3600
        notImproveEpoch: 738
        最好适应度为:1.8961464729342093E-6
        当前最优路线为:Array(113, 96, 54, 103, 90, 89, 0, 7, 65, 91, 49, 109, 87, 95, 14, 2, 80, 23, 22, 79, 19, 30, 76, 8, 60, 3, 120, 126, 106, 94, 74, 68, 88, 59, 71, 58, 34, 20, 11, 117, 75, 115, 57, 124, 50, 1, 78, 97, 110, 12, 107, 61, 85, 86, 25, 44, 42, 114, 46, 104, 18, 28, 17, 111, 92, 33, 29, 116, 45, 43, 84, 108, 83, 73, 35, 52, 112, 98, 16, 82, 66, 67, 77, 64, 6, 38, 40, 69, 15, 81, 118, 70, 4, 13, 47, 53, 99, 119, 62, 37, 55, 21, 100, 26, 31, 27, 105, 121, 32, 36, 56, 51, 5, 122, 125, 10, 39, 93, 123, 9, 63, 102, 101, 48, 72, 24, 41)
        当前最优路线距离为:527385.4178852232

        epoch: 3800
        notImproveEpoch: 938
        最好适应度为:1.8961464729342093E-6
        当前最优路线为:Array(113, 96, 54, 103, 90, 89, 0, 7, 65, 91, 49, 109, 87, 95, 14, 2, 80, 23, 22, 79, 19, 30, 76, 8, 60, 3, 120, 126, 106, 94, 74, 68, 88, 59, 71, 58, 34, 20, 11, 117, 75, 115, 57, 124, 50, 1, 78, 97, 110, 12, 107, 61, 85, 86, 25, 44, 42, 114, 46, 104, 18, 28, 17, 111, 92, 33, 29, 116, 45, 43, 84, 108, 83, 73, 35, 52, 112, 98, 16, 82, 66, 67, 77, 64, 6, 38, 40, 69, 15, 81, 118, 70, 4, 13, 47, 53, 99, 119, 62, 37, 55, 21, 100, 26, 31, 27, 105, 121, 32, 36, 56, 51, 5, 122, 125, 10, 39, 93, 123, 9, 63, 102, 101, 48, 72, 24, 41)
        当前最优路线距离为:527385.4178852232

        epoch: 4000
        notImproveEpoch: 1138
        最好适应度为:1.8961464729342093E-6
        当前最优路线为:Array(113, 96, 54, 103, 90, 89, 0, 7, 65, 91, 49, 109, 87, 95, 14, 2, 80, 23, 22, 79, 19, 30, 76, 8, 60, 3, 120, 126, 106, 94, 74, 68, 88, 59, 71, 58, 34, 20, 11, 117, 75, 115, 57, 124, 50, 1, 78, 97, 110, 12, 107, 61, 85, 86, 25, 44, 42, 114, 46, 104, 18, 28, 17, 111, 92, 33, 29, 116, 45, 43, 84, 108, 83, 73, 35, 52, 112, 98, 16, 82, 66, 67, 77, 64, 6, 38, 40, 69, 15, 81, 118, 70, 4, 13, 47, 53, 99, 119, 62, 37, 55, 21, 100, 26, 31, 27, 105, 121, 32, 36, 56, 51, 5, 122, 125, 10, 39, 93, 123, 9, 63, 102, 101, 48, 72, 24, 41)
        当前最优路线距离为:527385.4178852232

        epoch: 4200
        notImproveEpoch: 1338
        最好适应度为:1.8961464729342093E-6
        当前最优路线为:Array(113, 96, 54, 103, 90, 89, 0, 7, 65, 91, 49, 109, 87, 95, 14, 2, 80, 23, 22, 79, 19, 30, 76, 8, 60, 3, 120, 126, 106, 94, 74, 68, 88, 59, 71, 58, 34, 20, 11, 117, 75, 115, 57, 124, 50, 1, 78, 97, 110, 12, 107, 61, 85, 86, 25, 44, 42, 114, 46, 104, 18, 28, 17, 111, 92, 33, 29, 116, 45, 43, 84, 108, 83, 73, 35, 52, 112, 98, 16, 82, 66, 67, 77, 64, 6, 38, 40, 69, 15, 81, 118, 70, 4, 13, 47, 53, 99, 119, 62, 37, 55, 21, 100, 26, 31, 27, 105, 121, 32, 36, 56, 51, 5, 122, 125, 10, 39, 93, 123, 9, 63, 102, 101, 48, 72, 24, 41)
        当前最优路线距离为:527385.4178852232

        epoch: 4400
        notImproveEpoch: 1538
        最好适应度为:1.8961464729342093E-6
        当前最优路线为:Array(113, 96, 54, 103, 90, 89, 0, 7, 65, 91, 49, 109, 87, 95, 14, 2, 80, 23, 22, 79, 19, 30, 76, 8, 60, 3, 120, 126, 106, 94, 74, 68, 88, 59, 71, 58, 34, 20, 11, 117, 75, 115, 57, 124, 50, 1, 78, 97, 110, 12, 107, 61, 85, 86, 25, 44, 42, 114, 46, 104, 18, 28, 17, 111, 92, 33, 29, 116, 45, 43, 84, 108, 83, 73, 35, 52, 112, 98, 16, 82, 66, 67, 77, 64, 6, 38, 40, 69, 15, 81, 118, 70, 4, 13, 47, 53, 99, 119, 62, 37, 55, 21, 100, 26, 31, 27, 105, 121, 32, 36, 56, 51, 5, 122, 125, 10, 39, 93, 123, 9, 63, 102, 101, 48, 72, 24, 41)
        当前最优路线距离为:527385.4178852232

        epoch: 4600
        notImproveEpoch: 1738
        最好适应度为:1.8961464729342093E-6
        当前最优路线为:Array(113, 96, 54, 103, 90, 89, 0, 7, 65, 91, 49, 109, 87, 95, 14, 2, 80, 23, 22, 79, 19, 30, 76, 8, 60, 3, 120, 126, 106, 94, 74, 68, 88, 59, 71, 58, 34, 20, 11, 117, 75, 115, 57, 124, 50, 1, 78, 97, 110, 12, 107, 61, 85, 86, 25, 44, 42, 114, 46, 104, 18, 28, 17, 111, 92, 33, 29, 116, 45, 43, 84, 108, 83, 73, 35, 52, 112, 98, 16, 82, 66, 67, 77, 64, 6, 38, 40, 69, 15, 81, 118, 70, 4, 13, 47, 53, 99, 119, 62, 37, 55, 21, 100, 26, 31, 27, 105, 121, 32, 36, 56, 51, 5, 122, 125, 10, 39, 93, 123, 9, 63, 102, 101, 48, 72, 24, 41)
        当前最优路线距离为:527385.4178852232

        epoch: 4800
        notImproveEpoch: 1938
        最好适应度为:1.8961464729342093E-6
        当前最优路线为:Array(113, 96, 54, 103, 90, 89, 0, 7, 65, 91, 49, 109, 87, 95, 14, 2, 80, 23, 22, 79, 19, 30, 76, 8, 60, 3, 120, 126, 106, 94, 74, 68, 88, 59, 71, 58, 34, 20, 11, 117, 75, 115, 57, 124, 50, 1, 78, 97, 110, 12, 107, 61, 85, 86, 25, 44, 42, 114, 46, 104, 18, 28, 17, 111, 92, 33, 29, 116, 45, 43, 84, 108, 83, 73, 35, 52, 112, 98, 16, 82, 66, 67, 77, 64, 6, 38, 40, 69, 15, 81, 118, 70, 4, 13, 47, 53, 99, 119, 62, 37, 55, 21, 100, 26, 31, 27, 105, 121, 32, 36, 56, 51, 5, 122, 125, 10, 39, 93, 123, 9, 63, 102, 101, 48, 72, 24, 41)
        当前最优路线距离为:527385.4178852232

        连续2000次迭代都没有改变最优路线,结束迭代
        最优路线为:Array(113, 96, 54, 103, 90, 89, 0, 7, 65, 91, 49, 109, 87, 95, 14, 2, 80, 23, 22, 79, 19, 30, 76, 8, 60, 3, 120, 126, 106, 94, 74, 68, 88, 59, 71, 58, 34, 20, 11, 117, 75, 115, 57, 124, 50, 1, 78, 97, 110, 12, 107, 61, 85, 86, 25, 44, 42, 114, 46, 104, 18, 28, 17, 111, 92, 33, 29, 116, 45, 43, 84, 108, 83, 73, 35, 52, 112, 98, 16, 82, 66, 67, 77, 64, 6, 38, 40, 69, 15, 81, 118, 70, 4, 13, 47, 53, 99, 119, 62, 37, 55, 21, 100, 26, 31, 27, 105, 121, 32, 36, 56, 51, 5, 122, 125, 10, 39, 93, 123, 9, 63, 102, 101, 48, 72, 24, 41)
        总距离为:527385.4178852232

        程序运行耗时: 12.00 s.
        Process finished with exit code 0

About

A project that solve TSP in Scala lang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages