Engineering shortest path algorithms (a round trip between theory and experiments) Camil Demetrescu University of Rome “La Sapienza” Giuseppe F. Italiano.

Slides:



Advertisements
Similar presentations
DC Responses Received WA OR ID MT WY CA NV UT CO AZ NM AK HI TX ND SD NE KS OK MN IA MO AR LA WI IL MI IN OH KY TN MS AL GA FL SC NC VA WV PA NY VT NH.
Advertisements

Single Source Shortest Paths
all-pairs shortest paths in undirected graphs
§3 Shortest Path Algorithms Given a digraph G = ( V, E ), and a cost function c( e ) for e  E( G ). The length of a path P from source to destination.
October 31, Algorithms and Data Structures Lecture XIII Simonas Šaltenis Nykredit Center for Database Research Aalborg University
1 Theory I Algorithm Design and Analysis (10 - Shortest paths in graphs) T. Lauer.
Dynamic All Pairs Shortest Paths Based on the following resources: Camil Demetrescu and Giuseppe F. Italiano (2004) A New Approach to Dynamic All Pairs.
Dynamic Shortest Paths Camil Demetrescu University of Rome “La Sapienza” Giuseppe F. Italiano University of Rome “Tor Vergata”
Maintaining Shortest Paths in Digraphs with Arbitrary Arc Weights University of Rome “La Sapienza” C. Demetrescu D. Frigioni A. Marchetti-Spaccamela U.
1 Advanced Algorithms All-pairs SPs DP algorithm Floyd-Warshall alg.
Dynamic Single-source Shortest Paths Camil Demetrescu University of Rome “La Sapienza”
Graph Algorithms. Definitions and Representation An undirected graph G is a pair (V,E), where V is a finite set of points called vertices and E is a finite.
All-Pairs Shortest Paths & Essential Subgraph 01/25/2005 Jinil Han.
Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this.
Essential Health Benefits Benchmark Plan Selection, as of October 2012
House price index for AK
WY WI WV WA VA VT UT TX TN SD SC RI PA OR* OK OH ND NC NY NM* NJ NH
WY WI WV WA VA VT UT TX TN SD SC RI PA OR* OK OH ND NC NY NM* NJ NH
Algorithms and Data Structures Lecture XIII
The State of the States Cindy Mann Center for Children and Families
Current Status of State Medicaid Expansion Decisions
Status of State Medicaid Expansion Decisions
Status of State Medicaid Expansion Decisions
Expansion states with Republican governors outnumber expansion states with Democratic governors, January WY WI WV◊ WA VA VT UT TX TN SD SC RI PA.
Status of State Medicaid Expansion Decisions
Non-Citizen Population, by State, 2011
Status of State Medicaid Expansion Decisions
Status of State Medicaid Expansion Decisions
Share of Women Ages 18 – 64 Who Are Uninsured, by State,
Executive Activity on the Medicaid Expansion Decision, May 9, 2013
WY WI WV WA VA VT UT TX TN1 SD SC RI PA1 OR OK OH ND NC NY NM NJ NH2
WY WI WV WA VA VT UT TX TN1 SD SC RI PA OR OK OH1 ND NC NY NM NJ NH NV
WY WI WV WA VA* VT UT TX TN SD SC RI PA OR* OK OH ND NC NY NM* NJ NH
WY WI WV WA VA VT UT TX TN SD SC RI PA OR* OK OH ND NC NY NM* NJ NH
Mobility Update and Discussion as of March 25, 2008
Current Status of the Medicaid Expansion Decision, as of May 30, 2013
IAH CONVERSION: ELIGIBLE BENEFICIARIES BY STATE
WAHBE Brokers / QHPs across the country as of
Current Status of State Medicaid Expansion Decisions
State Health Insurance Marketplace Types, 2015
State Health Insurance Marketplace Types, 2018
HHGM CASE WEIGHTS Early/Late Mix (Weighted Average)
Status of State Medicaid Expansion Decisions
Status of State Participation in Medicaid Expansion, as of March 2014
Percent of Women Ages 19 to 64 Uninsured by State,
Status of State Medicaid Expansion Decisions
Sampling Distribution of a Sample Mean
Current Status of State Medicaid Expansion Decisions
State Health Insurance Marketplace Types, 2017
(map is coded by CAE-CD region)
S Co-Sponsors by State – May 23, 2014
WY WI WV WA VA VT UT* TX TN SD SC RI PA OR* OK OH ND NC NY NM* NJ NH
Seventeen States Had Higher Uninsured Rates Than the National Average in 2013; Of Those, 11 Have Yet to Expand Eligibility for Medicaid AK NH WA VT ME.
Employer Premiums as Percentage of Median Household Income for Under-65 Population, 2003 and percent of under-65 population live where premiums.
Employer Premiums as Percentage of Median Household Income for Under-65 Population, 2003 and percent of under-65 population live where premiums.
Average annual growth rate
Sampling Distribution of a Sample Mean
Percent of Children Ages 0–17 Uninsured by State
Current Status of State Medicaid Expansion Decisions
Current Status of State Medicaid Expansion Decisions
How State Policies Limiting Abortion Coverage Changed Over Time
United States: age distribution family households and family size
Status of State Medicaid Expansion Decisions
Employer Premiums as Percentage of Median Household Income for Under-65 Population, 2003 and percent of under-65 population live where premiums.
Percent of Adults Ages 18–64 Uninsured by State
Status of State Medicaid Expansion Decisions
WY WI WV WA VA VT UT* TX TN SD SC RI PA OR* OK OH ND NC NY NM* NJ NH
WY WI WV WA VA VT UT* TX TN SD SC RI PA OR* OK OH ND NC NY NM* NJ NH
Current Status of State Individual Marketplace and Medicaid Expansion Decisions, as of September 30, 2013 WY WI WV WA VA VT UT TX TN SD SC RI PA OR OK.
Status of State Medicaid Expansion Decisions
Presentation transcript:

