当前位置:   article > 正文

智能优化算法:龙格-库塔优化算法 - 附代码_qt 龙格库塔

qt 龙格库塔

智能优化算法:龙格-库塔优化算法


摘要:龙格-库塔优化算法(Runge Kutta optimizer,RUN)是于2021年提出的一种新型智能优化算法,该算法基于龙格-库塔方法中提出的计算梯度搜索概念来指导寻优,具有寻优能力强,收敛速度快等特点。

1.算法原理

1.1 搜索机制

该算法的搜索机制基于RK方法,使用一组随机解搜索决策空间,并实现适当的全局和局部搜索。采用4阶RK方法。
S M = 1 6 ( x R K ) Δ x (1) SM=\frac{1}{6}(x_{RK})\Delta x\tag{1} SM=61(xRK)Δx(1)

x R K = k 1 + 2 k 2 + 2 k 3 + k 4 (2) x_{RK}=k_1+2k_2+2k_3+k_4 \tag{2} xRK=k1+2k2+2k3+k4(2)

k 1 = 1 2 Δ x ( r a n d ∗ x w − u ∗ x b ) (3) k_1=\frac{1}{2\Delta x}(rand*x_w-u*x_b)\tag{3} k1=2Δx1(randxwuxb)(3)

u = r o u n d ( 1 + r a n d ) ∗ ( 1 − r a n d ) (4) u=round(1+rand)*(1-rand)\tag{4} u=round(1+rand)(1rand)(4)

k 2 = 1 2 Δ x ( r a n d ( x w + r a n d 1 ∗ k 1 ∗ Δ x ) − ( u x b + r a n d 2 ∗ k 1 Δ x ) ) (5) k_2=\frac{1}{2\Delta x}(rand(x_w+rand_1*k_1*\Delta x)-(ux_b+rand_2*k_1\Delta x))\tag{5} k2=2Δx1(rand(xw+rand1k1Δx)(uxb+rand2k1Δx))(5)

k 3 = 1 2 Δ x ( r a n d ( x w + r a n d 1 ( k 2 / 2 ) Δ x ) − ( u x b + r a n d 2 ( k 2 / 2 ) Δ x ) ) (6) k_3=\frac{1}{2\Delta x}(rand(x_w+rand_1(k_2/2)\Delta x)-(ux_b+rand_2(k_2/2)\Delta x))\tag{6} k3=2Δx1(rand(xw+rand1(k2/2)Δx)(uxb+rand2(k2/2)Δx))(6)

k 4 = 1 2 Δ x ( r a n d ∗ ( x w + r a n d 1 k 3 Δ x ) − ( u x b + r a n d 2 k 3 Δ x ) ) (7) k_4=\frac{1}{2\Delta x}(rand*(x_w+rand_1k_3\Delta x)-(ux_b+rand_2k_3\Delta x))\tag{7} k4=2Δx1(rand(xw+rand1k3Δx)(uxb+rand2k3Δx))(7)

Δ x = 2 ∗ r a n d ∗ ∣ S t p ∣ (8) \Delta x=2*rand*|Stp| \tag{8} Δx=2randStp(8)

S t p = r a n d ∗ ( ( x b − r a n d ∗ x a v g ) + γ ) (9) Stp=rand*((x_b-rand*x_{avg})+\gamma) \tag{9} Stp=rand((xbrandxavg)+γ)(9)

γ = r a n d ∗ ( x n − r a n d ∗ ( u − l ) ∗ e x p ( − 4 i / M a x i ) ) (10) \gamma=rand*(x_n-rand*(u-l)*exp(-4i/Max_i))\tag{10} γ=rand(xnrand(ul)exp(4i/Maxi))(10)

其中 x b x_b xb x w x_w xw分别为种群的最优解和最差解。 r a n d 1 , r a n d 2 rand_1,rand_2 rand1,rand2为[0,1]之间的随机数。 x a v g x_{avg} xavg为种群的平均值。 i i i为当前迭代次数, M a x i Max_i Maxi为最大迭代次数。

1.2 位置更新

