CEC2021: Osprey optimization algorithm (OOA) solves CEC2021 (provide MATLAB code

1. Introduction to Osprey Optimization Algorithm

The Osprey optimization algorithm (OOA) was proposed by Mohammad Dehghani and Pavel Trojovský in 2023, which simulates the predation behavior of an osprey.
insert image description here

The osprey is the only medium-sized raptor belonging to the order Eagleformes, the family Osprey, and the genus Osprey. Male and female are similar. Body length 51-64 cm, weight 1000-1750 grams. The head is white, with dark brown longitudinal stripes on the top of the head, and the feathers on the occiput are slightly elongated in a lanceolate shape, forming a short crest. On the side of the head there is a broad black band running from the base of the forehead through the eyes to the nape of the neck where it blends with the blackness of the nape. The upper body is dark brown with a slight purple sheen. The underparts are white, the dark vertical stripes on the chest and flight feathers, and the alternate horizontal spots on the tail feathers are very eye-catching. The iris is light yellow or orange-yellow, the naked skin around the eyes is lead yellow-green, the mouth is black, the cere is lead blue, the feet and toes are yellow, and the claws are black.

Ospreys inhabit lakes, rivers, coasts or open areas, especially like to move in river valleys in mountain forests or water areas with trees. It is common to fly around rivers, lakes, marshes and seashores. When it sees bait in the water, it will go straight to the surface of the water and grab it with its feet. The toe has sharp claws, the bottom of the toe is full of thin spines, and the outer toe can turn from front to back, which are very suitable for fishing. On a sunny day, hover over the water, dive down after a fixed point, and then bring the caught fish to rocks, electric poles, trees and other places to enjoy. Nests often camp on rocky reefs on coasts or islands. It mainly feeds on fish, and sometimes preys on other small terrestrial animals such as frogs, lizards, and small birds. In addition to Antarctica and the Arctic, Asia, North America and other continents are distributed.

1.1 Osprey optimization algorithm principle

The Osprey optimization algorithm consists of two stages: the first stage is for the Osprey to identify the position of the fish and catch fish (global exploration), and the second stage is to bring the fish to a suitable location (local mining). The detailed design is as follows:

1.1.1 Population initialization

采用下式随机初始化鱼鹰种群:
X = [ X 1 ⋮ X i ⋮ X N ] N × m = [ x 1 , 1 ⋯ x 1 , j ⋯ x 1 , m ⋮ ⋱ ⋮ ⋱ ⋮ x i , 1 ⋯ x i , j ⋯ x i , m ⋮ ⋱ ⋮ ⋱ ⋮ x N , 1 ⋯ x N , j ⋯ x N , m ] N × m , x i , j = l b j + r i , j ⋅ ( u b j − l b j ) , i = 1 , 2 , … , N , j = 1 , 2 , … , m , \begin{array}{c} X=\left[\begin{array}{c} X_{1} \\ \vdots \\ X_{i} \\ \vdots \\ X_{N} \end{array}\right]_{N \times m}=\left[\begin{array}{ccccc} x_{1,1} & \cdots & x_{1, j} & \cdots & x_{1, m} \\ \vdots & \ddots & \vdots & \ddots & \vdots \\ x_{i, 1} & \cdots & x_{i, j} & \cdots & x_{i, m} \\ \vdots & \ddots & \vdots & \ddots & \vdots \\ x_{N, 1} & \cdots & x_{N, j} & \cdots & x_{N, m} \end{array}\right]_{N \times m}, \\ x_{i, j}=l b_{j}+r_{i, j} \cdot\left(u b_{j}-l b_{j}\right), i=1,2, \ldots, N, j=1,2, \ldots, m, \end{array} X= X1XiXN N×m= x1,1xi,1xN,1x1,jxi,jxN , jx1,mxi,mxN,m N×m,xi,j=lbj+ri,j(ubjlbj),i=1,2,,N,j=1,2,,m,
Among them, N is the number of ospreys, m is the dimension of the problem, and the fitness value is calculated according to the optimization problem after initializing the position:
F = [ F 1 ⋮ F i ⋮ FN ] N × 1 = [ F ( X 1 ) ⋮ F ( X i ) ⋮ F ( XN ) ] N × 1 F=\left[\begin{array}{c} F_{1} \\ \vdots \\ F_{i} \\ \vdots \\ F_{N} \end {array}\right]_{N \times 1}=\left[\begin{array}{c} F\left(X_{1}\right) \\ \vdots \\ F\left(X_{i} \right) \\ \vdots \\ F\left(X_{N}\right) \end{array}\right]_{N \times 1}F= F1FiFN N×1= F(X1)F(Xi)F(XN) N×1

1.1.2 Global Exploration (Phase 1: Location Identification and Fishing)

Ospreys are powerful hunters, able to detect the location of fish underwater due to their powerful eyesight. After locating the fish, they attack it and hunt the fish by diving underwater. The first phase of population renewal in OOA was modeled based on simulations of this natural behavior of ospreys. Modeling osprey attacks on fish results in significant shifts in the osprey's position in the search space, which increases the exploration power of OOA in identifying optimal regions and escaping local optima. In the OOA design, for each osprey, the positions of other ospreys with better objective function values ​​in the search space are considered as underwater fish. The position of each Osprey is specified using the following equation.
FP i = { X k ∣ k ∈ { 1 , 2 , … , N } ∧ F k < F i } ∪ { X best } \boldsymbol{FP _ { i }}=\left\{X_{k} \mid \boldsymbol{k} \in\{1,2, \ldots, N\} \wedge \boldsymbol{F}_{k}<\boldsymbol{F}_{i}\right\} \cup\left\{ \boldsymbol{X}_{\text {best }}\right\}FPi={ Xkk{ 1,2,,N}Fk<Fi}{ Xbest }
Among them,FP i FP _ { i }FPiis the location set of the i-th osprey, X best {X}_{\text {best }}Xbest Position for the best Osprey.
The Osprey randomly detects the location of one of the fish and attacks it. Based on the simulation of the movement of the osprey towards the fish, the new position of the corresponding osprey is calculated using the following equation. This new position, if its value of the objective function is better, replaces the previous position of the Osprey.
xi , j P 1 = xi , j + ri , j ⋅ ( SF i , j − I i , j ⋅ xi , j ) , xi , j P 1 = { xi , j P 1 , lbj ≤ xi , j P 1 ≤ ubj ; lbj , xi , j P 1 < lbj ; ubj , xi , j P 1 > ubj . X i = { X i P 1 , F i P 1 < F i ; X i , else , \begin{array} {l} x_{i, j}^{P 1}=x_{i, j}+r_{i, j} \cdot\left(S F_{i, j}-I_{i, j} \cdot x_ {i, j}\right), \\ x_{i, j}^{P 1}=\left\{\begin{array}{ll} x_{i, j}^{P 1}, & l b_ {j} \leq x_{i, j}^{P 1} \leq u b_{j} ; \\ l b_{j}, & x_{i, j}^{P 1}<l b_{j} ; \\ u b_{j}, & x_{i, j}^{P 1}>u b_{j} . \end{array}\right. \\ X_{i}=\left\{\begin{ array}{l} X_{i}^{P 1}, F_{i}^{P 1}<F_{i} ; \\ X_{i}, \text { else }, \end{array}\right .\\ \end{array}xi,jP1 _=xi,j+ri,j(SFi,jIi,jxi,j),xi,jP1 _= xi,jP1 _,lbj,ubj,lbjxi,jP1 _ubj;xi,jP1 _<lbj;xi,jP1 _>ubj.Xi={ XiP1 _,FiP1 _<Fi;Xi, else ,
Among them, xi , j P 1 x_{i, j}^{P 1}xi,jP1 _is the new position of the i-th osprey in the first stage, F i , j P 1 F_{i, j}^{P 1}Fi,jP1 _is its corresponding fitness value. SF i , j S F_{i, j}SFi,jIs a random number between [0,1], I i , j I_{i, j}Ii,jis a random number in the set {1,2}.

1.1.3 Local mining (second stage: bringing the fish to a suitable location)

After catching a fish, the osprey takes it to a suitable (safe for him) location and eats it there. The second phase of repopulation in OOA is based on simulation modeling of this natural behavior of ospreys. Modeling to bring the fish to a suitable location results in small changes in the osprey's position in the search space, leading to increased exploitation of OOA in local search and convergence to better solutions near the discovered solutions. In the design of OOA, in order to simulate this natural behavior of osprey, first, for each member of the population, use the following formula to calculate a new random position as the "suitable position for eating fish". Then, if the value of the objective function improves at this new location, the previous location of the corresponding osprey is replaced.
x i , j P 2 = x i , j + l b j + r ⋅ ( u b j − l b j ) t , i = 1 , 2 , … , N , j = 1 , 2 , … , m , t = 1 , 2 , … , T , x i , j P 2 = { x i , j P 2 , l b j ≤ x i , j P 2 ≤ u b j ; l b j , x i , j P 2 < l b j u b j , x i , j P 2 > u b j , X i = { X i P 2 , F i P 2 < F i ; X i ,  else  , \begin{array}{c} x_{i, j}^{P 2}=x_{i, j}+\frac{l b_{j}+r \cdot\left(u b_{j}-l b_{j}\right)}{t}, i=1,2, \ldots, N, j=1,2, \ldots, m, t=1,2, \ldots, T, \\ x_{i, j}^{P 2}=\left\{\begin{array}{l} x_{i, j}^{P 2}, l b_{j} \leq x_{i, j}^{P 2} \leq u b_{j} ; \\ l b_{j}, x_{i, j}^{P 2}<l b_{j} \\ u b_{j}, x_{i, j}^{P 2}>u b_{j}, \end{array}\right. \\ X_{i}=\left\{\begin{array}{l} X_{i}^{P 2}, F_{i}^{P 2}<F_{i} ; \\ X_{i}, \text { else }, \end{array}\right. \end{array} xi,jP2 _=xi,j+tlbj+r(ubjlbj),i=1,2,,N,j=1,2,,m,t=1,2,,T,xi,jP2 _= xi,jP2 _,lbjxi,jP2 _ubj;lbj,xi,jP2 _<lbjubj,xi,jP2 _>ubj,Xi={ XiP2 _,FiP2 _<Fi;Xi, else ,
Among them, xi , j P 2 x_{i, j}^{P 2}xi,jP2 _is the new position of the i-th osprey in the second stage, F i , j P 2 F_{i, j}^{P 2}Fi,jP2 _is its corresponding fitness value. rrr is a random number between [0,1],ttt andTTT are the current iteration number and the maximum iteration number respectively.

1.2 Algorithm description

insert image description here

1.3 Algorithm process

insert image description here

1.4 References

Dehghani Mohammad, Trojovský Pavel.Osprey optimization algorithm: A new bio-inspired metaheuristic algorithm for solving engineering optimization problems[J].Frontiers in Mechanical Engineering,2023,8.

2. CEC2021

CEC2021 has a total of 10 basic test functions, and the test dimensions include: 10D, 20D. CEC2021 test problems are extremely difficult to solve as the dimension increases. The basic function information is as follows:
insert image description here

Add operations such as rotation on the basis of the basic functions, and there are 8 combinations in total:
insert image description here

The theoretical optimal value of each function under each combination is as follows:
insert image description here

CEC2021 finally solves the following 5 combinations (the 3 groups marked in red are not used as test combinations)
insert image description here

3. Solution results

The complete code is added to the blogger WeChat at the bottom of the blog: djpcNLP123

The Osprey optimization algorithm OOA is applied to solve 10 test functions in CEC2021, and the dimensions that can be selected for each test function of each group of problems are: 10D and 20D. As the number of iterations increases, the solution of the algorithm is better. In this example, the test function selects Bias and Shift (110), its dimension is 20D, the population size is 100, and the maximum number of iterations is 50. The parameters can be adjusted according to your own needs.

close all
clear 
clc
SearchAgents_no=100; % 种群大小
Function_name=1; %测试函数1-10
Max_iteration=50; % 最大迭代次数
lb=-100;%变量下界
ub=100;%变量上界
dim=20;%维度 10/20
C = [0 0 0; 1 0 0;0 1 0; 0 0 1;
    1 1 0;1 0 1; 0 1 1;1 1 1; ];
[fMin,bestX,curve]=OOA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj);  %2 4 6 error
%Draw objective space
semilogy(curve,'Color','r','linewidth',2.5)
title('cec2021-F1(110)')
xlabel('Iteration');
ylabel('Best score obtained so far');
legend('OOA')
display(['The best solution obtained  is : ', num2str(bestX)]);
display(['The best optimal value of the objective funciton  is : ', num2str(fMin)]);

Some test results are as follows:

F1

insert image description here

F4

insert image description here

F8

insert image description here

4. Reference code

The complete code is added to the blogger WeChat at the bottom of the blog: djpcNLP123

Guess you like

Origin blog.csdn.net/weixin_46204734/article/details/129326898