Code covered by the BSD License  

Highlights from
Cross Entropy TSP Solver

image thumbnail
from Cross Entropy TSP Solver by Sebastien PARIS
Solve TSP problem with a CE method.

demo_TSP_CE.m
clear

clc

close all

n                        = 40;             % number of city

X1                       = 10;             % Start city index

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

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

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

option.beta              = 0.9;            % Determine the fraction of the Nrho*N sample who will be keep in each iteration

option.d                 = 30;              % 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;

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

L                        = distmat(option.V);  

[X_opt , S_opt , Pt , T] = TSP_CE(L , X1 , option);


figure(1)

clf

p1          = plot(option.V(X_opt , 1) , option.V(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 , T , S_opt) , 'fontsize' , 12 , 'fontname' , 'times');



figure(2)

bar3(Pt);

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