A list,
Ii. Source code
1, problem,1In the10Two optimal scheduling planning Matlab source program CLC for each center point; clear all; close all; position=load('Coordinate dot TXT'); [m,n]=size(position);
j=1;
sumx=0; sumy=0; for i=1:10
sumx=sumx+position(i,1); sumy=sumy+position(i,2);
end ave(j,1)=sumx/10; ave(j,2)=sumy/10; j=j+1;
sumx=0; sumy=0; for i=11:19
sumx=sumx+position(i,1); sumy=sumy+position(i,2);
end ave(j,1)=sumx/9; ave(j,2)=sumy/9; j=j+1;
sumx=0; sumy=0; for i=20:24
sumx=sumx+position(i,1); sumy=sumy+position(i,2);
end ave(j,1)=sumx/5; ave(j,2)=sumy/5; j=j+1;
sumx=0; sumy=0; for i=25:34
sumx=sumx+position(i,1); sumy=sumy+position(i,2);
end ave(j,1)=sumx/10; ave(j,2)=sumy/10; j=j+1;
sumx=0; sumy=0; for i=35:41
sumx=sumx+position(i,1); sumy=sumy+position(i,2);
end ave(j,1)=sumx/7; ave(j,2)=sumy/7; j=j+1;
sumx=0; sumy=0; for i=42:47
sumx=sumx+position(i,1); sumy=sumy+position(i,2);
end ave(j,1)=sumx/6; ave(j,2)=sumy/6; j=j+1;
sumx=0; sumy=0; for i=48:53
sumx=sumx+position(i,1); sumy=sumy+position(i,2);
end ave(j,1)=sumx/6; ave(j,2)=sumy/6; j=j+1;
sumx=0; sumy=0; for i=54:58
sumx=sumx+position(i,1); sumy=sumy+position(i,2);
end ave(j,1)=sumx/5; ave(j,2)=sumy/5; j=j+1;
sumx=0; sumy=0; for i=59:63
sumx=sumx+position(i,1); sumy=sumy+position(i,2);
end ave(j,1)=sumx/5; ave(j,2)=sumy/5; j=j+1;
sumx=0; sumy=0; for i=64:68
sumx=sumx+position(i,1); sumy=sumy+position(i,2);
end ave(j,1)=sumx/5; ave(j,2)=sumy/5; j=j+1;
% ave=position;
Routebest=10000000000; for one=1:2^10/2A=[]; B=[]; index=dec2bin(one,10); for two=1:10
if index(two)=='0' A=[A;ave(two,:)];
end
elseend B=[B;ave(two,:)]; [m,n]=size(A); fit1=[]; p1=[];if m==1fit1=A; L1=0;
else
[d1]=dj(A);
[p1,L1] = tspsearch2(d1,2);
for i=1:m
fit1(i,1)=A(p1(i),1);
fit1(i,2)=A(p1(i),2); end end [m,n]=size(B); fit2=[]; p2=[];if m==1fit2=B; L2=0;
else
[d2]=dj(B);
[p2,L2] = tspsearch2(d2,2);
for i=1:m
fit2(i,1)=B(p2(i),1);
fit2(i,2)=B(p2(i),2);
end
end
if (L1+L2)<Routebest Routebest=L1+L2; fit1best=[]; fit2best=[]; p1best=[]; p2best=[]; fit1best=fit1; fit2best=fit2; p1best=p1; p2best=p2; end end2, problem,1In the68Two sets of optimal scheduling planning Matlab source program CLC for two target points; clear all; close all; position=load('Coordinate dot TXT'); po1=position(1:10, :); %A1 po2=position(11:19, :); %A2 po8=position(54:58, :); %A8 po9=position(59:63, :); %A9 po3=position(20:24, :); %A3 po4=position(25:34, :); %A4 po10=position(64:68, :); %A10 po7=position(48:53, :); %A7 po5=position(35:41, :); %A5 po6=position(42:47, :); %A6 A=[po2;po3;po4;po5;po6;po7;po8;po9;po10]; B=po1; [d1]=dj(A); [p1,L1] = tspsearch2(d1,2); [m,n]=size(A) ;
for i=1:m
fit1(i,1)=A(p1(i),1);
fit1(i,2)=A(p1(i),2);
end
[d2]=dj(B);
[p2,L2] = tspsearch2(d2,2); [m,n]=size(B) ;
for i=1:m
fit2(i,1)=B(p2(i),1);
fit2(i,2)=B(p2(i),2);
end
Copy the code
Third, note
2014a