Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux 程式設計 >> Linux 程式設計

粒子群優化(PSO)入門:名詞、原理與標準更新公式

名詞對照

  • Particle swarm optimization:粒子群優化理論
  • Stochastic optimization technique:隨機優化技術
  • Evolutionary computation techniques:演化計算技術,用電腦模擬生物進化過程
  • Genetic algorithms:遺傳演算法
  • The problem space:待解問題的解空間
  • Fitness:適應度值
  • pbest:personal best,個體最佳值
  • lbest:local best,局部最佳值
  • gbest:global best,全域最佳值

它從哪裡來

Particle swarm optimization (PSO) is a population based stochastic optimization technique developed by Dr. Eberhart and Dr. Kennedy in 1995, inspired by social behavior of bird flocking or fish schooling.

粒子群優化於 1995 年由 Eberhart 與 Kennedy 博士首次在 IEEE 期刊公開發表。它屬於基於族群(population based)的隨機優化技術,靈感來自鳥群覓食、魚群游動這類社會性行為。

與遺傳演算法的異同

PSO shares many similarities with evolutionary computation techniques such as Genetic Algorithms (GA). The system is initialized with a population of random solutions and searches for optima by updating generations. However, unlike GA, PSO has no evolution operators such as crossover and mutation. In PSO, the potential solutions, called particles, fly through the problem space by following the current optimum particles.

PSO 與演化計算(如遺傳演算法)有相似之處:都先初始化一群隨機解,再靠世代迭代逼進最優解。但 PSO 沒有交叉與變異這兩種進化算子。取而代之的是:每個潛在解稱為一個「粒子」,它們在解空間中飛行,並追隨目前最優的粒子前進。

三種「最佳」的定義

Each particle keeps track of its coordinates in the problem space which are associated with the best solution (fitness) it has achieved so far. This value is called pbest. Another "best" value is the best value, obtained so far by any particle in the neighbors of the particle. This location is called lbest. When a particle takes all the population as its topological neighbors, the best value is a global best and is called gbest.

每個粒子會記住自己到目前為止走過的、適應度最好的那個位置,這就是 pbest。其次,粒子會與自己「鄰居」比較,取其中最好的位置作為 lbest;而當鄰居定義擴大到整個族群時,最好的那個就成了 gbest。

這裡要特別釐清一個常見誤解:粒子本身有兩個屬性——位置(代表候選解)與速度(決定位置如何改變)。沒有速度,粒子就無法在解空間中移動,也就無所謂進化。

每一步做什麼

The particle swarm optimization concept consists of, at each time step, changing the velocity of (accelerating) each particle toward its pbest and lbest locations. Acceleration is weighted by a random term, with separate random numbers being generated for acceleration toward pbest and lbest locations.

換句話說,每次迭代就是「調整速度,讓粒子加速飛向 pbest 與 lbest」。兩段加速各自乘上一個獨立產生的隨機權重,這正是 PSO 具隨機性的來源。

為什麼受歡迎

In past several years, PSO has been successfully applied in many research and application areas. It is demonstrated that PSO gets better results in a faster, cheaper way compared with other methods.

Another reason that PSO is attractive is that there are few parameters to adjust. One version, with slight variations, works well in a wide variety of applications.

過去十餘年,PSO 已成功應用於大量研究與實務領域,在速度與成本上都展現優勢。另一個吸引人的原因是待調參數很少:同一組公式稍作變動就能跨領域使用,對特定需求也能靠調整權重與學習因子來適配。

標準模型公式

每次迭代中,粒子依個體最佳與群體最佳更新自己的速度與位置:

V_id(k+1) = w · V_id(k)
          + c1 · r1 · (P_id - X_id(k))
          + c2 · r2 · (G_id - X_id(k))

X_id(k+1) = X_id(k) + V_id(k+1)

其中 w 為慣性權重;d = 1,2,…,D;i = 1,2,…,n;k 為當前迭代次數;V_id 為粒子速度;c1 與 c2 是非負常數,稱為加速度因子,一般取 c1 = c2 = 2;r1 與 r2 是介於 [0,1] 的隨機數。

為了避免粒子盲目亂飛,實務上會把位置與速度限制在 [-Xmax, Xmax] 與 [-Vmax, Vmax] 之內。w 大則偏重全域探索、小則偏重局部開發,這也是 PSO 調參時最該先動的旋鈕。

Copyright © Linux教程網 All Rights Reserved