A list,
Any optimization problem can be converted into a function, so the intelligent algorithm is widely used, and the same biological immune algorithm (AIA) is a simulation Darwin evolution of a new intelligent algorithm, biological immune algorithm (AIA) based on antibody antigen of processing mechanism, biological systems antibody evolution, and ultimately eliminate the antigen, This process is the global optimization of biological immune algorithm (AIA). Considering the universality of function optimization problems, in recent years, many scholars using a new algorithm for different function test, such as the stability of the algorithm, guangdong-based, effectiveness, global and local optimization ability, so the optimization function problem (single objective and multi-objective function optimization problem) has become a research focus in the scientific research personnel. According to the possible solutions obtained from the test function, the intelligent algorithm is constantly improved, and the theoretical foundation is gradually deepened, making the emission itself more robust and able to be quickly used in engineering. Artificial immune system is attracting great attention of people. Based on the principle of immune system, various algorithms have been developed, such as genetic algorithm GA, differential evolution algorithm DE, bee colony algorithm ABC, fish swarm algorithm FSA, etc., which have been applied more and more widely in practical engineering problems and achieved more and more achievements.
Iii. Source code
% % % % % % % % % % % % % % % % % % % % % % % immune algorithm for solving TSP problem % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % initialization % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % clear all; % clear all variables close all; % qing figure CLC; C = [% CLS1304 2312;3639 1315;4177 2244;3712 1399;3488 1535;3326 1556; .3238 1229;4196 1044;4312 790;4386 570;3007 1970;2562 1756; .2788 1491;2381 1676;1332 695;3715 1678;3918 2179;4061 2370; .3780 2212;3676 2578;4029 2838;4263 2931;3429 1908;3507 2376; .3394 2643;3439 3201;2935 3240;3140 3550;2545 2357;2778 2826; .2370 2975]; %31N=size(C,1); %TSP problem size, that is, the number of cities D= Zeros (N); % matrix between any two cities distance % % % % % % % % % % % % % % % % % % % % % o matrix between any two cities distance % % % % % % % % % % % % % % % % % % % % %for i=1:N
for j=1:N
D(i,j)=((C(i,1)-C(j,1)) ^2+(C(i,2)-C(j,2)) ^2) ^0.5;
end
end
NP=200; % Number of immune individuals G=1000; % maximum immune algebra f= Zeros (N,NP); % for the storage populationfor i=1:NP f(:,i)=randperm(N); End len=zeros(NP,1); % Length of the storage pathfor i=1:NP len(i)=func3(D,f(:,i),N); End [Sortlen,Index]=sort(len); Sortf=f(:,Index); % population individual sequencing gen=0; % immune algebra Ncl=10; Clone number % % % % % % % % % % % % % % % % % % % % % % % % % % % % immune % % % % % % % % % % % % % % % % % % % % % % % % % % % % %while gen<G
for i=1:NP/2%%%%%%%%%%%% Select NP/ before the excitation2%%%%%%%%%%%%%%% a=Sortf(:, I); Ca=repmat(a,1,Ncl);
for j=1:Ncl
p1=floor(1+N*rand());
p2=floor(1+N*rand());
while p1==p2
p1=floor(1+N*rand());
p2=floor(1+N*rand());
end
tmp=Ca(p1,j);
Ca(p1,j)=Ca(p2,j);
Ca(p2,j)=tmp;
end
Ca(:,1)=Sortf(:,i); Keep the clone source individual % % % % % % % % % % % % % clone suppression, retain the highest affinity individual % % % % % % % % % % % % % %for j=1:Ncl
Calen(j)=func3(D,Ca(:,j),N);
end
[SortCalen,Index]=sort(Calen);
af(:,i)=SortCa(:,1);
alen(i)=SortCalen(1); End % % % % % % % % % % % % % % % % % % % % % % % % % % population refresh % % % % % % % % % % % % % % % % % % % % % % % % % %for i=1:NP/2blen(i)=func3(D,bf(:,i),N); Calculating path length end % % % % % % % % % % % % % % % % % % % % % immune population a merger with the new population % % % % % % % % % % % % % % % % % % % % % f = [af, bf]; len=[alen,blen]; [Sortlen,Index]=sort(len); Sortf=f(:,Index); gen=gen+1;
trace(gen)=Sortlen(1);
end
Copy the code
Third, the operation result
Fourth, note
Version: 2014 a