Presentation is loading. Please wait.

Presentation is loading. Please wait.

2IMG15 Algorithms for Geographic Data

Similar presentations


Presentation on theme: "2IMG15 Algorithms for Geographic Data"— Presentation transcript:

1 2IMG15 Algorithms for Geographic Data
Fall Lecture 12: Modeling using Linear Programming

2 Modeling revisited Problems with geographic data often lack formalism
Typical algorithms approach Develop a model to formalize a problem Algorithmically solve the model Evaluate What if this “fails”? Time consuming to find good algorithms What if problems are NP-hard? Tweak the model if no efficient algorithms?

3 Modeling for modeling Today, we focus on modeling again
Leverage existing tools Quickly solve instances in practice to evaluate the model Hopefully... This may be the best you can hope for... Multiple competing criteria Let others do the heavy lifting

4 Linear programming

5 Linear program (LP) Given Variables 𝑥 1 , 𝑥 2 , 𝑥 3 , …, 𝑥 𝑛
with 𝑥 𝑖 ∈ℝ Hard constraints 𝑖 𝑎 𝑖,𝑗 ∙ 𝑥 𝑖 ≤ 𝑐 𝑗 for constants 𝑎 𝑖,𝑗 and 𝑐 𝑗 Objective function 𝑖 𝑤 𝑖 ∙𝑥 𝑖 (soft constraints) for constants 𝑤 𝑖 Compute Values for all 𝑥 𝑖 such that All constraints are met Objective function is maximized (or minimized)

6 Integer linear program (ILP)
Integer variables 𝑥 𝑖 ∈ℤ NP-complete More powerful as it allows representing discrete choices Variants Mixed-integer linear program (MIP) 0-1 (integer) linear program (0/1-LP)