Engineering shortest path algorithms (a round trip between theory and experiments) Camil Demetrescu University of Rome “La Sapienza” Giuseppe F. Italiano University of Rome “Tor Vergata”

Outline of the Talk Conclusions Back from Experiments to Theory The Algorithm Engineering Cycle From Theory to Experiments

Why Engineering Algorithms? Theory In theory, theory and practice are the same.

Why Engineering Algorithms? The real world out there... In practice, theory and practice may be quite different…

Programs are first class citizens as well int, float, double Number types: N, R Only asymptotics matter Seconds do matter Abstract algorithm description Non-trivial implementation decisions, error-prone Unbounded memory, unit access cost Memory hierarchy / bandwidth Elementary operations take constant time Instruction pipelining, … TheoryPractice

The Algorithm Engineering Cycle Algorithm implementation Experimental analysisTheoretical analysis Bottlenecks, Heuristics Deeper insights More realistic models Hints to refine analysis Algorithm design

Fully Dynamic all-pairs shortest paths Given a weighted directed graph G=(V,E,w), perform any intermixed sequence of the following operations: return distance from x to y (or shortest path from x to y) Query(x,y): update cost of edge (u,v) to w Update(u,v,w): update edges incident to v [w( )] Update(v,w):

State of the Art First fully dynamic algorithms date back to the 60’s P. Loubal, A network evaluation procedure, Highway Research Record 205, , J. Murchland, The effect of increasing or decreasing the length of a single arc on all shortest distances in a graph, TR LBS-TNT-26, Transport Network Theory Unit, London Business School, V. Rodionov, A dynamization of the all-pairs least cost problem, USSR Comput. Math. And Math. Phys. 8, , …

State of the Art # papers

State of the Art Until 1999, none of them was better in the worst case than recomputing APSP from scratch (~ cubic time!) generalreal? < o(n 3 )O(1) QueryUpdateGraphWeight Ramaling.&Reps 96generalreal O(n 3 )O(1) King 99general[0,C]O(n 2.5 (C log n) 0.5 )O(1)D. & Italiano 01generalS realO(n 2.5 (S log 3 n) 0.5 )O(1)

Fully Dynamic APSP Edge insertions (edge cost decreases) Quite easy: O(n 2 ) 10 For each pair x,y check whether d(x,i) + w(i,j) + d(j,y) < d(x,y) xy i j

Fully Dynamic APSP Edge deletions (edge cost increases) Seem the hard operations When edge (shortest path) deleted: need info about second shortest path? (3rd, 4th, …) Now we take a little break from this problem… Edge insertions (edge cost decreases) Quite easy: O(n 2 )

Engineering Dijkstra’s AP Shortest Path y’ The algorithm: Run Dijkstra from all vertices “in parallel” Possibly insert (x,y’) into heap or decrease priority3. 2. Scan only y’ for which (a,y’) shortest (suboptimality) Can we do better? Extract shortest pair (x,y) from heap: xy 1. a Possibly insert (x,y’) into heap or decrease its priority3. y’ 2. Scan all neighbors y’ of y Edge scanning bottleneck for dense graphs [Goldberg] Extract shortest pair (x,y) from heap: xy 1.

Definition: Locally Shortest Paths [DI’03] A path is locally shortest if all of its proper subpaths are shortest paths Shortest path xy π xy Locally shortest path

