a tree search algorithm for solving the two-dimensional knapsack problem t. fanslau and a. bortfeldt...

27
A Tree Search Algorithm A Tree Search Algorithm for for Solving the Two- Solving the Two- Dimensional Knapsack Dimensional Knapsack Problem Problem T. Fanslau and A. Bortfeldt University in Hagen, Germany Contents: 1 Introduction 2 The Tree Search Algorithm 3 Numerical Test 4 Conclusions

Upload: reginald-mitchell

Post on 30-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

A Tree Search Algorithm for A Tree Search Algorithm for Solving the Two-Dimensional Solving the Two-Dimensional

Knapsack ProblemKnapsack Problem

T. Fanslau and A. Bortfeldt University in Hagen,

Germany

Contents:1 Introduction2 The Tree Search Algorithm3 Numerical Test4 Conclusions

1 Introduction

1 Introduction2D-Knapsack Problem (2D-KP)

Given: - a large rectangle (container)- a set of small rectangles (pieces);

each piece has a value (area, …)

Determine: feasible arrangement of subset of pieces in the container so that total value of the packed pieces is maximized and relevant constraints are met

Special case: value = area total covered area to maximize

Feasibility conditions:

– any two packed pieces do not overlap – each packed piece lies entirely inside the container– each packed piece is placed parallel to the container sides

1 Introduction

Guillotinecutting

Guillotine cutting is not required

F

Guillotine cutting is required

GOrientation of pieces

Pieces may be rotated by 90° R

SubtypeRF

SubtypeRG

Orientation of pieces is fixed O

SubtypeOF

SubtypeOG

Usual constraints:(C1) Orientation constraint: orientation of all pieces fixed; 90° rotating not allowed

(C2) Guillotine constraint: all pieces of a pattern can be cut by guillotine cuts

(edge-to-edge-cuts, parallel to container edges)

Subtypes of 2D-KP (Lodi et al. 1999):

1 Introduction

Subtype Method / Authors Method type

OG Fayard et al. (1998) DO

OG Alvarez-Valdes et al. (2002) TS

OG Morabito / Pureza (2007) DO, TRS (And/Or-Graphs)

OG/RG Bortfeldt / Winter (2007) GA

OF Beasley (2004) GA

OF Alvarez-Valdes et al. (2005, 2007) GRASP, TS

OF Gonçalves / Resende (2006) GA

OF Hadjiconstantinou / Iori (2007) GA

RF Huang et al. (2007) TRS

OF/RF Bortfeldt / Winter (2007) GA

Literature overview Common approaches (2D-KP - NP-hard ): tree search (TRS), dynamic optimization (DO), metaheuristics (GA, TS, …)

2 The Tree-Search Algorithm

A) Overall algorithm

initialize: search_effort := 1;repeat generate complete solution s; // using search_effort!

update best solution if necessary: sbest := s; update parameter: search_effort := 2 * search_effort;

until time_limit exceeded;

- multiple solutions generated one by one- internal parameter search_effort

. range of tree search

. doubled per solution- current best solution - upper bound- stop after time limit exceeded

2 The Tree Search Algorithm

2.1 TRS Algorithm for non-guillotine case

2 The Tree-Search Algorithm

B) Generating one solution

Residual space (RS): - rectangular free space within container- data: 2 dimensions, reference corner

RS_set:- generated, yet unprocessed RS - first RS to be filled: empty container - not disjoint in general

Procedure: - RS filled one after another

- each RS filled by best rectangle placement, one rectangle placed in reference corner

- if no rectangle fits – RS only removed

- RS_set updated after placement - new solution complete if RS_set empty

- chosen placement – no more changed!

2 The Tree-Search Algorithm

Generating one solution – pseudocode

// initializeset of residual rectangles Rres := {all rectangles};solution s := ;set of residual spaces RS_set := {container};// fill residual spaces successivelywhile RS_set do

rs := RS nearest to origin; // Manhattan dist.: x+y ->min!remove rs from RS_set;

determine best rect. placement rpl* = (r,o,x,y) for rs; // R! if placement found then

extend solution s := s {rpl*}; Rres := Rres \ {r};

endif;

update RS_set; // R!endwhile;

// “R!” – parts to be refined

2 The Tree-Search Algorithm

C) Updating the set of residual spaces- always to be done after RS processed (also if no placement) - updating includes: .processed RS removed .new RS created .existing RS reduced

legend:

- RS

- rectangle

wC, y

IC, x

- ref. corner of RS

RS0

2 The Tree-Search Algorithm

C) Updating the set of residual spaces- always to be done after RS processed (also if no placement) - updating includes: .processed RS removed .new RS created .existing RS reduced

wC, y

IC, x

RS1

RS2

2 new overlapping RS

rect1

2 The Tree-Search Algorithm

C) Updating the set of residual spaces- always to be done after RS processed (also if no placement) - updating includes: .processed RS removed .new RS created .existing RS reduced

wC, y

IC, x

rect2

RS2rect1

RS3new RS

reduced RS

2 The Tree-Search Algorithm