7 Tools Many tools exist to solve (mixed, integer) linear programs
IBM ILOG CPLEX [ibm.onthehub.com] Gurobi [ ... These tend to be very configurable Many parameters Many methods Typically needs engineering to get a good performance

8 Labeling historic maps
Budig, Van Dijk & Wolff [2016]

9 Labeling historic maps
Digitizing historic maps Matching between graphical marker and textual label unclear Match many pairs Closer matches are better Do not match well separated pairs

10 Some formalization Let P be the markers and L the labels A matching M
Set of (p,l) pairs Each p in P in at most one pair Each l in L in at most one pair Find the matching M that maximizes (𝑝,𝑙)∈𝑀 𝑟 −𝑑(𝑝,𝑙) Match many pairs benefit r Closer matches are better distance d(p,l) Do not match well separated pairs no match if d(p,l) > r

11 Linear program Variables
𝑥 𝑝,𝑙 ∈ 0,1 [0,1] per pair p,l with d(p,l) ≤ r Maximize 𝑝,𝑙 𝑟 −𝑑 𝑝,𝑙 ∙ 𝑥 𝑝,𝑙 Constraints 𝑙 𝑥 𝑝,𝑙 ≤1 per p 𝑝 𝑥 𝑝,𝑙 ≤1 per l This gives an integer solution for free Due to flow theory

12 Stability analysis Two solutions may have very similar quality
For each matched p,l pair, we may ask: How much worse does the optimal solution become, if we do not allow matching p,l?

13 Stability analysis How much worse does the optimal solution become, if we do not allow matching p,l? Recompute from scratch is costly Re-use information from the computation of the optimal matching to speed this up “Warm start” Overall analysis down to 78.5 sec (from close to an hour)

14 Building footprints Haunert & Wolff [2010]

15 Building footprints Simplify a building with shortcuts Model
Each output edge corresponds to an input edge Corresponding edges are a subsequence Hausdorff distance between original and shortcut is bounded Output edges do not intersect

16 Shortcuts Two edges (e,f) define a shortcut Not all pairs are valid
Two shortcuts (e,f) and (f,g) define the edge of f in the result Whether intersections occur depends on other shortcuts Do not allow directions to change

17 Output quality Few edges Little change in area
Angles close to 90 degrees Similar edge directions and lengths 𝑤 𝑠 : weight of a shortcut, its influence on the above

18 Variables & constraints
One variable 𝑥 𝑠 ∈{0,1} per shortcut s Minimize 𝑠 𝑤 𝑠 ∙ 𝑥 𝑠 Constraints A cycle of shortcuts: each edge either starts a shortcut or is skipped over by another 𝑠 𝑥 𝑠 =1 per edge e Pair of shortcuts may not invert direction 𝑥 𝑠 + 𝑥 𝑡 ≤1 if s and t cause inversion Output edges may not intersect 𝑥 𝑠 + 𝑥 𝑡 + 𝑥 𝑢 + 𝑥 𝑣 ≤3 if s,t and u,v cause intersection

19 Counting constraints Constraints
A cycle of shortcuts: each edge either starts a shortcut or is skipped over by another 𝑠 𝑥 𝑠 =1 per edge e Pair of shortcuts may not invert direction 𝑥 𝑠 + 𝑥 𝑡 ≤1 if s and t cause inversion Output edges may not intersect 𝑥 𝑠 + 𝑥 𝑡 + 𝑥 𝑢 + 𝑥 𝑣 ≤3 if s,t and u,v cause intersection Variables involved Number of constraints 1. O(n2) O(n) 2. 2 O(n3) 3. 4 O(n6)

20 Lazy constraints Many constraints may be satisfied “by accident”
So, let’s not include them in the ILP initially If an incumbent solution is found Check for violations If violations present, add the relevant constraints This keeps the ILP smaller Avoids setup of unnecessary constraints But don’t overdo it...

21 Schematizing networks
Nollenburg & Wolff [2011]

22 Schematizing networks
Turn a detailed geographic map into a simple abstract one

23 Formalization Plane graph G = (V,E) Line cover L Set of paths in G
Each edge in at least one path Goal is to find a drawing of D of (G,L) What are the requirements?

24 Requirements H1 Segment D(e) is octilinear for each edge e H2 Circular order of neigbors same in D and G H3 Segment D(e) must have a minimal length lmin H4 D(e) must be at least distance dmin away from any other D(e’) S1 D(l) has few bends for each line l Bends have large angles S2 Direction of e and D(e) should be similar S3 Total edge length of D should be small NP-hard to decide if there is a solution to H1-4 Efficient algorithm if we change H1 to rectilinear paths

25 Modeling For simplicity, use 4 axis x, y, z1, z2 z1 = (x+y)/2
Use L∞ metric Distance (x,y) to (x’,y’) is max{ |x-x’| , |y-y’| }

26 Octilinearity (H1) & min length (H3)
Define 8 sectors around input vertex secu(v) : sector of v w.r.t. u For each output edge dir(u,v) : direction from u to v Restrict choices to the three closest (optional, S2)

27 Circular order (H2) Next direction is -1 (modulo 8)
Must maintain the cyclic order around v

28 Edge spacing (H4) Enough to separate in one direction

29 Line bends (S1) Introduce a bend cost bd(u,v,w) Add minimization
We want A lower bound in linear form Minimization does the rest

30 Relative positions (S2)
We had already restricted dir(u,v) Add minimization rpos(uv) is 1 iff dir(u,v) = secu(v)

31 Total edge length (S3) Add minimization
Lower bound this with the coordinates Minimization does the rest

32 Summary Minimize Quadratic size for H4
Use only pairs on the same face of the embedded graph Lazy evaluation

33 Some results Input Bends Directions Total length

34 Sydney, with and without labels

35 Aggregation in land cover maps
Haunert & Wolff [2011]

36 Aggregation

37 Formalization Given Set of colors Γ Adjacency graph 𝐺 = (𝑉,𝐸)
Node weights 𝑤 :𝑉→ ℝ 0 + and colors 𝛾 :𝑉 →Γ Minimal aggregate weight 𝜃>0 Distance cost for recoloring 𝛿 : Γ 2 → ℝ 0 + Compute a partition 𝑃= 𝑉 1 ,…, 𝑉 𝑘 of 𝑉 A color assignment 𝛾 ′ :𝑃 →Γ Each 𝑉 𝑖 is connected 𝑣 𝑤 𝑣 ≥𝜃 for each 𝑉 𝑖 Minimize 𝑣 𝑤 𝑣 ∙𝛿(𝛾 𝑣 , 𝛾 ′ 𝑣 )

38 Idea Use “flow” to model connections Quantify of flow is area 𝑤
Connected by flow implies the same color A center for each connected component is a sink Absorb at least 𝜃− 𝑤(𝑣) flow All other regions produce 𝑤(𝑣) flow Send it to one of its neighbors

39 As a MIP Variables 𝑠 𝑣 ∈ 0,1 is v a sink? 𝑓 𝑎 ≥0 flow on arc a = uv
𝐹 𝑎 ∈{0,1} is there flow on arc a? 𝑦 𝑣𝑐 ∈{0,1} does node v have color c? Minimize 𝑣,𝑐 𝑤 𝑣 ∙𝑑 𝛾 𝑣 ,𝑐 ∙𝑦 𝑣𝑐 Constraints 𝑀∙ 𝐹 𝑎 ≥ 𝑓 𝑎 per arc a Flow 𝑓 𝑣𝑢 − 𝑓 𝑢𝑣 ≥𝑤 𝑣 − 𝑠 𝑣 ∙𝑀 per vertex v Flow 𝑓 𝑣𝑢 − 𝑓 𝑢𝑣 ≤𝑤 𝑣 − 𝑠 𝑣 ∙𝜃 per vertex v One color 𝑦 𝑣𝑐 =1 per vertex v Color flow y uc ≥ 𝑦 𝑣𝑐 + 𝐹 𝑢𝑣 −1 per arc uv, color c One arc 𝐹 𝑣𝑢 =1− 𝑠 𝑣 per vertex v

40 Need more than color difference
We want resulting regions to be compact

41 Formalization Given Set of colors Γ Adjacency graph 𝐺 = (𝑉,𝐸)
Node weights 𝑤 :𝑉→ ℝ 0 + and colors 𝛾 :𝑉 →Γ Minimal aggregate weight 𝜃>0 Distance cost for recoloring 𝛿 : Γ 2 → ℝ 0 + Compute a partition 𝑃= 𝑉 1 ,…, 𝑉 𝑘 of 𝑉 A color assignment 𝛾 ′ :𝑃 →Γ Each 𝑉 𝑖 is connected 𝑣 𝑤 𝑣 ≥𝜃 for each 𝑉 𝑖 Minimize 𝑣 𝑤 𝑣 ∙𝛿(𝛾 𝑣 , 𝛾 ′ 𝑣 )

42 Formalization Given Set of colors Γ Adjacency graph 𝐺 = (𝑉,𝐸)
Node weights 𝑤 :𝑉→ ℝ 0 + and colors 𝛾 :𝑉 →Γ Minimal aggregate weight 𝜃 :Γ→ ℝ 0 + Distance cost for recoloring 𝛿 : Γ 2 → ℝ 0 + Non-compactness cost c : 2 𝑉 ×Γ→ ℝ 0 + Parameter 𝑠∈[0,1] Compute a partition 𝑃= 𝑉 1 ,…, 𝑉 𝑘 of 𝑉 A color assignment 𝛾 ′ :𝑃 →Γ Each 𝑉 𝑖 is connected 𝑣 𝑤 𝑣 ≥𝜃 for each 𝑉 𝑖 Minimize 𝑠 𝑣 𝑤 𝑣 ∙𝛿(𝛾 𝑣 , 𝛾 ′ 𝑣 ) + 1−𝑠 𝑉 𝑖 𝑐( 𝑉 𝑖 ,𝛾′( 𝑉 𝑖 ))

43 Compactness Compactness of a aggregate 𝑉 𝑖 Perimeter
𝑝𝑒𝑟𝑖𝑚𝑒𝑡𝑒𝑟 2 𝜋⋅𝑎𝑟𝑒𝑎 ? [MacEachran, 1985] 𝑝𝑒𝑟𝑖𝑚𝑒𝑡𝑒𝑟 Distance min ∑𝑤 𝑣 ⋅𝛿 𝑣,𝑢 | 𝑢∈ 𝑉 𝑖 ∧𝛾 𝑢 =𝛾 𝑉 𝑖 Shortest paths min ∑𝑤 𝑣 ⋅ 𝛿 𝑉 𝑣,𝑢 | 𝑢∈ 𝑉 𝑖 ∧𝛾 𝑢 =𝛾 𝑉 𝑖

44 Compactness in a MIP We can use or modify the previous MIP, if:
No compactness (s = 0) Shortest-path model Which was nicely linear ... We need a bigger MIP for dealing with the other models

45 MIP with Distance model
Variables 𝑥 𝑢𝑣 ∈ 0,1 does v belong to center u? Minimize s 𝑢,𝑣 𝑤 𝑣 ∙𝑑 𝛾 𝑣 ,𝛾(𝑢) ∙𝑥 𝑢𝑣 + (1−s) 𝑢,𝑣 𝑤 𝑣 ∙𝛿 𝑢,𝑣 ∙𝑥 𝑢𝑣 Constraints 𝑥 𝑢𝑣 =1 per vertex v 𝑤 𝑣 ⋅𝑥 𝑢𝑣 ≥𝜃 𝛾 𝑢 ⋅ 𝑥 𝑢𝑢 per center u 𝑤∈ Pred 𝑢 (𝑣) 𝑥 𝑢𝑤 ≥ 𝑥 𝑢𝑣 per vertices u ≠ v

46 Using predecessors for connectivity
Assign nodes a distance from center u Predecessors of v are its neighbors that are closer to u 𝑉 𝑖 is connected if each node v has a neighbor also in 𝑉 𝑖 closer to u This excludes solutions and thus is a heuristic! But likely excludes mostly noncompact shapes...

47 MIP with Perimeter model
𝑝𝑒𝑟𝑖𝑚𝑒𝑡𝑒𝑟 𝑉 𝑖 = 𝑝𝑒𝑟𝑖𝑚𝑒𝑡𝑒𝑟(𝑣) −2 𝜆(𝑒) where 𝑒 are edges within one component 𝑉 𝑖 Because 𝑝𝑒𝑟𝑖𝑚𝑒𝑡𝑒𝑟(𝑣) counts internal boundaries twice

48 MIP with Perimeter model
𝑝𝑒𝑟𝑖𝑚𝑒𝑡𝑒𝑟 𝑉 𝑖 = 𝑝𝑒𝑟𝑖𝑚𝑒𝑡𝑒𝑟(𝑣) −2 𝜆(𝑒) where 𝑒 are edges within one component 𝑉 𝑖 We add... Variables 𝑦 𝑢𝑒 ∈ 0,1 does e fully belong to center u? Minimize −2 𝑢,𝑒 𝜆 𝑒 ∙ 𝑦 𝑢𝑒 Constraints 𝑦 𝑢𝑒 ≤ 𝑥 𝑢𝑤 and 𝑦 𝑢𝑒 ≤ 𝑥 𝑢𝑣 per center u and e = (v,w)

49 Recap

50 Leveraging existing tools
Linear programming is a powerful framework Implemented by many tools Can solve a variety of cartographic problems

51 Other frameworks Minimum-cost flow Grid map layouts [Eppstein, 2015]
Least-squares adjustment Cartographic generalization [Sester, 2005] Focus maps [Van Dijk & Haunert, 2014] Convex quadratic programming Focus maps [Haunert & Sering, 2011]


Download ppt "2IMG15 Algorithms for Geographic Data"

Similar presentations


Ads by Google