Simulated Annealing and Tabu Search

35
1 Simulated Annealin Simulated Annealin g and Tabu Search g and Tabu Search

description

.

Transcript of Simulated Annealing and Tabu Search

Page 1: Simulated Annealing and Tabu Search

11

Simulated Annealing and Simulated Annealing and Tabu SearchTabu Search

Page 2: Simulated Annealing and Tabu Search

22

OutlineOutline

Local SearchLocal Search Simulated AnnealingSimulated Annealing Apply SA to Vehicle Route PlanningApply SA to Vehicle Route Planning Tabu SearchTabu Search

Page 3: Simulated Annealing and Tabu Search

33

Local search methodLocal search method(1/5)(1/5) Elements of Local SearchElements of Local Search

Representation of the solutionRepresentation of the solution Evaluation functionEvaluation function;; Neighbourhood functionNeighbourhood function: to define solutions which : to define solutions which

can be considered close to a given solution.can be considered close to a given solution. Neighbourhood search strategyNeighbourhood search strategy: random and : random and

systematic search;systematic search; Acceptance criterionAcceptance criterion: first improvement, best : first improvement, best

improvement, best of non-improving solutions, improvement, best of non-improving solutions, random criteria;random criteria;

Page 4: Simulated Annealing and Tabu Search

44

Local search methodLocal search method(2/5)(2/5)

Example of Local Search Algorithm : Hill ClimbingExample of Local Search Algorithm : Hill Climbing

Local optimu

m

Initial solution

Global optimum

Neighbourhood of solution

Page 5: Simulated Annealing and Tabu Search

55

Local search methodLocal search method(3/5)(3/5)

Hill Climbing - AlgorithmHill Climbing - Algorithm

1. Pick a random point in the search space

2. Consider all the neighbors of the current state

3. Choose the neighbors with the best quality and move to that state

4. Repeat 2 thru 4 until all the neighboring states are of lower quality

5. Return the current state as the solution state

Page 6: Simulated Annealing and Tabu Search

66

Local search methodLocal search method(4/5)(4/5)

Hill Climbing – Algorithm (pseudo code)Hill Climbing – Algorithm (pseudo code)

Function HILL-CLIMBING(Problem) returns a solution state

Inputs: Problem, problem

Local variables: Current, a node

Next, a node

Current = MAKE-NODE(INITIAL-STATE[Problem])

Loop do

Next = a highest-valued successor of Current

If VALUE[Next] < VALUE[Current] then return Current

Current = Next

End

Page 7: Simulated Annealing and Tabu Search

77

Simulated annealing: The ideaSimulated annealing: The idea

Accepting improving solutions only may end up with a local minimum.

Allowing worse solutions may help us to escape local minimum.

Page 8: Simulated Annealing and Tabu Search

88

Simulated annealingSimulated annealing(1/9)(1/9) Motivated by the physical annealing process(Motivated by the physical annealing process( 例例 : : 煉鋼煉鋼 )) Material is heated and slowly cooled into a uniform structurMaterial is heated and slowly cooled into a uniform structur

ee Simulated annealing mimics this processSimulated annealing mimics this process The first SA algorithm was developed in 1953 (Metropolis)The first SA algorithm was developed in 1953 (Metropolis)

Kirkpatrick (1983) applied SA to optimization probleKirkpatrick (1983) applied SA to optimization problemsms Kirkpatrick, S , Gelatt, C.D., Vecchi, M.P. 1983. OptimizatKirkpatrick, S , Gelatt, C.D., Vecchi, M.P. 1983. Optimizat

ion by Simulated Annealing. Science, vol 220, No. 4598, pion by Simulated Annealing. Science, vol 220, No. 4598, pp 671-680p 671-680

Page 9: Simulated Annealing and Tabu Search

99

Simulated annealingSimulated annealing(2/9)(2/9) Elements of SAElements of SA

Representation of the solution (same as HC)Representation of the solution (same as HC) Evaluation function (same as HC)Evaluation function (same as HC) Neighbourhood function (same as HC)Neighbourhood function (same as HC) Neighbourhood search strategy (same as HC)Neighbourhood search strategy (same as HC) Acceptance criterionAcceptance criterion : : 根據熱力學原理衍生的公式根據熱力學原理衍生的公式