D) Evaluating of placements- multiple possible placements per RS in general- evaluation criteria: 1) specific value := value / area 2) smoothness index (0, 1 or 2) 3) area- all poss. placements ordered by evaluation criteria 1) – 3); first ns placements tried in this order (ns = curr. no. of succ.)

IC, x

current RS

wC, y

rect2

rect1

2 The Tree-Search Algorithm

D) Evaluating of placements- multiple possible placements per RS in general- evaluation criteria: 1) specific value := value / area 2) smoothness index (0, 1 or 2) 3) area- all poss. placements ordered by evaluation criteria 1) – 3); first ns placements tried in this order (ns = curr. no. of succ.)

wC, y

IC, x

y‘

yN

xC x‘ xN

xN – nearby edge on the right of xC

yN – nearby edge above yC

no coincidence:

x‘ < xN

y‘ > yN

smoothness index = 0

rect2

rect1

yC

2 The Tree-Search Algorithm

D) Evaluating of placements- multiple possible placements per RS in general- evaluation criteria: 1) specific value := value / area 2) smoothness index (0, 1 or 2) 3) area- all poss. placements ordered by evaluation criteria 1) – 3); first ns placements tried in this order (ns = curr. no. of succ.)

wC, y

IC, x

y‘, yN

xC x‘

xN – nearby edge on the right of xC

yN – nearby edge above yC

one coincidence case:

x‘ < xN

y‘ = yN

smoothness index = 1

xN

yCrect2

rect1

2 The Tree-Search Algorithm

D) Evaluating of placements- multiple possible placements per RS in general- evaluation criteria: 1) specific value := value / area 2) smoothness index (0, 1 or 2) 3) area- all poss. placements ordered by evaluation criteria 1) – 3); first ns placements tried in this order (ns = curr. no. of succ.)

wC, y

IC, x

y‘, yN

xC x‘, xN

xN – nearby edge on the right of xC

yN – nearby edge above yC

two coincidence cases:

x‘ = xN

y‘ = yN

smoothness index = 2

yCrect2

rect1

2 The Tree-Search Algorithm

E) Determining the best placement for a RSTask:

- given: partial solution s with n - 1 rectangles (n ≥ 1), set Rres - request: best nth placement rpl* for current residual space rs

Approach: Partition Controlled Tree Search (PCTRS)

1) multiple complete solutions sc generated – all extending s; best placement rpl* = nth placement of best solution sc

2) additional search depth sd specified - RS of levels n,…,n+sd–1: multiple placements per RS tried RS of levels n+sd,…: only first placement tried (evaluation!) ith search level ↔ ith placement - sd increases with parameter search_effort

3) complete solutions generated by different extension strategies - each strategy calculates its own best solution - best solution sc over all strategies determines best placement rpl* - each extension strategy defined by a partition of sd

4) advantages of PCTRS - only small fraction of complete solutions tried compared to const. no. of succ. - mix of strategies cares for suitable balance between 2 factors: . width of seach – no of succ. per extension . degree of foresight – no. of simultaneous considered search levels.

2 The Tree-Search Algorithm

Expl.: extension strategy for partition “2+1” (two stages)

• stage 1: tree with two levels n and n+1 and ns = 2 constructed - complete all sol. s, - select best complete sol. sb, - reduce sb to n+1 placements, - pass sb to next stage

• stage 2: tree with one level n+2 and ns = 8 constructed; best complete solution of 2nd stage returned at last

fixed partial plan, level n-1

stage 1, level n

stage 1, level n + 1

stage 2, level n + 2

ad

d. s

ea

rch

de

pth

0

1

2

3

partial plan completed plan

...

2 The Tree-Search Algorithm

Packing units: - blocks with n 1 rectangles - simple blocks (one item type), general blocks (small inner gaps) - 2 super phases: 1: simple blocks only, 2: general blocks

Residual spaces (RS): - container – first RS - each RS filled by 1 block; remaining empty space then cut into three daughter spaces - unprocessed RS always disjoint - heuristic rules for cutting RS and processing order of RS

Tree search: - PCTRS - largest blocks tried per RS

Guillotine constraint: - observed by (single) blocks - observed by complete plans (sequences of blocks) since residual spaces generated by guillotine cuts

2.2 TRS-Algorithm for guillotine case

3 Numerical Test

3 Numerical Test

Implementation, names: algorithm implemented in C, called: CLTRS

variant for subtypes OG/RG: CLTRS–G variant for subtypes OF/RF: CLTRS–F

PC/OS: AMD Athlon, 2.6 GHz, Windows XP

Configuration: parameters uniformly set per CLTRS variant exception: time limits

Reporting of results: - gap := relative deviation from upper bound (or known optimum)

(bound – objective value) / bound (in %)- only best values per method and instance considered- only one run per instance with CLTRS (G or F)

3 Numerical Test

A) 630 instances from Beasley (2004)

CLTRS–F: mean computing time 22.1 Secs.

Sub-type

Method / Authors Gap (%)

Gap-250 (%)

#Optima

OF Beasley (2004) 1.67 0.30 n.k.

Alvarez-Valdes et al. (2005) 1.07 0.07 n.k.

Gonçalves / Resende (2006) 0.98 0.07 n.k.

