A list,

Introduction of simulated annealing algorithm









3 parameters of simulated annealing algorithm

Simulated annealing is a kind of optimization algorithm, it can’t exist independently, needs to have a applications, of which temperature is simulated annealing to optimize the parameters, if it is applied to clustering analysis, so the clustering analysis has a certain or a few parameters are optimized, and the parameters, or parameter set is represented by the temperature. It could be some index, some correlation, some distance, etc.

Ii. Source code

Clear all close All CLC TIC %% Enter NIND=100; % Population size MAXGEN=200; % Genetic algebra GGAP=0.9; Generation gap Pc = %0.75; % cross probability Pm=0.1; % variation probabilityconst=20; % Customers X=[3.2.14.1;3.8.5.5;15.2.10.9;18.6.12.9;11.9.8.2;10.2.9.5;5.3.9.6;0.6.9.9;6.1.18.0;7.6.19.2
    16.0.15.7;15.3.15.2;1.6.14.7;9.0.9.2;5.4.13.3;7.8.10.0;18.6.7.8;14.5.4.3;15.0.18.7;9.8.5.0;1.4.6.9]; % Demand point position coordinates,1Carload_min =3; % Load limit for small cars demand=[0.8.0.6.0.4.1.4.0.8.0.6.1.9.1.3.1.8.1.5.0.4.1.6.1.1.1.6.1.0.0.8.1.4.1.2.0.4.1.4]; % service point demand D=Distanse(X); %% population initialization Chrom= Zeros (NIND,const);
for i=1:NIND
    Chrom(i,:)=randperm(const); [ObjV,route]=PathLength(D,Chrom); % Calculate route length and path preObjV=min(ObjV); % route_initial=routemake(route,1); % DrawPath(route_initial,X); % hold off % pause(0.0001); %% Output path and total distance of random solution disp('A random value in the initial population :')
OutputPath(route_initial);
disp(['Total cost:',num2str(ObjV(1))); disp('~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~') %% compute objective function %% optimization gen=0;
MinY=inf;
trace=zeros(MAXGEN,1);
h=waitbar(0.'Program is starting, please wait... ');
whileGen <MAXGEN %% calculate fitness [ObjV,route]=PathLength(D,Chrom); % Calculate the route length %line([gen- 1,gen],[preObjV,min(ObjV)]);
    %pause(0.0001) %preObjV=min(ObjV); % Fitness function FitnV=Fitness(ObjV); Choose SelCh % = the Select (Chrom, FitnV GGAP); % SelCh=Recombin(SelCh,Pc); Variation SelCh % = Mutate (SelCh, Pm); SelCh=Reverse(SelCh,D); % New population Chrom=Reins(Chrom,SelCh,ObjV); % Number of update iterations gen=gen+1; % save [minObjV,minInd]=min(ObjV); % Calculate the optimal route_new=routemake(route,minInd); % Final pathif minObjV<MinY
        MinY=minObjV;
        best_route=route_new;
        trace(gen,1)=MinY;
    else
        trace(gen,1)=trace(gen- 1.1);
    end
    str=['Normal operation of the program,'.'Iterated',num2str(gen),'time'];
    waitbar(gen/MAXGEN,h,str);
    pause(0.05); End %% plot(1:gen,trace);
title('Optimization process');
xlabel('Number of iterations');
ylabel('Optimal value'); Car1_num,car2_num]=car_type(best_route,demand,carload_min); Num_car=car1_num+car2_num; DrawPath(best_route,X); hold offCopy the code

3. Operation results





Fourth, note

Version: 2014 a