【智能算法】星鸦优化算法(NOA)原理及实现

发布时间:2025-09-13 11:50

学习并实践零基预算法来优化现金流 #生活技巧# #财务管理技巧# #现金流管理#

目录 1.背景2.算法原理2.1算法思想2.2算法过程 3.结果展示4.参考文献

1.背景

2023年,M Abdel-Basset等人受到克拉克的星鸦自然行为启发,提出了星鸦优化算法算法(Nutcracker Optimization Algorithm, NOA)。


2.算法原理

2.1算法思想

NOA模拟了星鸦自然行为,星鸦在不同的时期表现出两种不同的行为。星鸦的季节性行为可以分为两个主要部分:

夏季和秋季的种子储存:在这两个季节,星鸦积极寻找种子并将其储存在精心挑选的贮藏处,为冬季缺食的时期做准备。冬季和春季的基于记忆的寻食:利用空间记忆策略,星鸦通过识别地标和其他视觉线索来找到之前隐藏的种子。如果无法找到储存的种子,它们则会随机探索周围环境以寻找食物。

2.2算法过程

NOA模拟星鸦的行为,两种主要策略:(i)觅食和储存策略;(ii)缓存搜索和恢复策略

觅食阶段:探索阶段1

星鸦在搜索空间内进行寻食,它首先检查每个锥体的初始位置来寻找种子。如果发现优质的种子,星鸦会将其运送到储藏区并将其埋藏。如果未找到优质种子,它将继续在松树或其他树种的不同位置搜索新的种子:
X ⃗ i t + 1 = { X i , j t i f τ 1 < τ 2 { X m , j t + γ ⋅ ( X A , j t − X B , j t ) + μ . ( r 2 . U j − L j ) , i f t ≤ T m a x / 2.0 X C , j t + μ ⋅ ( X A , j t − X B , j t ) + μ . ( r 1 < δ ) . ( r 2 . U j − L j ) , o t h e r w i s e (1) \vec{X}_{i}^{t+1}=\begin{cases}X_{i,j}^{t}&\mathrm{if~}\tau_{1}<\tau_{2}\\\begin{cases}X_{m,j}^{t}+\gamma\cdot\left(X_{A,j}^{t}-X_{B,j}^{t}\right)\\\\+\mu.\left(r^{2}.U_{j}-L_{j}\right),&\mathrm{if~}t\leq T_{max}/2.0\\\\X_{C,j}^{t}+\mu\cdot\left(X_{A,j}^{t}-X_{B,j}^{t}\right)\\\\+\mu.\left(r_{1}<\delta\right).\left(r^{2}.U_{j}-L_{j}\right),&\mathrm{otherwise}\end{cases}\\\end{cases}\tag{1} X

it+1​=⎩

⎧​Xi,jt​⎩

⎧​Xm,jt​+γ⋅(XA,jt​−XB,jt​)+μ.(r2.Uj​−Lj​),XC,jt​+μ⋅(XA,jt​−XB,jt​)+μ.(r1​<δ).(r2.Uj​−Lj​),​if t≤Tmax​/2.0otherwise​​if τ1​<τ2​(1)
γ参数为莱维飞行得到,µ是基于正态分布(τ4), levy-flight (τ5),随机在0到1 (τ3)之间生成的数:
μ = { τ 3 i f r 1 < r 2 τ 4 i f r 2 < r 3 τ 5 i f r 1 < r 3 (2) \mu=\begin{cases}\tau_3&if r_1<r_2\\[2ex]\tau_4&if r_2<r_3\\[2ex]\tau_5&if r_1<r_3\end{cases}\tag{2} μ=⎩

⎧​τ3​τ4​τ5​​ifr1​<r2​ifr2​<r3​ifr1​<r3​​(2)
τ1和τ2作为尺度因子控制NOA探索能力,可以在τ1和τ2的大小范围内交替进行局部和全局搜索。µ提供星鸦信息有关所需的方向与各种步长,以探索一个新的位置。

存储阶段:开发阶段1

星鸦首先将在前一阶段(探索阶段1)中获得的食物运送到临时存储地点(存储区域):
X ⃗ i t + 1 ( n e w ) = { X ⃗ i t + μ ⋅ ( X ⃗ b e s t t − X ⃗ i t ) ⋅ ∣ λ ∣ + r 1 ⋅ ( X ⃗ A t − X ⃗ B t ) if  τ 1 < τ 2 X ⃗ b e s t t + μ ⋅ ( X ⃗ A t − X ⃗ B t ) if  τ 1 < τ 3 X ⃗ b e s t t ⋅ l Otherwise (3) \vec{X}_i^{t+1(new)}=\begin{cases}\vec{X}_i^t+\mu\cdot\left(\vec{X}_{best}^t-\vec{X}_i^t\right)\cdot|\lambda|+r_1\cdot\left(\vec{X}_A^t-\vec{X}_B^t\right)&\text{if }\tau_1<\tau_2\\\vec{X}_{best}^t+\mu\cdot\left(\vec{X}_A^t-\vec{X}_B^t\right)&\text{if }\tau_1<\tau_3\\\vec{X}_{best}^t\cdot l&\text{Otherwise}\end{cases}\tag{3} X

it+1(new)​=⎩

⎧​X

it​+μ⋅(X

bestt​−X

it​)⋅∣λ∣+r1​⋅(X

At​−X

Bt​)X

bestt​+μ⋅(X

At​−X

Bt​)X

bestt​⋅l​if τ1​<τ2​if τ1​<τ3​Otherwise​(3)
l是NOA开发行为从1到0线性递减的因子,觅食阶段与缓存之间平衡:
X ⃗ i t + 1 = { Eq.(1), if  φ > P a 1 Eq.(3), otherwise (4) \vec{X}_i^{t+1}=\begin{cases}\text{Eq.(1),}&\text{if }\varphi>P_{a_1}\\[2ex]\text{Eq.(3),}&\text{otherwise}\end{cases}\tag{4} X

it+1​=⎩

⎧​Eq.(1),Eq.(3),​if φ>Pa1​​otherwise​(4)
其中φ是0到1之间的随机数,Pa1表示从1到0线性递减的概率值。

参考记忆

在将种子储存好之后,星鸦将会激活记忆,它们依靠对贮藏物所在位置的记忆来度过冬天。

缓存搜索阶段:探索阶段2

星鸦利用了一种层级记忆策略来恢复它们隐藏的食物,如果星鸦不能找到第一个RP储存的食物,那么它将通过第二个RP识别它。如果星鸦不能第二次检索它的缓存,那么它将使用第三个引用。第一个RP是通过更新相邻区域内的当前位置来找到星鸦周围隐藏的缓存:
R P → i , k t = X ⃗ i t + α ⋅ cos ⁡ ( θ ) ⋅ ( ( X ⃗ A t − X ⃗ B t ) ) , k = 1 (5) \overrightarrow{RP}_{i,k}^t=\vec{X}_i^t+\alpha\cdot\cos{(\theta)}\cdot\left(\left(\vec{X}_A^t-\vec{X}_B^t\right)\right),k=1\tag{5} RP

i,kt​=X

it​+α⋅cos(θ)⋅((X

At​−X

Bt​)),k=1(5)

探索不同的区域寻找隐藏的宝藏,第二个RP表述为:
R P → i , k t = X ⃗ i t + α ⋅ cos ⁡ ( θ ) ⋅ ( ( U ⃗ − L ⃗ ) ⋅ τ 3 + L ⃗ ) ⋅ U → 2 , k = 2 U → 1 = { 1 r 2 → < P τ p 0 o t h e r w i s e (6) \begin{aligned}&\overrightarrow{RP}_{i,k}^{t}=\vec{X}_{i}^{t}+\alpha\cdot\cos{(\theta)}\cdot\left(\left(\vec{U}-\vec{L}\right)\cdot\tau_{3}+\vec{L}\right)\cdot\overrightarrow{U}_{2},k=2\\&\overrightarrow{U}_{1}=\begin{cases}1&\overrightarrow{r_{2}}<P_{\tau p}\\0&otherwise\end{cases}\end{aligned}\tag{6} ​RP

i,kt​=X

it​+α⋅cos(θ)⋅((U

−L

)⋅τ3​+L

)⋅U

2​,k=2U

1​={10​r2​

​<Pτp​otherwise​​(6)
星鸦在三维空间中有三个不同的位置,一个缓存有三个不同的RP位置:
R P → i , 1 t = { X ⃗ i t + α ⋅ cos ⁡ ( θ ) ⋅ ( ( X ⃗ A t − X ⃗ B t ) ) + α ⋅ R P , i f θ = π / 2 X ⃗ i t + α ⋅ cos ⁡ ( θ ) ⋅ ( ( X ⃗ A t − X ⃗ B t ) ) , o t h e r w i s e (7) \overrightarrow{RP}_{i,1}^{t}=\begin{cases}\vec{X}_{i}^{t}+\alpha\cdot\cos\left(\theta\right)\cdot\left(\left(\vec{X}_{A}^{t}-\vec{X}_{B}^{t}\right)\right)+\alpha\cdot RP,&if \theta=\pi/2\\\vec{X}_{i}^{t}+\alpha\cdot\cos\left(\theta\right)\cdot\left(\left(\vec{X}_{A}^{t}-\vec{X}_{B}^{t}\right)\right),&other wise\end{cases}\tag{7} RP

i,1t​=⎩

⎧​X

it​+α⋅cos(θ)⋅((X

At​−X

Bt​))+α⋅RP,X

it​+α⋅cos(θ)⋅((X

At​−X

Bt​)),​ifθ=π/2otherwise​(7)
R P → i , 2 t = { X ⃗ i t + ( α ⋅ cos ⁡ ( θ ) ⋅ ( ( U ⃗ − L ⃗ ) ⋅ τ 3 + L ⃗ ) + α ⋅ R P ) ⋅ U → 2 , i f θ = π / 2 X ⃗ i t + α ⋅ cos ⁡ ( θ ) ⋅ ( ( U ⃗ − L ⃗ ) ⋅ τ 3 + L ⃗ ) ⋅ U → 2 , o t h e r w i s e (8) \overrightarrow{RP}_{i,2}^{t}=\begin{cases}\vec{X}_{i}^{t}+\left(\alpha\cdot\cos\left(\theta\right)\cdot\left(\left(\vec{U}-\vec{L}\right)\cdot\tau_{3}+\vec{L}\right)+\alpha\cdot RP\right)\cdot\overrightarrow{U}_{2}, if \theta=\pi/2\\\vec{X}_{i}^{t}+\alpha\cdot\cos(\theta)\cdot\left(\left(\vec{U}-\vec{L}\right)\cdot\tau_{3}+\vec{L}\right)\cdot\overrightarrow{U}_{2},&other wise\end{cases}\tag{8} RP

i,2t​=⎩

⎧​X

it​+(α⋅cos(θ)⋅((U

−L

)⋅τ3​+L

)+α⋅RP)⋅U

2​,ifθ=π/2X

it​+α⋅cos(θ)⋅((U

−L

)⋅τ3​+L

)⋅U

2​,​otherwise​(8)
α确保NOA定期收敛,允许胡桃夹子在下一代中改进其RP选择:
α = { ( 1 − t T m a x ) 2 t T m a x , i f r 1 > r 2 ( t T m a x ) 2 t , o t h e r w i s e (9) \alpha=\begin{cases}\left(1-\frac t{T_{max}}\right)^{2\frac t{T_{max}}},&if r_1>r_2\\\\\left(\frac t{T_{max}}\right)^{\frac2t},&otherwise&\end{cases}\tag{9} α=⎩

⎧​(1−Tmax​t​)2Tmax​t​,(Tmax​t​)t2​,​ifr1​>r2​otherwise​​(9)
随着每次迭代,算法将以适当的rp探索和利用缓存周围的区域,以避免陷入局部最小值:
X ⃗ i t + 1 = { X ⃗ i t , i f f ( X ⃗ i t ) < i f ( R P ⃗ i , 1 t ) R P → i , 1 t , o t h e r w i s e (10) \vec{X}_i^{t+1}=\begin{cases}\vec{X}_i^t,&\quad if f\left(\vec{X}_i^t\right)<if (\vec{RP}_{i,1}^t)\\\overrightarrow{RP}_{i,1}^t,&\quad other wise\end{cases}\tag{10} X

it+1​=⎩

⎧​X

it​,RP

i,1t​,​iff(X

it​)<if(RP

i,1t​)otherwise​(10)

恢复阶段:开发阶段2

星鸦在寻找它的食物时可能存在两种可能。第一,星鸦可以使用第一个RP记住缓存的位置。第二,该食物不存在:
X i , j t + 1 = { X i , j t , i f τ 3 < τ 4 X i , j t + r 1 ⋅ ( X b e s t , j t − X i , j t ) + r 2 ⋅ ( R P → i , 1 t − X C , j t ) , o t h e r w i s e (11) X_{i,j}^{t+1}=\begin{cases}X_{i,j}^{t},&if \tau_{3}<\tau_{4}\\X_{i,j}^{t}+r_{1}\cdot\left(X_{best,j}^{t}-X_{i,j}^{t}\right)+r_{2}\cdot\left(\overrightarrow{RP}_{i,1}^{t}-X_{C,j}^{t}\right),&otherwise\end{cases}\tag{11} Xi,jt+1​=⎩

⎧​Xi,jt​,Xi,jt​+r1​⋅(Xbest,jt​−Xi,jt​)+r2​⋅(RP

i,1t​−XC,jt​),​ifτ3​<τ4​otherwise​(11)

第二个RP进行更新:
X ⃗ i t + 1 = { X ⃗ i t , i f f ( X ⃗ i t ) < i f ( R P ⃗ i , 2 t ) R P → i , 2 t , o t h e r w i s e (12) \vec{X}_{i}^{t+1}=\begin{cases}\vec{X}_{i}^{t},&if f\left(\vec{X}_{i}^{t}\right)<if (\vec{RP}_{i,2}^{t})\\\overrightarrow{RP}_{i,2}^{t},&otherwise\end{cases}\tag{12} X

it+1​=⎩

⎧​X

it​,RP

i,2t​,​iff(X

it​)<if(RP

i,2t​)otherwise​(12)
假设星鸦使用第二个RP找到它的缓存:
X i j t + 1 = { X i j t , i f τ 5 < τ 6 X i j t + r 1 ⋅ ( X b e s t , j t − X i j t ) + r 2 ⋅ ( R → P i , 2 t − X c j t ) , o t h e r w i s e (13) X_{ij}^{t+1}=\begin{cases}X_{ij}^t,&if \tau_5<\tau_6\\X_{ij}^t+r_1\cdot\left(X_{best,j}^t-X_{ij}^t\right)+r_2\cdot\left(\overrightarrow{R}P_{i,2}^t-X_{cj}^t\right),&otherwise\end{cases}\tag{13} Xijt+1​={Xijt​,Xijt​+r1​⋅(Xbest,jt​−Xijt​)+r2​⋅(R

Pi,2t​−Xcjt​),​ifτ5​<τ6​otherwise​(13)
算法围绕涉及最优解的最合适区域加强局部搜索,总结为:
X ⃗ i t + 1 = { Eq.(13), if τ 7 < τ 8 Eq.(15), otherwise (14) \vec{X}_i^{t+1}=\begin{cases}\text{Eq.(13),}&\text{if} \tau_7<\tau_8\\[2ex]\text{Eq.(15),}&\text{otherwise}\end{cases}\tag{14} X

it+1​=⎩

⎧​Eq.(13),Eq.(15),​ifτ7​<τ8​otherwise​(14)
等式中的第一种情况表示记住隐藏存储的星鸦,而第二种情况表示不记住隐藏存储的星鸦。第一个rp和第二个rp的探索行为之间平衡:
X ⃗ i t + 1 = { Eq.(12), if f(Eq.(12))<f(Eq.(14)) Eq.(14), otherwise (15) \vec{X}_{i}^{t+1}=\begin{cases}\text{Eq.(12),}&\text{if f(Eq.(12))<f(Eq.(14))}\\\text{Eq.(14),}&\text{otherwise}\end{cases}\tag{15} X

it+1​={Eq.(12),Eq.(14),​if f(Eq.(12))<f(Eq.(14))otherwise​(15)
缓存搜索阶段与回收阶段的交换按照下式进行,以保持勘探与开采的平衡:
X ⃗ i t + 1 = { E q . ( 16 ) , i f ϕ > P a 2 E q . ( 17 ) , o t h e r w i s e (16) \vec{X}_{i}^{t+1}=\begin{cases}\mathrm{Eq.} ( 16),\quad if \phi>P_{a_{2}}\\[2ex]\mathrm{Eq.} ( 17 ),\quad other wise\end{cases}\tag{16} X

it+1​=⎩

⎧​Eq.(16),ifϕ>Pa2​​Eq.(17),otherwise​(16)

伪代码

3.结果展示

使用测试框架,测试NOA性能 一键run.m

【智能算法】省时方便,智能算法统计指标——一键运行~

CEC2017-F13


4.参考文献

[1] Abdel-Basset M, Mohamed R, Jameel M, et al. Nutcracker optimizer: A novel nature-inspired metaheuristic algorithm for global optimization and engineering design problems[J]. Knowledge-Based Systems, 2023, 262: 110248.

网址:【智能算法】星鸦优化算法(NOA)原理及实现 https://www.yuejiaxmz.com/news/view/1295394

相关内容

【智能算法】星鸦优化算法(NOA)原理及实现
智能优化算法及优化案例目录
智能优化算法
揭秘带宽使用:高效算法助力网络优化
最优化算法——常见优化算法分类及总结
L3准入倒计时:2025中国智能辅助驾驶算力、数据、算法有何新突破?
智能家居能耗优化算法
基于Python算法优化:智能衣柜管理系统设计与实现
APS智能排产+运筹优化算法=?
全场景NOA全国开城 诠释头部智能化实力 长城汽车闪耀广州车展

随便看看