Hadjiconstantinou / Iori (2007) 1.32 0.28 n.k.

Alvarez-Valdes et al. (2007) 0.98 0.05 n.k.

Bortfeldt / Winter (2007) 0.99 0.04 254 (40%)

CLTRS–F 0.83 0.03 306 (49%)

Optimization criterion: packed valueInstance size: m: 40 …1000

3 Numerical Test

B) 21 instances from Hopper and Turton (2004)

CLTRS–F: mean computing time – OF: 129.5 Secs, – RF: 1.8 Secs.

Sub-type

Method / Authors Gap (%)

#Best #Optima

OF Alvarez-Valdes et al. (2005) 1.50 3 3

Alvarez-Valdes et al. (2007) 0.47 9 9

Bortfeldt / Winter (2007) 0.40 6 6

CLTRS–F 0.02 21 16

RF Huang et al. (2007) 0.03 16 16

Bortfeldt / Winter (2007) 0.02 17 17

CLTRS–F 0.00 21 21

Optimization criterion: packed area; filling rate 100% poss. Instance size: m: 16 …197

3 Numerical Test

C) 44 instances from Fayard et al. (1998)

CLTRS–G: mean computing time 252 Secs.

Sub-type

Sub-set

Method / Authors Gap (%)

#Optima

OG CU/CW Fayard et al. (1998) 1.74 5

Alvarez-Valdes et al. (2002) 0.07 15

Morabito / Pureza (2007) 0.00 22

Bortfeldt / Winter (2007) 1.07 10

CLTRS–G 0.02 20

UU/UW Fayard et al. (1998) 0.09 17

Bortfeldt / Winter (2007) 1.92 7

CLTRS–G 0.00 22

Piece set: constrained (C), unconstrained (U) Optimization criterion: packed area (U), packed value (W) Resulting subsets: CU, CW, UU, UW - 11 instances each Instance size: m: 25 …60

4 Conclusions

4 Conclusions

Heuristic CLTRS: - excellent solution quality - time consumption: OF/RF – excellent; OG/RG – moderate - few parameters, no tuning

New concepts: - problem specific: . CLTRS–F: smoothness index – heart of approach . CLTRS–G: generalized block concept

- generic: Partition Controlled Tree Search (PCTRS) . new type of incomplete tree search / beam search . economical generation of solutions . balance of: search width – degree of foresight

Topics of further research: - 3D-CLTRS, non-guillotine case - 2D-CLTRS, extension to strip packing - application of PCTRS to other problems.

5 Appendix

Appendix: Detailed description of PCTRS

5 Appendix

Search stage:

- input: solution sin with m filled RS (m ≥ n-1) - procedure:

subtree of partial solutions of depth d constructed (d ≤ sd),all constructed solutions of level m + d are completed

- ns – no. successors per node = no. tried blocks per RS; ns = f(d, search_effort); d small ↔ ns big ! - output: best complete solution sout

Extension strategy (ES):

- results by chaining of search stages, i.e. input sin of stage x+1 = output sout of stage x - for given search depth sd all possible ES given by all partitions of sd example: search depth sd = 3, ordered partition p: 3; 2+1; 1+2; 1+1+1; no. of summands t: 1 2 2 3- no of summands t = no. of stages; ith summand = depth d of ith stage

Partition Controlled Tree Search (PCTRS):

- all possible ES used concurrently - search stages / ES differ in terms of

a) search width, i.e. no. of tested placements per RS (ns) b) degree of foresight, i.e. no. of simultaneous considered RS (d)

- PCTRS cares for suitable balance of both factors!

5 Appendix

1) extension strategy for partition “3” (one stage)

• for each RS of levels n, n+1, n+2 the first ns = 2 admissible placements are tried

• each partial plan with n+2 blocks is completed; best complete solution returned

fixed partial plan, level n-1

stage 1, level n

stage 1, level n + 1

stage 1, level n + 2

ad

d. s

ea

rch

de

pth

0

1

2

3

partial plan completed plan, standard completion from next level (here: n + 3)

5 Appendix

2) extension strategy for partition “1+1+1” (three stages)

• stage 1: for RS of level n first ns = 8 admissible placements are tried; each resulting plan is completed; s1 – best solution of stage 1

• stages 2, 3: same procedure repeated on levels n+1, n+2, yielding best solutions s2 and s3, s3 is returned

• chaining: s1 is input for 2nd stage, s2 is input for 3rd stage

fixed partial plan, level n-1

stage 1, level n

stage 2, level n + 1

stage 3, level n + 2

ad

d. s

ea

rch

de

pth

0

1

2

3

partial plan completed plan

...

...

...

5 Appendix

3) extension strategy for partition “2+1” (two stages)

• stage 1: tree with two levels n and n+1 and ns = 2 constructed

• stage 2: tree with one level n+2 and ns = 8 constructed; best solution of 2nd stage returned at last

• chaining: best solution of stage 1 is input for stage 2

fixed partial plan, level n-1

stage 1, level n

stage 1, level n + 1

stage 2, level n + 2

ad

d. s

ea

rch

de

pth

0

1

2

3

partial plan completed plan

...