lec10

advertisement
Lecture 10. The Bin Packing Problem
The one dimensional bin packing problem is defined as follows. Given a set ๐ฟ =
{1, … , ๐‘›} of items and theirs weights ๐‘ค๐‘– ๏ƒŽ(0,1), ๐‘–๏ƒŽ๐ฟ. We wish to partition the
set ๐ฟ into minimal number ๐‘š of subsets ๐ต1 , ๐ต2 , … , ๐ต๐‘š in such a way that
∑ ๐‘ค๐‘– ≤ 1, 1 ≤ ๐‘— ≤ ๐‘š.
๐‘–ฯต๐ต๐‘—
The sets ๐ต๐‘— we will call bins.
In other words, we wish to pack all items in a minimal number of bins.
It is NP-hard problem in the strong sense.
Lecture 10
1
Mathematical Model
Decision variables:
1 if bin ๐‘— is used
๐‘ฆ๐‘— = {
;
0 otherwise
๐‘ฅ๐‘–๐‘— = {
๐‘›
1 if item ๐‘– is in bin ๐‘—
0 otherwise
min ∑ ๐‘ฆ๐‘—
๐‘—=1
๐‘›
s.t.
∑ ๐‘ค๐‘– ๐‘ฅ๐‘–๐‘— ≤ ๐‘ฆ๐‘— , ๐‘— = 1, … , ๐‘›;
๐‘–=1
๐‘›
∑ ๐‘ฅ๐‘–๐‘— = 1, ๐‘– = 1, … , ๐‘›;
๐‘—=1
๐‘ฆ๐‘– , ๐‘ฅ๐‘–๐‘— ฯต{0,1}, ๐‘–, ๐‘— = 1, … , ๐‘›.
Can we find the optimal solution for the linear programming relaxation
in polynomial time?
Lecture 10
2
Bad News
๏‚ท There is much symmetry in the model.
๏‚ท The problem is hard to approximate.
3
Theorem 1. The existence of a polynomial time ( − ๐œ€)-approximation algorithm
2
for any positive ๏ฅ implies P = NP.
Proof. Let us consider the following NP-complete problem. Given ๐‘› positive
numbers ๐‘Ž1 , … , ๐‘Ž๐‘› . Is it possible to partition this set into two subsets ๐ด1 , ๐ด2 in
such a way that ∑๐‘–∈๐ด1 ๐‘Ž๐‘– = ∑๐‘–∈๐ด2 ๐‘Ž๐‘– ?
1
๐‘Ž๐‘–
2
๐‘
We put ๐ถ = ∑๐‘›
๐‘–=1 ๐‘Ž๐‘– , ๐‘ค๐‘– =
3
, ๐‘– = 1, … , ๐‘›, and apply our (2 − ๐œ€)-
approximation algorithm. If we get 2 bins, then answer is Yes, otherwise No.
It is exact answer! ๏ฎ
Lecture 10
3
Strong Heuristic (FFD)
Rank the items by the weights:
๐‘ค1 ๏‚ณ ๐‘ค2 ๏‚ณ … ๏‚ณ ๐‘ค๐‘›
and apply the First Fit strategy:
๏€ญ put the first item in the first bin;
๏€ญ at the step ๐‘˜, we try to put item ๐‘˜ into the used bins and, if it is not possible,
we put item ๐‘˜ into a new bin.
Theorem 2. ๐น๐น๐ท(๐ฟ) ๏‚ฃ 11
๐‘‚๐‘ƒ๐‘‡(๐ฟ) + 4 for all ๐ฟ and there exist some instances
9
for the bin packing problem with
๐น๐น๐ท(๐ฟ) ๏‚ณ 11
๐‘‚๐‘ƒ๐‘‡(๐ฟ).
9
Lecture 10
4
1
Hard Example
๐ฟ = {1, … , 30 ๐‘š}
2
1
๐‘ค๐‘– =
4
1
4
1
+ ๐œ€,
1 ≤ ๐‘– ≤ 6๐‘š
+ 2๐œ€, 6๐‘š < ๐‘– ≤ 12๐‘š
+ ๐œ€, 12๐‘š < ๐‘– ≤ 18๐‘š
{ 4 − 2๐œ€, 18๐‘š < ๐‘– ≤ 30๐‘š
¼ – 2๏ฅ
¼ – 2๏ฅ
¼ + ๏ฅ
¼ – 2๏ฅ
½ +๏ฅ
¼ + 2๏ฅ
¼ + 2๏ฅ
¼ + ๏ฅ
½ +๏ฅ
¼ + ๏ฅ
¼ + 2๏ฅ
6๐‘š
3๐‘š
๐‘‚๐‘ƒ๐‘‡(๐ฟ) = 9๐‘š
Lecture 10
¼ + ๏ฅ
6m
¼ – 2๏ฅ
¼ – 2๏ฅ
¼ – 2๏ฅ
¼ – 2๏ฅ
2m
3m
FFD(L) = 11m
5
Huge Reformulation
Given ๐ฟ = {1, … , ๐‘›} is the set of items;
๐‘ค๐‘– > 0 is the weight of item ๐‘–;
๐‘›๐‘– > 0, integer, is the number of identical items ๐‘–
๐‘Ž๐‘–๐‘— is the number of identical items ๐‘– in packing pattern ๐‘—.
Find
a partition of all items into a minimal number of bins.
Variables:
๐‘ฅ๐‘— ≥ 0, integer, is the number of bins for the pattern ๐‘—
min ∑ ๐‘ฅ๐‘—
๐‘—∈๐ฝ
s.t.
∑ ๐‘Ž๐‘–๐‘— ๐‘ฅ๐‘— ≥ ๐‘›๐‘– , ๐‘– ∈ ๐ฟ;
๐‘—∈๐ฝ
๐‘ฅ๐‘— ≥ 0, integer, ๐‘— ∈ ๐ฝ.
๐ฝ is the set of all possible patterns.
Lecture 10
6
LP-Based Heuristic
Solve the linear programming relaxation
min ∑ ๐‘ฅ๐‘—
๐‘—∈๐ฝ
s.t.
∑ ๐‘Ž๐‘–๐‘— ๐‘ฅ๐‘— ≥ ๐‘›๐‘– , ๐‘– ∈ ๐ฟ;
๐‘—∈๐ฝ
๐‘ฅ๐‘— ≥ 0, ๐‘— ∈ ๐ฝ.
Put ๐‘ฅ๐‘— = ⌈๐‘ฅ๐‘—∗ ⌉, ๐‘— ∈ ๐ฝ. It is a feasible solution with deviation from the optimum
at most
๐œ€=
∑๐‘—∈๐ฝ(⌈๐‘ฅ๐‘—∗ ⌉ − ๐‘ฅ๐‘—∗ )
∑๐‘—∈๐ฝ ๐‘ฅ๐‘—∗
where ๐‘ฅ๐‘—∗ is the optimal solution for the LP model.
Can we solve LP?
Lecture 10
7
The Column Generation Method
Let us consider a subset ๐ฝ๏‚ข๏ƒŒ ๐ฝ of patterns and assume that the following subproblem
min ∑ ๐‘ฅ๐‘—
๐‘—∈๐ฝ′
s.t.
∑ ๐‘Ž๐‘–๐‘— ๐‘ฅ๐‘— ≥ ๐‘›๐‘– , ๐‘– ∈ ๐ฟ;
๐‘—∈๐ฝ′
๐‘ฅ๐‘— ๏‚ณ 0,
๐‘—๏ƒŽ๐ฝ′ ;
has at least one feasible solution.
Denote by ๐‘ฅ๐‘—∗ the optimal solution to this subproblem.
Lecture 10
8
The Dual Problem
max ∑ ๐‘›๐‘– ๐œ†๐‘–
๐‘–∈๐ฟ
∑ ๐‘Ž๐‘–๐‘— ๐œ†๐‘– ≤ 1, ๐‘— ∈ ๐ฝ′ ;
๐‘–∈๐ฟ
๐œ†๐‘– ≥ 0, ๐‘– ∈ ๐ฟ.
Denote by ๐œ†∗๐‘– ≥ 0 its optimal solution. If
∑ ๐‘Ž๐‘–๐‘— ๐œ†∗๐‘– ≤ 1, for ๐‘— ∈ ๐ฝ \ ๐ฝ′ ;
(๏€ช)
๐‘–∈๐ฟ
then
๐‘ฅ๐‘—∗ ,
๐‘— ∈ ๐ฝ′;
๐‘ฅฬ…๐‘— = {
0, ๐‘— ∈ ๐ฝ \ ๐ฝ′
is the optimal solution for the LP problem.
Lecture 10
9
How to Check (๏€ช)?
Let us consider the following knapsack problem:
๐›ผ = max ∑ ๐œ†∗๐‘– ๐‘ฆ๐‘–
๐‘–∈๐ฟ
s.t.
∑ ๐‘ค๐‘– ๐‘ฆ๐‘– ≤ 1 ;
(capacity of bin)
๐‘–∈๐ฟ
๐‘ฆ๐‘– ≥ 0, integer, ๐‘– ∈ ๐ฟ.
If ๐›ผ ≤ 1 then (๏€ช) is satisfied.
If ๐›ผ > 1 then we have got a new pattern and include it in ๐ฝ′ .
Lecture 10
10
The Framework of the Method
1. Select an initial subset ๐ฝ′ ⊂ ๐ฝ.
2. Solve the subproblem for ๐ฝ′ and its dual one, get ๐‘ฅ๐‘—∗ , ๐œ†∗๐‘– .
3. Solve the knapsack problem for ๐œ†∗ and compute ๐›ผ.
4. If ๐›ผ ≤ 1 then STOP.
5. Include new pattern ๐‘—0 : ๐‘Ž๐‘–๐‘—0 = ๐‘ฆ๐‘–∗ , ๐‘– ∈ ๐ฟ, into subset ๐ฝ′ and goto 2.
Surprise: As a rule, solution ๐‘ฅ๐‘— = ⌈๐‘ฅ๐‘—∗ ⌉, ๐‘— ∈ ๐ฝ is optimal for the bin packing
problem. If it is not true, we have at most one additional bin only!
Lecture 10
11
Two-Dimensional Packing Problem
Given: ๐‘› rectangles with size ๐‘ค๐‘– ๏‚ด ๐‘™๐‘– , ๐‘– = 1, … , ๐‘›.
Find: a packing of the rectangles into a rectangle area with minimal square.
Rotations are forbidden
๐‘ฆ
๐ฟ ๏‚ด ๐‘€ ๏‚ฎ min
6
2
๐‘Š
1
It is guillotine solution.
5
3
4
๐ฟ
Lecture 10
12
The Strip Packing Problem
ะ”ะฐะฝะพ: ๐‘› rectangles with size ๐‘ค๐‘– ๏‚ด๐‘™๐‘– , ๐‘– ∈ ๐ฟ, and large strip with width ๐‘Š.
Find: a packing of rectangles into the strip with minimal length.
๐‘ฆ
2
4
๐‘Š
1
For ๐‘™๐‘– = 1 we have
one-dimentional
bin packing problem
(NP-hard)
5
3
๐‘ฅ
Hometask. Design a linear integer programming model for the strip packing
problem (with and without 90° rotations).
Lecture 10
13
The Two-Dimensional Knapsack Problem
Given: ๐‘› rectangles with size ๐‘ค๐‘– ๏‚ด ๐‘™๐‘– , profit ๐‘๐‘– for each rectangle, and the size
of a vehicle ๐‘Š ๏‚ด ๐ฟ.
Find: a subset of rectangles with maximal total profit which can be packed into
the vehicle.
5
For ๐‘™๐‘– = ๐ฟ, we have
6
4
the classical knapsack
problem
9
7
๐‘Š
10
1
2
3
8
๐ฟ
Hometask. Design a linear integer programming model for the two-dimensional
knapsack problem.
Lecture 10
14
The Two-Dimensional Bin Packing Problem
Given: ๐‘› rectangles with size ๐‘ค๐‘– ๏‚ด ๐‘™๐‘– and the size of a vehicle ๐‘Š ๏‚ด ๐ฟ.
Find: a packing all rectangles into the minimal number of vehicles.
4
6
7
3
1
๐‘›– 1
5
๐‘›
2
...
Hometask. Design LP-based heuristic for the two-dimensional bin packing problem.
Lecture 10
15
Download