Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of...

20
Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Transcript of Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of...

Page 1: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Speeding Up Enumeration Algorithms with Amortized Analysis

Takeaki Uno (National Institute of Informatics, JAPAN)

Page 2: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Motivation & Goal

• There have been proposed huge number of (output) polynomial time listing, enumeration, and generation algorithms

<= Good construction schemes: Back tracking, Gray code, Binary partition, and Reverse search

• But, there are relatively few studies on Speeding up those algorithms (reducing complexities)

Page 3: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Motivation & Goal (2)

• Recently, enumeration algorithms are used

      in practical problems:

data mining, bioinformatics, computational linguistics

Practical & theoretical fast algorithms are required

• However, reducing time complexity ( per output )

is not easy

Page 4: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Motivation & Goal (3)

• Reducing # of iterations

    usually, hard ( or impossible if O(#output) ) • Reducing time complexity of iterations

    usually, difficult ( O(n5) O(n4) is possible, but O(n) O(log n), O(1) is hard )   Scheme using amortized analysis is required

we propose a scheme with amortized analysis

Page 5: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

• Almost enumeration algorithms are based on recursive calls ( enumeration tree )

• Iterations on lower levels take

less computation time

• Lower levels have much iterations

Observation & Idea

Move computation time from upper levels to lower levels( computation time will be amortized )

# large time short

# small time long

Page 6: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

• The shape of enumeration tree depends on problems ( not like merge sort )

• Difficult to decide(1) to which iteration, and(2) how much amount

How to Move?

Our rule is adaptive, (1) holds and receives(2) from parent to children, recursively(3) proportional to the computation time of children

…?

top-down

Page 7: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Bound by Amortized Analysis

O(iter) : amortized computation time per iteration

T(x) : computation time of iteration x T : maximum T(x) of bottom level iterationsα >1 : a constant

If α T(x) - α   ≤   ∑   T(y)       for any x                                    y is a child of x

O(iter) = O ( T )

Condition (1)

^

^

Page 8: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Condition (1) does not hold

If several x do not hold

Condition (1) : α T(x) - α ≤ ∑ T(y)

Some iterations receive

        much computation time from parents

If x receives > α T(x) move computation time to all descendants of x

x

Page 9: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Bound by Amortized Analysis (2)

Condition (2')

If ( # descendants of x ) = Ω ( T(x) )

( or T(x) - α ≤ ∑ T(y) for any x ) y is a child of x

If αT(y) + α ≥ T(x) for any x and its child y ,

O(iter) = O ( T × log ( T(root) ) )

Condition (2)

T(x)

# T(x)

^

Page 10: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

(case 1) a leaf iteration takes much computation time T increases(case 2) a parent takes much computation time than all the children Condition (1) (2') will be violated(case 3) a child takes few computation time than other children Condition (2) will be violated

Undesired Occasion

^

Page 11: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

In each iteration, we do

Trimming: remove unnecessary parts of input of each iteration for avoiding ( case 1 & 2 )

Balancing: take balance of computation time of children for avoiding ( case 3 )

Procedure to Avoid

Page 12: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

MatchingsMatchings

Algorithm satisfying Condition (1)

O(|V|) O( 1 )

Matroid BasesMatroid Bases

Algorithm satisfying Condition (1)             m :#elements

O(mn) O(1) ( oracle calls ) n :rank

Directed spanning treesDirected spanning trees

Trimming & balancing satisfying Condition (2') & (2)

O( |V|1/2 ) O( log2|V| )

Bipartite Perfect matchingsBipartite Perfect matchings

Trimming & balancing satisfying Condition (2') & (2)

O( |V| ) O( log|V| )

Results ( previous best new )

Page 13: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Input: Graph G = ( V, E )

Output: All matchings of G

• Simple binary partition ( divide and conquer )

(1) Choose a max degree vertex v

(2) For each e of E(v), Recursive call of G+(e)

E(v):     Edges incident to v

G+(e) : Removal of e and edges adjacent to e

Satisfies Condition (1)

At bottom level, T(x) = O(1) T = O(1)

Matchings

O(1) per matching ( = per iteration )

v

E(v)

e

G+(e)

^

Page 14: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Input: Matroid M = ( E, I ) Output: All bases of M

(1)      Choose e1 of E

(2-a) If { e1, ei } are circuits for e2,…, ek

Recursive calls of each M / ei and M \ {e1,…, ek }

(2-b) If { e1, ei } are cuts for e2,…, ek

Recursive calls of M / {e1,…, ek } and each M \ ei

(2-c) Otherwise

Recursive calls of M / e1 and M \ e1

Satisfies Condition (1) At bottom level, T(x) = O(1) oracle calls

Matroid Bases

O(1) oracle calls per base ( = per iteration )

e1

e2

e3

e4

e1,…, ek

e1

Page 15: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Input: Directed Graph G = ( V, A ), a vertex rOutput: All directed spanning trees of G rooted at r

• Binary partition with Trimming and Balancing

(1) Choose a vertex v

(2) Partition E+(v) into E1 and E2

(3) Recursive calls inputting G \ E1 and G \ E2

E+(v): Out-going Arcs of v

Directed Spanning Trees

v

E+(v)

r

Page 16: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Trimming:

(1) Remove arcs included in no directed spanning tree

(2) Contract arcs included in all directed spanning trees

Balancing:

Choose v satisfying Condition (2)

Satisfies Condition (2), (2')

At bottom level, T(x) = O(log |V|) ( = T )

Directed Spanning Trees (2)

O( log2|V| ) per tree ( = per iteration )

^

Page 17: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Input: Bipartite Graph G = ( V, E )

Output: All perfect matchings of G

• Binary partition with Trimming and Balancing

(1) Choose a vertex v

(2) Partition E(v) into E1 and E2

(3) Recursive calls inputting G \ E1 and G \ E2

Bipartite Perfect Matchings

v

E(v)

Page 18: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Trimming:

Remove edges

(a) included in no perfect matching

(b) included in all perfect matchings

(c) adjacent to edges of (b)

Contract consecutive degree 2 vertices

Balancing: Choose v satisfying Condition (2)

Satisfies Condition (2), (2')

At bottom level, T(x) = O(1) (= T )

Bipartite Perfect Matchings (2)

O( log |V| ) per perfect matching ( = per iteration )

^

Page 19: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Conclusion

• Proposed a new amortized analysis

• Proposed a new speeding up scheme

( trimming and balancing )

• Proposed fast enumeration algorithms for

• mathings

• matroid bases

• directed spanning trees

• bipartite perfect mathings

Page 20: Speeding Up Enumeration Algorithms with Amortized Analysis Takeaki Uno (National Institute of Informatics, JAPAN)

Future Works

• Improve other algorithms • possible? undirected s-t paths minimal cuts of planer graphs directed paths of planer graphs • impossible? minimal cuts directed s-t paths stable sets