You are on page 1of 38

Square Packing Almost Square Packing

Almost Square Packing


Helmut Simonis and Barry OSullivan
Cork Constraint Computation Centre Computer Science Department University College Cork Ireland

CSCLP 2010

Helmut Simonis and Barry OSullivan

Almost Square Packing

Square Packing Almost Square Packing

Points to Remember
Almost Square Packing: Generalization of Square Packing (Simonis and OSullivan, CP 2008) Allows rotation of items, extra degree of freedom Interleave orientation of item with interval choice for X Redundant constraints similar to square packing Further decomposition possible, treat X variables on their own Does not need disjoint2 and second cumulative constraint Problems up to N=26 solved optimally (very similar to square packing)

Helmut Simonis and Barry OSullivan

Almost Square Packing

Square Packing Almost Square Packing

Almost Square Packing

Consider almost squares, rectangles n (n + 1) Pack all items 1 2, 2 3, ..., n (n + 1) Into smallest possible rectangle Items are non-overlapping

Helmut Simonis and Barry OSullivan

Almost Square Packing

Square Packing Almost Square Packing

Background

Suggested by Prof. Des MacHale, Math, UCC Solved packing up to 13 14 by hand Starting point for Barrys and my interest in packing My objection: This is too complicated
Look at square packing Known results, benchmark comparison

Helmut Simonis and Barry OSullivan

Almost Square Packing

Square Packing Almost Square Packing

Simpler Problem: Square Packing

Consider squares, rectangles n n Pack all items 1 1, 2 2, ..., n n Into smallest possible rectangle Items are non-overlapping

Helmut Simonis and Barry OSullivan

Almost Square Packing

Square Packing Almost Square Packing

Outline

Square Packing Almost Square Packing

Helmut Simonis and Barry OSullivan

Almost Square Packing

Square Packing Almost Square Packing

Problem (N=26)
10 15 43 7 6 8 9 16 2 12 20 11 5 26 21 23 14 13 25 17 19

24

22

18

Helmut Simonis and Barry OSullivan

Almost Square Packing

Square Packing Almost Square Packing

Problem Decomposition

Search for candidate enclosing rectangle Area must be larger than sum of items to be placed Search in order of increasing area
and increasing squareness

Check each candidate for (in)feasibility until rst solution is found Observation: Only limited number of candidates explored

Helmut Simonis and Barry OSullivan

Almost Square Packing

Square Packing Almost Square Packing

Basic Model
Width

W H X,Y Height

disjoint2 cumulative

cumulative

Helmut Simonis and Barry OSullivan

Almost Square Packing

Square Packing Almost Square Packing

Interval Based Strategies

Key Idea: Fixing intervals, not values Fixing variables to values is too restrictive Select area in which item is placed Allows items to shift slightly Restrict domain to intervals Only at end x actual values

Helmut Simonis and Barry OSullivan

Almost Square Packing

10

Square Packing Almost Square Packing

Forcing Compulsory Parts


Small Interval
Xl Xr

Number of intervals: large

Compulsory parts

Xl

Xr

Large Interval Number of intervals: small

Helmut Simonis and Barry OSullivan

Almost Square Packing

11

Square Packing Almost Square Packing

Model Improvement: Dominance Criterion


X2 X1 W2 B X2 , Y2 D W1 Y2 + H2 Y1 + H1 W2 H1 D X2 , Y2 Y2 Y1 A H2 H2

X2 + W2 X1 + W1

X1 , Y1

Helmut Simonis and Barry OSullivan

Almost Square Packing

12

Square Packing Almost Square Packing

Strategies Comparison
1e+06

100000

10000

1000 Time[s]

100 Korf BlueBlocker naive naive gaps xtheny disj semantic4 semantic dual interval split xy 16 18 20 22 Problem Size 24 26 28

10

0.1

0.01

Helmut Simonis and Barry OSullivan

Almost Square Packing

13

Square Packing Almost Square Packing

Optimal Solution (N=27, CP 2008)

17

15

18

12

21

23

22

10

16

11

5 3 27

26

24

25

14

Even better results by R. Korf in IJCAI 2009

13

Helmut Simonis and Barry OSullivan

Almost Square Packing

19

20

14

Square Packing Almost Square Packing

Outline

Square Packing Almost Square Packing

Helmut Simonis and Barry OSullivan

Almost Square Packing

15

Square Packing Almost Square Packing

Back to the Future

