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

5 minute read

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


์ง€๋‚œ๋ฒˆ์— ์‚ดํŽด๋ณธ <Backtracking>๊ณผ ๋น„์Šทํ•˜๊ฒŒ <Branch-and-Bound> ํ…Œํฌ๋‹‰ ์—ญ์‹œ partial solution์„ ๊ฒ€์‚ฌํ•ด Search Space๋ฅผ ์ค„์ด๋Š” ํ…Œํฌ๋‹‰์ด๋‹ค. <Bracktracking>๊ณผ ์ „์ฒด์ ์ธ ๊ตฌ์กฐ๋Š” ์™„์ „ ๋™์ผํ•œ๋ฐ, partial solution์„ bound๋ฅผ ์‚ฌ์šฉํ•ด $\text{test}$ํ•œ๋‹ค๋Š” ๊ตฌ์ฒด์ ์ธ ๋ฐฉ๋ฒ•์ด ๋ช…์‹œ๋˜์–ด ์žˆ๋‹ค.

๋Œ€์ถฉ ์–ด๋–ค ๋Š๋‚Œ์ธ์ง€ ํ›‘๊ณ  ๊ฐ€์ž. ๋งŒ์•ฝ ์šฐ๋ฆฌ๊ฐ€ minimization problem์„ ํ’€๊ณ  ์žˆ๋‹ค๊ณ  ํ•˜์ž. ๊ทธ๋ฆฌ๊ณ  partial solution $S_i$๋ฅผ ํƒ์ƒ‰ํ•˜๊ณ  ์žˆ๋‹ค๊ณ  ํ•˜์ž. ์šฐ๋ฆฌ๋Š” ์ด partial solution $S_i$๋ฅผ ๋” ํ™•์žฅํ–ˆ์„ ๋•Œ์˜ ์ž ์žฌ์ ์ธ ๋น„์šฉ์„ โ€˜์˜ˆ์ƒโ€™ํ•  ๊ฒƒ์ด๋‹ค. ๊ตฌ์ฒด์ ์ธ ๋น„์šฉ์„ ๊ตฌํ•˜๋ ค๊ณ  ํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ โ€˜์˜ˆ์ƒโ€™์ด๊ธฐ ๋•Œ๋ฌธ์— โ€˜lower boundโ€™๋ฅผ ๊ณ„์‚ฐํ•  ๊ฒƒ์ด๋‹ค. ์‚ฌ๋ก€๋ฅผ ๋ณด๋ฉด ์ข€๋” ์ดํ•ด๊ฐ€ ๋น ๋ฅผ ๊ฒƒ์ด๋‹ค. <TSP> ๋ฌธ์ œ๋ฅผ <Branch-and-Bound>๋กœ ํ•ด๊ฒฐํ•˜๋Š” ๊ณผ์ •์„ ์‚ดํŽด๋ณด์ž!


TSP with Branch-and-Bound

Complete weighted graph $G = (V, E)$๋ฅผ ์ƒ๊ฐํ•ด๋ณด์ž. ์šฐ๋ฆฌ๋Š” ์ง€๊ธˆ $a$์—์„œ ์ถœ๋ฐœํ•ด $b$์— ๋„๋‹ฌํ•˜๋Š” partial solution์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค. ์ด partial solution์€ vertex set $S$์˜ ์›์†Œ๋“ค์„ ์ •ํ™•ํžˆ ํ•œ๋ฒˆ์”ฉ ์ง€๋‚˜๊ฐ€๋Š” Hamilton Path๋‹ค. ์ด partial solution์„ $[a, S, b]$๋กœ ํ‘œํ˜„ํ•˜๊ฒ ๋‹ค.

