2020-1ํ•™๊ธฐ, ๋Œ€ํ•™์—์„œ โ€˜์•Œ๊ณ ๋ฆฌ์ฆ˜โ€™ ์ˆ˜์—…์„ ๋“ฃ๊ณ  ๊ณต๋ถ€ํ•œ ๋ฐ”๋ฅผ ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. ์ง€์ ์€ ์–ธ์ œ๋‚˜ ํ™˜์˜์ž…๋‹ˆ๋‹ค :)

6 minute read

2020-1ํ•™๊ธฐ, ๋Œ€ํ•™์—์„œ โ€˜์•Œ๊ณ ๋ฆฌ์ฆ˜โ€™ ์ˆ˜์—…์„ ๋“ฃ๊ณ  ๊ณต๋ถ€ํ•œ ๋ฐ”๋ฅผ ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. ์ง€์ ์€ ์–ธ์ œ๋‚˜ ํ™˜์˜์ž…๋‹ˆ๋‹ค :)


์ด์ „์˜ ๋‘ ํฌ์ŠคํŠธ, <Backtracking>๊ณผ <Branch-and-Bound>๋Š” Exhausitive Search ๋ฐฉ์‹์ด์—ˆ๋‹ค. ์ด๋ฒˆ์— ์‚ดํŽด๋ณด๋Š” <Local Search>๋Š” Heuristic Algorithm์˜ ์ผ์ข…์œผ๋กœ โ€œOptimality of the solutionโ€๋ฅผ ํฌ์ƒํ•ด ๋น ๋ฅด๊ฒŒ solution์„ ์ฐพ๋Š” ๊ธฐ๋ฒ•์ด๋‹ค.

<Local Search>๋Š” ํ˜„์žฌ์˜ partial solution์—์„œ ๊ฐ€๊นŒ์šด ์ด์›ƒ solution์„ ํƒ์ƒ‰ํ•ด ๊ทธ ์ค‘ ๊ฐ€์žฅ ์ข‹์€ ๋…€์„์œผ๋กœ partial solution์„ ๊ฐฑ์‹ ํ•˜๋Š” ๊ธฐ๋ฒ•์ด๋‹ค.

incremental process of introducing small mutations and keeping them if they work well!

์ด๋ฒˆ์—๋„ <TSP> ๋ฌธ์ œ๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ <Local Search>๋ฅผ ์ข€๋” ์ดํ•ดํ•ด๋ณด์ž.


์šฐ์„  ์—ฌ๊ธฐ์„œ์˜ <TSP> partial solution์€ ์–ด๋–ค Hamilton Cycle์ด๋‹ค. ๊ทธ๋ž˜ํ”„๊ฐ€ Complete Graph๋ผ๋ฉด, ๋‹น์—ฐํžˆ Hamilton Cycle์ด ์กด์žฌ ํ•  ๊ฒƒ์ด๋‹ˆ ์ผ๋‹จ ํ•˜๋‚˜๋ฅผ ๋งŒ๋“ค์–ด ๋‘”๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์ด partial solution์„ ์•„์ฃผ ์•ฝ๊ฐ„ ์ˆ˜์ •ํ•ด neighborhood solution์„ ๋งŒ๋“ ๋‹ค. ์„œ๋กœ ๋‹ค๋ฅธ ๋‘ ํˆฌ์–ด(tour)๊ฐ€ ์„œ๋กœ ์–ผ๋งˆ๋‚˜ ๊ฐ€๊นŒ์šด์ง€, ์„œ๋กœ ์ด์›ƒ์ธ์ง€๋ฅผ ์–ด๋–ป๊ฒŒ ์ •์˜ํ• ๊นŒ?

์šฐ๋ฆฌ๋Š” cycle์„ ๋‹ค๋ฃจ๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์—, ๋‘ cycle์ด ํ•˜๋‚˜์˜ edge๋งŒ ๋‹ค๋ฅผ ์ˆœ ์—†๋‹ค. ์ ์–ด๋„ 2๊ฐœ์˜ edge๋ฅผ ๋ฐ”๊ฟ”์ค˜์•ผ ์ƒˆ๋กœ์šด cycle์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ๊ทธ๋ž˜์„œ ์šฐ๋ฆฌ๋Š” โ€œ2-change neighborhoodโ€๋ผ๊ณ  2๊ฐœ์˜ edge๊ฐ€ ๋ฐ”๊ฟ” partial solution์˜ neighborhood solution์„ ์ƒ์„ฑํ•˜๊ฒ ๋‹ค.

