Bin Packing Michael T. Goodrich Some slides adapted from slides from

Slides:



Advertisements
Similar presentations
1 Chapter 8 Approximation Algorithms (Part II). 2 Outline Scheduling Independent tasks Bin packing.
Advertisements

Algorithm Design Methods Spring 2007 CSE, POSTECH.
 Review: The Greedy Method
Algorithm Design Techniques: Greedy Algorithms. Introduction Algorithm Design Techniques –Design of algorithms –Algorithms commonly used to solve problems.
Biologically Inspired Computation Really finishing off EC.
CS223 Advanced Data Structures and Algorithms 1 Greedy Algorithms Neil Tang 4/8/2010.
Tournament Trees CSE, POSTECH.
Winner trees. Loser Trees.
Sorting Comparison-based algorithm review –You should know most of the algorithms –We will concentrate on their analyses –Special emphasis: Heapsort Lower.
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
© The McGraw-Hill Companies, Inc., Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
PTAS for Bin-Packing. Special Cases of Bin Packing 1. All item sizes smaller than Claim 1: Proof: If then So assume Therefore:
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
88- 1 Chapter 8 The Theory of NP-Completeness P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class.
Tirgul 4 Order Statistics Heaps minimum/maximum Selection Overview
© 2010 AT&T Intellectual Property. All rights reserved. AT&T and the AT&T logo are trademarks of AT&T Intellectual Property. Bin Packing: From Theory to.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
B-trees (Balanced Trees) A B-tree is a special kind of tree, similar to a binary tree. However, It is not a binary search tree. It is not a binary tree.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 B Trees - Motivation Recall our discussion on AVL-trees –The maximum height of an AVL-tree with n-nodes is log 2 (n) since the branching factor (degree,
Chapter 12 Coping with the Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Approximation schemes Bin packing problem. Bin Packing problem Given n items with sizes a 1,…,a n  (0,1]. Find a packing in unit-sized bins that minimizes.
Presented by Dajiang Zhu 09/20/2011.  Motivation  Introduction & Conclusion  Pre – Definition Approximation Algorithms  Two problems as examples SUBSET-SUM.
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
© 2009 IBM Corporation 1 Improving Consolidation of Virtual Machines with Risk-aware Bandwidth Oversubscription in Compute Clouds Amir Epstein Joint work.
© 2010 AT&T Intellectual Property. All rights reserved. AT&T and the AT&T logo are trademarks of AT&T Intellectual Property. Case Studies: Bin Packing.
Chapter 15 Approximation Algorithm Introduction Basic Definition Difference Bounds Relative Performance Bounds Polynomial approximation Schemes Fully Polynomial.
The Lower Bounds of Problems
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
Cliff Shaffer Computer Science Computational Complexity.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
A Membrane Algorithm for the Min Storage problem Dipartimento di Informatica, Sistemistica e Comunicazione Università degli Studi di Milano – Bicocca WMC.
FALL 2005CENG 213 Data Structures1 Priority Queues (Heaps) Reference: Chapter 7.
The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects.
Computability NP complete problems. Space complexity. Homework: [Post proposal]. Find PSPACE- Complete problems. Work on presentations.
Winner trees. Loser Trees.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
Errol Lloyd Design and Analysis of Algorithms Approximation Algorithms for NP-complete Problems Bin Packing Networks.
Conceptual Foundations © 2008 Pearson Education Australia Lecture slides for this course are based on teaching materials provided/referred by: (1) Statistics.
What is the runtime of the best possible (comparison based) sorting algorithm? 1.O(log n) 2.O(n) 3.O(n log n) 4.O(n 2 ) 5.None of the above.
CSE332: Data Abstractions Lecture 7: AVL Trees
The Theory of NP-Completeness
Decision Trees DEFINITION: DECISION TREE A decision tree is a tree in which the internal nodes represent actions, the arcs represent outcomes of an action,
8.3.2 Constant Distance Approximations
Andreas Klappenecker [partially based on the slides of Prof. Welch]
Lecture 15 Nov 3, 2013 Height-balanced BST Recall:
Approximation Algorithms
Algorithm Design Methods
AVL Trees 6/25/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M.
Priority Queues © 2010 Goodrich, Tamassia Priority Queues 1
Best-fit bin packing in O(n log n) time
COSC160: Data Structures Linked Lists
AVL Trees 4/29/15 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H.
Algorithm design and Analysis
Bin Fu Department of Computer Science
Exam 2 LZW not on syllabus. 73% / 75%.
CSE373: Data Structures & Algorithms Lecture 5: AVL Trees
A new and improved algorithm for online bin packing
PTAS for Bin-Packing.
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
Algorithm Design Methods
ICS 353: Design and Analysis of Algorithms
Algorithm Design Methods
The Theory of NP-Completeness
Instructor: Aaron Roth
Approximation Algorithm
Algorithm Design Methods
Presentation transcript:

Bin Packing Michael T. Goodrich Some slides adapted from slides from Professor C. L. Liu, Tsing Hua University Professor Teofilo F. Gonzalez, UCSB

Bin Packing Example Items to be packed .5 .7 .5 .2 .4 .2 .5 .1 .6 The bins; (capacity 1) 1 …… .5 .7 .5 .2 .4 .2 .5 .1 .6 .5 .7 .5 .2 .4 .2 .5 .1 .6 Items to be packed

Bin Packing Problem Definition Given n items with sizes s1, s2, ..., sn such that 0 ≤ si ≤ 1 for 1 ≤ i ≤ n, pack them into the fewest number of unit capacity bins. Problem is NP-hard (NP-Complete for the decision version). There is no known polynomial time algorithm for its solution, and it is conjectured that none exists.

Example Applications Filling recycle bins Loading trucks

Historical Application Mix tapes

Bin Packing Optimal Solution Bin Packing Problem 1 …… .5 .7 .5 .2 .4 .2 .5 .1 .6 Optimal Packing .5 .1 .2 .5 .6 MOpt = 4 .7 .5 .4 .2

Next-Fit (NF) Algorithm Check to see if the current item fits in the current bin. If so, then place it there, otherwise start a new bin.

Next Fit (NF) Packing Algorithm Example Bin Packing Problem .5 .7 .5 .2 .4 .2 .5 .1 .6 .5 .1 .2 .5 .6 MOpt = 4 .7 .5 .4 .2 Next Fit Packing Algorithm .7 .2 .2 .1 .6 .5 .5 .5 .4 M = 6

Approx. Ratio = Alg(I)/Opt(I) Approximation Ratios Approximation Algorithm: Not an optimal solution, but with some performance ratio guarantee for a given problem instance, I (e.g., no worst than twice the optimal) Approx. Ratio = Alg(I)/Opt(I)

Next Fit (NF) Approximation Ratio Theorem: Let M be the number of bins required to pack a list I of items optimally. Next Fit will use at most 2M bins. Proof: Let s(Bi) be the sum of sizes of the items assigned to bin Bi in the Next Fit solution. For any two adjacent bins (Bj and Bj+1), we know that s(Bj) + s(Bj+1) > 1.

Next Fit (NF) Approximation Ratio Let k be the number of bins used by Next Fit for list I. We prove the case when k is even (odd case is similar).

Next Fit (NF) Lower Bound There exist sequences such that Next Fit uses 2M −2 bins, where M is the number of bins in an optimal solution. Proof:

First Fit (FF) Algorithm Scan the bins in order and place the new item in the first bin that is large enough to hold it. A new bin is created only when an item does not fit in the previous bins.

First Fit (FF) Packing Algorithm Example .5 .7 .5 .2 .4 .2 .5 .1 .6 Next Fit Packing Algorithm .7 .2 .2 .1 .6 .5 .5 .5 .4 First Fit Packing Algorithm .5 .1 .2 .7 .2 .6 .5 .5 .4 M = 5

Running Time for First Fit Easily implemented in O(n2) time Can be implemented in O(n log n) time: Idea: Use a balanced search tree with height O(log n). Each node has three values: index of bin, remaining capacity of bin, and best (largest) in all the bins represented by the subtree rooted at the node. The ordering of the tree is by bin index.

Faster First-Fit (FF) Algorithm 8 bins:

First-Fit (FF) Approx. Ratio Let M be the optimal number of bins required to pack a list I of items. Then First Fit never uses more than ⌈1.7M⌉. Proof: [omitted]

First-Fit (FF) Approx. Ratio There exist sequences such that First Fit uses 1.6666…(M) bins. Proof:

First-Fit (FF) Lower Bound First Fit uses 10M bins, but optimal uses 6M

Best Fit Algorithm (BF) New item is placed in a bin where it fits the tightest. If it does not fit in any bin, then start a new bin. Can be implemented in O(n log n) time, by using a balanced binary tree storing bins ordered by remaining capacity.

Example for Best Fit (BF)

Other Heuristics First Fit Decreasing (FFD): First order the items by size, from largest to smallest, then run the First Fit Algorithm. Best Fit Decreasing (BFD): First order the items by size, from largest to smallest, then run the Best Fit Algorithm.

Experiments It is difficult to experimentally compute approximation ratios. It requires that we know the optimal solution to an NP-hard problem! But we can do experiments for a related parameter: Define the waste, W(A), for a bin-packing algorithm A to be the number of bins that it uses minus the total size of all n items.

Experiments We are interested in experiments for estimating the waste, W(A), as a function of n and as n grows towards infinity, for random items uniformly distributed in the interval (0,1), for the following algorithms: A = Next Fit (NF) A = First Fit (FF) A = Best Fit (BF) A = First Fit Decreasing (FFD) A = Best Fit Decreasing (BFD)