Apply lessons learned to almost square packing Added degree of freedom, rotation of items Weak impact, length only changes by one But 2n additional choices

Helmut Simonis and Barry OSullivan

Almost Square Packing

16

Square Packing Almost Square Packing

Almost Square, Optimal Solution (N=26)

14x13

12x13

15x14

20x21

23x22

23x24

18x17

3x4 4x5

6x7

5x6

17x16

10x11 11x12

7x8

2x3 2x1

22x21

19x18

19x20

Helmut Simonis and Barry OSullivan

10x9

Almost Square Packing

24x25

25x26

27x26

9x8

15x16

17

Square Packing Almost Square Packing

Visualization: Search Tree (N=20)


w20
2

20

x202
1..7

w192
19

x196
1..6

w182
18
2 6 x187 1..6 8..13 17..22

77387 66481

43 27

w172
17 18 55775 46472

x178
1..6

w16

16 17 6077 4580

x16

10

1..6

w15

15 16 1297 919

x15

20

w14
14

15

543 416

x14
1..5

13 1

21
2

157 87

w13 x13

13
16

1..4

w12

12
2 x123 19..22 23..26

10 8 13 7

w112
11 12
1 4 x118 14..17 18..21 24

141 76

5 3

w102
10

x1010
14..17

w9 2
9

x9 w8
8

19..21 1

x8 w7
7

28
2

x7 w6
6

28
2

x6 w5
5

21
1

x5 w4
4

19
1

x4

20

w3 2
3 4

x3

14

w2 2
2 3

x2

21
1 xx20

1
1 xx19

xx18
18

xx17
1

xx16
1

xx15
20

xx14
21

xx13
1

xx12
24

xx11
24

xx10
14

xx91
19

xx81
28

xx71
28

xx61
21

xx51
19

xx41
20

xx31
14

xx2 y20
41 25 4 3 40 23

21
20 27 37 38 25..31

1..7 8..14 18..24

y19
1 2 1 1 13 5

19 57 58 1 7

1..7 8..14 46..52 58..64 69

y18 y17 y16


1

44

1..6 1

52
1

y15

1 4 9

62..66 67..71 74

y14 y13 y12

15

31..35 1

17
27

20..23 1 y1117 47..50 63

y101
20

y9 y8 y7 y6 y5 y4 y3 y2

53
8

47..49 1

56
1

47
1

63
1

69
1

17
1

31

yy20
31

yy19
69

yy18
1

yy17
52

yy16
1

yy15
74

1 yy14

33
1 yy13

17
1 yy12

20
1 yy11

63
1 yy10

20

yy91
53

yy8 yy7 yy6 yy5 yy4 yy3 yy2

47
1

56
1

47
1

63
1

69
1

17
1

31

Helmut Simonis and Barry OSullivan

Almost Square Packing

18

Square Packing Almost Square Packing

Problem with Tree View

Showing complete tree is clearly infeasible We only show path to solution But most time is spent in non-solution parts of tree

Helmut Simonis and Barry OSullivan

Almost Square Packing

19

Square Packing Almost Square Packing

Search Choices

Based on best method for square packing Assign X intervals, x X values, assign Y intervals, x Y values When to x orientation? Eager Before assigning X intervals Lazy After assigning X intervals Interleaved Mixed with X interval assignment

Helmut Simonis and Barry OSullivan

Almost Square Packing

20

Square Packing Almost Square Packing

Eager Orientation (N=17)


1e+07 FAIL TRY 1e+06

100000

10000 Nodes 1000

100

10

1 0 10 20 30 40 Depth 50 60 70 80

Helmut Simonis and Barry OSullivan

Almost Square Packing

21

Square Packing Almost Square Packing

Lazy Orientation (N=17)


1e+07 FAIL TRY 1e+06

100000

10000 Nodes 1000

100

10

1 0 10 20 30 40 Depth 50 60 70 80

Helmut Simonis and Barry OSullivan

Almost Square Packing

22

Square Packing Almost Square Packing

Interleaved Orientation (N=17)


100000 FAIL TRY

10000

1000 Nodes

100

10

1 0 10 20 30 40 Depth 50 60 70 80

Helmut Simonis and Barry OSullivan

Almost Square Packing

23

Square Packing Almost Square Packing

Comparison (N=17)
1e+07 Eager Lazy Interleaved 1e+06

100000

10000 Nodes 1000

100

10

1 0 10 20 30 40 Depth 50 60 70 80