partial solution $[a, S, b]$๋ฅผ ํ™•์žฅํ•ด๋ณด์ž. ๊ทธ๊ฒƒ์€ $S$๋ฅผ ์ œ์™ธํ•œ vertex $x \in V \setminus S$ ์ค‘์— ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•ด $(b, x)$ edge๋ฅผ ์ถ”๊ฐ€ํ•ด ํ•ด๋ฐ€ํ„ด ๊ฒฝ๋กœ๋ฅผ ํ™•์žฅํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ์ด๋ ‡๊ฒŒ ํ•  ๊ฒฝ์šฐ, ๋‚จ์€ ์ •์  ์ˆ˜ $\left| V \setminus S \right|$๋งŒํผ์˜ subproblem $[a, S \cup \{ x \}, x]$๊ฐ€ ์ƒˆ๋กœ ์ƒ์„ฑ๋œ๋‹ค.

์—ฌ๊ธฐ๊นŒ์ง€ <TSP> ๋ฌธ์ œ๋ฅผ ํƒ์ƒ‰๊ณผ subproblem์˜ ๊ด€์ ์—์„œ ๊ธฐ์ˆ ํ•ด๋ณธ ๊ฒƒ์ด๋‹ค.


์šฐ๋ฆฌ๋Š” partial solution $[a, S, b]$๋ฅผ ํ™•์žฅํ•˜๊ธฐ ์ „์—, ๋‚จ์€ vertex set $V \setminus S$๋ฅผ ํ†ตํ•ด TSP์˜ lower bound๋ฅผ ๊ตฌํ•  ์ˆ˜ ์žˆ๋‹ค! lower bound๋ฅผ ๊ตฌํ•˜๋Š” ์—ฌ๋Ÿฌ ๋ฐฉ๋ฒ•๋“ค์ด ์žˆ๊ฒ ์ง€๋งŒ, ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์€ ์•„๋ž˜ 4๊ฐ€์ง€ ๋น„์šฉ์˜ ํ•ฉ์„ lower bound๋กœ ์‚ผ๋Š” ๊ฒƒ์ด๋‹ค.

  • the lightest edge from $a$ to $V \setminus S$
  • the lightest edge from $b$ to $V \setminus S$
  • the minimum spanning tree of $V \setminus S$
  • and current cost of partial solution

๊ฐ๊ฐ ๋ชจ๋‘ $V \setminus S$์˜ ์ •์ ์œผ๋กœ partial solution์„ ํ™•์žฅ ํ–ˆ์„ ๋•Œ ๊ฐ€๋Šฅํ•œ ๊ฐ€์žฅ ์ตœ์†Œ ์ˆ˜์ค€์˜ ๋น„์šฉ์ด๋‹ค. ๊ทธ๋ž˜ํ”„์˜ MST๋ฅผ ๊ตฌํ•˜๋Š” ๊ฒƒ์€ polynomial-time์œผ๋กœ ๊ฐ€๋Šฅํ•˜๊ธฐ์— ๋ณต์žก๋„์— ํฐ ์˜ํ–ฅ์„ ์ฃผ์ง€๋„ ์•Š๋Š”๋‹ค. ๋”ฐ๋ผ์„œ ์ด๋ฅผ lower bound๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์€ ์ ์ ˆํ•˜๋‹ค!


์ข€๋” ๊ตฌ์ฒด์ ์ธ ์˜ˆ๋ฅผ ํ†ตํ•ด ์ต์ˆ™ํ•ด์ ธ๋ณด์ž!

์œ„์™€ ๊ฐ™์€ Graph์—์„œ TSP ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•œ๋‹ค๊ณ  ํ•ด๋ณด์ž. ์ผ๋‹จ $A$ ๋…ธ๋“œ์—์„œ ์‹œ์ž‘ํ•˜๋Š” ํƒ์ƒ‰ ํŠธ๋ฆฌ๋ฅผ ํ™•์žฅํ•ด๊ฐ€์ž.

