Code covered by the BSD License  

Highlights from
TSP solver by CE & BK algorithms

image thumbnail
from TSP solver by CE & BK algorithms by Sebastien PARIS
Solve TSP problems with 2 stochastic solvers : CE & BK algorithms

demo_ce_tsp.m
clear, clc, close all

prob                     = {'random','st70', 'si175','pr76','pr107','pr124','pr136','pr144','pr152','eil101','a280','rd100','gr120','gr202','dsj1000'};

num                      = 1; %9

if(num > 1)

    data                     = prob{num};

    load(data)

    n                        = size(C , 1);
    
    option.V                 = x;
    

else

    n                        = 50;             % number of city

    option.V                 = 10*rand(n , 2);

    C                        = distmat(option.V);

end

option.N                 = round(6*n*n);   % number of tours to generate by MCWR

option.rho               = 10*10e-3;        % threshold for selectionning the best rho*N paths

option.alpha             = 0.8;            % weight for updating Transition Matrix

option.beta              = 0.95;            % Determine the fraction of the Nrho*N "best of best" samples who will be keep in each iteration

option.gamma             = 0.00;            % P0;

option.d                 = 60;             % indicate how many iterations to wait until to declare the solution is reached

option.T_max             = 10000;           % Maximum number of iteration

option.epsilon           = 70*eps;

option.digit             = 5;

option.verbose           = 1;


tic,out                  = ce_tsp(C , option);,toc


figure(1)

clf

p1          = plot(option.V(out.X_opt , 1) , option.V(out.X_opt , 2) , 'r' , option.V(: , 1) , option.V( : , 2) ,  '+' , 'markersize' , 8 , 'linewidth' , 2);
        
text(option.V(: , 1) , option.V(: , 2) , num2str((1 : n)' , '%0.0f') , 'fontname' , 'times' , 'fontsize' , 12);

title(sprintf('\\bf{n = %d, N = %d, \\gamma_{%d} = %6.2f}' , n , option.N , length(out.St) , out.S_opt) , 'fontsize' , 12 , 'fontname' , 'times');



figure(2)

bar3(out.Pt_opt);

axis([0 , n+1 , 0 , n+1 , 0 , 1])

view([-50 50]);

title(['State transition probabilities matrix after convergence'] , 'fontsize' , 13 , 'fontname' , 'times');

Contact us at files@mathworks.com