balanced mobiles
play

Balanced Mobiles Yassine Hamoudi , Sophie Laplante , Roberto Mantaci - PowerPoint PPT Presentation

Balanced Mobiles Yassine Hamoudi , Sophie Laplante , Roberto Mantaci May 17, 2017 ENS Lyon IRIF, Paris Diderot Mobile . Calder, 1932. 1 Introduction A mobile M is a full binary tree in which each leaf has a (positive) weight. 5 3 15 2 4


  1. 1 2 3 4 1 w 1 ℓ 1 , 1 = 1 ℓ 1 , 2 = 1 ℓ 1 , 3 = 1 ℓ 1 , 4 = 0 r 1 , 1 = 0 r 1 , 2 = 0 r 1 , 3 = 0 r 1 , 4 = 0 w 2 ℓ 2 , 1 = 1 ℓ 2 , 2 = 1 ℓ 2 , 3 = 0 ℓ 2 , 4 = 0 2 w 5 r 2 , 1 = 0 r 2 , 2 = 0 r 2 , 3 = 1 r 2 , 4 = 0 w 3 ℓ 3 , 1 = 1 ℓ 3 , 2 = 0 ℓ 3 , 3 = 0 ℓ 3 , 4 = 1 3 4 r 3 , 1 = 0 r 3 , 2 = 1 r 3 , 3 = 0 r 3 , 4 = 0 ℓ 4 , 1 = 1 ℓ 4 , 2 = 0 ℓ 4 , 3 = 0 ℓ 4 , 4 = 0 w 4 r 4 , 1 = 0 r 4 , 2 = 1 r 4 , 3 = 0 r 4 , 4 = 1 w 1 w 2 w 3 w 4 w 5 ℓ 5 , 1 = 0 ℓ 5 , 2 = 0 ℓ 5 , 3 = 0 ℓ 5 , 4 = 0 r 5 , 1 = 1 r 5 , 2 = 0 r 5 , 3 = 0 r 5 , 4 = 0 The weight w i cannot be simultaneously in the left and right subtrees of the node u . ∀ i , u , ℓ i , u + r i , u ≤ 1 16

  2. 1 2 3 4 1 w 1 ℓ 1 , 1 = 1 ℓ 1 , 2 = 1 ℓ 1 , 3 = 1 ℓ 1 , 4 = 0 r 1 , 1 = 0 r 1 , 2 = 0 r 1 , 3 = 0 r 1 , 4 = 0 w 2 ℓ 2 , 1 = 1 ℓ 2 , 2 = 1 ℓ 2 , 3 = 0 ℓ 2 , 4 = 0 2 w 5 r 2 , 1 = 0 r 2 , 2 = 0 r 2 , 3 = 1 r 2 , 4 = 0 w 3 ℓ 3 , 1 = 1 ℓ 3 , 2 = 0 ℓ 3 , 3 = 0 ℓ 3 , 4 = 1 3 4 r 3 , 1 = 0 r 3 , 2 = 1 r 3 , 3 = 0 r 3 , 4 = 0 ℓ 4 , 1 = 1 ℓ 4 , 2 = 0 ℓ 4 , 3 = 0 ℓ 4 , 4 = 0 w 4 r 4 , 1 = 0 r 4 , 2 = 1 r 4 , 3 = 0 r 4 , 4 = 1 w 1 w 2 w 3 w 4 w 5 ℓ 5 , 1 = 0 ℓ 5 , 2 = 0 ℓ 5 , 3 = 0 ℓ 5 , 4 = 0 r 5 , 1 = 1 r 5 , 2 = 0 r 5 , 3 = 0 r 5 , 4 = 0 If the weight w i is the right (resp. left) child of the node u , then none of the other leaves can be in the right (resp. left) subtree of the node u . � (1 − ℓ i , u ) + � v > u ( ℓ i , v + r i , v ) ≥ ℓ j , u ∀ i � = j , ∀ u , (1 − r i , u ) + � v > u ( ℓ i , v + r i , v ) ≥ r j , u 16

  3. n − 1 � n � � � � � w i ( ℓ i , u − r i , u ) � subject to: Minimize � � � � u =1 � i =1 ∀ i , u , ℓ i , u + r i , u ≤ 1 ∀ i , ℓ i , 1 + r i , 1 = 1 ∀ u , � i ℓ i , u > 0 and � i r i , u > 0 � (1 − ℓ i , u ) + � v > u ( ℓ i , v + r i , v ) ≥ ℓ j , u ∀ i � = j , ∀ u , (1 − r i , u ) + � v > u ( ℓ i , v + r i , v ) ≥ r j , u � ℓ i , u + ( ℓ i , v + r i , v + ℓ j , v + r j , v ) ≤ 2 + ℓ j , u ∀ i � = j , ∀ u < v , r i , u + ( ℓ i , v + r i , v + ℓ j , v + r j , v ) ≤ 2 + r j , u � 2 − ℓ i , u − ℓ j , u + � u ′ w = u +1 ( ℓ i , w + r i , w ) ≥ r j , u ′ + r j , u ′ ∀ i � = j , ∀ u < u ′ , 2 − r i , u − r j , u + � u ′ w = u +1 ( ℓ i , w + r i , w ) ≥ ℓ j , u ′ + ℓ j , u ′ 17

  4. The Evaluation Trees problem

  5. Non-Abelian Evaluation Trees Problem Given n elements x 1 , . . . , x n of a set X equipped with an associative operator ◦ : X × X → X and a cost function c : X × X → R + , find the optimal evaluation tree to compute x 1 ◦ x 2 ◦ . . . ◦ x n . 18

  6. Non-Abelian Evaluation Trees Problem Given n elements x 1 , . . . , x n of a set X equipped with an associative operator ◦ : X × X → X and a cost function c : X × X → R + , find the optimal evaluation tree to compute x 1 ◦ x 2 ◦ . . . ◦ x n . ◦ ◦ ◦ x 1 x 2 x 3 x 4 (( x 1 ◦ x 2 ) ◦ ( x 3 ◦ x 4 )) 18

  7. Non-Abelian Evaluation Trees Problem Given n elements x 1 , . . . , x n of a set X equipped with an associative operator ◦ : X × X → X and a cost function c : X × X → R + , find the optimal evaluation tree to compute x 1 ◦ x 2 ◦ . . . ◦ x n . ◦ ◦ x 4 ◦ x 1 x 2 x 3 (( x 1 ◦ ( x 2 ◦ x 3 )) ◦ x 4 ) 18

  8. Non-Abelian Evaluation Trees Problem Given n elements x 1 , . . . , x n of a set X equipped with an associative operator ◦ : X × X → X and a cost function c : X × X → R + , find the optimal evaluation tree to compute x 1 ◦ x 2 ◦ . . . ◦ x n . c ( x 1 ◦ x 2 ◦ x 3 , x 4 ) c ( x 1 , x 2 ◦ x 3 ) x 4 x 1 c ( x 2 , x 3 ) x 2 x 3 c ( x 1 ◦ x 2 ◦ x 3 , x 4 ) + c ( x 1 , x 2 ◦ x 3 ) + c ( x 2 , x 3 ) 18

  9. Ordered Balanced Mobiles Given a sequence of weights ( w 1 , . . . , w n ), find a mobile of imbalance as small as possible with these weights in the same order from left to right. 3 4 1 2 4 8 7 3 5 An optimal mobile for the sequence (4 , 8 , 3 , 5 , 7). 19

  10. Ordered Balanced Mobiles Given a sequence of weights ( w 1 , . . . , w n ), find a mobile of imbalance as small as possible with these weights in the same order from left to right. This is a Non-Abelian Evaluation Trees problem with: ❼ x i = w i and X = N ❼ c ( x , y ) = | x − y | ❼ x ◦ y = x + y 19

  11. ❼ ❼ ❼ Matrix Chain Multiplication Given a sequence of matrices ( M 1 , . . . , M n ) where dim ( M i ) = ( n i − 1 , n i ), find the optimal way to compute the product M 1 × · · · × M n . 20

  12. Matrix Chain Multiplication Given a sequence of matrices ( M 1 , . . . , M n ) where dim ( M i ) = ( n i − 1 , n i ), find the optimal way to compute the product M 1 × · · · × M n . This is a Non-Abelian Evaluation Trees problem with: ❼ x i = ( n i − 1 , n i ) and X = N × N ❼ c ( x , y ) = n × m × k where x = ( n , m ) and y = ( m , k ) ❼ x ◦ y = ( n , k ) where x = ( n , m ) and y = ( m , k ) 20

  13. Matrix Chain Multiplication Given a sequence of matrices ( M 1 , . . . , M n ) where dim ( M i ) = ( n i − 1 , n i ), find the optimal way to compute the product M 1 × · · · × M n . This is a Non-Abelian Evaluation Trees problem with: ❼ x i = ( n i − 1 , n i ) and X = N × N ❼ c ( x , y ) = n × m × k where x = ( n , m ) and y = ( m , k ) ❼ x ◦ y = ( n , k ) where x = ( n , m ) and y = ( m , k ) � n 3 � Dynamic programming in O : � 0 if i = j C [ i , j ] = i ≤ k < j { C [ i , k ] + C [ k + 1 , j ] + c ( x i ◦ · · · ◦ x k , x k +1 ◦ · · · ◦ x j ) , } min if i < j 20

  14. Abelian Evaluation Trees Problem Given n elements x 1 , . . . , x n of a set X equipped with an associative and commutative operator ◦ : X × X → X and a cost function c : X × X → R + , find the optimal evaluation tree to compute x 1 ◦ x 2 ◦ . . . ◦ x n . ◦ ◦ x 2 ◦ x 3 x 1 x 4 (( x 3 ◦ ( x 1 ◦ x 4 )) ◦ x 2 ) 21

  15. Balanced Mobiles Given a set of weights { w 1 , . . . , w n } , find a mobile of imbalance as small as possible with these weights. This is an Abelian Evaluation Trees problem with: ❼ x i = w i and X = N ❼ c ( x , y ) = | x − y | ❼ x ◦ y = x + y 22

  16. ❼ ❼ ❼ Huffman Coding Given an alphabet { a 1 , . . . , a n } and the number of occurencies w i of each a i , find a prefix-free binary code ( c 1 , . . . , c n ) that minimizes � i w i · | c i | . 23

  17. ❼ ❼ ❼ Huffman Coding Given an alphabet { a 1 , . . . , a n } and the number of occurencies w i of each a i , find a prefix-free binary code ( c 1 , . . . , c n ) that minimizes � i w i · | c i | . w 2 w 3 w 1 w 4 3 w 1 + w 2 + 2 w 3 + 3 w 4 23

  18. ❼ ❼ ❼ Huffman Coding Given an alphabet { a 1 , . . . , a n } and the number of occurencies w i of each a i , find a prefix-free binary code ( c 1 , . . . , c n ) that minimizes � i w i · | c i | . w 2 + ( w 1 + w 3 + w 4 ) ( w 1 + w 4 ) + w 3 w 2 w 1 + w 4 w 3 w 1 w 4 3 w 1 + w 2 + 2 w 3 + 3 w 4 23

  19. Huffman Coding Given an alphabet { a 1 , . . . , a n } and the number of occurencies w i of each a i , find a prefix-free binary code ( c 1 , . . . , c n ) that minimizes � i w i · | c i | . w 2 + ( w 1 + w 3 + w 4 ) ( w 1 + w 4 ) + w 3 w 2 w 1 + w 4 w 3 w 1 w 4 3 w 1 + w 2 + 2 w 3 + 3 w 4 This is an Abelian Evaluation Trees problem with: ❼ x i = w i and X = N ❼ c ( x , y ) = x + y ❼ x ◦ y = x + y 23

  20. Generalized Huffman Coding The coding alphabet is made of two letters of unequal lengths α and β . 24

  21. Generalized Huffman Coding The coding alphabet is made of two letters of unequal lengths α and β . β α β w 3 α w 2 β α w 4 w 1 (2 α + β ) w 1 + 2 β w 2 + α w 3 + ( α + 2 β ) w 4 24

  22. Generalized Huffman Coding The coding alphabet is made of two letters of unequal lengths α and β . α w 3 + β ( w 1 + w 2 + w 4 ) α ( w 1 + w 4 ) + β w 2 w 3 w 2 α w 1 + β w 4 w 4 w 1 (2 α + β ) w 1 + 2 β w 2 + α w 3 + ( α + 2 β ) w 4 24

  23. Generalized Huffman Coding The coding alphabet is made of two letters of unequal lengths α and β . This is an Abelian Evaluation Trees problem with: ❼ x i = w i and X = N ❼ c ( x , y ) = α x + β y ❼ x ◦ y = x + y 24

  24. Generalized Huffman Coding The coding alphabet is made of two letters of unequal lengths α and β . ❼ The case α = β is Huffman Coding [Huf52] . This is solved in O ( n log n ) by Smallest . ❼ The case w 1 = · · · = w n is solved in poly-time [Var71, GY96, CG01] . ❼ First known algorithm for the general case is an ILP [Kar61] . n max( α,β ) � � ❼ Dynamic programming algorithm in O [GR98, BGLR02] . ❼ PTAS [GMY12] No poly-time algorithm for the general case nor it is known to be NP-hard. 24

  25. Dynamic programming Using dynamic programming, compute for all S ⊆ { 1 , . . . , n } the optimal cost C ( S ) for ◦ i ∈ S x i . � � + C ( S ′ ) + C ( S \ S ′ ) C ( S ) = S ′ ⊆ S , S ′ � = ∅ c min i ∈ S ′ x i , ◦ ◦ ◦ i ∈ S \ S ′ x i ◦ ◦ ◦ ( n ) time and O (2 n ) space. It runs in 2 O 25

  26. Integer Linear Programming (Balanced Mobiles) n − 1 � n � � � � � ( ℓ i , u − r i , u ) · w i � subject to: Minimize � � � � u =1 � i =1 ∀ i , u , ℓ i , u + r i , u ≤ 1 ∀ i , ℓ i , 1 + r i , 1 = 1 ∀ u , � i ℓ i , u > 0 and � i r i , u > 0 � (1 − ℓ i , u ) + � v > u ( ℓ i , v + r i , v ) ≥ ℓ j , u ∀ i � = j , ∀ u , (1 − r i , u ) + � v > u ( ℓ i , v + r i , v ) ≥ r j , u � ℓ i , u + ( ℓ i , v + r i , v + ℓ j , v + r j , v ) ≤ 2 + ℓ j , u ∀ i � = j , ∀ u < v , r i , u + ( ℓ i , v + r i , v + ℓ j , v + r j , v ) ≤ 2 + r j , u � 2 − ℓ i , u − ℓ j , u + � u ′ w = u +1 ( ℓ i , w + r i , w ) ≥ r j , u ′ + r j , u ′ ∀ i � = j , ∀ u < u ′ , 2 − r i , u − r j , u + � u ′ w = u +1 ( ℓ i , w + r i , w ) ≥ ℓ j , u ′ + ℓ j , u ′ 26

  27. Integer Linear Programming (Huffman Coding) n − 1 n � � ( α · ℓ i , u + β · r i , u ) · w i subject to: Minimize u =1 i =1 ∀ i , u , ℓ i , u + r i , u ≤ 1 ∀ i , ℓ i , 1 + r i , 1 = 1 ∀ u , � i ℓ i , u > 0 and � i r i , u > 0 � (1 − ℓ i , u ) + � v > u ( ℓ i , v + r i , v ) ≥ ℓ j , u ∀ i � = j , ∀ u , (1 − r i , u ) + � v > u ( ℓ i , v + r i , v ) ≥ r j , u � ℓ i , u + ( ℓ i , v + r i , v + ℓ j , v + r j , v ) ≤ 2 + ℓ j , u ∀ i � = j , ∀ u < v , r i , u + ( ℓ i , v + r i , v + ℓ j , v + r j , v ) ≤ 2 + r j , u � 2 − ℓ i , u − ℓ j , u + � u ′ w = u +1 ( ℓ i , w + r i , w ) ≥ r j , u ′ + r j , u ′ ∀ i � = j , ∀ u < u ′ , 2 − r i , u − r j , u + � u ′ w = u +1 ( ℓ i , w + r i , w ) ≥ ℓ j , u ′ + ℓ j , u ′ 27

  28. R-Smallest algorithm The R-Smallest algorithm can be used whenever the “rotation property” holds: ∀ x ≤ y ≤ z , c ( x , y ) + c ( x ◦ y , z ) ≤ c ( y , z ) + c ( y ◦ z , x ) w 1 − → B w 1 A B A 28

  29. Enumeration of Trees Enumerate all the leaf-labelled, unordered, full binary trees with n leaves. Bijection with perfect matchings over N = 2( n − 1) vertices [Che90, BDN10] 1 2 3 4 5 6 7 8 9 10 11 12 n n / 2 � � There are N !! = O such matchings. 29

  30. Enumeration of Trees Enumerate all the leaf-labelled, unordered, full binary trees with n leaves. Bijection with perfect matchings over N = 2( n − 1) vertices [Che90, BDN10] 12 11 − → 1 2 3 4 5 6 7 8 9 10 11 12 n n / 2 � � There are N !! = O such matchings. 29

  31. Enumeration of Trees Enumerate all the leaf-labelled, unordered, full binary trees with n leaves. Bijection with perfect matchings over N = 2( n − 1) vertices [Che90, BDN10] 12 11 10 − → 2 1 2 3 4 5 6 7 8 9 10 11 12 n n / 2 � � There are N !! = O such matchings. 29

  32. Enumeration of Trees Enumerate all the leaf-labelled, unordered, full binary trees with n leaves. Bijection with perfect matchings over N = 2( n − 1) vertices [Che90, BDN10] 12 11 10 9 − → 2 4 1 2 3 4 5 6 7 8 9 10 11 12 n n / 2 � � There are N !! = O such matchings. 29

  33. Enumeration of Trees Enumerate all the leaf-labelled, unordered, full binary trees with n leaves. Bijection with perfect matchings over N = 2( n − 1) vertices [Che90, BDN10] 12 11 10 9 − → 2 4 8 5 1 2 3 4 5 6 7 8 9 10 11 12 n n / 2 � � There are N !! = O such matchings. 29

  34. Enumeration of Trees Enumerate all the leaf-labelled, unordered, full binary trees with n leaves. Bijection with perfect matchings over N = 2( n − 1) vertices [Che90, BDN10] 12 11 10 9 − → 2 4 8 5 1 7 1 2 3 4 5 6 7 8 9 10 11 12 n n / 2 � � There are N !! = O such matchings. 29

  35. Enumeration of Trees Enumerate all the leaf-labelled, unordered, full binary trees with n leaves. Bijection with perfect matchings over N = 2( n − 1) vertices [Che90, BDN10] 12 11 10 9 − → 2 4 8 5 1 7 1 2 3 4 5 6 7 8 9 10 11 12 3 6 n n / 2 � � There are N !! = O such matchings. 29

  36. Enumeration of Trees Enumerate all the leaf-labelled, unordered, full binary trees with n leaves. Bijection with perfect matchings over N = 2( n − 1) vertices [Che90, BDN10] − → x 2 x 4 x 5 x 1 x 7 1 2 3 4 5 6 7 8 9 10 11 12 x 3 x 6 n n / 2 � � There are N !! = O such matchings. 29

  37. Algorithms for Abelian Evaluation Trees Time Space 2 O ( n ) O (2 n ) Dynamic Programming n 2 variables and n 4 constraints Integer Programming* log( n ) n min( C , n )+1 � � R-Smallest * O O ( n log n ) n n / 2 � � Enumeration of Trees O O ( n log n ) 30

  38. Conclusion

  39. Open questions 1. Is Balanced Mobiles NP-hard? 2. What are the polynomial-time instances of Abelian Evaluation Trees ? 3. For which instances is Smallest optimal? 4. Which instances admit an approximation scheme? What if the shape of the mobile is fixed and one has just to find the permutation of the weights that minimizes the imbalance? 31

  40. References i O. Bernardi, B. Duplantier, and P. Nadeau. A bijection between well-labelled positive paths and matchings. In S´ eminaire Lotharingien de Combinatoire , volume 63, page B63e, 2010. Phillip G. Bradford, Mordecai J. Golin, Lawrence L. Larmore, and Wojciech Rytter. Optimal prefix-free codes for unequal letter costs: Dynamic programming with the Monge property. Journal of Algorithms , 42(2):277–303, 2002. V. Choi and M. J. Golin. Lopsided trees, I: Analyses. Algorithmica , 31(3):240–290, 2001. 32

  41. References ii W. Y. C. Chen. A general bijective algorithm for trees. Proc. Nat. Acad. Sci. U.S.A., , 87(24):9635—9639, 1990. Mordecai J. Golin, Claire Mathieu, and Neal E. Young. Huffman coding with letter costs: A linear-time approximation scheme. SIAM J. Comput. , 41(3):684–713, 2012. M. J. Golin and G. Rote. A dynamic programming algorithm for constructing optimal prefix-free codes with unequal letter costs. IEEE Transactions on Information Theory , 44(5):1770–1781, Sep 1998. 33

  42. References iii Mordecai J. Golin and Neal Young. Prefix codes: Equiprobable words, unequal letter costs. SIAM Journal on Computing , 25(6):1281–1292, 1996. D.A. Huffman. A method for the construction of minimum-redundancy codes. Proceedings of the IRE , 40(9):1098–1101, Sept 1952. Richard M. Karp. Minimum-redundancy coding for the discrete noiseless channel. Information Theory, IRE Transactions on , 7(1):27–38, January 1961. Ben Varn. Optimal variable length codes (arbitrary symbol cost and equal code word probability). Information and Control , 19(4):289 – 301, 1971. 34

  43. References iv 35

  44. Powers-Of-Two Weights

  45. Irregular mobiles A mobile M is irregular if: ❼ it is an optimal mobile built on powers-of-two weights ❼ it cannot be built by Smallest ❼ its imbalance is less than the one obtained by Smallest on the same weights. 36

  46. Irregular mobiles A mobile M is irregular if: ❼ it is an optimal mobile built on powers-of-two weights ❼ it cannot be built by Smallest ❼ its imbalance is less than the one obtained by Smallest on the same weights. Proposition The Smallest algorithm is optimal for powers-of-two weights if and only if there is no irregular mobiles. 36

  47. ❼ ❼ A special irregular mobile Assume by contradiction that there exist irregular mobiles. 37

  48. A special irregular mobile Assume by contradiction that there exist irregular mobiles. Take such a mobile M with: ❼ the smallest maximum weight ❼ the smallest number of leaves (among the irregular mobiles having the smallest maximum weight) M L M R 37

  49. ❼ ❼ ❼ A special irregular mobile Note that: ❼ the maximum weight of M is at least 2 38

  50. ❼ ❼ A special irregular mobile Note that: ❼ the maximum weight of M is at least 2 ❼ M has at least one leaf of weight 1 38

  51. ❼ A special irregular mobile Note that: ❼ the maximum weight of M is at least 2 ❼ M has at least one leaf of weight 1 ❼ w.l.o.g. M L and M R are built by Smallest 38

  52. A special irregular mobile Note that: ❼ the maximum weight of M is at least 2 ❼ M has at least one leaf of weight 1 ❼ w.l.o.g. M L and M R are built by Smallest ❼ M L and M R have at most one leaf of weight 1 each 38

  53. A special irregular mobile Note that: ❼ the maximum weight of M is at least 2 ❼ M has at least one leaf of weight 1 ❼ w.l.o.g. M L and M R are built by Smallest ❼ M L and M R have at most one leaf of weight 1 each M R M L M L M R 2 a 2 a 1 1 1 2 b First type Second type 38

  54. First possible shape M R M L 1 2 a Mobile M + Mobile M − M R M R M L M L 2 a 2 a 2 ∆ M = 1 2 ∆ M + + 1 2 ∆ M − + 2 a − 1 39

  55. First possible shape Take the (non-optimal) mobile M s built by Smallest : M s , R M s , L 1 2 b 40

Recommend


More recommend