Helmut Simonis and Barry OSullivan

Almost Square Packing

24

Square Packing Almost Square Packing

Node Distribution (N=20)


20_35_88 100000 W and X Interval X Assignment Y Interval Y Assignment FAIL TRY

10000

1000 Nodes

100

10

1 0 10 20 30 40 50 Depth 60 70 80 90 100

Helmut Simonis and Barry OSullivan

Almost Square Packing

25

Square Packing Almost Square Packing

Problem with Slack (N=21)


21_46_77 1e+06 "flat_21_46_77.dat"

100000

10000

Nodes

1000

100

10

1 0 10 20 30 Depth 40 50 60 70

Helmut Simonis and Barry OSullivan

Almost Square Packing

26

Square Packing Almost Square Packing

Impact of Interval Size (N=26)


26_42_156 1e+07 0.25 0.30 0.35 0.40 0.45

1e+06

100000

10000 Nodes 1000

100

10

1 0 20 40 60 Depth 80 100 120 140

Helmut Simonis and Barry OSullivan

Almost Square Packing

27

Square Packing Almost Square Packing

Basic Model Results (SICStus Prolog 4.04), 2008 Desktop


N 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Loss 0.00 0.00 1.79 0.00 0.00 1.82 0.45 0.00 0.96 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.00 0.00 0.00 0.00 0.00 First Solution Back Time 2 00:00 4 00:00 16 00:00 19 00:00 6 00:00 54 00:00 323 00:00 99 00:00 546 00:00 1900 00:00 2937 00:00 14440 00:00 15967 00:01 210878 00:14 9734 00:00 102235 00:08 351659 00:34 14036353 21:38 58206362 01:37:30 14490682 30:12 27475258 55:05 35282646 01:23:12 92228265 03:28:20 Sols 8 16 216 65 12 9170 1854 4 25180 42 4 4 544 16 110288 526 1988 3250117 688 6784 96 1007780 1056 All Solutions Back 6 14 24 76 83 3137 1379 268 13795 6197 9604 50592 48711 398759 152032 3240741 3612859 720146935 122563947 136039535 99731414 Time 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:02 00:00 00:00 00:03 00:03 00:27 00:24 04:26 05:52 25:13:20 03:23:19 04:38:40 03:20:37

Helmut Simonis and Barry OSullivan

Almost Square Packing

28

Square Packing Almost Square Packing

Redundant Constraints

Forbidden gaps Ignore small blocks Symmetries of aligned blocks(?)

Helmut Simonis and Barry OSullivan

Almost Square Packing

29

Square Packing Almost Square Packing

Forbidden Gaps

Large items can be placed either directly on border or away from border Otherwise gap must be lled with small items and slack For each gap size, pre-compute length of item that can not be covered Slight complication due to rotation of items, use constructive disjunction
Remove most forbidden gaps at setup by reducing domains Further reduction when item is oriented

Does not handle interaction of multiple gaps

Helmut Simonis and Barry OSullivan

Almost Square Packing

30

Square Packing Almost Square Packing

Pseudo Solution Removing 1 2 Block

14x13 6x5 12x11 7x6 13x12 4x5 15x14 7x8 10x11 4x3 2x3 16x17 16x15

10x9 8x9

Helmut Simonis and Barry OSullivan

Almost Square Packing

31

Square Packing Almost Square Packing

Redundant Constraint Result


N 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Basic Model Back Time 2 00:00 4 00:00 16 00:00 19 00:00 6 00:00 54 00:00 323 00:00 99 00:00 546 00:00 1900 00:00 2937 00:00 14440 00:00 15967 00:01 210878 00:14 9734 00:00 102235 00:08 351659 00:34 14036353 21:38 58206362 01:37:30 14490682 30:12 27475258 55:05 35282646 01:23:12 92228265 03:28:20 Not One Back Time 2 00:00 3 00:00 16 00:00 18 00:00 5 00:00 54 00:00 323 00:00 99 00:00 546 00:00 1900 00:00 2936 00:00 14425 00:00 9338 00:00 210850 00:13 9734 00:00 102235 00:08 355964 00:33 10859861 16:01 58214183 01:33:03 14490682 29:16 27475258 53:11 35502799 01:21:25 92228259 03:22:33 Gap Back 2 2 6 10 17 27 159 54 274 1040 1505 7632 7264 107639 5550 13694 157312 9499957 17312971 6400629 9801577 13030167 29432477 Time 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:07 00:00 00:01 00:14 14:14 24:37 11:01 16:39 25:16 55:38 Both Back 2 1 6 9 10 27 159 54 274 1040 1501 7617 3989 107611 5550 13690 161410 6524396 17319946 6400629 9801577 13232221 29432467 Time 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:07 00:00 00:01 00:14 09:13 23:54 10:33 16:10 25:15 54:08

