location_improveliu.asv

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

ASV
74
字号
function [x,l,tabu]=location_improve(x0,l0,tabu)

global customer;
global depot;
global demand;
global bestx;
global bestl;
global bestSC;

%内循环次数
inner=5;
Ts=10;
T=70;
r=0.9;
outer=1;
while T>Ts
               [x1,move,l1,tabu]=tabu_locationmove(x0,l0,tabu);
               SCx1=SC(x1,l1);
              x0=x1;
              l0=l1;
             %'SCx0'
              SCx0=SCx1;
              record=1;
              count=1;
     %for inner_count=1:inner
     while count<=inner
                 SCx0
             [x1,move,l1,tabu]=sa_locationmove(x0,l0,tabu); 
             SCx1=SC(x1,l1);
             'SCx1'
             SCx1
             delet=SCx1-SCx0;
             if delet<=0
                   'jieshou'
                    x0=x1;l0=l1;
                    SCx0=SCx1;
                    tabu=updatetabu(x1,tabu);%将这个解放到tabu中
                    solution(outer,count)=SCx0;
                    count=count+1
                    %把该接受的解记录到集合SET中
                     if SCx1<=bestSC
                         '3'
                          bestx=x1;
                          bestl=l1;
                          bestSC=SCx1;
                      end
              elseif (-delet/T)>rand
                     if record>1
                       record=1;
                     end
                     'jieshou'
                      x0=x1;
                      l0=l1;
                      SCx0=SCx1;
                      tabu=updatetabu(x1,tabu);%将这个解放到tabu中
                     solution(outer,count)=SCx0;
                     count=count+1; 
                 else 

                      
             end
            
    end  %接受解的个数达到要求
     count
  
              T=T*r;  
    
     end
     

   x=x0;
   l=l0;
  
      

⌨️ 快捷键说明

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