plotpicture2.m

来自「TSP问题,即旅行商问题,matlab环境下可以运行」· M 代码 · 共 51 行

M
51
字号
global demand;
global customer;
global depot;

v=[ 3    14     5
     3    10    12
     3     7     6
     1     8    15
     1    13     3
     1     4    11
     1     1     9
     1     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

z
for j=1:depot
  % if z(j)==1
       hold on
       plot(demand(j+customer,1),demand(j+customer,2),'s');
       %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 + -
显示快捷键?