Partial Soluti on and Entropy Tadao Takaoka Department of Computer Science University of Canterbury Christchurch, New Zealand.

Slides:



Advertisements
Similar presentations
Single Source Shortest Paths
Advertisements

Greed is good. (Some of the time)
CSC 2300 Data Structures & Algorithms April 13, 2007 Chapter 9. Graph Algorithms.
Minimum Spanning Trees Definition Two properties of MST’s Prim and Kruskal’s Algorithm –Proofs of correctness Boruvka’s algorithm Verifying an MST Randomized.
The selfish-edges Shortest-Path problem. The selfish-edges SP problem Input: an undirected graph G=(V,E) such that each edge is owned by a distinct selfish.
Shortest-paths. p2. Shortest-paths problems : G=(V,E) : weighted, directed graph w : E  R : weight function P=
1 Theory I Algorithm Design and Analysis (10 - Shortest paths in graphs) T. Lauer.
By Amber McKenzie and Laura Boccanfuso. Dijkstra’s Algorithm Question: How do you know that Dijkstra’s algorithm finds the shortest path and is optimal.
1 Greedy 2 Jose Rolim University of Geneva. Algorithmique Greedy 2Jose Rolim2 Examples Greedy  Minimum Spanning Trees  Shortest Paths Dijkstra.
CPSC 411, Fall 2008: Set 9 1 CPSC 411 Design and Analysis of Algorithms Set 9: More Graph Algorithms Prof. Jennifer Welch Fall 2008.
Discussion #36 Spanning Trees
CSE 780 Algorithms Advanced Algorithms Minimum spanning tree Generic algorithm Kruskal’s algorithm Prim’s algorithm.
CSE 421 Algorithms Richard Anderson Dijkstra’s algorithm.
1 7-MST Minimal Spanning Trees Fonts: MTExtra:  (comment) Symbol:  Wingdings: Fonts: MTExtra:  (comment) Symbol:  Wingdings:
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
DAST 2005 Tirgul 12 (and more) sample questions. DAST 2005 Q.We’ve seen that solving the shortest paths problem requires O(VE) time using the Belman-Ford.
CSE 421 Algorithms Richard Anderson Lecture 10 Minimum Spanning Trees.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
More Graph Algorithms Weiss ch Exercise: MST idea from yesterday Alternative minimum spanning tree algorithm idea Idea: Look at smallest edge not.
Dijkstra’s Algorithm Slide Courtesy: Uwash, UT 1.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20.
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
TECH Computer Science Graph Optimization Problems and Greedy Algorithms Greedy Algorithms  // Make the best choice now! Optimization Problems  Minimizing.
Minimum Spanning Trees What is a MST (Minimum Spanning Tree) and how to find it with Prim’s algorithm and Kruskal’s algorithm.
Theory of Computing Lecture 7 MAS 714 Hartmut Klauck.
Minimal Spanning Trees What is a minimal spanning tree (MST) and how to find one.
1 Binomial heaps, Fibonacci heaps, and applications.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
Course notes CS2606: Data Structures and Object-Oriented Development Graphs Department of Computer Science Virginia Tech Spring 2008 (The following notes.
1 GRAPHS - ADVANCED APPLICATIONS Minimim Spanning Trees Shortest Path Transitive Closure.
9/10/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 8 Greedy Graph.
2IL05 Data Structures Fall 2007 Lecture 13: Minimum Spanning Trees.
Spring 2015 Lecture 11: Minimum Spanning Trees
Minimum Spanning Trees CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
Kruskal’s and Dijkstra’s Algorithm.  Kruskal's algorithm is an algorithm in graph theory that finds a minimum spanning tree for a connected weighted.
November 13, Algorithms and Data Structures Lecture XII Simonas Šaltenis Aalborg University
The Shortest-Path problem in graphs with selfish-edges.
En tropy as Computational Complexity Computer Science Replugged Tadao Takaoka Department of Computer Science University of Canterbury Christchurch, New.
1 Prim’s algorithm. 2 Minimum Spanning Tree Given a weighted undirected graph G, find a tree T that spans all the vertices of G and minimizes the sum.
Lecture 13 Algorithm Analysis
CSCE 411 Design and Analysis of Algorithms Set 9: More Graph Algorithms Prof. Jennifer Welch Spring 2012 CSCE 411, Spring 2012: Set 9 1.
NOTE: To change the image on this slide, select the picture and delete it. Then click the Pictures icon in the placeholder to insert your own image. Fast.
Lecture 12 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
November 22, Algorithms and Data Structures Lecture XII Simonas Šaltenis Nykredit Center for Database Research Aalborg University
CSE 373: Data Structures and Algorithms Lecture 21: Graphs V 1.
Chapter 9 : Graphs Part II (Minimum Spanning Trees)
Introduction to Algorithms
Computing Connected Components on Parallel Computers
Binomial heaps, Fibonacci heaps, and applications
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Minimum-Cost Spanning Tree
CSCE350 Algorithms and Data Structure
Minimum Spanning Tree.
Minimum Spanning Tree.
ICS 353: Design and Analysis of Algorithms
Algorithms and Data Structures Lecture XII
Minimum-Cost Spanning Tree
Minimum-Cost Spanning Tree
Lecture 13 Algorithm Analysis
Lecture 13 Algorithm Analysis
Autumn 2015 Lecture 10 Minimum Spanning Trees
Lecture 13 Algorithm Analysis
Lecture 13 Algorithm Analysis
Autumn 2016 Lecture 10 Minimum Spanning Trees
Graph Algorithms: Shortest Path
CSE 417: Algorithms and Computational Complexity
Algorithms CSCI 235, Spring 2019 Lecture 35 Graphs IV
Winter 2019 Lecture 10 Minimum Spanning Trees
Minimum-Cost Spanning Tree
Presentation transcript:

Partial Soluti on and Entropy Tadao Takaoka Department of Computer Science University of Canterbury Christchurch, New Zealand

Genera framework and motivation If the given problem is partially solved, how much more time is needed to solve the problem completely. AlgorithmInput data Saved data SaveRecover Output Time =Time spent + Time to be spent A possible scenario: Suppose computer is stopped by power cut and partially solved data are saved by battery. After a while power is back on, data are recovered, and computation resumes. How much more time ? Estimate from the partially solved data.

Definition of entropy Let X be the data set and X be decomposed like S(X)=(X 1, …, X k ). Each X i is solved. S(X) is a state of data, and abbreviated as S. Let p i =|X i |/|X|, and |X|=n. The entropy H(S) is defined by H(S) =  [i=1, k] |X i |log(|X|/|X i |) = -n  [i=1,k] p i log(p i )  p i = 1, 0  H(S)  nlog(k), maximum when all |X i | are equal to 1/k.

Amortized analysis The accounting equation at the i-th operation becomes a i = t i - ΔH(S i ), actual time – decrease of entropy where ΔH(S i ) = H(S i-1 ) - H(S i ). Let T and A be the actual total time and the amortized total time. Summing up a i for i=1,..., N, we have A = T + H(S N ) - H(S 0 ), or T = A + H(S 0 ) - H(S N ). For some applications, a i = t i - cΔH(S i ) for some costant c

Problems analyzed by entropy Minimal Mergesort : merging shortest ascending runs Shortest Path Problem: Solid parts solved. Make a single shortest path spanning tree Minimum Spanning Tree : solid part solved. Make a single tree souurce

Three examples with k=3 (1) Minimal mergesort Time =O(H(S)) Xi are ascending runs S(X) = ( ) X1=(2 5 6), X2 =(1 4 7), X3=(3 8 9) (2) Shortest paths for nearly acyclic graphs Time=O(m+H(S)) G=(V, E) is a graph. S(V)=(V1, V2, V3) V i is an acyclic graph dominated by v i (3) Minimum spanning tree Time = O(m+H(S)) S(V)=(V1, V2, V3), subgraph Gi=(Vi, Ei) is the induced graph from Vi. We assume minimum spanning tree Ti for Gi is already obtained

Time complexities of the three problems Minimal mergesort O(H(S)) worst case O(nlog(n)) Single source shortest paths O(m+H(S)) worst case time O(m+nlog(n)) data structures: Fibonacci heap or 2-3 heap Minimum cost spanning trees O(m+H(S)) Presort of edges (mlog(n)) excluded worst case time O(m+nlog(n))

Minimal mergesort picture Metasort ML ...... W1W1 W2W2 W S(X) S’(X) merge...

Minimal Mergesort M  L : first list of L is moved to the last of M Meta-sort S(X) into S’(X) by length of X i Let L = S’(X); /* L : list of lists */ M=φ; M  L; /* M : list of lists */ for i=1 to k-1 do begin W 1  M; W 2  M; W=merge(W 1, W 2 ); While L  φ and |W|>first(L) do M  L M  L End

Lemma. L and M are meta-sorted. If W 2 is a merged list, I.e., not original X i, |W 1 | ≦ |W 2 | ≦ 2|W 1 | Lemma. Amortized time for i-th merge a i ≦ 0 Proof. Let |W 1 |=n 1 and |W 2 |=n 2 ΔH = n 1 log(n/n 1 )+n 2 log(n/n 2 )-(n 1 +n 2 )log(n/(n 1 +n 2 )  n 1 log(1+n 2 /n 1 )+n 2 log(1+n 1 /n 2 )  n 1 log2+n 2 (log(3/2)=log(3/2)(n 1 +n 2 ) a i = t i – cΔH ≦ n 1 +n ΔH /log(3/2) ≦ 0

Main results in minimal mergesort Theorem. Minimal mergesort sorts sequence S(X) in O(H(S)) time Theorem. Any sorting algorithm takes  (H(S)) time if |X i |  2 for all i. If |X i |=1 for all I, S(X) is reverse-sorted, and it can be sorted in ascending order, in O(n) ttime.

Dijkstra’s algorithm for shortest paths with a priority queue d[s]=0 S={s}; F={w|(s,w) in out(s)} while |S|<n do delete v from F such that d[v] is minimum //delete-min add v to S O(log n) for w in out(v) do if w is not in S then if w is if F then d[w]=min{d[v], d[v]+c[v,w] //decrease- key O(1) else {d[w]=d[v]+c[v,w]; add w to F} //insert O(1) end do

Expansion of solution set S: solution set of vertices to which shortest distances are known F: frontier set of vertices connected from solution set by single edges v w w S : solution setF : frontier s Time = O(m + nlogn)

Efficient shortest path algorithm for nearly acyclic graphs d[s]=0 S={s}; Q={w|(s,w) in out(s)}; // F is organized as priority queue Q while |S|<n do if there is a vertex in F with no incoming edge from V-S then choose v // easy vertex else choose v from F such that d[v] is minimum //difficult add v to S Delete v from F for w in out(v) do if w is not in S then if w is in F then d[w]=min{d[v], d[v]+c[v,w] //decrease-key else {d[w]=d[v]+c[v,w]; add w to F} //insert O(1) end do

Easy vertices and difficult vertices v w ws difficult easy S F

Entropy analysis of the shortest path algorithm There are t difficult vertices u 1, …, u t. Each u i and the following easy vertices form an acyclic sub-graph. Let {v 1,…, v k }, where v 1 =u i for some i, be one of the above acyclic sub-graphs. Let the number of descendants of v i be n i. Delete v 1, …, v k. Time = log(n i )+…+log(n k ) ≦ O(klog(n/k). Let us index k by i for u i. Then the total time for deletes is O(k 1 log(n/k 1 )+…+k t log(n/k t ) = O(H(S)) where S(V)=(V 1, …, V t ). The rest of the time is O(m). Thus total time is O(m+O(H(S))

Nearly acyclic graph Acyclic components are regarded as solved There are three acyclic components in this graph. Vertices in the component V i can be deleted from the queue once the distance to the trigger v i is finalized ViVi vivi Acyclic graph topologically sorted

Algorithm 3 on the reduced graph ViVi vivi V1V1 After V 1 is finalized, the reduced graph becomes acyclic

Minimum spanning trees Blue fonts : vertices T1 T2 T3 L=( )  L=( ) name =( )  ( )

Kruskal’s completion algorithm 1 Let the sorted edge list L be partially scanned 2 Minimum spanning trees for G 1,..., G k have been obtained 3 for i=1 to k do for v in V k do name[v]:=k 4 while k > 1 do begin 5 Remove the first edge (u, v) from L 6 if u and v belong to different sub-trees T1 and T2 7 then begin 8 Connect T1 and T2 by (u, v) 9 Change the names of the nodes in the smaller tree to that of the larger tree; 10 k:=k - 1; 11 end 12 end.

Entropy analysi s for name changes the decrease of entropy is ΔH = n 1 log(n/n 1 ) + n 2 log(n/n 2 ) -(n 1 +n 2 )log(n/(n 1 +n 2 )) = n 1 log(1+n 2 /n 1 ) + n 2 log(1+n 1 /n 2 ) ≥ min{n 1, n 2 } Noting that t i <= min{n 1, n 2 }, amortized time becomes a i = t i - ΔH(S i ) ≦ 0 Scanning L takes O(m) time. Thus T=(m+H(S 0 )), where H(S 0 ) is the initial entropy.