Seagull Optimization Algorithm (SOA)


原论文:
[1]Gaurav Dhiman, Vijay Kumar. Seagull optimization algorithm: Theory and its applications for large-scale industrial engineering problems. Knowledge-Based Systems. 2019(165), 169-196.

1 Algorithm thinking

Drawing on Biological Behavior :
Migration and Aggression in Seagulls. Seagulls migrate according to the change of seasons. Seagulls avoid colliding with each other during migratory flight; seagulls attack prey in a spiral movement; in a group, seagulls move towards the best position.

2 Algorithm steps

  1. Initialization parameters;
  2. Initialize the population position;
  3. Calculate the fitness value and retain the global optimal position;
  4. Migration, global search:
    There are three main steps in the migration behavior of abstract seagulls. The first is to meet the collision avoidance conditions (this can ensure population diversity); the second is to calculate the direction of the best position; the third is to move to a new location according to this direction. Location. First, calculate the new position C s ( t ) C_s(t)
    that does not collide with adjacent seagullsCs(t)
    C s ( t ) = A × P s ( t ) A = f c − ( t × f c M a x i t e r a t i o n ) C_s(t)=A×P_s(t) \\ A = f_c-(t×\frac{f_c}{Max_{iteration}}) Cs(t)=A×Ps(t)A=fc(t×Maxiterationfc)
    among them,P s ( t ) P_s(t)Ps( t ) is the current position; t is the current iteration number; A is the movement behavior of the seagull in the search space;fc f_cfcIt is a function to control the changing frequency of A, linearly decreasing from 2 to 0; Maxiteration Max_{iteration}Maxiterationis the maximum number of iterations.
    Second, calculate the direction of the best position M s ( t ) M_s(t)Ms(t)
    M s ( t ) = B × ( P b e s t ( t ) − P s ( t ) ) B = 2 × A 2 × r M_s(t)=B×(P_{best}(t)-P_s(t)) \\ B=2×A^2×r Ms(t)=B×(Pbest(t)Ps(t))B=2×A2×r
    Among them,P best ( t ) P_{best}(t)Pbest( t ) is the current best position;P s ( t ) P_s(t)Ps( t ) is the current position; B is a random number that balances global and local search capabilities; r is a random number in [0,1].
    Third, move to a new positionD s ( t ) D_s(t)Ds(t)
    D s ( t ) = ∣ C s ( t ) + M s ( t ) ∣ D_s(t)=|C_s(t)+M_s(t)| Ds(t)=Cs(t)+Ms(t)
  5. Attacking prey, local search:
    seagulls perform spiral motion in the air when attacking prey, abstracted into three-dimensional space as:
    { x = rcos ( θ ) y = rsin ( θ ) z = r θ r = u × e θ v \left\ { \begin{aligned} & x=rcos(\theta) \\ & y=rsin(\theta) \\ & z=r\theta \\ & r=u×e^{\theta v} \end{aligned } \right. x=rcos ( θ )y=rs in ( θ )z=rθr=u×eθv
    Among them, r is the spiral radius, which will become smaller and smaller; θ \thetaθ is a random angle value within [0, 2π]; u and v are two parameters that determine the shape of the spiral, and the simulated trajectory looks like this:
    insert image description here

The new position P s ( t ) P_s(t) of the seagull after attacking the preyPs(t)
P s ( t ) = D s ( t ) × x × y × z + P b e s t ( t ) P_s(t)=D_s(t)×x×y×z+P_{best}(t) Ps(t)=Ds(t)×x×y×z+Pbest( t )
6. Determine whether the termination condition is satisfied, if not, return to step 3.

3 Find the maximum value of the function (Python implementation)

Find the minimum of the following function:
f ( x 1 , x 2 ) = x 1 2 + x 2 2 f(x_1,x_2)=x_1^2+x_2^2f(x1,x2)=x12+x22
The standard answer is 0, the function looks like this:
insert image description here
main function:

import numpy as np
from matplotlib import pyplot as plt
import SOA

'''适应度函数'''
def fun(X):
        Results = np.sum(X ** 2)
        return Results

'''主函数 '''
#设置参数
pop = 30 #种群数量
MaxIter = 200 #最大迭代次数
dim = 2 #维度
lb = -10*np.ones(dim) #下边界
ub = 10*np.ones(dim)#上边界
#适应度函数选择
fobj = fun
GbestScore,GbestPositon,Curve = SOA.SOA(pop,dim,lb,ub,MaxIter,fobj) # 调用SOA函数
print('最优适应度值:',GbestScore)
print('最优解:',GbestPositon)

SOA.py:

import numpy as np
import copy

'''海鸥优化算法'''
'''
输入:
pop:种群数量
dim:每个个体的维度
lb:个体下边界,维度为[1,dim]
ub:个体上边界,维度为[1,dim]
MaxIter:最大迭代次数
fun:适应度函数接口
输出:
GbestScore:最优解对应的适应度值
GbestPositon:最优解
Curve:画迭代图用
'''
def SOA(pop, dim, lb, ub, MaxIter, fun):
    # 1.初始化参数
    Curve = np.zeros([MaxIter, 1])  # 画迭代图用
    CS = np.zeros([pop, dim])  # 海鸥迁徙过程用到的三个变量,CS为满足避免碰撞条件的位置
    MS = np.zeros([pop, dim])  # MS为最佳位置的方向
    DS = np.zeros([pop, dim])  # DS为最终迁徙完得到的新位置
    fc = 2  # ???论文中的fc从2线性递减到0,可以控制变量A的变化频率,第4.1步用
    u = 1  # 螺旋形状的相关参数,第5步用
    v = 1  # 螺旋形状的相关参数,第5步用

    # 2.根据种群数量与边界来初始化种群位置
    X = initialization(pop, ub, lb, dim)  # 初始化种群

    # 3.计算适应度值并保留全局最优值
    fitness = CaculateFitness(X, fun)  # 计算适应度值
    fitness, sortIndex = SortFitness(fitness)  # 对适应度值排序,得到排序后的适应度值和对应的索引
    X = SortPosition(X, sortIndex)  # 根据排序后的索引对种群排序
    GbestScore = copy.copy(fitness[0])  # 此时fitness的第一个值为最好的适应度值
    GbestPositon = np.zeros([1, dim])
    GbestPositon[0, :] = copy.copy(X[0, :])  # 此时X的第一个值为最好的个体

    X_new = copy.copy(X)
    for i in range(MaxIter):
        # print("第"+str(i)+"次迭代")
        Pbest = X[0, :]
        for j in range(pop):
            # 4.1计算Cs,得到避免碰撞的位置,保持种群多样性,全局搜索
            A = fc - (i * (fc / MaxIter))
            CS[j, :] = X[j, :] * A
            # 4.2计算Ms,得到最佳位置的方向
            rd = np.random.random()
            B = 2 * (A ** 2) * rd
            MS[j, :] = B * (Pbest - X[j, :])
            # 4.3计算Ds,到达新位置
            DS[j, :] = np.abs(CS[j, :] + MS[j, :])

            # 5.海鸥进行螺旋运动攻击猎物,局部搜索
            # 螺旋形状
            theta = np.random.random()
            r = u * np.exp(theta * v) # theta为[0,1]
            x = r * np.cos(theta * 2 * np.pi) # theta为[0,2π]
            y = r * np.sin(theta * 2 * np.pi) # theta为[0,2π]
            z = r * theta # theta为[0,1]
            # 攻击猎物后的位置
            X_new[j, :] = x * y * z * DS[j, :] + Pbest

        X = BorderCheck(X_new, ub, lb, pop, dim)  # 边界检查
        fitness = CaculateFitness(X, fun)  # 计算适应度值
        fitness, sortIndex = SortFitness(fitness)  # 对适应度值排序,拿到索引
        X = SortPosition(X, sortIndex)  # 根据索引对种群排序
        if (fitness[0] <= GbestScore):  # 更新全局最优
            GbestScore = copy.copy(fitness[0])
            GbestPositon[0, :] = copy.copy(X[0, :])
        Curve[i] = GbestScore

    return GbestScore, GbestPositon, Curve

Running results:
Optimal fitness value: [6.28823104e-226]
Optimal solution: [[-1.77578646e-113 1.77054045e-113]]
You can see that the answer is very close to the optimal fitness value of 0.

4 Advanced algorithm

  1. Average performance in standard test functions and CEC2014 test functions;
  2. SOA has great advantages in standard engineering optimization design problems;
  3. The spiral behavior is somewhat similar to the whale optimization algorithm;
  4. The formula in the original text is different from the formula in the source code uploaded by the author;
  5. In the early stage of the iteration, the convergence speed is very slow, and it is easy to fall into the local optimum;
  6. Although the current individual does not have position conflicts with other individuals, there will inevitably be individual collisions during the spiral flight, and the global search ability is not as good as imagined;
  7. There is a problem in optimizing the Quadric function (F3), which differs by tens of thousands from the global optimum;
  8. The effect of optimizing the Rosenbrock function (F5) is not good, and the difference from the global optimum is 4;
  9. Optimizing the Rastrigin function Griewank (F9, 11, 16, 18) works well and can find the global optimum;

Improving SOA directly

literature improvement strategy
Wang Peichong, Yin Xinjie, Li Lirong. A Seagull Optimization Algorithm with Learning Mechanism[J]. Journal of Zhengzhou University (Engineering Science), 2022,43(06):8-14. reverse learning
Long Wen, Xu Ming, Yang Yang. Somersault Foraging Seagull Optimization Algorithm for Function Optimization and Feature Selection[J/OL]. Computer Application Research: 1-7[2022-10-19]. somersault foraging strategy
Yan Aijun, Hu Kaicheng. Improvement strategy and application to improve the search ability of sea-gull optimization algorithm[J/OL]. Information and Control: 1-11[2022-10-19]. Parallel Search + Reverse Learning + Markov Process
Wang Juan, Qin Jiangtao. Seagull optimization algorithm improved by chaotic mapping and t-distribution mutation strategy[J].Computer Application Research,2022,39(01):170-176+182. Tent chaotic map + t distribution variation
Wang Ning, He Qing. Seagull Optimization Algorithm Combining Golden Sine and Sigmoid Continuous[J]. Computer Application Research, 2022,39(01):157-162+169. sigmoid continuous
Qin Weina, Zhang Damin, Yin Dexin, Cai Pengchen.A Seagull Optimization Algorithm Based on Nonlinear Inertial Weight[J].Small Microcomputer System,2022,43(01):10-14. Nonlinear inertial weights + Levi's flight mechanism
Mao Qinghua, Wang Yinggang. Adaptive t-distribution Seagull Algorithm Combining Improved Logistics Chaos and Sine-Cosine Operator[J/OL]. Small Microcomputer System: 1-9[2022-10-19]. Logistics chaotic map + t distribution variation

Integrating other intelligent optimization algorithms to improve SMA

literature Integrated intelligent optimization algorithm
Wang Ning, He Qing. Seagull Optimization Algorithm Combining Golden Sine and Sigmoid Continuous[J]. Computer Application Research, 2022,39(01):157-162+169. golden sine
Ding Fei, Jiang Mingyan.House Price Prediction Based on Improved Lion Pride Algorithm and BP Neural Network Model[J].Journal of Shandong University (Engineering Science Edition),2021,51(04):8-16. Lion Pride Algorithm LSO
Mao Qinghua, Wang Yinggang. Adaptive t-distribution Seagull Algorithm Combining Improved Logistics Chaos and Sine-Cosine Operator[J/OL]. Small Microcomputer System: 1-9[2022-10-19]. Sine and cosine

SMA and its improved applications

literature application
Long Wen, Xu Ming, Yang Yang. Somersault Foraging Seagull Optimization Algorithm for Function Optimization and Feature Selection[J/OL]. Computer Application Research: 1-7[2022-10-19]. feature selection
Ding Fei, Jiang Mingyan.House Price Prediction Based on Improved Lion Pride Algorithm and BP Neural Network Model[J].Journal of Shandong University (Engineering Science Edition),2021,51(04):8-16. BP neural network + house price prediction
Improved seagull optimization algorithm of partition and XGBoost of prediction for fuzzy time series forecasting of COVID-19 daily confirmed xgboost+time series forecasting
Wang Rui. Research on Flexible Job Shop Scheduling in Smart Factory Based on Improved Seagull Optimization Algorithm[D]. Yanshan University, 2021. job shop scheduling problem
Cheng Yanan, Wang Xiaofeng, Liu Songzuo, Liu Zilin, Zhang Jiulong.A seagull algorithm for solving TSP problems[J].Modern Electronic Technology,2022,45(07):112-116. traveling salesman problem

Reference books: Fan Xu, "Python Intelligent Optimization Algorithm——From Principle to Code Implementation and Application", the first edition, Electronic Industry Press.

Guess you like

Origin blog.csdn.net/weixin_46838605/article/details/127429415