better moves are always accepted. better moves are always accepted. Worse moves are accepted by probabilityWorse moves are accepted by probability

Page 10: Simulated Annealing and Tabu Search

1010 X

f(X)

( )

Neighbourhood

of solution

E(Current point)

Current point

Neighbour

E(Neighbour)

Simulated annealingSimulated annealing(3/9)(3/9) To accept or not to accept ? To accept or not to accept ?

熱力學定律熱力學定律 : at temperature, t, the probability of an increa: at temperature, t, the probability of an increase in energy of magnitude, δE, is given byse in energy of magnitude, δE, is given by

Where k is a constant known as Boltzmann’s constantWhere k is a constant known as Boltzmann’s constantBoltzmann constant = 1.3806503 × 10Boltzmann constant = 1.3806503 × 10-23-23 m m22 kg s kg s-2-2 K K-1-1

P(.) = exp(-E /kt)

Page 11: Simulated Annealing and Tabu Search

1111

Simulated annealingSimulated annealing(4/9)(4/9)

To accept or not to accept - SA?To accept or not to accept - SA?

WhereWhere c is change in the evaluation functionc is change in the evaluation function t the current temperaturet the current temperature r is a random number between 0 and 1r is a random number between 0 and 1

P = exp(-c/t) > r

Page 12: Simulated Annealing and Tabu Search

1212

Change inEvaluationFunction

Temperatureof System exp(-C/T)

Change inEvaluationFunction

Temperatureof System exp(-C/T)

10 100 0.904837418 10 10 0.36787944120 100 0.818730753 20 10 0.13533528330 100 0.740818221 30 10 0.04978706840 100 0.670320046 40 10 0.01831563950 100 0.60653066 50 10 0.00673794760 100 0.548811636 60 10 0.00247875270 100 0.496585304 70 10 0.00091188280 100 0.449328964 80 10 0.00033546390 100 0.40656966 90 10 0.00012341

100 100 0.367879441 100 10 4.53999E-05110 100 0.332871084 110 10 1.67017E-05120 100 0.301194212 120 10 6.14421E-06130 100 0.272531793 130 10 2.26033E-06140 100 0.246596964 140 10 8.31529E-07150 100 0.22313016 150 10 3.05902E-07160 100 0.201896518 160 10 1.12535E-07170 100 0.182683524 170 10 4.13994E-08180 100 0.165298888 180 10 1.523E-08190 100 0.149568619 190 10 5.6028E-09200 100 0.135335283 200 10 2.06115E-09

SImulated Annealing Acceptance Probability

00.10.20.30.40.50.60.70.80.9

1

1 3 5 7 9 11 13 15 17 19

Change in Evaluation

Pro

bab

ility

of

Acc

epta

nce

Temp = 100

Temp = 10

Page 13: Simulated Annealing and Tabu Search

1313

Simulated annealingSimulated annealing(5/9)(5/9) To accept or not to accept - SA?To accept or not to accept - SA? The probability of accepting a worse state is a The probability of accepting a worse state is a

function of both the function of both the temperature of the systemtemperature of the system and and the the change in the cost functionchange in the cost function

As the As the temperature decreasestemperature decreases, the , the probabilityprobability of of accepting worse moves accepting worse moves decreasesdecreases

If If t=0t=0, no worse moves are accepted (i.e. , no worse moves are accepted (i.e. hill hill climbingclimbing))

Page 14: Simulated Annealing and Tabu Search

1414

Simulated annealingSimulated annealing(6/9)(6/9) The most common way of implementing an SAThe most common way of implementing an SA

To implement hill climbing and modify the accept function for SATo implement hill climbing and modify the accept function for SAFunction SIMULATED-ANNEALING(Problem, Schedule) returns a solution state

Inputs: Problem, a problemSchedule, a mapping from time to temperatureLocal Variables : Current, a nodeNext, a nodeT, a “temperature” controlling the probability of downward steps

Current = MAKE-NODE(INITIAL-STATE[Problem])For t = 1 to do