Let $s$ be any initial solution.

while there is some solution $sโ€™$ in the neighborhood of $s$
ย ย for which $\text{cost}(sโ€™) < \text{cost}(s)$: replace $s$ by $sโ€™$.

return $s$.

์ด ๋ฐฉ์‹์€ ์ •๋ง ๋น ๋ฅด๋‹ค. ์–ด๋–ค partial solution์ด๋ผ๋„ 2-change neighborhood๋Š” $O(n^2)$ ๋งŒํผ ์กด์žฌํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ iteration์„ โ€˜์–ธ์ œโ€™ ๋ฉˆ์ถฐ์•ผ ํ• ์ง€๋Š” ์ •ํ•ด์ง€์ง€ ์•Š์•˜๋‹ค. ์šด์ด ์•ˆ ์ข‹์œผ๋ฉด ํ‰์ƒ iteration์„ ํ•ด๋„ ์›ํ•˜๋Š” solution์— ๋„๋‹ฌํ•˜์ง€ ๋ชปํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๊ฒƒ์ด <Local Search>์˜ ๋‹จ์ ์ธ๋ฐ, ํƒ์ƒ‰์„ ํ†ตํ•ด ์ฐพ์€ final solution์ด optimal solution์ž„์„ ๋‹จ์–ธํ•  ์ˆ˜ ์—†๋‹ค. ๊ทธ๊ฒƒ์€ ๋‹จ์ง€ local optimal solution์ผ ๋ฟ์ด๋‹ค!

์ด๊ฒƒ์„ ํ•ด๊ฒฐํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, ์ด์›ƒ์˜ ์ •์˜๋ฅผ ์ข€๋” ๋„“๊ฒŒ ์žก์œผ๋ฉด ๋œ๋‹ค. 3๊ฐœ์˜ edge๊ฐ€ ๋‹ค๋ฅธ ๋…€์„๋„ ์ด์›ƒ์œผ๋กœ ๋ณด๊ณ , 4๊ฐœ์˜ edge๋„ ์ด์›ƒ์œผ๋กœ ๋ณธ๋‹ค๋ฉด, ๋” ๋„“์€ ๋ฒ”์œ„๋ฅผ ํ›„๋ณด๋กœ ์žก์•„ ์ฃผ๋ณ€ ๋…€์„๊ณผ ๋น„๊ตํ•ด ์ข€๋” ์ข‹์€ ๋…€์„์œผ๋กœ solution์„ ๊ฐฑ์‹ ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ์ด๋‹ค.

๊ทธ๋Ÿฌ๋‚˜ ์ด๋ ‡๊ฒŒ ์ด์›ƒ์˜ ์ •์˜๋ฅผ ํ™•์žฅํ•œ๋‹ค๋ฉด, ํ•œ iteration์—์„œ ํƒ์ƒ‰ํ•ด์•ผ ํ•  ์ด์›ƒ์˜ ์ˆ˜๊ฐ€ ๋Š˜์–ด๊ฐ€๊ฒŒ ๋œ๋‹ค. 3-change neighborhood๋ผ๋ฉด $O(n^3)$์˜ ๋น„์šฉ์ด ๋“ค๊ฒŒ ๋œ๋‹ค. ๊ทธ๋ž˜์„œ optimality์™€ complexity ์‚ฌ์ด์˜ ์ ์ ˆํ•œ ์ˆ˜์ค€์œผ๋กœ ํƒ€ํ˜‘ํ•ด Neighborhood-ness๋ฅผ ๊ฒฐ์ •ํ•˜๋„๋ก ํ•˜์ž.

Dealing with local optima: Simulated Annealing

