Multi-target salp algorithm MATLAB actual combat (with source code)

Today I will share with you the multi-objective salp algorithm, mainly starting from the algorithm principle and code practice. Those who need to understand theories related to intelligent algorithms, machine learning, deep learning and signal processing can private message in the background. The content shared in the next issue is what you want to know.

1. Algorithm principle

The SSA algorithm shared in the previous article can drive salps closer to the food source and update it during the iterative process. However, this algorithm cannot solve the multi-objective problem mainly for the following two reasons:

1. SSA only stores one solution as the best solution, so it cannot store multiple solutions as the best solution to a multi-objective problem.

2. SSA updates the food source with the optimal solution obtained so far in each iteration, but there is no single optimal solution for multi-objective problems.

The Multi-objective Salp Swarm Algorithm (SSA) is proposed on the basis of the SSA algorithm for multi-objective problems.

For the principle of the SSA algorithm, you can refer to the previous article: Salp group algorithm MATLAB actual combat

For some related explanations about multi-objective problems, please refer to my previous article: Multi-objective particle swarm algorithm MATLAB combat

The first problem is solved by equipping the SSA algorithm with a library of food sources. This repository maintains the optimal solutions obtained so far during the optimization process, much like an archive in multi-objective particle swarm optimization (MOPSO) [78]. The repository has a maximum size to store a finite number of optimal solutions. During optimization, each salp is compared to all repository original proposals using the Pareto dominance operator. If a salp dominates the repository, they must be swapped (put the salp in the repository, the original plan out). If a salp is superior to a set of solutions in the repository, then the set of solutions should be removed from the repository altogether, and the salp should be added to the repository. If at least one of the original solutions in the repository is better than the salp, then the salp should be discarded and not added to the repository.

If the salp is mutually exclusive compared to all repository residents, then the salp is the optimal solution and must be added to the repository.

These rules ensure that the repository always obtains the optimal solution obtained by the algorithm so far. However, there is a special case, that is, the repository is full, and the salp is not dominant compared with the original solution of the repository. At this time, the salp should have been added to the repository, but the repository is full. Of course, the easiest way is to randomly delete one of the solutions in the archive and replace it with this salp.

A more sensible approach would be to remove a similar non-dominated solution in the repository: the best candidate for removal from the archive is in a densely populated region. This approach improves the distribution of proposals in the repository during iteration.

In order to find a non-dominated solution with a population in the neighborhood, it is necessary to calculate the number of solutions with a certain maximum distance in the neighborhood. The definition of this distance is:

Max and min are two vectors storing the maximum and minimum values ​​of each objective function, respectively. A repository with one solution in each segment is the best case. After assigning a level to each repository residency based on the number of adjacent solutions, a roulette wheel is used to select one for deletion. The higher the number of adjacent solutions to a solution (the higher the number of levels), the more likely it is to be removed from the repository. Figure 1 shows an example of this repository update mechanism. Note that neighborhoods should be defined for all solutions, but only 4 non-dominated solutions are studied in this graph.

Figure 1 Update mechanism when the repository is full

As shown in the figure, after introducing the update mechanism of the repository, the second problem of using SSA to solve multi-objective problems is the selection of food sources, since there is more than one optimal solution in the multi-objective search space. Likewise, food sources can be randomly selected from the repository. However, a more appropriate approach is to choose the least crowded region from a set of optimal solutions . This can be done using the same sorting process and roulette wheel selection used in the repository maintenance operator. The main difference is the probability of choosing the optimal solution. In repository maintenance deletion, solutions with higher rank (neighborhood crowding) are more likely to be selected. In contrast, for the optimal solution in the repository, the smaller the population (lower rank number), the more likely it is to be selected as a food source. (In this way, more unexplored areas can be developed and the global search ability can be strengthened. If you keep searching dense areas, it is easy to fall into the local optimum, and choosing sparse areas as food can reduce the possibility of falling into the local optimum.) As shown in Figure 2 , the optimal solution with no adjacent solutions in the middle is selected as the food source with the highest probability.

Figure 2 The white point in the red box has the highest probability of being selected as a food source

The pseudocode of the MSSA algorithm is shown in Figure 3.