T = Schedule[t] // Cooling Scheduleif T = 0 then return CurrentNext = a randomly selected successor of CurrentE = VALUE[Next] – VALUE[Current]if E > 0 then Current = Nextelse Current = Next only with probability exp(-E/T)

End

Page 15: Simulated Annealing and Tabu Search

1515

Simulated annealingSimulated annealing(7/9)(7/9) The The cooling schedulecooling schedule is hidden in this algorithm, but it is i is hidden in this algorithm, but it is i

mportant mportant SA assumes that annealing will continue until temperature iSA assumes that annealing will continue until temperature i

s s zerozero SA Cooling ScheduleSA Cooling Schedule

Starting TemperatureStarting Temperature Final TemperatureFinal Temperature

Approach to zeroApproach to zero : : the system is “frozen”the system is “frozen” Temperature DecrementTemperature Decrement Iterations at each temperatureIterations at each temperature

Page 16: Simulated Annealing and Tabu Search

1616

Simulated annealingSimulated annealing(8/9)(8/9)

Temperature DecrementTemperature Decrement LinearLinear

temp = temp - xtemp = temp - x GeometricGeometric

temp = temp * temp = temp * Experience has shown that α should be between 0.8 and 0.99Experience has shown that α should be between 0.8 and 0.99 the higher the value of α, the longer the system will run.the higher the value of α, the longer the system will run.

Iterations at each temperatureIterations at each temperature A constant number of iterations at each temperatureA constant number of iterations at each temperature only do one iteration at each temperature, but to decrease the only do one iteration at each temperature, but to decrease the

temperature very slowly(Lundy, 1986) temperature very slowly(Lundy, 1986)

Page 17: Simulated Annealing and Tabu Search

1717

Simulated annealingSimulated annealing(9/9)(9/9)

Iterations at each temperatureIterations at each temperature The formula used by Lundy isThe formula used by Lundy is

where β is a suitably small valuewhere β is a suitably small value An alternative : dynamically change the number of An alternative : dynamically change the number of

iterationsiterations At lower temperatures ; a large number of iterations are done At lower temperatures ; a large number of iterations are done

so that the local optimum can be fully exploredso that the local optimum can be fully explored

At higher temperatures, the number of iterations can be lessAt higher temperatures, the number of iterations can be less

t = t/(1 + βt)

Page 18: Simulated Annealing and Tabu Search

1818

SA ApplicationSA Application

Apply SA to the Vehicle Route PlanningApply SA to the Vehicle Route Planning

Page 19: Simulated Annealing and Tabu Search

1919

物流中心車輛配送路線問題之求解物流中心車輛配送路線問題之求解

20002000 年 人工智慧研討會年 人工智慧研討會

8989 年年 1111 月月 1717 日日

Page 20: Simulated Annealing and Tabu Search

2020

緒緒 論論 研究目的研究目的 研究背景研究背景 研究方法研究方法 : : 分兩階段分兩階段

1.1. 劃分車輛尋訪區域劃分車輛尋訪區域2.2. 規劃車輛在尋訪區域中的路徑規劃車輛在尋訪區域中的路徑

簡報大綱簡報大綱

Page 21: Simulated Annealing and Tabu Search

2121

問問 題題 說說 明明

目標函數目標函數 : : 最小化所有車輛總旅行距離最小化所有車輛總旅行距離限制條件限制條件 ::

1.1. 車輛之起點與終點皆為物流中心。車輛之起點與終點皆為物流中心。2.2. 車輛所尋訪顧客之總需求量車輛所尋訪顧客之總需求量 , , 小於可裝載量。小於可裝載量。3.3. 每位顧客只能且必須接受一次車輛服務。每位顧客只能且必須接受一次車輛服務。4.4. 必須滿足所有顧客之裝載需求量。必須滿足所有顧客之裝載需求量。5.5. 假設為單一物流中心。假設為單一物流中心。

Page 22: Simulated Annealing and Tabu Search

2222

物 流 中 心 示 意 圖物 流 中 心 示 意 圖

顧 客

物流中心

車輛路徑

Page 23: Simulated Annealing and Tabu Search

2323

研研 究究 方方 法法 第一階段:劃分車輛尋訪區域第一階段:劃分車輛尋訪區域

