fitting a step function to a point set
play

Fitting a Step Function to a Point Set e Fournier 1 Antoine Vigneron - PowerPoint PPT Presentation

Fitting a Step Function to a Point Set e Fournier 1 Antoine Vigneron 2 Herv 1 University of Versailles St-Quentin en Yvelines 2 INRA Jouy-en-Josas December 4, 2008 H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set


  1. Optimization algorithm { y 1 , . . . , y n } denote the y -coordinates of points in P . H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 7 / 20

  2. Optimization algorithm { y 1 , . . . , y n } denote the y -coordinates of points in P . Let ε ij = 1 2 ( y i − y j ). H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 7 / 20

  3. Optimization algorithm { y 1 , . . . , y n } denote the y -coordinates of points in P . Let ε ij = 1 2 ( y i − y j ). Then ε ∗ = ε ij for some i , j . H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 7 / 20

  4. Optimization algorithm { y 1 , . . . , y n } denote the y -coordinates of points in P . Let ε ij = 1 2 ( y i − y j ). Then ε ∗ = ε ij for some i , j . Simple algorithm: H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 7 / 20

  5. Optimization algorithm { y 1 , . . . , y n } denote the y -coordinates of points in P . Let ε ij = 1 2 ( y i − y j ). Then ε ∗ = ε ij for some i , j . Simple algorithm: ◮ Sort the ε ij ’s: O ( n 2 log n ) time. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 7 / 20

  6. Optimization algorithm { y 1 , . . . , y n } denote the y -coordinates of points in P . Let ε ij = 1 2 ( y i − y j ). Then ε ∗ = ε ij for some i , j . Simple algorithm: ◮ Sort the ε ij ’s: O ( n 2 log n ) time. ◮ Perform binary search using the decision algorithm: O ( n log n ). H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 7 / 20

  7. Optimization algorithm { y 1 , . . . , y n } denote the y -coordinates of points in P . Let ε ij = 1 2 ( y i − y j ). Then ε ∗ = ε ij for some i , j . Simple algorithm: ◮ Sort the ε ij ’s: O ( n 2 log n ) time. ◮ Perform binary search using the decision algorithm: O ( n log n ). Can be improved to O ( n log n ) using Frederickson and Johnson’s sorted matrix searching technique. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 7 / 20

  8. Optimization algorithm { y 1 , . . . , y n } denote the y -coordinates of points in P . Let ε ij = 1 2 ( y i − y j ). Then ε ∗ = ε ij for some i , j . Simple algorithm: ◮ Sort the ε ij ’s: O ( n 2 log n ) time. ◮ Perform binary search using the decision algorithm: O ( n log n ). Can be improved to O ( n log n ) using Frederickson and Johnson’s sorted matrix searching technique. Let ˜ y 1 � . . . � ˜ y n denote the y -coordinates in sorted order. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 7 / 20

  9. Optimization algorithm { y 1 , . . . , y n } denote the y -coordinates of points in P . Let ε ij = 1 2 ( y i − y j ). Then ε ∗ = ε ij for some i , j . Simple algorithm: ◮ Sort the ε ij ’s: O ( n 2 log n ) time. ◮ Perform binary search using the decision algorithm: O ( n log n ). Can be improved to O ( n log n ) using Frederickson and Johnson’s sorted matrix searching technique. Let ˜ y 1 � . . . � ˜ y n denote the y -coordinates in sorted order. Let M ij = 1 2 (˜ y i − ˜ y n +1 − j ). H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 7 / 20

  10. Optimization algorithm { y 1 , . . . , y n } denote the y -coordinates of points in P . Let ε ij = 1 2 ( y i − y j ). Then ε ∗ = ε ij for some i , j . Simple algorithm: ◮ Sort the ε ij ’s: O ( n 2 log n ) time. ◮ Perform binary search using the decision algorithm: O ( n log n ). Can be improved to O ( n log n ) using Frederickson and Johnson’s sorted matrix searching technique. Let ˜ y 1 � . . . � ˜ y n denote the y -coordinates in sorted order. Let M ij = 1 2 (˜ y i − ˜ y n +1 − j ). M is a sorted matrix : i � i ′ and j � j ′ implies M ij � M i ′ j ′ . H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 7 / 20

  11. Searching in a sorted matrix 1 2 3 4 5 6 7 8 2 3 5 6 7 8 9 10 3 6 7 8 10 11 12 13 4 7 8 9 11 12 13 15 6 9 10 11 12 14 15 17 7 10 11 13 14 16 17 18 8 12 13 14 15 18 19 20 9 13 14 16 17 19 21 23 a sorted matrix M H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 8 / 20

  12. Searching in a sorted matrix 1 2 3 4 5 6 7 8 2 3 5 6 7 8 9 10 3 6 7 8 10 11 12 13 4 7 8 9 11 12 13 15 6 9 10 11 12 14 15 17 7 10 11 13 14 16 17 18 8 12 13 14 15 18 19 20 9 13 14 16 17 19 21 23 a sorted matrix M an increasing boolean function g : there exists x ∗ such that g ( x ) = FALSE for all x < x ∗ , and g ( x ) = TRUE for all x � x ∗ . H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 8 / 20

  13. Searching in a sorted matrix 1 2 3 4 5 6 7 8 2 3 5 6 7 8 9 10 3 6 7 8 10 11 12 13 4 7 8 9 11 12 13 15 6 9 10 11 12 14 15 17 7 10 11 13 14 16 17 18 8 12 13 14 15 18 19 20 9 13 14 16 17 19 21 23 a sorted matrix M an increasing boolean function g : there exists x ∗ such that g ( x ) = FALSE for all x < x ∗ , and g ( x ) = TRUE for all x � x ∗ . Problem: search for x ∗ in M . H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 8 / 20

  14. Searching in a sorted matrix 1 2 3 4 5 6 7 8 2 3 5 6 7 8 9 10 3 6 7 8 10 11 12 13 4 7 8 9 11 12 13 15 6 9 10 11 12 14 15 17 7 10 11 13 14 16 17 18 8 12 13 14 15 18 19 20 9 13 14 16 17 19 21 23 smallest elements in submatrices: { 1 , 5 , 6 , 12 } ; median=6. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 9 / 20

  15. Searching in a sorted matrix 1 2 3 4 5 6 7 8 2 3 5 6 7 8 9 10 3 6 7 8 10 11 12 13 4 7 8 9 11 12 13 15 6 9 10 11 12 14 15 17 7 10 11 13 14 16 17 18 8 12 13 14 15 18 19 20 9 13 14 16 17 19 21 23 smallest elements in submatrices: { 1 , 5 , 6 , 12 } ; median=6. largest elements in submatrices: { 9 , 15 , 16 , 23 } ; median=16. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 9 / 20

  16. Searching in a sorted matrix 1 2 3 4 5 6 7 8 2 3 5 6 7 8 9 10 3 6 7 8 10 11 12 13 4 7 8 9 11 12 13 15 6 9 10 11 12 14 15 17 7 10 11 13 14 16 17 18 8 12 13 14 15 18 19 20 9 13 14 16 17 19 21 23 smallest elements in submatrices: { 1 , 5 , 6 , 12 } ; median=6. largest elements in submatrices: { 9 , 15 , 16 , 23 } ; median=16. we compute g (6) = FALSE and g (16) = TRUE . H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 9 / 20

  17. Searching in a sorted matrix 1 2 3 4 5 6 7 8 2 3 5 6 7 8 9 10 3 6 7 8 10 11 12 13 4 7 8 9 11 12 13 15 6 9 10 11 12 14 15 17 7 10 11 13 14 16 17 18 8 12 13 14 15 18 19 20 9 13 14 16 17 19 21 23 smallest elements in submatrices: { 1 , 5 , 6 , 12 } ; median=6. largest elements in submatrices: { 9 , 15 , 16 , 23 } ; median=16. we compute g (6) = FALSE and g (16) = TRUE . we did not make progress. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 9 / 20

  18. Searching in a sorted matrix 1 2 3 4 5 6 7 8 2 3 5 6 7 8 9 10 3 6 7 8 10 11 12 13 4 7 8 9 11 12 13 15 6 9 10 11 12 14 15 17 7 10 11 13 14 16 17 18 8 12 13 14 15 18 19 20 9 13 14 16 17 19 21 23 smallest elements: { 1 , 3 , 5 , 6 , 7 , 8 , 10 , 12 , 13 , 15 , 19 } ; median=8. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 10 / 20

  19. Searching in a sorted matrix 1 2 3 4 5 6 7 8 2 3 5 6 7 8 9 10 3 6 7 8 10 11 12 13 4 7 8 9 11 12 13 15 6 9 10 11 12 14 15 17 7 10 11 13 14 16 17 18 8 12 13 14 15 18 19 20 9 13 14 16 17 19 21 23 smallest elements: { 1 , 3 , 5 , 6 , 7 , 8 , 10 , 12 , 13 , 15 , 19 } ; median=8. largest elements: { 3 , 6 , 7 , 8 , 9 , 10 , 12 , 13 , 15 , 16 , 18 , 19 , 23 } ; median=12. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 10 / 20

  20. Searching in a sorted matrix 1 2 3 4 5 6 7 8 2 3 5 6 7 8 9 10 3 6 7 8 10 11 12 13 4 7 8 9 11 12 13 15 6 9 10 11 12 14 15 17 7 10 11 13 14 16 17 18 8 12 13 14 15 18 19 20 9 13 14 16 17 19 21 23 smallest elements: { 1 , 3 , 5 , 6 , 7 , 8 , 10 , 12 , 13 , 15 , 19 } ; median=8. largest elements: { 3 , 6 , 7 , 8 , 9 , 10 , 12 , 13 , 15 , 16 , 18 , 19 , 23 } ; median=12. we compute g (8) = FALSE and g (12) = TRUE . H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 10 / 20

  21. Searching in a sorted matrix 1 2 3 4 5 6 7 8 2 3 5 6 7 8 9 10 3 6 7 8 10 11 12 13 4 7 8 9 11 12 13 15 6 9 10 11 12 14 15 17 7 10 11 13 14 16 17 18 8 12 13 14 15 18 19 20 9 13 14 16 17 19 21 23 smallest elements: { 1 , 3 , 5 , 6 , 7 , 8 , 10 , 12 , 13 , 15 , 19 } ; median=8. largest elements: { 3 , 6 , 7 , 8 , 9 , 10 , 12 , 13 , 15 , 16 , 18 , 19 , 23 } ; median=12. we compute g (8) = FALSE and g (12) = TRUE . we can discard 8 submatrices. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 10 / 20

  22. Searching in a sorted matrix 7 8 9 10 7 8 10 11 12 13 8 9 11 12 13 15 6 9 10 11 12 14 7 10 11 13 14 16 8 12 9 13 smallest elements: { 1 , 3 , 5 , 6 , 7 , 8 , 10 , 12 , 13 , 15 , 19 } ; median=8. largest elements: { 3 , 6 , 7 , 8 , 9 , 10 , 12 , 13 , 15 , 16 , 18 , 19 , 23 } ; median=12. we compute g (8) = FALSE and g (12) = TRUE . we can discard 8 submatrices. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 11 / 20

  23. Searching in a sorted matrix 7 8 9 10 7 8 10 11 12 13 8 9 11 12 13 15 6 9 10 11 12 14 7 10 11 13 14 16 8 12 9 13 remaining elements { 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 } ; median=12. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 12 / 20

  24. Searching in a sorted matrix 7 8 9 10 7 8 10 11 12 13 8 9 11 12 13 15 6 9 10 11 12 14 7 10 11 13 14 16 8 12 9 13 remaining elements { 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 } ; median=12. we compute g (12) = TRUE H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 12 / 20

  25. Searching in a sorted matrix 7 8 9 10 7 8 10 11 12 13 8 9 11 12 13 15 6 9 10 11 12 14 7 10 11 13 14 16 8 12 9 13 remaining elements { 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 } ; median=12. we compute g (12) = TRUE we discard all elements > 12. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 12 / 20

  26. Searching in a sorted matrix 7 8 9 10 7 8 10 11 12 8 9 11 12 6 9 10 11 12 7 10 11 8 12 9 repeat until one value is left. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 13 / 20

  27. Searching in a sorted matrix 7 8 9 10 7 8 10 11 12 8 9 11 12 6 9 10 11 12 7 10 11 8 12 9 repeat until one value is left. O (log n ) calls to the decision algorithm H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 13 / 20

  28. Searching in a sorted matrix 7 8 9 10 7 8 10 11 12 8 9 11 12 6 9 10 11 12 7 10 11 8 12 9 repeat until one value is left. O (log n ) calls to the decision algorithm O ( n log n ) time for the rest of the algorithm, assuming each matrix element can be accessed in O (1) time. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 13 / 20

  29. Searching in a sorted matrix 7 8 9 10 7 8 10 11 12 8 9 11 12 6 9 10 11 12 7 10 11 8 12 9 repeat until one value is left. O (log n ) calls to the decision algorithm O ( n log n ) time for the rest of the algorithm, assuming each matrix element can be accessed in O (1) time. Therefore, we can compute an optimal step function in O ( n log n ) time. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 13 / 20

  30. Path partitioning INPUT: a path P with n weighted nodes, and an integer k H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 14 / 20

  31. Path partitioning INPUT: a path P with n weighted nodes, and an integer k OUTPUT: a partition of P into k subpaths that minimizes the maximum weight of the subpaths. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 14 / 20

  32. Path partitioning INPUT: a path P with n weighted nodes, and an integer k OUTPUT: a partition of P into k subpaths that minimizes the maximum weight of the subpaths. Example: weights { 3 , 1 , 4 , 3 , 2 , 4 , 1 } , k = 3. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 14 / 20

  33. Path partitioning INPUT: a path P with n weighted nodes, and an integer k OUTPUT: a partition of P into k subpaths that minimizes the maximum weight of the subpaths. Example: weights { 3 , 1 , 4 , 3 , 2 , 4 , 1 } , k = 3. Answer: { 3 , 1 } , { 4 , 3 } , { 2 , 4 , 1 } . Max weight=7. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 14 / 20

  34. Path partitioning INPUT: a path P with n weighted nodes, and an integer k OUTPUT: a partition of P into k subpaths that minimizes the maximum weight of the subpaths. Example: weights { 3 , 1 , 4 , 3 , 2 , 4 , 1 } , k = 3. Answer: { 3 , 1 } , { 4 , 3 } , { 2 , 4 , 1 } . Max weight=7. The path partitioning problem can be solved in O ( n log n ) time by sorted matrix searching. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 14 / 20

  35. Path partitioning INPUT: a path P with n weighted nodes, and an integer k OUTPUT: a partition of P into k subpaths that minimizes the maximum weight of the subpaths. Example: weights { 3 , 1 , 4 , 3 , 2 , 4 , 1 } , k = 3. Answer: { 3 , 1 } , { 4 , 3 } , { 2 , 4 , 1 } . Max weight=7. The path partitioning problem can be solved in O ( n log n ) time by sorted matrix searching. Frederickson found an optimal O ( n ) time algorithm for path partitioning. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 14 / 20

  36. Path partitioning INPUT: a path P with n weighted nodes, and an integer k OUTPUT: a partition of P into k subpaths that minimizes the maximum weight of the subpaths. Example: weights { 3 , 1 , 4 , 3 , 2 , 4 , 1 } , k = 3. Answer: { 3 , 1 } , { 4 , 3 } , { 2 , 4 , 1 } . Max weight=7. The path partitioning problem can be solved in O ( n log n ) time by sorted matrix searching. Frederickson found an optimal O ( n ) time algorithm for path partitioning. This algorithm works in the following, more general case: H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 14 / 20

  37. General framework Σ an alphabet (e.g. Σ = { a , b } or Σ = R ) H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 15 / 20

  38. General framework Σ an alphabet (e.g. Σ = { a , b } or Σ = R ) θ : Σ ∗ → R + with θ ( e ) = 0 H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 15 / 20

  39. General framework Σ an alphabet (e.g. Σ = { a , b } or Σ = R ) θ : Σ ∗ → R + with θ ( e ) = 0 MIN-MAX PARTITION ( θ ) problem: H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 15 / 20

  40. General framework Σ an alphabet (e.g. Σ = { a , b } or Σ = R ) θ : Σ ∗ → R + with θ ( e ) = 0 MIN-MAX PARTITION ( θ ) problem: ◮ Given w ∈ Σ ∗ and k > 0, compute a factorization w = w 1 w 2 . . . w k minimizing i ∈{ 1 ,..., k } θ ( w i ) max H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 15 / 20

  41. General framework Σ an alphabet (e.g. Σ = { a , b } or Σ = R ) θ : Σ ∗ → R + with θ ( e ) = 0 MIN-MAX PARTITION ( θ ) problem: ◮ Given w ∈ Σ ∗ and k > 0, compute a factorization w = w 1 w 2 . . . w k minimizing i ∈{ 1 ,..., k } θ ( w i ) max Frederickson’s problem is obtained with: H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 15 / 20

  42. General framework Σ an alphabet (e.g. Σ = { a , b } or Σ = R ) θ : Σ ∗ → R + with θ ( e ) = 0 MIN-MAX PARTITION ( θ ) problem: ◮ Given w ∈ Σ ∗ and k > 0, compute a factorization w = w 1 w 2 . . . w k minimizing i ∈{ 1 ,..., k } θ ( w i ) max Frederickson’s problem is obtained with: ◮ Σ = R + H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 15 / 20

  43. General framework Σ an alphabet (e.g. Σ = { a , b } or Σ = R ) θ : Σ ∗ → R + with θ ( e ) = 0 MIN-MAX PARTITION ( θ ) problem: ◮ Given w ∈ Σ ∗ and k > 0, compute a factorization w = w 1 w 2 . . . w k minimizing i ∈{ 1 ,..., k } θ ( w i ) max Frederickson’s problem is obtained with: ◮ Σ = R + ◮ θ ( a 1 . . . a p ) = a 1 + . . . + a p H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 15 / 20

  44. General framework Let Σ be an alphabet, and θ : Σ ∗ → R + be a mapping such that θ ( e ) = 0. Suppose that θ has the following properties: H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 16 / 20

  45. General framework Let Σ be an alphabet, and θ : Σ ∗ → R + be a mapping such that θ ( e ) = 0. Suppose that θ has the following properties: (i) θ is non-decreasing, that is, θ ( v ) � θ ( uvw ) for all u , v , w ∈ Σ ∗ . H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 16 / 20

  46. General framework Let Σ be an alphabet, and θ : Σ ∗ → R + be a mapping such that θ ( e ) = 0. Suppose that θ has the following properties: (i) θ is non-decreasing, that is, θ ( v ) � θ ( uvw ) for all u , v , w ∈ Σ ∗ . (ii) We can preprocess a 1 . . . a n ∈ Σ n in time π ( n ) so that, given any query ( i , j ), we can compute θ ( a i . . . a j ) in time κ ( n ). H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 16 / 20

  47. General framework Let Σ be an alphabet, and θ : Σ ∗ → R + be a mapping such that θ ( e ) = 0. Suppose that θ has the following properties: (i) θ is non-decreasing, that is, θ ( v ) � θ ( uvw ) for all u , v , w ∈ Σ ∗ . (ii) We can preprocess a 1 . . . a n ∈ Σ n in time π ( n ) so that, given any query ( i , j ), we can compute θ ( a i . . . a j ) in time κ ( n ). Then MIN-MAX PARTITION ( θ ) can be solved in time O ( π ( n ) + n κ ( n )). H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 16 / 20

  48. General framework Let Σ be an alphabet, and θ : Σ ∗ → R + be a mapping such that θ ( e ) = 0. Suppose that θ has the following properties: (i) θ is non-decreasing, that is, θ ( v ) � θ ( uvw ) for all u , v , w ∈ Σ ∗ . (ii) We can preprocess a 1 . . . a n ∈ Σ n in time π ( n ) so that, given any query ( i , j ), we can compute θ ( a i . . . a j ) in time κ ( n ). Then MIN-MAX PARTITION ( θ ) can be solved in time O ( π ( n ) + n κ ( n )). Example: path partitioning. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 16 / 20

  49. General framework Let Σ be an alphabet, and θ : Σ ∗ → R + be a mapping such that θ ( e ) = 0. Suppose that θ has the following properties: (i) θ is non-decreasing, that is, θ ( v ) � θ ( uvw ) for all u , v , w ∈ Σ ∗ . (ii) We can preprocess a 1 . . . a n ∈ Σ n in time π ( n ) so that, given any query ( i , j ), we can compute θ ( a i . . . a j ) in time κ ( n ). Then MIN-MAX PARTITION ( θ ) can be solved in time O ( π ( n ) + n κ ( n )). Example: path partitioning. ◮ Preprocessing: compute S i = � i ℓ =1 ω ℓ for all i . H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 16 / 20

  50. General framework Let Σ be an alphabet, and θ : Σ ∗ → R + be a mapping such that θ ( e ) = 0. Suppose that θ has the following properties: (i) θ is non-decreasing, that is, θ ( v ) � θ ( uvw ) for all u , v , w ∈ Σ ∗ . (ii) We can preprocess a 1 . . . a n ∈ Σ n in time π ( n ) so that, given any query ( i , j ), we can compute θ ( a i . . . a j ) in time κ ( n ). Then MIN-MAX PARTITION ( θ ) can be solved in time O ( π ( n ) + n κ ( n )). Example: path partitioning. ◮ Preprocessing: compute S i = � i ℓ =1 ω ℓ for all i . ◮ Query: ( i , j ) �→ θ ( ω i , . . . , ω j ) = � j ℓ = i ω ℓ = S j − S i − 1 . H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 16 / 20

  51. General framework Let Σ be an alphabet, and θ : Σ ∗ → R + be a mapping such that θ ( e ) = 0. Suppose that θ has the following properties: (i) θ is non-decreasing, that is, θ ( v ) � θ ( uvw ) for all u , v , w ∈ Σ ∗ . (ii) We can preprocess a 1 . . . a n ∈ Σ n in time π ( n ) so that, given any query ( i , j ), we can compute θ ( a i . . . a j ) in time κ ( n ). Then MIN-MAX PARTITION ( θ ) can be solved in time O ( π ( n ) + n κ ( n )). Example: path partitioning. ◮ Preprocessing: compute S i = � i ℓ =1 ω ℓ for all i . ◮ Query: ( i , j ) �→ θ ( ω i , . . . , ω j ) = � j ℓ = i ω ℓ = S j − S i − 1 . ◮ π ( n ) = O ( n ) and κ ( n ) = O (1), so running time O ( n ). H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 16 / 20

  52. Linear-time algorithm for fitting a step function Application of previous theorem with: H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 17 / 20

  53. Linear-time algorithm for fitting a step function Application of previous theorem with: Σ = R H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 17 / 20

  54. Linear-time algorithm for fitting a step function Application of previous theorem with: Σ = R θ ( a 1 . . . a p ) = 1 2 (max( a 1 , . . . , a p ) − min( a 1 , . . . , a p )) H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 17 / 20

  55. Linear-time algorithm for fitting a step function Application of previous theorem with: Σ = R θ ( a 1 . . . a p ) = 1 2 (max( a 1 , . . . , a p ) − min( a 1 , . . . , a p )) Range maxima problem: H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 17 / 20

  56. Linear-time algorithm for fitting a step function Application of previous theorem with: Σ = R θ ( a 1 . . . a p ) = 1 2 (max( a 1 , . . . , a p ) − min( a 1 , . . . , a p )) Range maxima problem: ◮ Preprocess a sequence of numbers ( y 1 , . . . , y n ) to allow efficient answer to query ( i , j ) �→ max( y i , . . . , y j ) H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 17 / 20

  57. Linear-time algorithm for fitting a step function Application of previous theorem with: Σ = R θ ( a 1 . . . a p ) = 1 2 (max( a 1 , . . . , a p ) − min( a 1 , . . . , a p )) Range maxima problem: ◮ Preprocess a sequence of numbers ( y 1 , . . . , y n ) to allow efficient answer to query ( i , j ) �→ max( y i , . . . , y j ) ◮ Gabow, Bentley, and Tarjan (1984): O (1) query time and O ( n ) time preprocessing. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 17 / 20

  58. Linear-time algorithm for fitting a step function Application of previous theorem with: Σ = R θ ( a 1 . . . a p ) = 1 2 (max( a 1 , . . . , a p ) − min( a 1 , . . . , a p )) Range maxima problem: ◮ Preprocess a sequence of numbers ( y 1 , . . . , y n ) to allow efficient answer to query ( i , j ) �→ max( y i , . . . , y j ) ◮ Gabow, Bentley, and Tarjan (1984): O (1) query time and O ( n ) time preprocessing. Conclusion: the sorted case can be solved in O ( n ) time. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 17 / 20

  59. Weighted version Given a set of points in the plane { ( x 1 , y 1 ) , . . . , ( x n , y n ) } with positive weights µ 1 , . . . , µ n and an integer k > 0, compute a k -step function f such that 1 � i � n µ i | f ( x i ) − y i | max is minimized. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 18 / 20

  60. Weighted version Given a set of points in the plane { ( x 1 , y 1 ) , . . . , ( x n , y n ) } with positive weights µ 1 , . . . , µ n and an integer k > 0, compute a k -step function f such that 1 � i � n µ i | f ( x i ) − y i | max is minimized. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 18 / 20

  61. Weighted version Given a set of points in the plane { ( x 1 , y 1 ) , . . . , ( x n , y n ) } with positive weights µ 1 , . . . , µ n and an integer k > 0, compute a k -step function f such that 1 � i � n µ i | f ( x i ) − y i | max is minimized. Data structure by Guha and Shim: preprocessing π ( n ) = O ( n log n ) and query time κ ( n ) = O (log 4 n ). H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 18 / 20

  62. Weighted version Given a set of points in the plane { ( x 1 , y 1 ) , . . . , ( x n , y n ) } with positive weights µ 1 , . . . , µ n and an integer k > 0, compute a k -step function f such that 1 � i � n µ i | f ( x i ) − y i | max is minimized. Data structure by Guha and Shim: preprocessing π ( n ) = O ( n log n ) and query time κ ( n ) = O (log 4 n ). So we obtain an O ( n log 4 n ) time algorithm. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 18 / 20

  63. Weighted version Given a set of points in the plane { ( x 1 , y 1 ) , . . . , ( x n , y n ) } with positive weights µ 1 , . . . , µ n and an integer k > 0, compute a k -step function f such that 1 � i � n µ i | f ( x i ) − y i | max is minimized. Data structure by Guha and Shim: preprocessing π ( n ) = O ( n log n ) and query time κ ( n ) = O (log 4 n ). So we obtain an O ( n log 4 n ) time algorithm. Guha and Shim gave an O ( n log n + k 2 log 6 n ) time algorithm. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 18 / 20

  64. Frederickson’s algorithm (sketch) Partition a 1 a 2 . . . a n into n / r factors of length r , for r = ⌈ log n ⌉ . H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 19 / 20

  65. Frederickson’s algorithm (sketch) Partition a 1 a 2 . . . a n into n / r factors of length r , for r = ⌈ log n ⌉ . construct a collection of submatrices, each submatrix corresponding to one factor. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 19 / 20

  66. Frederickson’s algorithm (sketch) Partition a 1 a 2 . . . a n into n / r factors of length r , for r = ⌈ log n ⌉ . construct a collection of submatrices, each submatrix corresponding to one factor. apply the matrix searching technique on this collection of submatrices, until O ( n / r 2 ) elements remain. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 19 / 20

  67. Frederickson’s algorithm (sketch) Partition a 1 a 2 . . . a n into n / r factors of length r , for r = ⌈ log n ⌉ . construct a collection of submatrices, each submatrix corresponding to one factor. apply the matrix searching technique on this collection of submatrices, until O ( n / r 2 ) elements remain. using this information, we do some preprocessing on each subinterval that is not associated with any remaining matrix element. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 19 / 20

  68. Frederickson’s algorithm (sketch) Partition a 1 a 2 . . . a n into n / r factors of length r , for r = ⌈ log n ⌉ . construct a collection of submatrices, each submatrix corresponding to one factor. apply the matrix searching technique on this collection of submatrices, until O ( n / r 2 ) elements remain. using this information, we do some preprocessing on each subinterval that is not associated with any remaining matrix element. it gives us an O ( n log log n / log n ) time decision algorithm. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 19 / 20

  69. Frederickson’s algorithm (sketch) Partition a 1 a 2 . . . a n into n / r factors of length r , for r = ⌈ log n ⌉ . construct a collection of submatrices, each submatrix corresponding to one factor. apply the matrix searching technique on this collection of submatrices, until O ( n / r 2 ) elements remain. using this information, we do some preprocessing on each subinterval that is not associated with any remaining matrix element. it gives us an O ( n log log n / log n ) time decision algorithm. using it to search the whole matrix, we get an O ( n log log n ) optimization algorithm. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 19 / 20

  70. Frederickson’s algorithm (sketch) Partition a 1 a 2 . . . a n into n / r factors of length r , for r = ⌈ log n ⌉ . construct a collection of submatrices, each submatrix corresponding to one factor. apply the matrix searching technique on this collection of submatrices, until O ( n / r 2 ) elements remain. using this information, we do some preprocessing on each subinterval that is not associated with any remaining matrix element. it gives us an O ( n log log n / log n ) time decision algorithm. using it to search the whole matrix, we get an O ( n log log n ) optimization algorithm. It can be improved to O ( n log ∗ n ) by cutting the factors recursively. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 19 / 20

  71. Frederickson’s algorithm (sketch) Partition a 1 a 2 . . . a n into n / r factors of length r , for r = ⌈ log n ⌉ . construct a collection of submatrices, each submatrix corresponding to one factor. apply the matrix searching technique on this collection of submatrices, until O ( n / r 2 ) elements remain. using this information, we do some preprocessing on each subinterval that is not associated with any remaining matrix element. it gives us an O ( n log log n / log n ) time decision algorithm. using it to search the whole matrix, we get an O ( n log log n ) optimization algorithm. It can be improved to O ( n log ∗ n ) by cutting the factors recursively. It can be further improved to O ( n ), using careful counting arguments. H. Fournier and A. Vigneron (UVSQ, INRA) Fitting a Step Function to a Point Set December 4, 2008 19 / 20

Recommend


More recommend