Figure 3 Pseudocode of MSSA algorithm

2. Code combat

Use ZDT1 as the test function to carry out the simulation experiment

clc;
clear;
close all;

% Change these details with respect to your problem%%%%%%%%%%%%%%
ObjectiveFunction=@ZDT1;
dim=5;
lb=0;
ub=1;
obj_no=2;

if size(ub,2)==1
    ub=ones(1,dim)*ub;
    lb=ones(1,dim)*lb;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

max_iter=100;
N=200;
ArchiveMaxSize=100;

Archive_X=zeros(100,dim);
Archive_F=ones(100,obj_no)*inf;

Archive_member_no=0;

r=(ub-lb)/2;
V_max=(ub(1)-lb(1))/10;

Food_fitness=inf*ones(1,obj_no);
Food_position=zeros(dim,1);

Salps_X=initialization(N,dim,ub,lb);
fitness=zeros(N,2);

V=initialization(N,dim,ub,lb);
iter=0;

position_history=zeros(N,max_iter,dim);

for iter=1:max_iter
    
    c1 = 2*exp(-(4*iter/max_iter)^2); % Eq. (3.2) in the paper
    
    for i=1:N %Calculate all the objective values first
        Salps_fitness(i,:)=ObjectiveFunction(Salps_X(:,i)');
        if dominates(Salps_fitness(i,:),Food_fitness)
            Food_fitness=Salps_fitness(i,:);
            Food_position=Salps_X(:,i);
        end
    end
    
    [Archive_X, Archive_F, Archive_member_no]=UpdateArchive(Archive_X, Archive_F, Salps_X, Salps_fitness, Archive_member_no);
    
    if Archive_member_no>ArchiveMaxSize
        Archive_mem_ranks=RankingProcess(Archive_F, ArchiveMaxSize, obj_no);
        [Archive_X, Archive_F, Archive_mem_ranks, Archive_member_no]=HandleFullArchive(Archive_X, Archive_F, Archive_member_no, Archive_mem_ranks, ArchiveMaxSize);
    else
        Archive_mem_ranks=RankingProcess(Archive_F, ArchiveMaxSize, obj_no);
    end
    
    Archive_mem_ranks=RankingProcess(Archive_F, ArchiveMaxSize, obj_no);
    % Archive_mem_ranks
    % Chose the archive member in the least population area as food`
    % to improve coverage
    index=RouletteWheelSelection(1./Archive_mem_ranks);
    if index==-1
        index=1;
    end
    Food_fitness=Archive_F(index,:);
    Food_position=Archive_X(index,:)';
    
    for i=1:N
        
        index=0;
        neighbours_no=0;
        
        if i<=N/2
            for j=1:1:dim
                c2=rand();
                c3=rand();
                %%%%%%%%%%%%% % Eq. (3.1) in the paper %%%%%%%%%%%%%%
                if c3<0.5
                    Salps_X(j,i)=Food_position(j)+c1*((ub(j)-lb(j))*c2+lb(j));
                else
                    Salps_X(j,i)=Food_position(j)-c1*((ub(j)-lb(j))*c2+lb(j));
                end
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            end
        elseif i>N/2 && i<N+1
            
            point1=Salps_X(:,i-1);
            point2=Salps_X(:,i);
            
            Salps_X(:,i)=(point2+point1)/(2); % Eq. (3.4) in the paper
        end
        
        Flag4ub=Salps_X(:,i)>ub';
        Flag4lb=Salps_X(:,i)<lb';
        Salps_X(:,i)=(Salps_X(:,i).*(~(Flag4ub+Flag4lb)))+ub'.*Flag4ub+lb'.*Flag4lb;
        
    end
    
    display(['At the iteration ', num2str(iter), ' there are ', num2str(Archive_member_no), ' non-dominated solutions in the archive']);
    
end

figure

Draw_ZDT1();

hold on

plot(Archive_F(:,1),Archive_F(:,2),'ro','MarkerSize',8,'markerfacecolor','k');

legend('True PF','Obtained PF');
title('MSSA');

set(gcf, 'pos', [403   466   230   200])

 

 Full code:

Guess you like

Origin blog.csdn.net/qq_45013535/article/details/131359739