啟發式演算法 啟發式演算法 (by us)(by us) 第二階段:車輛尋訪路線規劃第二階段:車輛尋訪路線規劃

應用模擬退火法應用模擬退火法 求解 求解 VRP VRP 之演算法:結合以上兩階段之演算法:結合以上兩階段

Page 24: Simulated Annealing and Tabu Search

2424

階段一:劃分車輛尋訪區域階段一:劃分車輛尋訪區域

13

1

234

6

5

7 8

9 10 11

12

θ

第 1 輛車巡訪區域

第 2 輛車巡訪區域

第 3 輛車巡訪區域

第 4 輛車巡訪區域

排序後順序

Page 25: Simulated Annealing and Tabu Search

2525

階段一:尋訪區域劃方方法階段一:尋訪區域劃方方法

平均載運量

差距較小,列為同一區。

1 2 3 4 … 顧 客

Page 26: Simulated Annealing and Tabu Search

2626

階段二:車輛尋訪路經規劃階段二:車輛尋訪路經規劃- - 模擬退火程序模擬退火程序

反轉前的總距離: Eold 反轉後的總距離: Enew

△E = Enew - Eold

18

26

3

45

7

12

6

37

8

45

反轉2,3,4,5,6,7

接受新的解 Xnew△E 0≦△E > 0

隨 機 數h<exp(- E /T)△

?

接受新的解 Xnew

Yes

捨棄新的解 Xnew

No

Page 27: Simulated Annealing and Tabu Search

2727

求解 求解 VRP VRP 之演算法之演算法

… … …

… … …

1

尋訪區域

旋轉方向

總旅行距離 D1

1

總旅行距離 D2

1

總旅行距離 D12

最佳解 = path :

max {D1, D2,…,D12}

Page 28: Simulated Annealing and Tabu Search

2828

.

實實 例例 驗驗 證證

0 10 20 30 40 50 60 70 80 90 1000

10

20

30

40

50

60

70

80

90

100

1

2

3

4

56

7

8

9

10

11

12

13

1415

16

1718

19

20

21

22

2324

25

26

2728

29

30

3132

33

34

35

36

37

38

39

40

41

42

43

4445

46

47

48

49

50

範 例 說 明•物流中心位置 : (50,50)•車輛裝載限制 : 220•顧客總需求量 : 1210•總車輛數 : 6•資料來源 : 蘇純增與陳信翰 演 算 結 果

最佳總旅行距離 = 852.82

VS. 蘇與陳 之結果

最佳總旅行距離 = 853.49

Page 29: Simulated Annealing and Tabu Search

2929

比比 較較 結結 果果 比較的範例比較的範例問題問題 顧客數顧客數 車輛數車輛數 總需總需

求量求量原始載原始載重限制重限制

放寬載放寬載重限制重限制

11 5050 55 777777 160160 170170

22 7575 1010 13641364 140140 151151

33 100100 88 14581458 200200 203203

44 150150 1212 22352235 200200 207207

Page 30: Simulated Annealing and Tabu Search

3030

比較結果比較結果

與其他方法在總旅行距離的比較與其他方法在總旅行距離的比較 問題問題 方 法方 法

11 22 33 44 55 66 77 本法本法

11 585585 574574 532532 53453433 550550 52452422 535535 52352311

22 900900 893893 874874 871871 883883 85785711 87087033 86486422

3 3  886886 869869 85185133 85185133 85185133 83383311 85085022 85185133

44 12041204 11851185 1079107933 1064106422 10931093 1014101411 10951095 10891089

Page 31: Simulated Annealing and Tabu Search

3131

結結 論論 與與 建建 議議

1.1. 結結 論論1.1. 提出一種簡單的 提出一種簡單的 VRPVRP 演算法。演算法。2.2. 以兩階段分派車輛運送路線。以兩階段分派車輛運送路線。3.3. 比較結果屬於次優,仍有改善空間。比較結果屬於次優,仍有改善空間。

2.2. 建建 議議1.1. FuzzyFuzzy Clustering Clustering 可應用於車輛區域可應用於車輛區域

的劃分。的劃分。2.2. 兩段式 兩段式 Fuzzy ClusteringFuzzy Clustering 可應用於多可應用於多