Locally shortest paths Locally Shortest Paths Shortest paths By optimal-substructure property of shortest paths:

How much do we gain? Running time on directed graphs with real edge weights O(n 2 ) spaceO( #LS-paths + n 2 log n) time Q.: How many locally shortest paths ? Q.: How much can we gain in practice? A.: #LS-paths ≤ mn. No gain in asymptopia…

How many LS paths in a graph?

What about real-world graphs?

US road networks

Can we exploit this in practice?

Theoretical analysis Bottlenecks, Heuristics What we have seen so far Algorithm implementation Deeper insights More realistic models Hints to refine analysis Algorithm design Experimental analysis

Bottlenecks, Heuristics Return trip to Theory Algorithm implementation Theoretical analysis Deeper insights More realistic models Hints to refine analysis Algorithm design Experimental analysis

Back to Fully Dynamic APSP Given a weighted directed graph G=(V,E,w), perform any intermixed sequence of the following operations: return distance from x to y (or shortest path from x to y) Query(x,y): update cost of edge (u,v) to w Update(u,v,w):

Recall Fully Dynamic APSP Hard operations seem edge deletions (edge cost increases) When edge (shortest path) deleted: need info about second shortest path? (3rd, 4th, …) Shortest path xy π xy Hey… what about locally shortest paths? Candidate for being shortest path? Locally shortest path

Locally shortest paths for dynamic APSP Idea: Maintain all the locally shortest paths of the graph How do locally shortest paths change in a dynamic graph?

Assumptions behind the analysis Locally shortest paths π xy are internally vertex-disjoint xy π1π1 π3π3 π2π2 No two paths share the same weight.

Tie breaking Shortest paths are unique Assumptions In theory, tie breaking is not a problem Practice In practice, tie breaking can be subtle

Appearing Locally Shortest Paths Fact 1 At most mn (n 3 ) paths can START being locally shortest after an increase xy xy

Disappearing Locally Shortest Paths Fact 2 At most n 2 paths can STOP being locally shortest after an increase if π stops being locally shortest after increase of e subpath of π (was shortest path) must contain e shortest paths are unique: at most n 2 contain e

Maintaining Locally Shortest Paths # Locally shortest paths appearing after increase: < n 3 # Locally shortest paths disappearing after increase: < n 2 The amortized number of changes in the set of locally shortest paths at each update in an increase-only sequence is O(n 2 )

An Increase-only update Algorithm This gives (almost) immediately: O(n 2 log n) amortized time per increase O(mn) space

Maintaining Locally Shortest Paths xy xy What about fully dynamic sequences?

xy How to pay only once? xy xy This path remains the same while flipping between being LS and non-LS: Would like to have update algorithm that pays only once for it until it is further updated...

xy Looking at the substructure xy …but if we removed the same edge it would be a shortest path again! It is not dead! This path remains a shortest path after the insertion This path is no longer a shortest path after the insertion…

Historical Paths xy A path is historical if it was shortest at some time since it was last updated historical path

Locally Historical Paths Shortest path x y π xy Locally shortest path Historical path x y π xy Locally historical path

Key idea for Partially Dynamic LSP SP

Key idea for Fully Dynamic LHP HP

Key Idea for Fully Dynamic LHP SP HP

Putting things into perspective: LHP HP LSP SP

The fully dynamic update algorithm O(n 2 log 3 n) amortized time per update Fully dynamic update algorithm very similar to partially dynamic, but maintains locally historical paths instead of locally shortest paths (+ performs some other operations) O(mn log n) space Idea: Maintain all the locally historical paths of the graph

Experiments (update time)

What about real graphs? (update time)

Relative time performance D-RLL/D-LHP Number of edges (x 100) D-LHP slower than D-RRL D-LHP faster than D-RRL Experiments on US road networks IBM Power 4 Sun UltraSPARC IIi AMD Athlon (32MB L3 cache) (256KB L2 cache) (2MB L2 cache) OH NC CA MO MN AL IA MI KY KS AR IN MS NE MD CO LA NJ MACT NM ND MT ID AZ ME NH NV DE IBM Power 4 Sun UltraSPARC IIi AMD Athlon (on different platforms)

Cache effects Cache size KB256KB512KB1MB2MB4MB8MB16MB32MB Simulated cache miss ratio D-RRL/D-LHP Performance ratio D-RRL/D-LHP on real architectures UltraSPARC IIi Xeon Athlon 1.59 Power 4 Colorado road network

Conclusions and open problems… C Code publicly available at ~ demetres/experim/dsp O(n 2 ) space too much for applications Trading-off space and (query) time? Fully dynamic single source shortest path problem?

The world is not perfect…