【优化求解】基于病毒免疫算法(CHIO)求解最优目标matlab源码

1 简介

In this paper, a new nature-inspired human-based optimization algorithm is proposed which called Coronavirus Herd Immunity Optimizer (CHIO). The inspiration of CHIO is originated from the herd immunity concept as a way to tackle coronavirus pandemic (COVID-19). The speed of spreading coronavirus infection depends on how the infected individuals directly contact with other society members. In order to protect other members of society from the disease social distancing is suggested by health experts. Herd immunity is a state the population reach when most of the population is immune which results in the prevention of disease transmission. These concepts are modeled in terms of optimization concepts. CHIO mimics the herd immunity strategy as well as the social distancing concepts. Three types of individual cases are utilized for herd immunity: susceptible, infected, and immuned. This is to determine how the newly generated solution updates its genes with social distancing strategies. CHIO is evaluated using 23 well-known benchmark functions. Initially, the sensitivity of CHIO to its parameters is studied. Thereafter, the comparative evaluation against seven state-of-the-art methods is conducted. The comparative analysis verifies that CHIO is able to yield very competitive results compared to those obtained by other well-established methods. In conclusion, CHIO is a very powerful optimization algorithm that can be used to tackle many optimization problems across a wide variety of optimization domains.

【优化求解】基于病毒免疫算法(CHIO)求解最优目标matlab源码_第1张图片

2 部分代码

%=======================================================================
%           Coronavirus herd immunity optimizer (CHIO)

% All rights reserved.       
%=======================================================================


clear all
close all
clc

PopSize=30; %/* The number of Solutions*/

MaxAge = 100;

C0 = 1; % number of solutions have corona virus

Max_iter=100000; %/*The number of cycles for foraging {a stopping criteria}*/

SpreadingRate = 0.05;   % Spreading rate parameter

runs = 1;%/*Algorithm can be run many times in order to see its robustness*/

ObjVal = zeros(1,PopSize);

Age = zeros(1,PopSize);

BestResults = zeros(runs,1); % saving the best solution at each run

for funNum=7:7  % fun#1 to fun#23
   if(funNum==1)
       Function_name='F1';
   elseif(funNum==2)
       Function_name='F2';
   elseif(funNum==3)
       Function_name='F3';
   elseif(funNum==4)
       Function_name='F4';
   elseif(funNum==5)
       Function_name='F5';
   elseif(funNum==6)
       Function_name='F6';
   elseif(funNum==7)
       Function_name='F7';
   elseif(funNum==8)
       Function_name='F8';
   elseif(funNum==9)
       Function_name='F9';
   elseif(funNum==10)
       Function_name='F10';
   elseif(funNum==11)
       Function_name='F11';
   elseif(funNum==12)
       Function_name='F12';
   elseif(funNum==13)
       Function_name='F13';
   elseif(funNum==14)
       Function_name='F14';
   elseif(funNum==15)
       Function_name='F15';
   elseif(funNum==16)
       Function_name='F16';
   elseif(funNum==17)
       Function_name='F17';
   elseif(funNum==18)
       Function_name='F18';
   elseif(funNum==19)
       Function_name='F19';
   elseif(funNum==20)
       Function_name='F20';
   elseif(funNum==21)
       Function_name='F21';
   elseif(funNum==22)
       Function_name='F22';
   elseif(funNum==23)
       Function_name='F23';
   end

   % Load details of the selected benchmark function
  [lb,ub,dim,fobj]=Get_Functions_details(Function_name);

   for run = 1:runs
       % Initializing arrays
       swarm=zeros(PopSize,dim);
       
       % Initialize the population/solutions
       swarm=initialization(PopSize,dim,ub,lb);

       for i=1:PopSize,
         ObjVal(i)=fobj(swarm(i,:));
       end
       
       Fitness=calculateFitness(ObjVal);
       
       
       %% update the status of the swarms (normal, confirmed) 
       %%the minmum C0 Immune rate will take 1 status which means 
       %%infected by corona 

       Status=zeros(1,PopSize);
       
       for i=1:C0,
           Status(fix(rand*(PopSize))+1)=1;  
       end
       
     %===================== loop ===================================
     tic
     
     itr=1;   % Loop counter

     while itr0)
                 Status(i) = 1;
                 Age(i)=1;
             end
             
             % change the solution from confirmed to recovered
             if ((Fitness(i) >= mean(Fitness))&& Status(i)==1)
                 Status(i) = 2; 
                 Age(i)=0;
             end
             
             % killed the current soluion and regenerated from scratch
             if(Age(i)>=MaxAge)
                 NewSolConst = initialization(1,dim,ub,lb);
                 swarm(i,:) = NewSolConst(:);
                 Status(i) = 0;
             end
         end
               
         if(mod(itr,100)==0)
            display(['Fun#',num2str(funNum),' Run#', num2str(run), ', Itr ', num2str(itr), ' Results ', num2str(min(ObjVal))]);
      y(itr)=min(ObjVal);
         end

         itr=itr+1;    
     end
     
     toc;
   
     % Save the best results at each iteration
     BestResults(run)=min(ObjVal);

   end % run
 
   fprintf(1, '\n\n Done \n\n'); 
 
end
figure(1)
plot(y)
xlabel('迭代次数')
ylabel('适应度值')

3 仿真结果

【优化求解】基于病毒免疫算法(CHIO)求解最优目标matlab源码_第2张图片

4 参考文献

[1] Al-Betar, M. A. , et al. "Coronavirus herd immunity optimizer (CHIO)." (2020).

 

你可能感兴趣的:(优化求解,1024程序员节)