當前位置:編程學習大全網 - 網站源碼 - 粒子群優化算法的算法介紹

粒子群優化算法的算法介紹

在找到這兩個最優值時,粒子根據如下的公式來更新自己的速度和新的位置

v[] = v[] + c1 * rand() * (pbest[] - present[]) + c2 * rand() * (gbest[] - present[]) (a)

present[] = present[] + v[] (b)

v[] 是粒子的速度, present[] 是當前粒子的位置. pbest[] and gbest[] 如前定義 rand () 是介於(0, 1)之間的隨機數. c1, c2 是學習因子. 通常 c1 = c2 = 2.

程序的偽代碼如下

For each particle

____Initialize particle

END

Do

____For each particle

________Calculate fitness value

________If the fitness value is better than the best fitness value (pBest) in history

____________set current value as the new pBest

____End

____Choose the particle with the best fitness value of all the particles as the gBest

____For each particle

________Calculate particle velocity according equation (a)

________Update particle position according equation (b)

____End

While maximum iterations or minimum error criteria is not attained

在每壹維粒子的速度都會被限制在壹個最大速度Vmax,如果某壹維更新後的速度超過用戶設定的Vmax,那麽這壹維的速度就被限定為Vmax。

  • 上一篇:在C++中用vector如何實現元素逆序存儲
  • 下一篇:佛教的寺和廟有什麽區別?都是和尚住的地方為什麽有的叫寺,有的叫廟?
  • copyright 2024編程學習大全網