Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rectangle Visibility and Elusive K23

Rectangle Visibility and Elusive K23

A talk detailing my attempts to find the 3D Rectangle Visibility Diagram for the K23 graph using Genetic Algorithms

Rod Hilton

May 02, 2013
Tweet

More Decks by Rod Hilton

Other Decks in Technology

Transcript

  1. Given a Rectangle Diagram, can we come up with a

    Visibility Graph for it? A E C B D A B D C E This is easy! For a set of rectangles R: For every pair of rectangles (r1 ,r2 ) in R: see if there is a horizontal or vertical line from r1 to r2 , unobstructed by any other rectangle in R. K5 !
  2. What if we drew our rectangles not side-by-side on a

    plane, but one on top of another in 3D? R B R B
  3. Who Cares? 2D Rectangle Visibility Graphs have applications in circuit

    board layout 3D R.V.G.’s have applications in visualizing software dependency diagrams There are lots of unanswered questions, isn’t that enough?
  4. Special Graph: Cn! 1 2 3 n 1 2 3

    … n-1! n! In fact, any planar graph has a representation!
  5. Special Graph: Km,n! 1 2 3 m 1 n 2

    … … 1 2 3 … m! 1 2 … n!
  6. What is the largest number of rectangles you can arrange

    and still have them all be visible to each other?
  7. In other words…. What is the largest n such that

    Kn has a 3D Rectangle Visibility Representation? K4 ? R G O B K5 ? ✔ ✔ K6 ? ✔ …?
  8. First, how high can’t we go? No complete graph Kn

    has a 3D Rectangle Visibility Diagram representation when n ≥ 56! - “A Visibility Representation for Graphs in Three Dimensions”, Bose, et. al. To K55 maybe! And no further! This upper bound is not sharp Doesn’t mean K55 does have one
  9. Upper bound of 55 shown via proof by contradiction (trust

    me) Lower bounds can be shown via construction If we can construct a diagram for some n, we have one for n-1 (just remove the top)
  10. ✔ 22 and down 56 and up ✗ K23 K24

    K25 K26 K27 K28 K29 K30 K31 K33 KXX KXX KXX KXX KXX KXX KXX KXX KXX KXX KXX KXX KXX KXX KXX KXX KXX KXX K XX KXX K54 K55
  11. How will we find a 3D Rectangle Visibility Representation for

    K23 ? We can’t just algorithmically convert complete graphs to rectangle diagrams (it’s NP-Complete) What if we could somehow enumerate every possible arrangement of 23 rectangles? Then we could search through them, checking if any of them is fully connected. So we have an enormous search space that we want to search quickly…
  12. Metaheuristics can find solutions to problems that deterministic optimization algorithms

    can’t (efficiently). 1.  Examine candidate solution(s) 2.  Evaluate how well solution(s) solve the problem 3.  Modify solution(s) 4.  Repeat Works for problems whose sub-optimal solutions can be compared!
  13. Psst… this graph is a perfect use case for a

    3D rectangle visibility diagram
  14. Genetic Algorithms 1.  Generate P random solutions to your problem

    (initialization) 2.  Score each solution on well it solves the problem (the fitness) 3.  Take the best N solutions, combine them (crossover) 4.  Slightly modify the combined solutions to get P more (mutation) 5.  Go to 2. Science!
  15. Example: Infinite Monkey Theorem Goal: tobeornottobe 2613 combinations! (That’s 2,481,152,873,203,736,576!)

    vacfnlpingsde sojwsmuelwapy lrkyycpicckxs sfadpfpkxujgm knqruazzbibry ssqsyawkhgesd wlmkglwqwdffl vvbpcmgdjkeqt sdchkmlunsxzf bankorwteyzqt 1 1 0 0 0 0 0 1 0 2
  16. Example: Infinite Monkey Theorem Goal: tobeornottobe 2613 combinations! (That’s 2,481,152,873,203,736,576!)

    bankorwteyzqt vacfnlpingsde bankorwtegsde vacfnlpinyzqt vacfilpinyzqt vacfnlpinyzqh vacfnlpjnyzqt bankorwtfgsde vacfnlpinyzqd bankorwtegsde bankorwteosde badkorwtegsde vacfnlpinpzqt bankorwtegrde 0 0 0 3 0 3 3 3 0 3 tobeorsottnve 10 per generation 50 generations ~1 second
  17. How many possible arrangements of 23 rectangles are there? 5?

    543? There are only 23 relevant unique positions on an axis on each side
  18. How many possible arrangements of 23 rectangles are there? For

    any fully connected visibility diagram, there must be a region where all rectangles overlap Let’s call this (0,0)
  19. How many possible arrangements of 23 rectangles are there? Each

    rectangle is (E, N, W, S)! (1, 3, 3, 1)! (3, 2, 1, 1)! (1, 1, 2, 3)! This ensures our rectangles always overlap!
  20. How many possible arrangements of 23 rectangles are there? Our

    rectangle diagram’s “gene”: { 23: ( 2, 20, 14, 7) 22: (15, 1, 9, 1) 21: (13, 12, 17, 11) 20: (10, 18, 13, 10) 19: ( 9, 10, 20, 9) 18: ( 7, 13, 14, 8) 17: ( 5, 20, 16, 7) 16: (19, 2, 11, 5) 15: (17, 3, 10, 4) 14: (18, 6, 6, 3) 13: ( 6, 14, 19, 1) 12: ( 4, 19, 2, 16) 11: ( 3, 15, 3, 15) 10: (14, 4, 1, 20) 9: ( 2, 16, 4, 12) 8: ( 1, 17, 5, 14) 7: (12, 1, 7, 18) 6: (11, 5, 8, 17) 5: ( 8, 7, 9, 19) 4: (20, 8, 12, 2) 3: (15, 9, 18, 6) 2: (16, 11, 15, 13) 1: (22, 22, 22, 22) } 4 * 23 = 92 possible slots 23 possible values per slot = 2392 possible diagrams 190,090,719,111,086,999,142,918,580,674,213, 624,851,393,339,907,036,543,758,193,303,444, 850,234,108,744,968,124,140,618,335,905,659, 363,676,581,401,527,869,136,497,121!
  21. Initialization? 23: ( ?, ?, ?, ?) 22: ( ?,

    ?, ?, ?) 21: ( ?, ?, ?, ?) 20: ( ?, ?, ?, ?) 19: ( ?, ?, ?, ?) 18: ( ?, ?, ?, ?) 17: ( ?, ?, ?, ?) 16: ( ?, ?, ?, ?) 15: ( ?, ?, ?, ?) 14: ( ?, ?, ?, ?) 13: ( ?, ?, ?, ?) 12: ( ?, ?, ?, ?) 11: ( ?, ?, ?, ?) 10: ( ?, ?, ?, ?) 9: ( ?, ?, ?, ?) 8: ( ?, ?, ?, ?) 7: ( ?, ?, ?, ?) 6: ( ?, ?, ?, ?) 5: ( ?, ?, ?, ?) 4: ( ?, ?, ?, ?) 3: ( ?, ?, ?, ?) 2: ( ?, ?, ?, ?) 1: ( ?, ?, ?, ?) Pick a random number from 1 to 23 for each
  22. Fitness function? We can quickly determine if any two rectangles

    can “see” each other (in polynomial time) So we can simply go through every pair of rectangles and check if they can see each other. There are only n(n-1) / 2 possible pairs to check, in other words, the number of edges in Kn! Fitness score = the number of pairs of rectangles that can see each other (the maximum fitness for n rectangles is n(n-1) / 2 )
  23. Fitness function? Since every rectangle shares the origin point in

    the center, two rectangles can see each other if any one of their corners are both free (not blocked by other rectangles) So for any two rectangles A and B, one of the free corner conditions must hold for every rectangle r between A and B: •  FCne (A,B) (northeast free): (Er < min{Ea ,Eb } or Nr < min{Na ,Nb })! •  FCnw (A,B) (northwest free): (Nr < min{Na ,Nb } or Wr < min{Wa ,Wb })! •  FCsw (A,B) (southwest free): (Wr < min{Wa ,Wb } or Sr < min{Sa ,Sb })! •  FCse (A,B) (southeast free): (Sr < min{Sa ,Sb } or Er < min{Ea ,Eb })!
  24. Crossover? 23: ( 2, 20, 14, 7) 22: (15, 1,

    9, 1) 21: (13, 12, 17, 11) 20: (10, 18, 13, 10) 19: ( 9, 10, 20, 9) 18: ( 7, 13, 14, 8) 17: ( 5, 20, 16, 7) 16: (19, 2, 11, 5) 15: (17, 3, 10, 4) 14: (18, 6, 6, 3) 13: ( 6, 14, 19, 1) 12: ( 4, 19, 2, 16) 11: ( 3, 15, 3, 15) 10: (14, 4, 1, 20) 9: ( 2, 16, 4, 12) 8: ( 1, 17, 5, 14) 7: (12, 1, 7, 18) 6: (11, 5, 8, 17) 5: ( 8, 7, 9, 19) 4: (20, 8, 12, 2) 3: (15, 9, 18, 6) 2: (16, 11, 15, 13) 1: (22, 22, 22, 22) 23: (23, 23, 23, 23) 22: (16, 20, 18, 19) 21: (23, 6, 15, 18) 20: (17, 19, 16, 13) 19: (21, 3, 13, 14) 18: (15, 22, 3, 17) 17: (11, 18, 21, 5) 16: (19, 4, 22, 3) 15: (12, 21, 1, 23) 14: (10, 3, 17, 12) 13: (18, 7, 9, 6) 12: ( 7, 19, 5, 21) 11: ( 6, 22, 7, 15) 10: ( 5, 23, 8, 23) 9: (23, 12, 11, 2) 8: ( 3, 22, 12, 16) 7: ( 1, 23, 14, 15) 6: (16, 15, 19, 10) 5: (21, 20, 15, 5) 4: (22, 20, 6, 13) 3: (13, 1, 7, 20) 2: (18, 1, 22, 17) 1: (23, 23, 23, 23)
  25. Mutation? 23: (23, 23, 23, 23) 22: (16, 20, 18,

    19) 21: (23, 6, 15, 18) 20: (17, 19, 16, 13) 19: (21, 3, 13, 14) 18: (15, 22, 3, 17) 17: (11, 18, 21, 5) 16: (19, 4, 22, 3) 15: (12, 21, 1, 23) 14: (10, 3, 17, 12) 13: (18, 7, 9, 6) 12: ( 7, 19, 5, 21) 11: ( 6, 22, 7, 15) 10: ( 5, 23, 8, 23) 9: (23, 12, 11, 2) 8: ( 3, 22, 12, 16) 7: ( 1, 23, 14, 15) 6: (16, 15, 19, 10) 5: (21, 20, 15, 5) 4: (22, 20, 6, 13) 3: (13, 1, 7, 20) 2: (18, 1, 22, 17) 1: (23, 23, 23, 23) 6,
  26. Library Code: https://github.com/rodhilton/metaheuristics-engine Language: Java License: LGPL v3.0 App Code:

    https://github.com/rodhilton/rectangle_visibility Language: Groovy License: Apache v2.0 Rectangle Visibility Searcher
  27. Uniquely assign position values Try alternative metaheuristics Try regularly “packing”

    rectangles Tool for experimenting by hand with partial result Is K22 the upper bound?