1 graphical layout algorithms richard anderson university of washington theory seminar, september...

37
1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

Upload: barnaby-cameron

Post on 12-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

1

Graphical Layout Algorithms

Richard Anderson

University of Washington

Theory Seminar, September 28, 1999

Page 2: 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

Page 3: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

3

Approach/Assumptions

Geometric optimization problem Layout is placing rectangles Powerful algorithms available Algorithmic approach gives general

solutions Choices of content available with

priorities

Page 4: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 5: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

5

Geometry

Layout problem: placing rectangles Interesting cases - rich set of choices

available Placement Size, dimensions Content choice

Page 6: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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.

Page 7: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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.

Page 8: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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.

Page 9: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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>

Page 10: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 11: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

11

Content Choice

Algorithmic choice: rectangles with values. Place one rectangle from each set to maximize value.

4040

25 20 15

Page 12: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 13: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 14: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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?

Page 15: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 16: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 17: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 18: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 19: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 20: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 21: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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)

Page 22: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 23: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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.

Page 24: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 25: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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.

Page 26: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 27: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 28: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 29: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 30: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 31: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 32: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 33: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

33

Frame problem

Optimize allocation of areas between display objects for a fixed geometry

Links

Icons

Header

Flowable text

Page 34: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

34

Optimization problem

Tables are a special case (rows and columns given by constraints)

General problem - NP-complete Easy families of constraints

(pseudopolynomial)

Page 35: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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

Page 36: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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?

Page 37: 1 Graphical Layout Algorithms Richard Anderson University of Washington Theory Seminar, September 28, 1999

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