Two whale optimization algorithms (whale optimization algorithm, WOA) and simulation experiments - with code

Table of contents

Summary:

algorithm design:

The overall flowchart of WOA is as follows:

Enhanced WOA (E-WOA)

Simulation running effect:

Complete program:


Summary:

Whale optimization algorithm (Whale optimization algorithm, WOA) is a new swarm intelligence optimization algorithm proposed by Mirjalili of Griffith University in Australia in 2016. Its advantages are simple operation, few parameters to adjust and jumping out of local optimum. strong ability.

WOA simulates the hunting behavior of humpback whales in the ocean to design algorithms. This attack is accomplished by humpback whales forming unique bubbles along a spiral path as they surround their prey, as shown in Figure 2. Similar to other meta-heuristic algorithms, WOA's search process starts by initializing a random solution set. WOA has three phases: searching for prey, encircling the target, and spiral bubble net predation strategy. The performance of the algorithm depends on the balance between the global exploration phase and the local exploitation phase. In WOA, the dynamic balance between the exploration and development process is realized by using these three strategies.

In this paper, two different WOA algorithms are implemented, and the effectiveness of the intelligent algorithm in solving optimization problems is verified through simulation experiments. The key lines of the program are all annotated. The three WOA algorithms implemented are:

  1. Original WOA
  2. Improved WOA

algorithm design:

Humpback whales are highly intelligent and emotional animals that can judge, communicate and even learn like humans during hunting. WOA refers to the group hunting method of whales, and searches for the optimal solution by encircling the prey, preying on the bubble net and searching for the prey. Its algorithm design mainly includes three steps: (1) Surrounding the prey; (2) Foaming net attack; (3) Searching for prey. The specific method is as follows:

The overall flowchart of WOA is as follows:

Convergence_curve=zeros(1,Max_iter);
t=0;% Loop counter
% Main loop
while t<Max_iter
    for i=1:size(Positions,1)
        % Return back the search agents that go beyond the boundaries of the search space
        Flag4ub=Positions(i,:)>ub;
        Flag4lb=Positions(i,:)<lb;
        Positions(i,:)=(Positions(i,:).*(~(Flag4ub+Flag4lb)))+ub.*Flag4ub+lb.*Flag4lb;
        % Calculate objective function for each search agent
        fitness=fobj(Positions(i,:));
        % Update the leader
        if fitness<Leader_score % Change this to > for maximization problem
            Leader_score=fitness; % Update alpha
            Leader_pos=Positions(i,:);
        end
    end
    a=2-t*((2)/Max_iter); % a decreases linearly fron 2 to 0 in Eq. (2.3)
    % a2 linearly dicreases from -1 to -2 to calculate t in Eq. (3.12)
    a2=-1+t*((-1)/Max_iter);
    % Update the Position of search agents 
    for i=1:size(Positions,1)
        r1=rand(); % r1 is a random number in [0,1]
        r2=rand(); % r2 is a random number in [0,1]
        A=2*a*r1-a;  % Eq. (2.3) in the paper
        C=2*r2;      % Eq. (2.4) in the paper
        b=1;               %  parameters in Eq. (2.5)
        l=(a2-1)*rand+1;   %  parameters in Eq. (2.5)
        p = rand();        % p in Eq. (2.6)
        for j=1:size(Positions,2)
            if p<0.5   
                if abs(A)>=1
                    rand_leader_index = floor(SearchAgents_no*rand()+1);
                    X_rand = Positions(rand_leader_index, :);
                    D_X_rand=abs(C*X_rand(j)-Positions(i,j)); % Eq. (2.7)
                    Positions(i,j)=X_rand(j)-A*D_X_rand;      % Eq. (2.8)   
                elseif abs(A)<1
                    D_Leader=abs(C*Leader_pos(j)-Positions(i,j)); % Eq. (2.1)
                    Positions(i,j)=Leader_pos(j)-A*D_Leader;      % Eq. (2.2)
                end 
            elseif p>=0.5
                distance2Leader=abs(Leader_pos(j)-Positions(i,j));
                % Eq. (2.5)
                Positions(i,j)=distance2Leader*exp(b.*l).*cos(l.*2*pi)+Leader_pos(j); 
            end 
        end
    end
    t=t+1;
    Convergence_curve(t)=Leader_score;
    [t Leader_score]

Enhanced WOA (E-WOA)

The original WOA is a prominent problem solver widely used to solve NP-hard problems such as feature selection. However, it and most of its variants suffer from low population diversity and poor search strategies. To alleviate these core shortcomings of WOA, especially to deal with the feature selection problem, it is highly desirable to introduce effective strategies. Therefore, this paper is dedicated to proposing an enhanced whale optimization algorithm E-WOA based on pooling mechanism and 2019 effective search strategies, namely migration, priority selection and enrichment to encircle prey . The performance of E-WOA is evaluated and compared with well-known WOA variants to solve global optimization problems . The obtained results demonstrate that E-WOA outperforms the variants of WOA.

The improved flow chart is as follows:

Simulation running effect:

Complete program:

Guess you like

Origin blog.csdn.net/widhdbjf/article/details/130800521