1 / 38

期末專題 TSP &SA

期末專題 TSP &SA. 12. 1. 2. 1. 3. 8. 2. 10. 3. 4. 給定 4 個城市的相互距離. 12. 1. 2. 1. 3. 8. 2. 10. 3. 4. 最小展開樹問題 尋找一個將四個城市最經濟的聯結. 旅行推銷員問題 Traveling Salesman Problem (TSP) 尋找一個從 (1) 出發,回到 (1) 的最短走法. 12. 1. 2. 1. 3. 8. 2. 10. 3. 4. TSP 是一個公認的難題 NP-Complete.

jael-benson
Download Presentation

期末專題 TSP &SA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 期末專題TSP &SA

  2. 12 1 2 1 3 8 2 10 3 4 給定4個城市的相互距離

  3. 12 1 2 1 3 8 2 10 3 4 最小展開樹問題尋找一個將四個城市最經濟的聯結

  4. 旅行推銷員問題Traveling Salesman Problem (TSP)尋找一個從(1)出發,回到(1)的最短走法 12 1 2 1 3 8 2 10 3 4

  5. TSP是一個公認的難題NP-Complete • 意義:我們現在無法對所有輸入找到一個有效率的解法 • 避免浪費時間尋求更佳的解法 • Ref: Horowitz & Sahni,Fundamentals of Computer Algorithms, P528.

  6. 2n相當可怕 • 像satisfiabilibility problem • 目前只有exponential algorithm,還沒有人找到polynomial algorithm (你也不妨放棄!)這一類問題是NP-Complete Problem • Garey & Johnson “Computers & Intractability”

  7. 模擬退火 回火 策略Simulated-Annealing • Local maximal  global maximal 難 題 ! • Local maximal 不是 global maximal

  8. 模擬退火法(Simulated Annealing) procedure SIMULATED-ANNEALING begin INITIALIZE ( i start, c0, L0); k := 0; i := i start; repeat for l := 1 to Lk do begin GENERATE (j form Si); Greedy if f (j) <= f (i) then I := j else if exp { [f (i) – f (j)] / ck} > random [0, 1) then I := j end; f (i) – f (j)比ck愈小愈有機會反Greedy但不要太離譜! k := k +1; CALCULATE_ LENGTH (Lk); CALCULATE_ CONTROL (Lk); until stop criterion end;

  9. TSP如何做? 從一個tour裡任取兩個edge 決定到底要不要用 取代 原則:通常還是貪心,偶而讓它反其道一下

  10. 模擬退火是一種隨機方法,只能預設一個停止時間,看天吃飯。模擬退火是一種隨機方法,只能預設一個停止時間,看天吃飯。 • 模擬退火中有許多參數,要靠經驗或實驗。

  11. Simulated Annealing(模擬退火法) Graham Kendall Artificial Intelligence Methods (G5BAIM) The University of Nottingham

  12. 大綱 • 簡介 • 模擬退火法v.s. Hill Climbing • 模擬退火法的檢測標準 • 實際退火與模擬退火之間的關係 • 演算法 • 冷卻排程 • 其他的問題 • 提高效能 • 演算法修正 • 結論

  13. 簡介 • 模擬退火法是模擬冷卻晶體的過程 • 最早是由Metropolis等人在1953年提出 • 1982年,Kirkpatrick等人將其運用在求最佳化的問題上

  14. 模擬退火法v.s. Hill Climbing • Hill Climbing是挑選鄰近點中最好的點,但這樣會有局部最大值的問題 • 模擬演算法是亂數找尋鄰近的點 • 若找到的點比立足點好,則取之 • 否則依照機率決定是否取之

  15. 模擬退火法的檢測標準 • 根據熱力學定律,在溫度為t的情況下,能量差所表現的機率如下: P(ΔE)=exp(-ΔE / kt) • k是Boltzmann’s Constant • 轉換到模擬退火法,則變成 P=exp(-c / t)>r • c是評估函數的差 • r是0~1之間的亂數

  16. 實際退火與模擬退火之間的關係

  17. 演算法 • 設定終結溫度T及初始溫度t • 若t=0,則結束冷卻 • 否則亂數找一可用之點 • 計算ΔE,若大於零則接受新的值 • 若小於零,則透過機率函數已決定是否接受新值 • 決定是否下降溫度,做進一步的搜尋

  18. 冷卻排程 • 初始溫度(Starting Temperature) • 溫度要夠高才能移動到任何的狀態 • 溫度不能太高,否則會導致在一段時間內皆用亂數在湊解答 • 如果可以知道檢測函數的最大值就可以找到最好的初始溫度 • 快速提高溫度,然後又快速降溫,直到有60%的最差解被接受 • 快速提高溫度,但慢慢降溫,並定出適當比例最差解的接受度

  19. 冷卻排程(續) • 最終溫度(Final Temperature) • 通常是零,但會耗掉許多模擬時間 • 溫度趨近於零,其周遭狀態幾乎是一樣的 • 所以尋找一個低到可接受的溫度

  20. 冷卻排程(續) • 溫度減少(Temperature Decrement) • 每次降低溫度的差距以及在同一溫度反覆尋找最適解會導致指數般成長的搜尋空間 1.以線性降溫來說 Temp=Temp-x 2.以幾何觀念來看 Temp=Temp*y (y約0.8~0.99為佳)

  21. 冷卻排程(續) • 反覆次數(Iterations at each Temperature) • 一般會定一個常數 • Lundy認為只要反覆一次,但每次降低的溫度差距必須非常小 Temp=Temp / (1+a*Temp) a是非常小的值 • 低溫需要較多反覆次數以避免找到局部最大值,但高溫則可減少次數

  22. 其他的問題 • 價值函數(Cost Function) • 用來評估解的品質 • Delta Evaluation • 求某解與其鄰近點的價值 • Partial Evaluation • 不需額外產生的計算結果就可以判斷出來解的價值

  23. 其他的問題(續) • 價值函數(Cost Function) • Hard Constraints • 在不違背合適解的條件下,所提出的強制規定 • Soft Constraints • 無論這種解是否違背條件,都算是合適解 • Hard Constraints會給一個很大的weight • Soft Constraints則是情況給予不同的weight

  24. 其他的問題(續) • 鄰近點的結構(Neighborhood Structure) • 有些結構是對稱性的,即可以從A狀態到B狀態,也可以從B狀態到A狀態 • 條件較弱(結構較鬆散)的有穩定的收斂 • 條件定的好,就可以使得在各種狀態之下都可以到達另一種狀態

  25. 其他的問題(續) • 所有解的空間(The Solution Space) • 空間小,可以展開搜尋 • 若允許不合適的解也存在的話就會加大搜尋空間 • 我們想辦法取一個適當值,期望能快速搜尋,又可避免在不利的情況下沒有好的進展

  26. 提高效能 • 初始化(Initialization) • 將原本用亂數取初始值的方式改為盡可能找出一有用的起始點 • 雜交(Hybridization) • 結合兩種以上的搜尋演算法

  27. 演算法修正 • 可接受的機率(Acceptance Probability) P(ΔE)=1- (ΔE / t) • 少計算exponential會加快速度 • 建立一個可查詢各種值的table • 冷卻(Cooling) • 花一些時間找尋最佳溫度(包括最終溫度、溫差)

  28. 演算法修正(續) • 鄰近點(Neighborhood) • 對於不好的鄰近點給予一個懲罰值 • 價值函數(Cost Function) • 利用其他演算法的價值函數來做計算

  29. 結論 • 模擬退火法已經證明可能收斂出最好解 • 要花較多的時間去搜尋各種解 • 可將模擬退火法應用於其他問題上

  30. Mathematic model Description: • A salesman transports the products to all the cities in the map. • The salesman visits each city once and only once, and returns to the starting city. • Find the shortestroute to transport to lower cost. Flash demo

  31. Mathematic model • The total distance of the plan (order) P is the function - the sum of all distances in plan. • The aim of TSP is to get the minimum of this function f(P).

  32. Design of Simulated Annealing • Simulated Annealing (SA)It’s an algorithm to find the minimum of the function. The function of the problem is discrete and complex. the discrete function of the problem minimum

  33. Design of Simulated AnnealingRule of nature • Consider the rule of nature: Substance always closes to the lowest energy state. For example: 1.The river always goes to the lower height. 2.The thing at a high temperature always goes to the lower temperature.

  34. Design of Simulated AnnealingCooling Process • Simulated Annealing (SA)It simulates cooling the solid which is a behavior of physical process. At first the solid is at a high temperature, namely has a high energy. With the solid cooling, its energy is getting lower and lower. At last, the solid reaches the lowest energy at the normal temperature. The process of cooling is known as annealing.

  35. Design of Simulated AnnealingSupposition lowest energy Similarity? minimum Lowering energy figure Discrete function figure • Notice the lowest energy state has certain similarity to the minimum of the function!!! We can design an algorithm that can find the minimum automatically as substance closing to the lowest energy state.

  36. Simulated Annealing Algorithm • I’m Sorry.Because of the time limit, I jump over introducing the detail of SA.

  37. AnalyzeEfficiency • The rate of the value of the solution and the used time is quite higher than the way to get the real minimum in traditional way.When the traditional algorithm runs for years, SA runs in only seconds.“Time is money.” It satisfies the need of time for moderns. • For economy, the management used an efficient algorithm is important for the progress of the company in modern markets. • I think SA satisfies those conditions.

  38. Analyze Expandability • SA is not only used in solving TSP. It is the general algorithm for optimization.It can solve all the complex problems forming functions. • SA isn’t only a algorithm, but also a good thought to solve problems.It can be combined with some other algorithm for concrete problems.

More Related