物流中心之車輛路線規劃問題。物流中心之車輛路線規劃問題。

Page 32: Simulated Annealing and Tabu Search

3232

Tabu searchTabu search(1/4)(1/4)

Tabu SearchTabu Search Proposed independently by Glover(1986) and Hansen(19Proposed independently by Glover(1986) and Hansen(19

86);86); Tabu search is Tabu search is

"a meta-heuristic "a meta-heuristic superimposedsuperimposed on another heuristic" on another heuristic" "The overall approach is to avoid entrapment in cycles by "The overall approach is to avoid entrapment in cycles by forbiforbi

dding or penalizing movesdding or penalizing moves which take the solution, in the next i which take the solution, in the next iteration, to points in the solution space teration, to points in the solution space previously visitedpreviously visited (henc(hence tabu).e tabu).""

Page 33: Simulated Annealing and Tabu Search

3333

Tabu searchTabu search(2/4)(2/4)

Tabu SearchTabu Search Accepts non-improving solutions deterministicallyAccepts non-improving solutions deterministically

in order to escape from local optima in order to escape from local optima by guiding a steepest descent local search (or steepest asby guiding a steepest descent local search (or steepest as

cent hill climbing ) algorithm;cent hill climbing ) algorithm; Uses of memory to:Uses of memory to:

prevent the search from prevent the search from revisiting previously visitedrevisiting previously visited sol solutions;utions;

explore the unvisited areasexplore the unvisited areas of the solution space; of the solution space;

Page 34: Simulated Annealing and Tabu Search

3434

Tabu searchTabu search(3/4)(3/4)FunctionFunction TABU_SEARCH ( TABU_SEARCH (ProblemProblem)) returns returns a solution state a solution state

InputsInputs: : ProblemProblem, a problem, a problemLocal VariablesLocal Variables : : Current,Current, a state a stateNext,Next, a state a stateBestSolutionSeen,BestSolutionSeen, a state a stateHH, a history of visited states, a history of visited states

Current Current = MAKE-NODE(INITIAL-STATE[= MAKE-NODE(INITIAL-STATE[ProblemProblem])])

While not terminteWhile not terminteNextNext = a highest-valued successor of = a highest-valued successor of CurrentCurrentifif ( (notnot Move_Tabu( Move_Tabu(HH, , NextNext) ) oror Aspiration( Aspiration(NextNext)))) then then

Current Current = = NextNextUpdate Update BestSolutionSeenBestSolutionSeenH H = Recency(= Recency(HH + + CurrentCurrent))

EndifEndifEnd-WhileEnd-WhileReturnReturn BestSolutionSeen BestSolutionSeen

Page 35: Simulated Annealing and Tabu Search

3535

Tabu searchTabu search(4/4)(4/4) Elements of Tabu SearchElements of Tabu Search

Tabu ListTabu List (short term memory): to record a limited number of attributes (short term memory): to record a limited number of attributes of solutions (moves, selections, assignments, etc) to be discouraged in orof solutions (moves, selections, assignments, etc) to be discouraged in order to prevent revisiting a visited solution;der to prevent revisiting a visited solution;

Tabu tenureTabu tenure: number of iterations a tabu move is considered to remain ta: number of iterations a tabu move is considered to remain tabu;bu;

Aspiration criteriaAspiration criteria: accepting an improving solution even if generated by : accepting an improving solution even if generated by a tabu movea tabu move

Similar to SA in always accepting improving solutions, but accepting non-improvinSimilar to SA in always accepting improving solutions, but accepting non-improving ones when there is no improving solution in the neighbourhood;g ones when there is no improving solution in the neighbourhood;

Long term memoryLong term memory: to record attributes of elite solutions to be used in:: to record attributes of elite solutions to be used in: IntensificationIntensification: giving priority to attributes of a set of elite solutions (usually in wei: giving priority to attributes of a set of elite solutions (usually in wei

ghted probability manner)ghted probability manner) DiversificationDiversification: Discouraging attributes of elite solutions in selection functions in o: Discouraging attributes of elite solutions in selection functions in o

rder to diversify the search to other areas of solution space;rder to diversify the search to other areas of solution space;