1 graphical layout algorithms richard anderson university of washington theory seminar, september...
TRANSCRIPT
1
Graphical Layout Algorithms
Richard Anderson
University of Washington
Theory Seminar, September 28, 1999
2
Motivation Algorithms for graphical layout
Display to a range of devices Window sizes Fonts Portable devices Paper
For a range of viewers Vision levels Viewing goals (scanning, careful reading) Environment User preferences on content
3
Approach/Assumptions
Geometric optimization problem Layout is placing rectangles Powerful algorithms available Algorithmic approach gives general
solutions Choices of content available with
priorities
4
Research Style
Pure Theory Asymptotic / Complexity results
Applied Algorithms Use implementation to study algorithms
Applications Oriented Algorithms are a tool to achieve success in
the application domain
5
Geometry
Layout problem: placing rectangles Interesting cases - rich set of choices
available Placement Size, dimensions Content choice
6
Paragraphs Find minimum width paragraph for a given height. Solve for each height: best known: O(n3/2)
Malfoy couldn’t believe his eyes when he saw that Harry and Ron were still at Hogwarts the next day, looking tired but perfectly cheerful.
Malfoy couldn’t believe his eyes when he saw that Harry and Ron were still at Hogwarts the next day, looking tired but perfectly cheerful.
Malfoy couldn’t believe his eyes when he saw that Harry and Ron were still at Hogwarts the next day, looking tired but perfectly cheerful.
7
Content Choice If information does not fit, allow substitutionsThe Dark Forces: A Guide to Self-Protection, Quenton Trimble, Hogwarts Academic Press, Hogsmeade, 1999, 2nd Edition, 238 pages, Albus Dumbledore editor.
The Dark Forces: A Guide to Self-Protection, Quenton Trimble, Hogwarts, Hogsmeade, 1999, 2nd Ed., 238 pp.
The Dark Forces: A Guide to Self-Protection, Quenton Trimble, Hogwarts Ac. Press, Hogsmeade, 1999, 2nd Edition, 238 pages
The Dark Forces: A Guide to Self-Protection, Quenton Trimble, Hogwarts Ac. Press, Hogsmeade, 1999, 2nd Ed., 238 pp, Albus Dumbledore ed.
8
The Dark Forces: A Guide to Self-Protection, Q. Trimble, HAP, Hogs., `99, 2nd, 238 pp.
The Dark Forces, Q. Trimble, HAP, Hogs., 1999, 2nd, 238 pp.
The Dark Forces: Self-Protection, Q. Trimble, HAP, 1999, 2nd, 238 pp.
The Dark Forces Q. Trimble, HAP, `99, 2nd, 238 pp.
Dark Forces, Q. Trimble, HAP, `99, 2nd.
Dark Forces, Q. Trimble, HAP, 1999.
Dk. Forces, Q. Trimble, HAP, 1999.
Dark Forces, Trimble.
9
Source representation
<paragraph> <choice> <sel val=90> The Dark Forces: A Guide to Self-Protection </sel> <sel val=50> The Dark Forces: Self-Protection </sel> <sel val=30> The Dark Forces</sel> <sel val=20> Dark Forces</sel> <sel val=10> Dk. Forces</sel> </choice> <choice> <sel val=30> Hogwarts Academic Press </sel> <sel val=20> Hogwarts Ac. Press </sel> <sel val=15> Hogwarts </sel> <sel val=10> HAP </sel> <sel val=0> </sel> </choice> . . . </paragraph>
10
Typography with content choice
Problem 1: Given a fixed area for the text, find the
optimal choice of content Problem 2:
Find the set of all maximal configurations Problem 3:
Find a good approximation to the set of all maximal configurations
11
Content Choice
Algorithmic choice: rectangles with values. Place one rectangle from each set to maximize value.
4040
25 20 15
12
Warm up problem: Lists Optimally display the
list for a fixed height Set of configurations
for each list item. (height, value)
Solvable with knapsack dynamic programming algorithm
13
List compression
Harry Potter and the Prisoner of Azkaban ~ J. K. Rowling / Hardcover / Published 1999 Our Price: $9.98 Harry Potter and the Sorcerer's Stone J. K. Rowling / Hardcover / Published 1998 Our Price: $8.98 Harry Potter and the Chamber of Secrets J. K. Rowling / Hardcover / Published 1999 Our Price: $8.98
Harry Potter and the Prisoner of Azkaban ~ Usually ships in 24 hours J. K. Rowling / Hardcover / Published 1999 Our Price: $9.98 ~ You Save: $9.97 (50%) Harry Potter and the Sorcerer's Stone ~ Usually ships in 24 hours J. K. Rowling / Hardcover / Published 1998 Our Price: $8.98 ~ You Save: $8.97 (50%) Harry Potter and the Chamber of Secrets J. K. Rowling / Hardcover / Published 1999 Our Price: $8.98 ~ You Save: $8.97 (50%)
Harry Potter and the Prisoner of Azkaban ~ J. K. Rowling / HC / Publ 1999 Our Price: $9.98 Harry Potter and the Sorcerer's Stone J. K. Rowling / HC / 1998 $8.98 Harry Potter and the Chamber of Secrets J. K. Rowling / HC / 1999 $8.98
Harry Potter and the Prisoner of Azkaban J. K. Rowling $9.98 Harry Potter and the Sorcerer's Stone Rowling HP : Chamber of Secrets
14
Implementation goal
Real time resizing of lists Maintain optimal display as window size
changes. Recompute at refresh rate Knapsack/dynamic programming
algorithm Low level algorithmic issues?
15
Tables General Problem
Given a set of configurations for each cell, find the maximum value table that satisfies size constraints
Special Cases Layout Problem
No values, minimize table height for fixed width Compression Problem
Configurations for a cell satisfy nesting property Value decreases with size
16
Layout Problem (with S. Sobti)
NP complete Restricted instances: {(1,2), (2,1)}, {(1,1)}
Divination. Sybill Trelawney
Defense against dark arts. R. J. Lupin
Potions. Severus Snape
Care of magical creatures. Rubeus Hagrid
Divination. Sybill Trelawney
Defense against dark arts. R. J. Lupin
Potions. Severus Snape
Care of magical creatures. Rubeus Hagrid
17
Layout Problem: results
Fixed W, minimize H, NP complete
Minimize W+H solvable with mincut algorithm
Compute convex hull of feasible table configurations
Heuristic algorithm
18
Table compression problem Display a table in less than the required
area, with a penalty for shrinking cellsDivination. Sybill Trelawney
Defense against dark arts. R. J. Lupin
Potions. Severus Snape
Care of magical creatures. Rubeus Hagrid
Divin. Sybill T.
Defense against dark arts. Lupin
Potions. Severus Snape
Care of magical creatures. Hagrid
Divin. Sybill T.
Def. dark arts. Lupin
Potions. Severus Snape
Care of magical critters. Hagrid
Divin. Sybill T.
Def. dark arts. Lupin
Potions. S. Snape
Care of creatures. Hagrid
Divin. Sybill T.
Dark arts. Lupin
Potions. S. Snape
Critr care. Hagrid
Div D. arts. Lupin
Pot
Critters.Hagrid
19
Compression Problem NP complete for simple case
Choice cells: 1 x 1 (value 1), 0 x 0 (value 0) Dummy cells: 0 x 0 (value 0) Maximize number of full size choice cells in
when table n x n table compressed to n/2 x n/2.
Reduction from clique problem Incidence matrix reduction
20
Attacking the 0-1 problem
1
2
1
3 3
2
4 4
Choose n/2 vertices from each side to maximize the number of edges between chosen vertices
Equivalent problem: maximum density (n/2,n/2)-subgraph of a (n,n)-bipartite graph
21
Greedy Algorithm Find MDS of G=(X,Y,E)
Choose X’, the set of n/2 vertices of highest degree w.r.t. Y
Choose Y’, the set of n/2 vertices of highest degree w.r.t. X’
Claim: (X’,Y’) is a 1/2 approximation of the MDS
Proof: (X’,Y) has at least as many edges as the MDS.
(X’,Y’) has at least half as many edges as (X’,Y)
22
Greedy Algorithms
Non-bipartite graphs Add vertices of maximum degree starting
with empty graph Remove vertices of minimum degree,
starting with full graph 4/9 approximation algorithm (Asahiro et al.)
Open problem: generalize and analyze greedy algorithms for tables
23
Semidefinite programming Maxcut problem: divide vertices of a graph into two sets to
maximize number of edges between the sets. Goemans-Williamson SDP result:
Improved approximation bound from 0.5 to 0.878 Introduced new technique to the field Idea - solve the problem on an n-dimensional sphere, use a random
projection to divide vertices.
MDS problem can also be attacked with SDP. Technical problems with bipartiteness and equal division lead to a weak result.
24
Research directions
Can semidefinite programming beat the greedy algorithm on the 0-1 problem?
Develop greedy algorithms for the general case. Linear programming: fractional solution to table
problems has a natural interpretation. Results on rounding? Combinatorial algorithms for the fractional problem.
Develop/analyze fast heuristic algorithms
25
Another version of tables
Oriented aligned rectangle problem Agarwal-Shing (EJOR 1992)
Given nm rectangles, lay them out in a minimum sized n X m table, subject to row and column constraints.
26
Known results/ Open problems Polytime algorithms if rectangles heights increasing with
width, or decreasing with width
Open: Is this problem NP-complete?? Research directions
Approximation algorithms Choice of content
27
Unstructured layout Display object
Set of rectangles with values Layout of a collection of display objects
Disjoint placement of one rectangle of each display object to screen
Problem Maximize value of rectangles displayed
Versions Unconstrained vs. Fully constrained
28
Unconstrained problem
2-d bin packing with choices
7
4
8
3
5
5
4
3 6 Pack one rectangle of eachcolor to maximize value
29
Bin packing problems Find constant factor approximation algorithms for
optimization problem Many heuristics are known for 2-d packing
Branch and bound algorithm Instances are small Requires relaxed version
Additional constraints Symmetry, balance, uniform spacing . . .
7
5
46
30
Fixed horizontal bin packing Two-d bin packing, except that rectangles have fixed
horizontal positions Motivated by picture placement Best known result: 3-approximation algorithm Problem arises in memory allocation
31
Bin packing with text
Placing objects inside of text Movement of unbreakable
content Movement of anchors
Placing text objects Objects may be resized -
preserve area, not dimensions Overlap of text and picture
objects
32
Constrained layout problem
Every pair of display objects ordered with left/right or above/below constraints
Feasibility problem for ordered rectangles Expressible with difference constraints
(x < y + c) Solvable with Bellman-Ford algorithm
33
Frame problem
Optimize allocation of areas between display objects for a fixed geometry
Links
Icons
Header
Flowable text
34
Optimization problem
Tables are a special case (rows and columns given by constraints)
General problem - NP-complete Easy families of constraints
(pseudopolynomial)
35
Research problems
Determine which families of constraints are easy to solve
Apply these ideas to layout of hierarchical documents where the depth of display is not fixed
36
Summary Graphical layout as geometric optimization Theoretical background
Basic algorithms for rectangle placement Algorithm implementation
Performance requirements are significant Application
Do these techniques work for universal, customized display?
37
“Quals projects”
Typography with choices of text Compression problem for tables Oriented aligned rectangle problem 2d bin packing with rectangle choices Constrained layout Testbed implementation