<Local Search>๋Š” solution์˜ optimality๋ฅผ ๋ณด์žฅํ•˜์ง€ ๋ชปํ•œ๋‹ค๋Š” ๋‹จ์ ์ด ์žˆ๋‹ค. ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, ๋‹จ์ˆœํžˆ ์ƒˆ๋กœ์šด starting point์—์„œ <Local Search>๋ฅผ ์ˆ˜ํ–‰ํ•ด ์ƒˆ๋กœ์šด solution์„ ์–ป๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์„ ๊ฒƒ์ด๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ๋ฌด์‹ํ•˜๊ฒŒ Restart ํ•˜๋Š” ๊ฒƒ์€ ํƒ์ƒ‰ ๊ณต๊ฐ„์ด ๋ฌด์ง€๋ฌด์ง€ ํฌ๋‹ค๋ฉด, ์ •๋ง ๋งŽ์€ staring point๊ฐ€ ์กด์žฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ข‹์€ solution์„ ์ฐพ์„ ๊ฐ€๋Šฅ์„ฑ์ด ํฌ๊ฒŒ ์ค„์–ด๋“ ๋‹ค.

๊ทธ๋ž˜์„œ ์•ฝ๊ฐ„์˜ ํฌ์šฉ์„ฑ์„ ๊ฐ€์ง„ <Local Search> ๋ฐฉ์‹์ด ์ œ์‹œ๋˜์—ˆ๋‹ค. ์—ฌ๋Ÿฌ๋ฒˆ Restart ํ•˜๋Š” ๋Œ€์‹  ํ™•๋ฅ ์ ์œผ๋กœ bad solution์„ ํƒ์ƒ‰ํ•จ์œผ๋กœ์จ Restart์˜ ๋žœ๋ค์„ฑ์„ ํ™•๋ณดํ•œ๋‹ค.

Occasionally allow moves that actually increase the cost, in the hope that they will pull the search out of dead ends.

Let $s$ be any starting solution.

repeat
ย ย randomly choose a solution $sโ€™$ in the neighborhood of $s$
ย ย if $\text{cost}(sโ€™) < \text{cost}(s)$:
ย ย ย ย replace $s$ by $sโ€™$
ย ย else:
ย ย ย ย replace $s$ by $sโ€™$ with probability $p$

return $s$.


๊ทธ๋Ÿฌ๋‚˜ ์ด๋ ‡๊ฒŒ ํ•  ๊ฒฝ์šฐ, (์ •๋ง ์šด์ด ๋‚˜์˜๋ฉด) global solution ๋ฐ”๋กœ ์•ž์—์„œ randomly pickํ•œ neighbor๋กœ ๊ฐ€๋ฒ„๋ฆด ์ˆ˜ ์žˆ์„ ๊ฒƒ์ด๋‹ค. ์ด๋Ÿฐ ์ƒํ™ฉ์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด iteration์„ ์ง„ํ–‰ํ•  ์ˆ˜๋ก probability $p$์˜ ๊ฐ’์„ ์ค„์—ฌ ์˜ค์ง $\text{cost}(sโ€™) < \text{cost}(s)$๋งŒ ํ—ˆ์šฉํ•˜๋„๋ก <Local Search>๋ฅผ ์„ค๊ณ„ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๊ฒƒ์„ ์œ„ํ•ด cost difference $\Delta$์™€ temperature $T$๋ฅผ ๋„์ž…ํ•œ๋‹ค.

Let $s$ be any starting solution.

repeat
ย ย randomly choose a solution $sโ€™$ in the neighborhood of $s$
ย ย if $\Delta = \text{cost}(sโ€™) - \text{cost}(s) < 0$:
ย ย ย ย replace $s$ by $sโ€™$
ย ย else:
ย ย ย ย replace $s$ by $sโ€™$ with probability $e^{-\Delta / T}$

return $s$.

cost difference $\Delta$๋Š” iteration์„ ๋Œ๋ฉด์„œ ๋™์ ์œผ๋กœ ์ •ํ•ด์ง€๋Š” ๊ฐ’์ด๋‹ค. $\Delta < 0$์ด๋ฉด, $\text{cost}$๊ฐ€ ๊ฐ์†Œํ•˜๋ฏ€๋กœ ๊ทธ๊ฑธ ์„ ํƒํ•œ๋‹ค. $\Delta > 0$๋ผ๋ฉด bad solution์ด์ง€๋งŒ, ํ™•๋ฅ  $0 \le p = e^{-\Delta / T} \le 1$์— ๋”ฐ๋ผ accept ๋˜๋Š” reject ํ•œ๋‹ค.

