旅行商问题(TSP)祥解.ppt

旅行商问题(TSP)祥解.ppt

对角线完全算法 上述顶点序得到第二级重构距离矩阵 9 8 6 1 2 7 3 4 5 10 10 0* 9 0** 8 0* 6 0** 1 0* 2 0* 7 0* 3 0* 4 0* 5 335 最后还剩一个元素(5,10)不为零,没有选择余地,第三迭代必定是选(5,10)与前面得到的可行部分将一起构成H圈10-9-8-6-1-2-7-3-4-5-10. 对角线完全算法 因此第三级重构距离矩阵只需在第二级距离矩阵中335换成0***即可。第三级重构距离矩阵为: 9 8 6 1 2 7 3 4 5 10 10 0* 9 0** 8 0* 6 0** 1 0* 2 0* 7 0* 3 0* 4 0* 5 0*** 故所求H圈为:10-9-8-6-1-2-7-3-4-5-10,其权:W=3022。 旅行商问题的数学规划模型 旅行商问题的数学规划模型 或 旅行商问题的数学规划模型 例 用LINGO软件求解 MODEL: 1]sets: 2] cities/1..10/:level; !level(i)= the level of city; 3] link(cities, cities): 4] distance, !The distance matrix; 5] x; ! x(i,j)=1 if we use link i,j; 6]endsets 7]data: !Distance matrix, it need not be symmetirc; 8] distance = 0 8 5 9 12 14 12 16 17 22 旅行商问题的数学规划模型 9] 8 0 9 15 16 8 11 18 14 22 10] 5 9 0 7 9 11 7 12 12 17 11] 9 15 7 0 3 17 10 7 15 15 12] 12 16 9 3 0 8 10 6 15 15 13] 14 8 11 17 8 0 9 14 8 16 14] 12 11 7 10 10 9 0 8 6 11 15] 16 18 12 7 6 14 8 0 11 11 16] 17 14 12 15 15 8 6 11 0 10 17] 22 22 17 15 15 16 11 11 10 0; 18]enddata 19]n=@size(cities); !The model size; 20]! Minimize total distance of the links; 旅行商问题的数学规划模型 21]min=@sum(link(i,j)|i #ne# j: distance(i,j)*x(i,j)); 22]!For city i; 23]@for(cities(i) : 24]! It must be entered; 25] @sum(cities(j)| j #ne# i: x(j,i))=1; 26]! It must be departed; 27] @sum(cities(j)| j #ne# i: x(i,j))=1; 28]! level(j)=levle(i)+1, if we link j and i; 29] @for(cities(j)| j #gt# 1 #and# j #ne# i : 30] level(j) = level(i) + x(i,j) 31] - (n-2)*(1-x(i,j)) + (n-3)*x(j,i); 32] ); 33]); 旅行商问题的数学规划模型 34]! Make the xs 0/1; 35]@for(link : @bin(x)); 36]! For the first and last stop; 37]@for(cities(i) | i #gt# 1 : 38] level(i)=n-1-(n-2)*x(1,i); 39] level(i)=1+(n-2)*x(i,1); 40]); END 水平变量(level)仍然是用

文档评论(0)

1亿VIP精品文档

相关文档