Helmut Simonis and Barry OSullivan

Almost Square Packing

32

Square Packing Almost Square Packing

Impact of Interval Size


12000 10000 8000 Time[s] 6000 4000 2000 0 0.1

17 18 19 20 21 22 23 24 25 26

0.15

0.2

0.25

0.3

0.35

0.4

0.45

Parameter

Helmut Simonis and Barry OSullivan

Almost Square Packing

33

Square Packing Almost Square Packing

Further Problem Decomposition

Do we really need the full basic model? Most search in X variable search phase Postpone setting up Y variables, disjoint2 and 2nd cumulative Only create them when complete solution for X variables found Uses just single cumulative constraint We can even replace disjoint2 by reied inequalities

Helmut Simonis and Barry OSullivan

Almost Square Packing

34

Square Packing Almost Square Packing

Decomposition Results
N 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Basic Model Back Time 2 00:00 1 00:00 6 00:00 9 00:00 10 00:00 27 00:00 159 00:00 54 00:00 274 00:00 1040 00:00 1501 00:00 7617 00:00 3989 00:00 107611 00:07 5550 00:00 13690 00:01 161410 00:14 6524396 09:13 17319946 23:54 6400629 10:33 9801577 16:10 13232221 25:15 29432467 54:08 With Redundant Constraints Decomposed Model Decomposed Reied Back Time Back Time 2 00:00 2 00:00 1 00:00 1 00:00 6 00:00 6 00:00 9 00:00 9 00:00 10 00:00 10 00:00 27 00:00 27 00:00 176 00:00 176 00:00 54 00:00 54 00:00 301 00:00 301 00:00 1040 00:00 1040 00:00 1501 00:00 1501 00:00 7617 00:00 7617 00:00 3989 00:00 3989 00:00 107611 00:05 107611 00:06 5550 00:00 5550 00:00 13690 00:00 13690 00:00 161410 00:11 161410 00:16 6524396 07:10 6524396 08:05 17319946 19:13 17319946 21:50 6400629 08:04 6400629 08:58 9801577 12:11 9801577 13:07 13232221 20:07 13232773 23:34 29432467 40:26 29432467 43:51

Helmut Simonis and Barry OSullivan

Almost Square Packing

35

Square Packing Almost Square Packing

Comparison with (Korf et al., 2010)

Size 17 18 19 20 21 22 23 24 25 26

Area 3457 3076 3576 3588 3991 4492 40115 40130 45130 42156

Korf, Moftt and Pollack Nodes Times 6,889,973 :07 22,393,428 :26 11,918,834 :11 608,635,198 12:50 792,197,287 23:21 4,544,585,807 1:49:32 32,222,677,089 15:06:56 41,976,042,836 18:39:34 557,540,262,189 12:11:30:32 -

Redundant Back Times 107611 00:07 5550 00:00 13690 00:01 161410 00:14 6524396 09:13 17319946 23:54 6400629 10:33 9801577 16:10 13232221 25:15 29432467 54:08

Decomposition Back Times 107611 00:05 5550 00:00 13690 00:00 161410 00:11 6524396 07:10 17319946 19:13 6400629 08:04 9801577 12:11 13232221 20:07 29432467 40:26

Helmut Simonis and Barry OSullivan

Almost Square Packing

36

Square Packing Almost Square Packing

Future Work

SICStus Prolog cumulative does not know about volume of items Domain variables [n, n + 1] for duration and resource use Does not know that w h is n (n + 1) Underestimates volume as n n Improved energetic reasoning possible (CHIP)

Helmut Simonis and Barry OSullivan

Almost Square Packing

37

Square Packing Almost Square Packing

Points to Remember

Almost Square Packing: Generalization of Square Packing (CP 2008) Interleave orientation of item with interval choice for X Further decomposition possible, treat X variables on their own Does not need disjoint2 and second cumulative constraint Problems up to N=26 solved optimally (very similar to square packing) Outperforms best published results by 103

Helmut Simonis and Barry OSullivan

Almost Square Packing

38

You might also like