NP-困難な組合せ最適化問題に対する近似解法 -巡回セールスマン問題を例として- Traveling Salesman Problem Approximate Algorithm Implementation Experimental Analysis Metaheuristics for Combinatorial Optimization Problems Traveling Salesman Problem (TSP) Definition Given n points (cities) and a distance function between two points, find a minimum length Hamiltonian circuit a b |ab|=|ba| Symmetric TSP |ab|=|ba| otherwise b a c Asymmetric TSP |ac|≦|ab|+|bc| ΔTSP points are in d-dim. Euclidean space Euclidean TSP Icosian Game (Origin of Hamiltonian Circuit) Invented by W. R. Hamilton Icosian Game (1) 20 4 2 1 3 Icosian Game (2) 20 5 4 2 1 3 6 7 Icosian Game (3) 20 9 5 4 2 1 3 6 7 8 Icosian Game (4) 11 20 13 12 14 5 4 2 1 10 3 6 7 8 9 Icosian Game (5) 19 18 17 20 16 11 13 12 14 15 2 1 10 5 4 3 6 7 8 9 Knight Tour Knight Tour (by Leonhard Euler) Applications of TSP 基盤配線 配送計画 タンパク質構造解析 Applications clustering a data array 10 P p= 2 circuit board assembly computer wiring 3 circuit board drilling 4 vehicle routing protein conformations x-ray crystallography 5 VLSI Scan Chain Optimization 6 VLSI fabrication 7 World Record of Exact Algorithm for Euclidean Benchmarks (TSPLIB95) • Dantzig, Fulkerson & Johnson 49 cities (1954) • Held & Karp 65 cities (1971) • Crowder & Padberg 318 cities (1980) • Padberg & Rinaldi 532 cities (1987) • Grotschel & Holland 666 cities (1991) • Padberg & Rinaldi 2392 cities (1991) • Applegate, Bixby, Chvatal, & Cook 7392 cities (1996) Theoretical Results Symmetric TSP A(I)/OPT(I) ≦1.5 (Christofides’ O(n3) algorithm) A(I)/OPT(I) ≦ 1+ε for any ε>0 if d is O(1) (Arora’s O(n 12 2 13 log n/ε) algorithm) △TSP d-dimensional Euclidean TSP Assuming P ≠NP no polynomial-time algorithm can guarantee A(I)/OPT(I) ≦ 2 p(n) for any fixed polynomial p A(I)/OPT(I) ≦ 1+ε for an ε>0 A(I)/OPT(I) ≦ 1+ε for an ε>0 if d is Θ(n) Approximate Algorithms Construction – – – – – – Algorithms Nearest Neighbor Greedy Christiofides’ Insertion Karp’s Bucket Improvement Algorithm – 2,3,..k-opt – Lin-Kernighan opt Nearest Neighbor 適当な点から出発し、まだ訪問していない最も近い点へ移動する 全ての点を訪問したら出発点へもどる Nearest Neighbor (Worst Case Results) 2 Running Time : n 1 NN(I) log 2 n 1 2 OPT(I) log n NN(I) OPT(I) ∀I ∃I Greedy (Multiple Fragment) 閉路ができたり、次数が2を超えないように、枝を短い順に加えていく Greedy (Worst Case Results) 2 Running Time : n log n Greedy(I) 1 log 2 n 1 2 OPT(I) log n Greedy(I) 3 log log n OPT(I) ∀I ∃I Christofides’ (1) 奇数次数を持つ頂点に対して最小マッチングを求める 奇数次数を持つ頂点を赤く塗りつぶす 最小木を作る Christofides’ (2) まだ通過していない枝をグラフ非連結にならないようにたどる 一度通過した点をスキップすることにより、順回路をえる Christofides’ (Worst Case Results) 3 Running Time : n Christofides(I) 3 2 OPT(I) 3 2 Christofides(I) OPT(I) ∀I ∃I Convex Hull +Insertion 2 Running Time : n 凸包で点を囲むように巡回路をつくる 巡回路に入っていない,最も遠い点へ移動する Karp’s Partitioning Method (1) 長方形で、p個の点が入るように分割する 各小領域に対する最適巡回路を求める Karp’s Partitioning Method (2) 長方体と交わる点の枝を非連結にならないようにたどる Karp’s Partitioning Method Probabilisitcs Analysis BHH Theorem (Beardwood, Halton and Hammersley, 1959) 面積Aの正方領域にランダムにばらまかれた n個の点に対する lim OPT(I) = An (β≒0.7124) β=0.749 BHH (1959) too optimistic! β=0.765 Stein (1977) Bucket Running Time : n 全ての点を含む単位正方形で小領域に分割し、適当な順序をつける 決められた順序(小領域内では任意)で点を訪問する 組合せ最適化問題(概念図) 目的関数 f(x) 大域的最適解 実行可能解の集合 F 山頂を目指す闇夜の登山者 x 近傍 N(x) 2-opt,3-opt neighborhood Local Search 闇夜の登山者(ここが山頂?) 局所最適解 2-opt,3-opt,k-opt (Worst Case Results) n2 Running Time : 2 ∃I k 6 opt PLS-complete Lin Kernighan opt 1 n 4 1 6 1 n 4 1 21k n 4 A 2-opt(I) OPT(I) A 3-opt(I) OPT(I) A k-opt(I) OPT(I) ∃I A 2,3,k-opt(I) OPT(I) 4 n ∀I Implementation Geometric data structure – Bucket – Delaunay Triangulation – K-d tree Tour – – – – data structure Array Two-level Tree Segment Tree Splay Tree for solving 108 TSP within 1% of optimum Semidynamic K-d tree kdtree Build K-d tree (1) K A D E F GH J cutdim=X cutval=x(N) I B C M P L O N ABCDEPONFGHIJKML Build K-d tree (2) K A D E F GH J I B C cutdim=X cutval= X(N) cutdim=Y cutval=Y(B) M P L O N ABDECPON FGHIJKML Build K-d tree (3) : O(Kn + n log n) time K A D E F GH J I B C cutdim=X cutval= X(N) cutdim=Y cutval=Y(B) cutdim=Y cutval=Y(F) M P L O N ABDECPON FGJK HIML Delete point Delete(D) (1) D φ=0 cutdim=X cutval= X(N) K A D E F GH J I B C φ=0 φ=0 cutdim=Y cutval=Y(B) cutdim=Y cutval=Y(F) M P L O N φ=0 ABDECPON FGJK HIML φ=0 φ=0 φ=0 LOPT HIPT Delete point Delete(D) (2) D φ=0 cutdim=X cutval= X(N) K A E F GH J I B C M P L O N φ=0 φ=0 cutdim=Y cutval=Y(B) cutdim=Y cutval=Y(F) φ=0 ABEDCPON FGJK HIML LOPT HIPT φ=0 φ=0 φ=0 Delete (Undelete) point: O(1) amortized time φ=0 cutdim=X cutval= X(N) φ=0 φ=1 cutdim=Y cutval=Y(F) cutdim=Y cutval=Y(B) φ=1 φ=1 ABDECPON FGJK HIML φ=0 HIPT< LOPT φ=0 Nearest Neighbor Search Find the nearest point of point nn(E) (1) cutdim=X cutval= X(N) A D B E cutdim=Y cutval=Y(B) Find the nearest point in the same bucket! ABDE Nearest Neighbor Search Find the nearest point of point nn(E) (2) cutdim=X cutval= X(N) A D E cutdim=Y cutval=Y(B) B C Check the points in the bucket, too! P O N ABDECPON Conjecture (via experimental analysis) The expected running time is O(1). Nearest Neighbor Method nntour for TSP using K-d tree Void nntour(point_set *N, int start_point, Int *tour) { tree = new kdtree(N); // O(n log n) tour[0] = start_point; tree -> Delete( tour[0] ); for ( i=1; i < n; i++){ tour[i] =tree->nn(tour[i-1]); // O(1) (average) tree-> Delete(tour[i]); // O(1) (amortized) } } Average runing time: O(n log n) Fixed-Radius Near Neighbor frnn (E, r, f) Find the point(s) f within radius r of point E (1) cutdim=X cutval= X(N) A D B E r cutdim=Y cutval=Y(B) Check the point in the same bucket! ABDE Fixed-Radius Near Neighbor frnn (E, r, f) Find the point(s) f within radius r of point E (2) cutdim=X cutval= X(N) A D E cutdim=Y cutval=Y(B) B C Check the points in the bucket, too! P O N ABDECPON 2-opt (1) frnn(a,|ab|) b=next(a) a c |ab|+|cd| > |ac| + |bd| d=next(c) 2-opt (2) b=next(a) a c flip(a,b,c,d) d=next(c) 2-opt procedure two_opt for TSP using K-d tree Tour Database Type void two_opt (point_set *N, int *tour) Array Splay Tree { restart: (amortized) for all a ∈unserched_list) { O(1) O(log n) b = next(a); for all c ∈ frnn(a,|ab|){ O(1) O(log n) d =next (c); if (|ab|+|cd|>|ac|+bd|){ O(n) O(log n) flip(a,b,c,d); add b,c,d to unserched_list; goto restart; } Average runing time: O(n log n) } remove point a from unserched_list; } } Ball Search ballsearch(E, f) Each point has an associated radius. Query asks which balls contain a given point. K A D E F GH J I B C cutdim=X cutval= X(N) cutdim=Y cutval=Y(B) cutdim=Y cutval=Y(F) M P L O N ABDECPON FGJK HIML Balls that A,B,D,E,F,P intersect the bucket Insertion Method using K-d tree(1) ballsearch(a) a b=nn(a) Insertion Method using K-d tree(2) a Average running time: O(n log n) Tabu Search 1 に戻らないように 一番高い地点へ移動しよう! Tabu Search 2 |TL|=2 Tabu Search 3 |TL|=2 FIFO Tabu Search 4 Tabu Search 5 Tabu Search 6 Tabu Search 7 Tabu Search 8 Tabu Search 9 Tabu Search 10 Lin-Kernighan opt (=3-opt + Depth-first Tabu Search using 2-opt neighborhood) c f d e b a LK Search (Depth-first Tabu Search using 2-opt neighborhood) c f d e b a d a e b Tabu c f LK Search (Depth-first Tabu Search using 2-opt neighborhood) d a a f a f e c b c e b d f e d b c Experimental Analysis Using random Euclidean instances with n=100 to 1000000 cities. Using TSPLIB (real) instances n=48 to 85900 cities. Using random distance instances. Quality for tour generation heuristics 30 Percent Excess over the Held-Karp Lower Bound 25 20 Christofides Clarke-Wright Greedy Nearest Neighbor 15 10 5 0 2 2.5 3 3.5 4 4.5 5 5.5 6 P P (# of Cities =10 ) Running times for tour generation heuristics CPU Time in Seconds on 150Mhz SGI Challenge 100000 10000 1000 100 Christofides Clarke-Wright Greedy Nearest Neighbor 10 1 2 0.1 2.5 3 3.5 4 4.5 5 5.5 6 P 0.01 0.001 P (# of Cities =10 ) Quality for improvement heuristics Percent Excess over the Held-Karp Lower Bound 5 4.5 4 3.5 2-opt 3-opt Lin-Kernighan Iterated LK SA2 3 2.5 2 1.5 1 0.5 0 2 2.5 3 3.5 4 4.5 5 5.5 6 P P (# of Cities =10 ) Running times for improvement heuristics 100000 CPU Time in Seconds on 150Mhz SGI Challenge 10000 1000 2-opt 3-opt Lin-Kernighan Iterated LK SA2 100 10 1 2 0.1 2.5 3 3.5 4 4.5 5 5.5 6 P 0.01 P (# of Cities =10 ) Undominated Algorithms Percent Excess over OPT(I) 30% Karp’s Bucket 25% Nearest Neighbor Insertion Greedy Christofides’ 15% 2-opt 5% 3% 2% 1% 0% 3-opt SA Lin-Kernighan Iterated-LK n nlogn Running Time