Traveling Salesman Problem Based on Genetic Algorithm

I. Description of the problem:

Traveling salesman problem: with n cities and distance matrix D = [dij], where dij is the distance of the city i to j, i, j = 1,2 ... n, the problem is to find for each visited city exactly once and make a loop path length is the shortest.

Second, the purpose of the experiment:

In the same set of data, the observed population size and parameters are not the same situation summary of the experimental results.

Third, the program flow
1, the gene sequence according to the city initialization input;
2, calculated for each gene sequence adaptability, adaptability and inversely proportional to the path length (path length where I represents the inverse of using individual adaptability);
3, depending on the individual adaptively selecting a subject survive, is left to the individual selected according to a threshold value;
4, after the selection, the number of individuals of less than the initial population of individuals, the wheel selection method used to select male;
5, if the probability is greater than the selected predetermined paternal crossover probability, directly retained, otherwise produce progeny by cross-
6, progeny mutation operation, i.e. two nodes exchange values;
7 determines whether the number of iterations is ended, returns the optimal solution; No, go step 2.

The initial parameter data:

Fitness function:

select:

variation:

cross:

Initial run:

Fourth, the experimental results:

The main parameters: population size, the number of cities, the maximum operating algebra, crossover probability, mutation probability

1, the impact on the results of population size

Constant parameters

Variable parameters: Population

Population M = 50:

 

Population M = 200:

Conclusion: Under the above circumstances, when the population size is greater than or equal to 30 when the correct solution can be obtained substantially algorithm, the algorithm 40 to obtain 100% of the shortest path, but not the best path fails algebraic stability, the smaller the population converges faster.

2, the greatest impact on the results of the algebraic operation

Constant parameters

Variable parameters: the maximum operating Algebra

Conclusion: Under the above circumstances, when the maximum operating algebraic algorithm to achieve stable operation results 1000 (obtained stably shortest path), then the efficiency of the algorithm is relatively high.

When reached 10,000 100% correct, but the best path to appear on behalf of the algebraic stability within 2000, so I want to calculate after the 2000s are unnecessary, the maximum operating algebraic algorithm for optimal parameter 2000.

3, the number of cities on the results of the impact

Constant parameters

Variable parameters: the number of cities

The number of cities N = 10:

 

城市数量N=50:

 结论:上述情况下,当城市数量<=20时,算法100%的到正确解。当城市数量越大,越难得到最优解。

调整分以下情况:

(1)其他参数不变,种群规模逐渐调到150时,算法结果稳定。
(2)其他参数不变,最大运行代数逐渐调到10000时,算法结果稳定。
(3)其他参数不变,交叉概率不管怎么调,算法都得不到最优解。但是将种群规模调大到40,交叉概率调为0.1时,算法结果趋于稳定
综合(1)(2)(3)发现似乎一开始交叉概率就有问题,对于该算法交叉概率应该调低。当交叉概率较高时无论是提高种群规模还是最大运行代数,代价都太大。

Guess you like

Origin www.cnblogs.com/cenyan/p/11889895.html