RUN算法的位置更新如式(11)所示
x n + 1 = { ( x c + r ∗ S F ∗ g ∗ x c ) + S F ∗ S M + u ∗ x s , i f   r a n d < 0.5 ( x m + r ∗ S F ∗ g ∗ x m ) + S F ∗ S M + u ∗ x s ′ , e l s e (11) x_{n+1}={(xc+rSFgxc)+SFSM+uxs,ifrand<0.5(xm+rSFgxm)+SFSM+uxs,else

\tag{11} xn+1={(xc+rSFgxc)+SFSM+uxs,ifrand<0.5(xm+rSFgxm)+SFSM+uxs,else(11)

x s = r a n d n ∗ ( x m − x c ) (12) x_s=randn*(x_m-x_c)\tag{12} xs=randn(xmxc)(12)

x s ′ = r a n d n ∗ ( x r 1 − x r 2 ) (13) xs'=randn*(x_{r1}-x_{r2})\tag{13} xs=randn(xr1xr2)(13)

中, r r r是1或-1的整数; g g g是[0,2]的随机数; S F SF SF是自适应因子; u u u为随机数。

SF计算如下:
S F = 2 ∗ ( 0.5 − r a n d ) ∗ f (13) SF=2*(0.5-rand)*f\tag{13} SF=2(0.5rand)f(13)

f = a ∗ e x p ( − b ∗ r a n d ∗ i / M a x i ) (14) f=a*exp(-b*rand*i/Max_i)\tag{14} f=aexp(brandi/Maxi)(14)

其中 i i i为当前迭代次数, M a x i Max_i Maxi为最大迭代次数。 a a a b b b为一个常数。 r a n d rand rand为[0,1]之间的随机数。

x c x_c xc x m x_m xm的定义如下:
x c = φ x n + ( 1 − φ ) ∗ x r 1 (15) x_c=\varphi x_n+(1-\varphi)*x_{r_1} \tag{15} xc=φxn+(1φ)xr1(15)

x m = φ x b e s t + ( 1 − φ ) x l b e s t (16) x_m=\varphi x_{best}+(1-\varphi)x_{lbest} \tag{16} xm=φxbest+(1φ)xlbest(16)

其中 φ \varphi φ为[0,1]之间的随机数; x b e s t x_{best} xbest为全局最优解; x l b e s t x_{lbest} xlbest是每代最优位置。

1.3 解质量增强(ESQ)

在该算法中,采用解质量增强(ESQ)的方法来提高解的质量,避免每次迭代中出现局部最优。通过使用ESQ执行以下公式产生新解( x n e w 2 x_{new2} xnew2):
x n e w 2 = { x n e w 1 + r w ∣ ( x n e w 1 − x a v g ) + r a n d n ∣ , r a n d < 0.5 , w < 1 ( x n e w 1 − x a v g ) + r w ∣ ( u x n e w 1 − x a v g ) + r a n d n ∣ , r a n d < 0.5 , w ≥ 1 (17) x_{new2}={xnew1+rw|(xnew1xavg)+randn|,rand<0.5,w<1(xnew1xavg)+rw|(uxnew1xavg)+randn|,rand<0.5,w1

\tag{17} xnew2={xnew1+rw(xnew1xavg)+randn,rand<0.5,w<1(xnew1xavg)+rw(uxnew1xavg)+randn,rand<0.5,w1(17)
其中:
w = r a n d ( 0 , 2 ) ∗ e x p ( − c i / M a x i ) (18) w=rand(0,2)*exp(-ci/Max_i) \tag{18} w=rand(0,2)exp(ci/Maxi)(18)

x a v g = x r 1 + x r 2 + x r 3 3 (19) x_{avg}=\frac{x_{r1}+x_{r2}+x_{r3}}{3} \tag{19} xavg=3xr1+xr2+xr3(19)

x n e w 1 = β ∗ x a v g + ( 1 − β ) x b e s t (20) x_{new1}=\beta*x_{avg}+(1-\beta)x_{best} \tag{20} xnew1=βxavg+(1β)xbest(20)

其中, β \beta β为[0,1]之间随机数。 c c c为[0,5]之间随机数; r r r是1、0或-1的随机整数; x b e s t x_{best} xbest表示全局最优位置。该部分计算的解 x n e w 2 x_{new2} xnew2可能比不上当前解。为了增强解的质量,将生成另一个新解 x n e w 3 x_{new3} xnew3 ,定义如下:
x n e w 3 = ( x n e w 2 − r a n d x n e w 2 ) + S F ( r a n d ∗ x R K + ( v x b − x n e w 2 ) ) (21) x_{new3}=(x_{new2}-randx_{new2})+SF(rand*x_{RK}+(vx_b-x_{new2}))\tag{21} xnew3=(xnew2randxnew2)+SF(randxRK+(vxbxnew2))(21)
其中, v v v为2*rand的随机数。

算法伪代码如下:

Algorithm 1. The pseudo-code of RUN
Stage 1. Initialization
Initializea,b
Generate the RUN population X n (n = 1,2,…,N)
Calculate the objective function of each member of population
Determine the solutions x w , x b , andx best
Stage 2. RUN operators
for i = 1: Maxi
for n = 1 : N
for l = 1 : D
Calculate position x n+1,l  using Eq. (11)
end for
Enhance the solution quality
ifrand < 0.5
Calculate position x new2  using Eq. (17)
if f(x n ) < f(x new2 )
if rand<w
Calculate position x new3  using Eq. (21)
end
end
end
Update positions x w  andx b
end for
Update positionx best
i = i + 1
end
Stage 3. returnx best


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

2.实验结果

请添加图片描述

3.参考文献

[1] Iman Ahmadianfar, Ali Asghar Heidari, Amir H. Gandomi, Xuefeng Chu, Huiling Chen. RUN beyond the metaphor: An efficient optimization algorithm based on Runge Kutta method[J]. Expert Systems with Applications, 2021, 181(115079): 0957-4174.

4.Matlab代码

d the metaphor: An efficient optimization algorithm based on Runge Kutta method[J]. Expert Systems with Applications, 2021, 181(115079): 0957-4174.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/550582
推荐阅读
相关标签
  

闽ICP备14008679号