12.07.2015 Views

The Weak-Heap Family of Priority Queues in Theory ... - The CPH STL

The Weak-Heap Family of Priority Queues in Theory ... - The CPH STL

The Weak-Heap Family of Priority Queues in Theory ... - The CPH STL

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Our research programProvide the best bounds on the comparison complexity <strong>of</strong> priorityqueueoperations (n the current size <strong>of</strong> the data structure):f<strong>in</strong>d-m<strong>in</strong>: no element comparisonsdelete,delete-m<strong>in</strong>: ∼β lg n element comparisonsOther operations: ∼κ element comparisonswhere β and κ are constants.worst case per operationFull operation repertoire: <strong>in</strong>sert, borrow, decrease, meldc○ Performance Eng<strong>in</strong>eer<strong>in</strong>g Laboratory 18th CATS, Melbourne, 2 Feb. 2012 (2)


New gameApplication = Request sequence(Th<strong>in</strong>k graph applications)What is the best bound when handl<strong>in</strong>g arequest sequence consist<strong>in</strong>g <strong>of</strong> n <strong>in</strong>sert, ndelete-m<strong>in</strong>, and m decrease operations?worst case per sequencec○ Performance Eng<strong>in</strong>eer<strong>in</strong>g Laboratory 18th CATS, Melbourne, 2 Feb. 2012 (3)


<strong>Weak</strong> heap• A b<strong>in</strong>ary tree• <strong>The</strong> root only has a right child if any• Elements obey the weak-heap order<strong>in</strong>g:for element x, every element <strong>in</strong> the rightsubtree is ≥ x• With the exception <strong>of</strong> the root, the nodesthat have at most one child are at the lasttwo levels onlym<strong>in</strong>imumleaf registryOur representation po<strong>in</strong>ter-based!c○ Performance Eng<strong>in</strong>eer<strong>in</strong>g Laboratory 18th CATS, Melbourne, 2 Feb. 2012 (5)


Normal referee comments• Element comparisons are not relevant <strong>in</strong> practice!• Pair<strong>in</strong>g heaps are much faster <strong>in</strong> practice!• No one would ever implement Fibonacci heaps s<strong>in</strong>ce they are socomplicated.This is you guys! Thank you! You pushed us to do some practicalexperiments!c○ Performance Eng<strong>in</strong>eer<strong>in</strong>g Laboratory 18th CATS, Melbourne, 2 Feb. 2012 (7)


Interactiongraph0101010100 11tentative distance010100 11 0100 11 01 priority queuem<strong>in</strong>imumComb<strong>in</strong>e the graph vertex and the priorityqueuenode [Knuth 1994]→ improves cache behavioura factor <strong>of</strong> two speed-upc○ Performance Eng<strong>in</strong>eer<strong>in</strong>g Laboratory 18th CATS, Melbourne, 2 Feb. 2012 (10)


Tun<strong>in</strong>gRunn<strong>in</strong>g time per n [µs]Element comparisons per nStructure<strong>CPH</strong> <strong>STL</strong>FibonacciheapLEDA 6.2FibonacciheapOperation<strong>in</strong>sertn: 10 000 0.10 0.18n: 100 000 0.09 0.15n: 1 000 000 0.09 0.15decreasen: 10 000 0.03 0.06n: 100 000 0.05 0.22n: 1 000 000 0.06 0.31delete-m<strong>in</strong>n: 10 000 0.7 1.2n: 100 000 1.4 2.7n: 1 000 000 2.8 4.5On my computer (Ubuntu, gcc, with -O3)Structure<strong>CPH</strong> <strong>STL</strong>FibonacciheapLEDA 6.2FibonacciheapOperation<strong>in</strong>sertn: 10 000 0 1n: 100 000 0 1n: 1 000 000 0 1decreasen: 10 000 0 2n: 100 000 0 2n: 1 000 000 0 2delete-m<strong>in</strong>n: 10 000 16.2 29.9n: 100 000 21.2 38.3n: 1 000 000 26.2 46.5a factor <strong>of</strong> two speed-upc○ Performance Eng<strong>in</strong>eer<strong>in</strong>g Laboratory 18th CATS, Melbourne, 2 Feb. 2012 (11)


Parameterized designweak heapelement typecomparator type<strong>in</strong>t, double, ...std::less, std::greater, ...node type weak−heap node, comb<strong>in</strong>ed weak−heap node & graph node, ...modifier type relaxed heap modifier, ...level−registry typemark−registry typeleaf registry, ...naive mark registry, eager mark registry, lazy mark registry, ...• comparators shared• nodes shared• transformations shared• level registries shared• mark registries shareda factor <strong>of</strong> two less codec○ Performance Eng<strong>in</strong>eer<strong>in</strong>g Laboratory 18th CATS, Melbourne, 2 Feb. 2012 (12)


What is the best?Our reference sequence<strong>The</strong>ory: rank-relaxed weak heapDijkstra—time: b<strong>in</strong>ary heap[Williams 1964]Dijkstra—comps: weak heap[Dutton 1993]Worst case per operation<strong>in</strong>sert—time: Fibonacci heap[Fredman & Tarjan 1987]<strong>in</strong>sert—comps: Fibonacci heapdecrease—time: Fibonacci heapdecrease—comps: Fibonacci heapdelete-m<strong>in</strong>—time: weak queue[Vuillem<strong>in</strong> 1978]delete-m<strong>in</strong>—comps: weak heapc○ Performance Eng<strong>in</strong>eer<strong>in</strong>g Laboratory 18th CATS, Melbourne, 2 Feb. 2012 (13)


ConclusionsEarlier conjectures—see my SWAT-2010 slidesKataja<strong>in</strong>en’s third conjecture: Our reference sequence can be handledwith 2m + n lg n + o(n) element comparisons <strong>in</strong> O(m + n lg n)time.Cache effects: We have neglected the cache behaviour <strong>of</strong> priorityqueues for too long.Source code: Our programs are available via the <strong>CPH</strong> <strong>STL</strong> website.c○ Performance Eng<strong>in</strong>eer<strong>in</strong>g Laboratory 18th CATS, Melbourne, 2 Feb. 2012 (14)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!