ํŠธ๋ฆฌ ๋…ธ๋“œ ์˜†์˜ ์ƒ์ž์—” ํ•ด๋‹น ๋…ธ๋“œ์˜ lower bound๊ฐ€ ์ ํ˜€์žˆ๋‹ค. DFS ๋ฐฉ์‹์„ ํ†ตํ•ด ํŠธ๋ฆฌ๋ฅผ ํƒ์ƒ‰ํ•œ๋‹ค๊ณ  ํ•˜๋ฉด, ๊ฐ€์žฅ ๋จผ์ € $H$ ๋…ธ๋“œ๋กœ ๋๋‚˜๋Š” ์™ผ์ชฝ ๊ฒฝ๋กœ๋ฅผ ํƒ€๊ฒŒ ๋œ๋‹ค. ์ด๋•Œ์˜ total cost๊ฐ€ 11์ธ๋ฐ, ์ด๊ฒƒ์„ $\text{bestsofar}$ ๊ฐ’์œผ๋กœ ์ €์žฅํ•ด๋‘๊ณ  ๋‹ค์Œ ๋…ธ๋“œ๋ฅผ ์„ ํƒํ•ด ํ™•์žฅํ•ด๊ฐ„๋‹ค.

ํ˜„์žฌ ๋น„์šฉ 11์ด $\text{bestsorfar}$ ๊ฐ’์ด๋‹ค. ๋งŒ์•ฝ ๋‹ค์Œ partial solution์„ ํƒ์ƒ‰ํ–ˆ์„ ๋•Œ, ๋น„์šฉ์˜ lower bound๊ฐ€ $\text{bestsorfar} = 11$๋ณด๋‹ค ํฌ๋‹ค๋ฉด ํ•ด๋‹น ๋…ธ๋“œ๋Š” ํƒ์ƒ‰ํ•  ํ•„์š”๊ฐ€ ์—†๋‹ค!

์ด ๋ฐฉ๋ฒ•์„ ํ™œ์šฉํ•ด partial solution๋“ค์„ rejectํ•˜๊ณ  lower bound๊ฐ€ ์ ์ ˆํžˆ ๋‚ฎ์€ partial solution๋“ค๋งŒ ํ™•์žฅํ•ด๊ฐ„๋‹ค. ์ตœ์ข…์ ์œผ๋กœ๋Š” $\text{bestsorfar} = 8$์„ solution์œผ๋กœ ๋ฆฌํฌํŠธํ•œ๋‹ค.


Overview

To expand a subproblem, its lower bound should be smaller than the bestsofar. Otherwise, itโ€™s clear that the cost of subproblem will exceed the bestsofar, so reject it!

<Branch-and-Bound> ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ์›๋ฆฌ๋ฅผ ์š”์•ฝํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

Start with some problem $P_0$

Let $S = \{ P_0 \}$, the set of active subproblems.

Set $\text{bestsofar} = \inf$

while $S$ is non-empty:
ย ย choose a subproblem $P \in S$ and remove it from $S$.
ย ย expand it into smaller subproblems $P_1, P_2, \dots, P_k$
ย ย for each $P_i$:
ย ย ย ย if $P_i$ is a complete solution: update $\text{bestsofar}$
ย ย ย ย else: if $\text{lowerbound}(P_i) < \text{bestsofar}$, then add $P_i$ to $S$.

return $\text{bestsofar}$

์ด์ „์— ์‚ดํŽด๋ณธ <Backtracking>๊ณผ ํฐ ํ‹€์—์„œ ๋น„์Šทํ•˜๋‹ค! ๋‹จ์ง€ <Branch-and-Bound>๊ฐ€ $\text{test}(P_i)$๋ฅผ lower bound๋กœ ํŒ๋‹จํ•˜๊ณ  ๊ตฌ์ฒด์ ์œผ๋กœ ๋ช…์‹œ๋˜์–ด ์žˆ์„ ๋ฟ์ด๋‹ค!

ํ•จ๊ป˜๋ณด๊ธฐ

Categories:

Updated: