Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Ant Colony algorithm Needs explaination (has no refernece)

1 Ansicht (letzte 30 Tage)
Ahmed Hakim
Ahmed Hakim am 11 Mär. 2013
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Hello,
I was searching the google about Ant Colony Optimization Matlab Code and I found this nice code.
I was unlucky to find it in chinese language, It was my first problem. I tried to translate it as I can.
Now I am working to understand its concept but I have some problems, if anyone here could help me about ant colony optimization I will be grateful.
I will paste the code here (in its language) and then I will type my questions:
____________________________________________________________________________
function [BESTX,BESTY,ALLX,ALLY]=Ant(K,N,Rho,Q,Lambda,LB,UB,Num,Den,Delay,ts,StepNum,SigType,PIDLB,PIDUB)
%%?????????????????PID?????
%%??????
% K ????
% N ????
% Rho ??????????0?1???????0.7?0.95
% Q ??????????0?????1??
% Lambda ?????????0?1???????0.1?0.5
% LB ????????M×1???
% UB ????????M×1???
% Num ????????????????
% Den ????????????????
% Delay ????
% ts ??????
% StepNum ?????
% SigType ?????1??????2??????3??????
% PIDLB PID???????????
% PIDUB PID???????????
%%??????
% BESTX K×1???????????M×1?????????????
% BESTY K×1???????????????????
% ALLX K×1???????????M×N?????????????
% ALLY K×N????????????????
%%???????
M=length(LB);%???????
%???????
X=zeros(M,N);
for i=1:M
x=unifrnd(LB(i),UB(i),1,N);%%X?3*10????????????????10?????
X(i,:)=x;
end
%???????
ALLX=cell(K,1);%???????????M×N???????????
ALLY=zeros(K,N);%K×N?????????????
BESTX=cell(K,1);%???????????M×1?????????????
BESTY=zeros(K,1);%K×1???????????????????
k=1;%????????
Tau=ones(1,N);%??????
Y=zeros(1,N);%??????
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%?????
NN=5;
Rho_min=0.1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%????????
while k<=K
YY=zeros(1,N);
for n=1:N
x=X(:,n);
[J,u,yout,error]=OBJ(x(1),x(2),x(3),Num,Den,Delay,ts,StepNum,SigType,PIDLB,PIDUB);
YY(n)=J;
end
maxYY=max(YY);
temppos=find(YY==maxYY);
POS=temppos(1);
%??????
for n=1:N
if n~=POS
x=X(:,n);
[J,u,yout,error]=OBJ(x(1),x(2),x(3),Num,Den,Delay,ts,StepNum,SigType,PIDLB,PIDUB);
Fx=J;
mx=GaussMutation(x,LB,UB);
[J,u,yout,error]=OBJ(mx(1),mx(2),mx(3),Num,Den,Delay,ts,StepNum,SigType,PIDLB,PIDUB);
Fmx=J;
if Fmx<Fx
X(:,n)=mx;
Y(n)=Fmx;
elseif rand>1-(1/(sqrt(k)))%%????????????????????????????
X(:,n)=mx;
Y(n)=Fmx;
else
X(:,n)=x;
Y(n)=Fx;
end
end
end
for n=1:N
if n~=POS
x=X(:,n);
[J,u,yout,error]=OBJ(x(1),x(2),x(3),Num,Den,Delay,ts,StepNum,SigType,PIDLB,PIDUB);
Fx=J;
mx=GaussMutation(x,LB,UB);
[J,u,yout,error]=OBJ(mx(1),mx(2),mx(3),Num,Den,Delay,ts,StepNum,SigType,PIDLB,PIDUB);
Fmx=J;
if Fmx<Fx
X(:,n)=mx;
Y(n)=Fmx;
elseif rand>1-(1/(sqrt(k)))%%???????????????????????????????
X(:,n)=mx;
Y(n)=Fmx;
else
X(:,n)=x;
Y(n)=Fx;
end
end
end
%???????????
for n=1:N
if n~=POS
x=X(:,n);
r=(K+k)/(K+K);
p=randperm(N);%%?1?N??????
t=ceil(r*N);%?????????????r*N?????
pos=p(1:t);%%?p??t???????
TempTau=Tau(pos);
maxTempTau=max(TempTau);
pos2=find(TempTau==maxTempTau);
pos3=pos(pos2(1));
x2=X(:,pos3(1));%%%?????????????????
x3=(1-Lambda)*x+Lambda*x2;%%
[J,u,yout,error]=OBJ(x(1),x(2),x(3),Num,Den,Delay,ts,StepNum,SigType,PIDLB,PIDUB);
Fx=J;
[J,u,yout,error]=OBJ(x(1),x(2),x(3),Num,Den,Delay,ts,StepNum,SigType,PIDLB,PIDUB);%%%????????????x(1),x(2),x(3)??x3(1),x3(2),x3(3)
Fx3=J;
if Fx3<Fx
X(:,n)=x3;
Y(n)=Fx3;
elseif rand>1-(1/(sqrt(k)))
X(:,n)=x3;
Y(n)=Fx3;
else
X(:,n)=x;
Y(n)=Fx;
end
end
end
%????????
Tau=Tau*(1-Rho);
maxY=max(Y);
minY=min(Y);
DeltaTau=(maxY-Y)/(maxY-minY);
Tau=Tau+Q*DeltaTau;
ALLX{k}=X;
ALLY(k,:)=Y;
minY=min(Y);
pos4=find(Y==minY);
BESTX{k}=X(:,pos4(1));
BESTY(k)=minY;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%??????????
if k>NN
if BESTY(k)>=BESTY(k-NN)
if 0.95*Rho>=Rho_min
Rho=0.95*Rho
else
Rho=Rho_min;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp(k);
k=k+1;
end
_________________________________________________________________________
I concluded from this code that it is an improved Ant colony algorith that uses Mutation (guass mutation) to be having the genetics characteristics.
in the following portion of code: I can not define how the ant can find its next path pheromone (largest) where is the equation that is known as random probalistic used always ???
_______________________________________________________________________
%???????????
for n=1:N
if n~=POS
x=X(:,n);
r=(K+k)/(K+K);
p=randperm(N);%%?1?N??????
t=ceil(r*N);%?????????????r*N?????
pos=p(1:t);%%?p??t???????
TempTau=Tau(pos);
maxTempTau=max(TempTau);
pos2=find(TempTau==maxTempTau);
pos3=pos(pos2(1));
x2=X(:,pos3(1));%%%?????????????????
x3=(1-Lambda)*x+Lambda*x2;%%
________________________________________________________________________
what is the use of Lamda ???
what kind of equation you use to update the DeltaTau in the following
_______________________________________________________________________
%????????
Tau=Tau*(1-Rho);
maxY=max(Y);
minY=min(Y);
DeltaTau=(maxY-Y)/(maxY-minY);
Tau=Tau+Q*DeltaTau;
ALLX{k}=X;
ALLY(k,:)=Y;
minY=min(Y);
pos4=find(Y==minY);
BESTX{k}=X(:,pos4(1));
BESTY(k)=minY;
_________________________________________________________________
I hope to find a paper in english having this algorithm or if anyone has understood it and has a refernce equation , please help me
Thanks in advance

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by