๋งŒ์•ฝ $T = 0$๋ผ๋ฉด, $e^{-\Delta / T} \rightarrow e^{-\inf} = 0$์ด๊ธฐ ๋•Œ๋ฌธ์— pureํ•œ <Local Search>์™€ ๊ฐ™๋‹ค. ๋งŒ์•ฝ $T > 0$๋ผ๋ฉด, $0 < e^{-\Delta / T} < 1$๋กœ ๊ฐ€๋”์‹ bad solution์œผ๋กœ ํƒ์ƒ‰ํ•˜๊ฒŒ ๋œ๋‹ค.

๊ทธ๋Ÿฐ๋ฐ temperature $T$๋กœ ์–ด๋–ค ๊ฐ’์„ ์„ค์ •ํ•ด์•ผ ํ• ๊นŒ? ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์€ ์ฒ˜์Œ์—” ํฐ ๊ฐ’์˜ $T$๋กœ ์‹œ์ž‘ํ•ด์„œ iteration์„ ๋Œ ๋•Œ๋งˆ๋‹ค $T \leftarrow T - 1$์„ ํ•ด $T$ ๊ฐ’์„ ์ ์  ์ค„์—ฌ 0์œผ๋กœ ๋งŒ๋“œ๋Š” ๊ฒƒ์ด๋‹ค. ์ด๊ฒƒ์€ <Local Search> ์ดˆ๊ธฐ์—๋Š” ์ž์œ ๋กญ๊ฒŒ search space๋ฅผ ๋Œ์•„๋‹ค๋‹ˆ๋ฉฐ local optima์—์„œ ๋ฒ—์–ด๋‚˜๋ ค๊ณ  ํ•œ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ $T$ ๊ฐ’์ด 0์œผ๋กœ ์ˆ˜๋ ดํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ ์ฐจ strict <Local Search>๋ฅผ ์ˆ˜ํ–‰ํ•˜๊ฒŒ ๋œ๋‹ค.

์œ„์™€ ๊ฐ™์€ ๋ฐฉ์‹์„ <Simulated Annealing; ๋‹ด๊ธˆ์งˆ ๊ธฐ๋ฒ•>๋ผ๊ณ  ํ•˜๋Š”๋ฐ, โ€œAnnealingโ€์€ ๊ณ ์˜จ์˜ ๊ธˆ์†์„ ์„œ์„œํžˆ ์‹ํžˆ๋Š” ๋ฐฉ์‹์ด๋ผ๊ณ  ํ•œ๋‹ค. ๋ฌผ๋ฆฌํ•™(physics)์˜ ์ฝ˜์…‰ํŠธ์—์„œ ์˜๊ฐ์„ ๋ฐ›์€ ๊ธฐ๋ฒ•์ธ๋ฐ, ์ž…์ž๋“ค์ด ๊ณ ์˜จ์—์„  ๊ธฐ์ฒด/์•ก์ฒด ์ƒํƒœ๋กœ ์ž์œ ๋กญ๊ฒŒ ์›€์ง์ด์ง€๋งŒ, ์—ด์ด ์‹์œผ๋ฉด์„œ ๊ณ ์ฒด์˜ ํ˜•ํƒœ๋กœ ๊ทœ์น™์ ์ด๊ณ  ๊ฒฐ์ •์˜ ํ˜•ํƒœ๋กœ ๋ณ€ํ•˜๋Š” ๊ฒƒ์„ ๋ชจ์‚ฌํ•œ ๊ฒƒ์ด๋‹ค.


์ด๊ฒƒ์œผ๋กœ <์•Œ๊ณ ๋ฆฌ์ฆ˜; Algorithm;>์˜ ์ •๊ทœ ์ˆ˜์—…์—์„œ ๋‹ค๋ฃฌ ๋‚ด์šฉ์„ ๋ชจ๋‘ ์‚ดํŽด๋ณด์•˜๋‹ค ๐Ÿ‘ ๋‹ค์Œ ํฌ์ŠคํŠธ์—์„œ ๊ฐ„๋‹จํ•œ ํ›„๊ธฐ๋ฅผ ์จ๋ณด๊ณ ์ž ํ•œ๋‹ค ๐Ÿ™

Categories:

Updated: