plotpicture.m
来自「TSP问题,即旅行商问题,matlab环境下可以运行」· M 代码 · 共 46 行
M
46 行
global demand;
global customer;
global depot;
v=[3 12 10
3 5 14
1 13 3
3 9 6
3 15 8
1 11 4
3 1 7
3 2 0];
l=[2 2 2 2 2 2 2 1];
z=zeros(depot,1);
for i=1:length(l)
z(v(i,1))=1;
x1(1)=demand(v(i,1)+customer,1);
y1(1)=demand(v(i,1)+customer,2);
k=2;
while k<=l(i)+1
x1(k)=demand(v(i,k),1);
y1(k)=demand(v(i,k),2);
k=k+1;
end
x1(l(i)+2)=demand(v(i,1)+customer,1);
y1(l(i)+2)=demand(v(i,1)+customer,2);
line(x1,y1);
clear x1;
clear y1;
end
for j=1:depot
if z(j)==1
hold on
plot(demand(j+customer,1),demand(j+customer,2),'p');
else
hold on
plot(demand(j+customer,1),demand(j+customer,2),'s');
end
end
for i=1:customer
hold on
plot(demand(i,1),demand(i,2),'*');
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?