⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainliu.m

📁 TSP问题,即旅行商问题,matlab环境下可以运行
💻 M
字号:
timebegin=cputime;
%初始化定义全局变量
global customer;
global depot;
global demand;
global bestx;
global bestl;
global double bestSC;
global UD;global c;
global cm;
global h;
global A;
global hs;
global FC;
global W;
global Q;
global Max;

  
c=20;
cm=1;
h=1;
A=15;
hs=2;
Q=150;Max=1000;
depot=3;
customer=10;
UD=[5 4 8 9 6 7 6 5 8 7];
W=[2 3 2];
FC=[250 430 150];
demand=[142 85 385
       163 175 430
        87 96 540
        63 57 324
        204 217 238
        130 165 296
        180 210 340
        93 114 286
        170 163 392
        78 103 310
        50 148 0
        34 82 0
        185 198 0]; 
%FC=[250 430 150];
%W=[2 3 2];
x0=zeros(customer,2);
l0=zeros(1,customer);
%计算需求点和配送中心之间的距离
for j=1:depot
    for k=1:customer
        Dd(k,j)=sqrt((demand(k,1)-demand(j+customer,1))^2+(demand(k,2)-demand(j+customer,2))^2);
    end
end
for i=1:customer
   x0(i,2)=i;
   l0(i)=1;
   [dis,n]=min(Dd(i,:));
   x0(i,1)=n;
end


SCx0=SC(x0,l0);
'1'
bestx=x0;
bestl=l0;
bestSC=SCx0;


    one=x0(:);
  tabu=zeros(7,length(one));
  tabu=updatetabu(x0,tabu);
for count1=1:5
    [x1,l1,tabu]=location_improveliu(x0,l0,tabu);
     'location'
    [x2,l2,tabu]=routing_improveliu(x1,l1,tabu);
      'routing'
    x0=x2;
    l0=l2;
end
tabu
timeend=cputime;
time=timeend-timebegin
bestx
bestl
bestSC
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -