The latest intelligent optimization algorithm in 2023 - Energy valley optimizer (EVO), with MATLAB code and literature

Energy Valley Optimizer (EVO) is a new meta-heuristic algorithm whose algorithm is inspired by advanced physical principles about stability and decay modes of different particles. In the literature, the authors compare with the state-of-the-art algorithms in the CEC function and show that the algorithm is indeed robust. Please refer to the literature for the algorithm principle.

[1] Azizi M ,  Aickelin U ,  Khorshidi H A , et al. Energy valley optimizer: a novel metaheuristic algorithm for global and engineering optimization[J]. Scientific Reports.

Comparison results of evo algorithm and other algorithms:

 For more comparison results and data, please refer to this document. The document and the author of the code are packaged together. Please check it out.

Go directly to the result map:

Algorithm core code:

function [Best_score,Best_Pos,Conv_History]=EVO(nParticles,MaxFes,lb,ub,VarNumber,fobj)

%% Problem Information
CostFunction = fobj;          % @ Cost Function
VarMin = lb *ones(1,VarNumber);        % Lower bound of variable;
VarMax = ub *ones(1,VarNumber);         % Upper bound of variable;

%% Counters
Iter=0;   % Iterations
FEs=0;    % Function Evaluations

%% Initialization
Particles=[]; NELs=[];
for i=1:nParticles
    Particles(i,:)=unifrnd(VarMin,VarMax,[1 VarNumber]);
    NELs(i,1)=CostFunction(Particles(i,:));
    FEs=FEs+1;
end

% Sort Particles
[NELs, SortOrder]=sort(NELs);
Particles=Particles(SortOrder,:);
BS=Particles(1,:); 
BS_NEL=NELs(1);
WS_NEL=NELs(end);

%% Main Loop
while FEs<MaxFes
    Iter=Iter+1;
    NewParticles=[];
    NewNELs=[];   
   for i=1:nParticles
       Dist=[];
       for j=1:nParticles
           Dist(j,1)=distance(Particles(i,:), Particles(j,:));
       end
       [ ~, a]=sort(Dist);
       CnPtIndex=randi(nParticles);
       if CnPtIndex<3
           CnPtIndex=CnPtIndex+2;
       end
       CnPtA=Particles(a(2:CnPtIndex),:);
       CnPtB=NELs(a(2:CnPtIndex),:);
       X_NG=mean(CnPtA);
       X_CP=mean(Particles);
       EB=mean(NELs);            
       SL=(NELs(i)-BS_NEL)/(WS_NEL-BS_NEL); SB=rand;
       if NELs(i)>EB   
           if SB>SL         
               AlphaIndex1=randi(VarNumber);
               AlphaIndex2=randi([1 VarNumber], AlphaIndex1 , 1);
               NewParticle(1,:)=Particles(i,:);
               NewParticle(1,AlphaIndex2)=BS(AlphaIndex2);               
               GamaIndex1=randi(VarNumber);
               GamaIndex2=randi([1 VarNumber], GamaIndex1 , 1);
               NewParticle(2,:)=Particles(i,:);
               NewParticle(2,GamaIndex2)=X_NG(GamaIndex2);           
               NewParticle = max(NewParticle,VarMin);
               NewParticle = min(NewParticle,VarMax);  
               NewNEL(1,1)=CostFunction(NewParticle(1,:));
               NewNEL(2,1)=CostFunction(NewParticle(2,:));               
               FEs=FEs+2;    
           else               
               Ir=unifrnd(0,1,1,2); Jr=unifrnd(0,1,1,VarNumber);
               NewParticle(1,:)=Particles(i,:)+(Jr.*(Ir(1)*BS-Ir(2)*X_CP)/SL);
               Ir=unifrnd(0,1,1,2); Jr=unifrnd(0,1,1,VarNumber);
               NewParticle(2,:)=Particles(i,:)+(Jr.*(Ir(1)*BS-Ir(2)*X_NG));  
               NewParticle = max(NewParticle,VarMin);
               NewParticle = min(NewParticle,VarMax);
               NewNEL(1,1)=CostFunction(NewParticle(1,:));
               NewNEL(2,1)=CostFunction(NewParticle(2,:)); 
               FEs=FEs+2;   
           end    
       else 
           NewParticle(1,:)=Particles(i,:)+randn*SL*unifrnd(VarMin,VarMax,[1 VarNumber]);         
           NewParticle = max(NewParticle,VarMin);
           NewParticle = min(NewParticle,VarMax);
           NewNEL(1,1)=CostFunction(NewParticle(1,:));   
           FEs=FEs+1;
       end
   NewParticles=[NewParticles ; NewParticle];    
   NewNELs=[NewNELs ; NewNEL];
   end
   NewParticles=[NewParticles ; Particles];    
   NewNELs=[NewNELs ; NELs]; 
   
   % Sort Particles
   [NewNELs, SortOrder]=sort(NewNELs);
   NewParticles=NewParticles(SortOrder,:);
   BS=NewParticles(1,:); 
   BS_NEL=NewNELs(1); 
   WS_NEL=NewNELs(end);
   Particles=NewParticles(1:nParticles,:);
   NELs=NewNELs(1:nParticles,:);

   % Store Best Cost Ever Found
   BestCosts(Iter)=BS_NEL;
   
   % Show Iteration Information
   disp(['Iteration ' num2str(Iter) ': Best Cost = ' num2str(BestCosts(Iter))]);
end

Eval_Number=FEs;
Conv_History=BestCosts;
Best_Pos=BS;
Best_score=BestCosts(end);
end
%% Calculate the Euclidean Distance
function o = distance(a,b)
for i=1:size(a,1)
    o(1,i)=sqrt((a(i)-b(i))^2);
end
end

 Reply to the keyword in the small card below: 2023 , and get the matlab code of the collection of intelligent optimization algorithms in 2023 for free.

Follow-up will continue to release other latest optimization algorithms in 2023, so stay tuned.

Guess you like

Origin blog.csdn.net/woaipythonmeme/article/details/131289722