Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Basic ACO in TSP

Basic ACO in TSP

Few pages of my ACO notes, mainly introduce the procedure of ACO in TSP

gogochiou

August 28, 2023
Tweet

Other Decks in Programming

Transcript

  1. ACO in TSP Problem formulation 3 Basic ACO 1 5

    3 4 2 Travelling Salesman Problem 旅行推銷員問題 n City which number is n Route between 2 cities TSP是組合最佳化中的一個NP Hard問題,其問題 定義為「給定一系列城市和城市之間的距離,求解 訪問每座城市一次並回到起始城市的最短路徑」。 如果使用暴力迭代法(brute-force search),當 城市大於66個,一般的電腦就會無法解出。
  2. ACO in TSP Parameters Setting 4 Basic ACO 1 5

    3 4 2 ACO 參數設定 n City which number is n Route between 2 cities 1. Population size (N) 每一代中有多少螞蟻 2. Max Iterations 最大迭代的次數 3. Pheromone Evaporation Rate (p) 賀爾蒙消散的速率 4. Initial Artificial Pheromone (𝝉𝒊𝒏𝒊𝒕 ) 起始的費洛蒙濃度 5. Weight of Pheromone Density (𝜶) 費洛蒙濃度的影響係數 6. Weight of Route Distance\heuristic\proximity (𝜷) Heuristic的影響程度,TSP中heuristic是距離倒數 7. Weight of Total Travel Distance (Q) 各別螞蟻總路徑長,對於費洛蒙變化量的影響 a b c d
  3. ACO in TSP Important procedures & formulas 5 Basic ACO

    1 5 3 4 2 Probability of state transfer n City which number is n Route between 2 cities In TSP, it indicates the probability for ant K to moving from city i to city j. (在TSP中,每一代的每個螞蟻從 i 轉移到 j 的機率都是相同的,所以可以暫時忽略 k ) P𝒊𝒋 = (𝝉𝒊𝒋 )𝜶(𝜼𝒊𝒋 )𝜷 σ 𝒎∈𝒂𝒍𝒍𝒐𝒘𝒆𝒅 (𝝉𝒊𝒎 )𝜶(𝜼𝒊𝒎 )𝜷 𝝉𝒊𝒋 is the amount (density) of pheromone between city i and city j 𝜼𝒊𝒋 is the proximity between city i and city j . 𝜼𝒊𝒋 = ൗ 𝑸 𝒅𝒊𝒋 ( 常數Q / 路徑長𝒅𝒊𝒋 ) 由左圖解析,a、b、c、d分別表示各自路徑的𝝉𝜶𝜼𝜷 𝑷𝟏,𝟐 = 𝒂 𝒂 + 𝒃 + 𝒄 + 𝒅 , 𝑷𝟏,𝟑 = 𝒃 𝒂 + 𝒃 + 𝒄 + 𝒅 , 𝑷𝟏,𝟒 = 𝒄 𝒂 + 𝒃 + 𝒄 + 𝒅 , 𝑷𝟏,𝟓 = 𝒅 𝒂 + 𝒃 + 𝒄 + 𝒅 𝑷𝟏,𝟐 + 𝑷𝟏,𝟑 + 𝑷𝟏,𝟒 + 𝑷𝟏,𝟓 = 1 a b c d
  4. ACO in TSP Important procedures & formulas 6 Basic ACO

    Update Pheromone • Pheromone & Proximity(𝜼𝒊𝒋 ) between nodes to nodes 當第 t 代的螞蟻都走完,則需要根據每一隻螞蟻走過的路線來更 新費洛蒙濃度。對螞蟻k而言,其造成的費洛蒙變化量為 : ∆𝝉𝒊𝒋,𝒌 𝒕 = ቐ ൗ Q L𝒌 (𝒕) 𝒊𝒇 (𝒊, 𝒋) ∈ 𝑻𝒌 (𝒕) 𝟎 𝒊𝒇 (𝒊, 𝒋) ∉ 𝑻𝒌 (𝒕) L𝒌 (t) 代表第 t 代中,螞蟻 k 旅行的總路徑長 𝑻𝒌 (𝒕) 代表第 t 代中,螞蟻 k 旅行過的路徑 根據所有螞蟻造成的費洛蒙變化量,以及第 t 代的費洛蒙濃度, 我們可以更新第 t+1 代路徑上的費洛蒙濃度 : 𝝉𝒊𝒋 𝒕 + 𝟏 = 𝟏 − 𝒑 ∗ 𝝉𝒊𝒋 𝒕 + ෍ 𝒌=𝟏 𝑵 ∆𝝉𝒊𝒋,𝒌 𝒕 Proximity (Q/Distance) Pheromone Density
  5. ACO in TSP STEP by STEP 7 Basic ACO 1

    5 3 4 2 ACO Algorithm 步驟 n City which number is n Route between 2 cities 1. 設定初始參數、初始費洛蒙濃度 2. 讓 N 隻螞蟻從隨機的起始點開始探訪節點,直到回到起始點 每隻螞蟻的探索步驟 - a. 根據當前節點(city)計算到其他未探訪節點(city)的狀態 轉移機率 b. 根據狀態轉移機率建立Solution Set c. 隨機取一個介於 0 ~ 1 的數值,根據此數值找尋其位在 Solution Set 的位置,並決定下一個探訪的節點(city) d. 重複a, b, c 步驟直到沒有未探索的節點 e. 回到起始的節點 3. 根據每隻螞蟻的旅程,更新每個路徑的費洛蒙濃度 4. 重複2, 3 步驟直到收斂(收斂條件自行定義) P𝟏𝟐 P𝟏𝟑 P𝟏𝟒 P𝟏𝟓
  6. ACO in TSP STEP by STEP 8 Basic ACO 1

    5 3 4 2 ACO Algorithm 步驟 1. 設定初始參數、初始費洛蒙濃度 2. 讓 N 隻螞蟻從隨機的起始點開始探訪節點,直到回到起始點 每隻螞蟻的探索步驟 - a. 根據當前節點(city)計算到其他未探訪節點(city)的狀態 轉移機率 b. 根據狀態轉移機率建立Solution Set c. 隨機取一個介於 0 ~ 1 的數值,根據此數值找尋其位在 Solution Set 的位置,並決定下一個探訪的節點(city) d. 重複a, b, c 步驟直到沒有未探索的節點 e. 回到起始的節點 3. 根據每隻螞蟻的旅程,更新每個路徑的費洛蒙濃度 4. 重複2, 3 步驟直到收斂(收斂條件自行定義) P𝟏𝟐 = 𝟎. 𝟐 P𝟏𝟑 = 𝟎. 𝟏𝟓 P𝟏𝟒 = 𝟎. 𝟒 P𝟏𝟓 = 𝟎. 𝟐𝟓 P𝟏𝟐 P𝟏𝟑 P𝟏𝟒 P𝟏𝟓 0 0.2 0.35 0.75 1 0.25 (Random number) • 上圖中,隨機數值為0.25,位在Solution Set 中P𝟏𝟑 內,故選擇節點3為下一個探訪的城市