sa_routingmove.asv
来自「TSP问题,即旅行商问题,matlab环境下可以运行」· ASV 代码 · 共 59 行
ASV
59 行
function [x1,changex,l1,tabu]=sa_routingmove(x0,l0,tabu)
nu1=unidrnd(3);
switch nu
case 1
[x1,changex,l1]=insert(x0,l0);
case 2
[x1,changex,l1]=swap_routing(x0,l0);
case 3
[x1,changex,l1]=newroute(x0,l0);
end
x1
l1
% 满足容量需求
while condition(x1,changex,l1)==0 %不满足条件
nu=unidrnd(3);
switch nu
case 1
[x1,changex,l1]=insert(x0,l0);
case 2
[x1,changex,l1]=swap_routing(x0,l0);
case 3
[x1,changex,l1]=newroute(x0,l0);
end
end
while findintabu(changex,tabu)==1 %在tabu中
nu=unidrnd(3);
switch nu
case 1
[x1,changex,l1]=insert(x0,l0);
case 2
[x1,changex,l1]=swap_routing(x0,l0);
case 3
[x1,changex,l1]=newroute(x0,l0);
end
while condition(x1,changex,l1)==0 %不满足条件
nu=unidrnd(3);
switch nu
case 1
[x1,changex,l1]=insert(x0,l0);
case 2
[x1,changex,l1]=swap_routing(x0,l0);
case 3
[x1,changex,l1]=newroute(x0,l0);
end
end
x1
l1
end
x1
l1
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?