SlideShare a Scribd company logo
Spring 2015
Mathematics in
Management Science
Bin Packing
The Problem
The Algorithms
Different Scheduling Problem
Have collection of idpt tasks (all task
times ≤ 10). Instead of asking how
long to finish job with 3 processors,
instead ask,
“What is fewest number of processors
need to finish job in under 20 min?”
A very different question!
Example of a bin-packing problem.
The Bin Packing Problem
Assume have:
identical “bins” fixed capacity, and
objects (“weights”) of various sizes
that must be packed in bins.
How can we do this most efficiently
(i.e., with fewest bins)?
Example
A company buys bulk wire in 100 ft
spools. They use the wire in a variety of
lengths in their product. How should
they cut the wire so as to use the
fewest spools?
Example
A wall unit requires boards of lengths:
6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4
Stock boards come in 9ft lengths.
How should we cut the boards so as to
minimize the cost of material?
Variants
Two possibilities:
1. Only know next weight to pack.
(Think assembly line.)
2. Have full knowledge of all needed
sizes/weights.
(E.g., a work order that lists everything
that is needed.)
Variants
Two possibilities:
1. Only know next wt to pack.
2. Full knowledge all weights.
In (2), it makes sense to first sort the
weights in a decreasing list. (Why?)
Leads to two variants of every bin-
packing algorithm.
Variants
Two variants of every bin-packing
algorithm.
The Bin Packing Problem
Pack wts w1, w2, …,wn into bins.
Each bin has fixed capacity.
Use as few bins as possible.
A scheduling problem in disguise!
unlimited # of procs each with fixed
capacity (Goal: minimize # procs)
Dictionary
Scheduling
task
task time
processor
completion time
completing a task
# of processors
Bin Packing
item to pack
weight of item
bin
bin size
packing an item
# of bins
The Algorithms
Heuristic Algorithms
• NF – Next Fit
• FF – First Fit
• WF – Worst Fit
In last 2, bins stay
open until they are
completely full.
Decreasing Versions
• NFD – Next Fit D
• FFD – First Fit D
• WFD – Worst Fit D
With these first sort
wts into decreasing
order, then pack.
Next Fit Packing Algortihm
Only one bin open at a time!
Pack item in current bin.
If item will not fit in current bin:
close this bin & open a new bin.
Continue until all items packed.
Example using Next Fit Packing
Wts 6, 6, 5, 5, 5, 4, 4, 4, 4, 2, 2, 2, 2, 3, 3, 7, 7, 5, 5, 8, 8, 4, 4, 5
Next Fit Packing Algortihm
Advantages – Do not need to know all
the weights in advance; only need to
know the remaining space in the bin.
Disadvantages – The bin packed early
on may have had room for small items
that come later in the list.
Best method for assembly-line packing.
First Fit & Worst Fit Packing
Keep all bins open until full. Then close.
To pack an item, look at open bins.
FF Place item in first bin in which it fits.
WF Place item in bin with the most space
(and into which item fits) .
Only open new bin if item will not fit in any
of the already open bins.
Bin Packing Methods
Next Fit & First Fit & Worst Fit
NF A new bin is opened if the weight to be packed next
will not fit in the bin that is currently being filled; the
current bin is then closed.
FF The next weight to be packed is placed in the
lowest-numbered bin already opened into which it will
fit. If it does not fit in any open bins, a new bin is
opened.
WF The next weight to be packed is placed into the
open bin with the largest amount of room remaining. If
it does not fit in any bins, open a new bin.
Bin Packing Methods
Next Fit Decreasing (NFD)
First Fit Decreasing(FFD)
Worse Fit Decreasing(WFD)
Decreasing-Time Heuristics
NFD, FFD, WFD – Create the priority list by
listing the weights in order of decreasing size
before applying selected bin-packing
method.
Example: Next Fit
A wall unit requires boards of lengths:
6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4
Stock boards come in 9' lengths(!). How should you cut the boards
so as to minimize the cost of material? Use (1) NF and (2) NFD.
Next Fit: 6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4
8
4 6
5
4
5 2
2
3
7
5 5
8
4
4
3 1 3 1 1
4 4
0 2
2
Example: Next Fit
A wall unit requires boards of lengths:
6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4
Stock boards come in 9' lengths(!). How should you cut the boards
so as to minimize the cost of material? Use (1) NF and (2) NFD.
Next Fit Decreasing: 8, 7, 6, 5, 5, 5, 5, 4, 4, 4, 3, 2, 2, 2
8
4 8 7
6 5 5 5 5 4
4
4
3
2
2
2
1 1
0
2 3 4 4 4 0
Example
8
4 6
5
7
4
6
5
3
4
2
8
4 7 2
Pack the following weights: 6, 5, 7, 3, 4, 2 in bins of size 10 using
(1) NF and (2) NFD.
Next Fit: NFD: 7, 6, 5, 4, 3, 2
3
Example: First Fit
A wall unit requires boards of lengths:
6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4
Stock boards come in 9' lengths(!). How should you cut the boards
so as to minimize the cost of material? Use (1) FF and (2) FFD.
First Fit: 6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4
8
4 8
7
5 5
5
4
4 4
3 2
2
2
6
5
1
0 0
0 0 0 0
Example: First Fit
A wall unit requires boards of lengths:
6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4
Stock boards come in 91 lengths(!). How should you cut the boards
so as to minimize the cost of material? Use (1) FF and (2) FFD.
First Fit Decreasing: 8, 7, 6, 5, 5, 5, 5, 4, 4, 4, 3, 2, 2, 2
8
4 8
1
7
6 5 5 5 5
4 4 4
3
2 2
2
0 0 0 0 0 0
Example
4
Pack the following weights: 6, 5, 7, 3, 4, 2 in bins of size 10 using
(1) FF and (2) FFD.
First Fit: FFD: 7, 6, 5, 4, 3, 2
1 1 1 0 0 3
8 8
4
3 4 2
7
6
5
3 4
7 2
6
5
Example: Worst Fit
A wall unit requires boards of lengths:
6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4
Stock boards come in 9' lengths(!). How should you cut the boards
so as to minimize the cost of material? Use (1) WF and (2) WFD.
Worst Fit: 6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4
8
4
6 5
4
0
4
2
1
2
2
1
3
7
5
2
8
1
5 4
0
5
5
0
Example: Worst Fit
A wall unit requires boards of lengths:
6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4
Stock boards come in 91 lengths(!). How should you cut the boards
so as to minimize the cost of material? Use (1) WF and (2) WFD.
Worst Fit Decreasing: 8, 7, 6, 5, 5, 5, 5, 4, 4, 4, 3, 2, 2, 2
8
4 8
1
7
6 5 5 5 5
4
0
4
0
4
0
3
2
2
2
7
1
1
0
Example
4
Pack the following weights: 6, 5, 7, 3, 4, 2 in bins of size 10 using
(1) WF and (2) WFD.
Worst Fit: WFD: 7, 6, 5, 4, 3, 2
0 2 1 1 1 1
8 8
4
4
2
3
5
7
6
2 3 4
7
6
5
Exercise
Find a question of the form:
Use indicated bin-packing algorithm to
place given weight in the supplied,
already partially filled, bins.
Place wts in the bins and select the
next wt to be added in such a way that
each of the 3 algorithms (NF, FF, WF)
will place the wt in a different bin.

More Related Content

PPTX
Packaging & More
William Scott
 
PPT
Reboard S G I A V1
Terry Amerine
 
PDF
How our industry is adapting to change in customer requirements v 3.02
jcthomasva
 
PPT
Reboard Presentation 11 4 2009
Terry Amerine
 
PPTX
Mini project on gusset box
kartik16
 
PDF
BinPacking.pdf Dfghhjkkjjjjmkkkjnjjjjmmmk
ShivaniSharma335055
 
PPT
OS-20210426203801 introduction to os.ppt
naghamallella
 
PPT
basic logic gate presentation date23.ppt
naghamallella
 
Packaging & More
William Scott
 
Reboard S G I A V1
Terry Amerine
 
How our industry is adapting to change in customer requirements v 3.02
jcthomasva
 
Reboard Presentation 11 4 2009
Terry Amerine
 
Mini project on gusset box
kartik16
 
BinPacking.pdf Dfghhjkkjjjjmkkkjnjjjjmmmk
ShivaniSharma335055
 
OS-20210426203801 introduction to os.ppt
naghamallella
 
basic logic gate presentation date23.ppt
naghamallella
 

More from naghamallella (20)

PPT
logic gate presentation for and or n.ppt
naghamallella
 
PPT
6_2019_04_09!08_59_48_PM logic gate_.ppt
naghamallella
 
PPTX
bin packing2 and scheduling for mul.pptx
naghamallella
 
PPT
BOOTP computer science for multiproc.ppt
naghamallella
 
PPT
trusted computing platform alliancee.ppt
naghamallella
 
PPT
trusted computing for security confe.ppt
naghamallella
 
PPT
bin packing and scheduling multiproc.ppt
naghamallella
 
PPT
multiprocessor _system _presentation.ppt
naghamallella
 
PPT
image processing for jpeg presentati.ppt
naghamallella
 
PPT
introduction to jpeg for image proce.ppt
naghamallella
 
PPT
jpg image processing nagham salim_as.ppt
naghamallella
 
PPTX
lips _reading_nagham _salim compute.pptx
naghamallella
 
PPT
electronic mail security for authent.ppt
naghamallella
 
PPT
web _security_ for _confedindality s.ppt
naghamallella
 
PPT
lips _reading _in computer_ vision_n.ppt
naghamallella
 
PPT
thread_ multiprocessor_ scheduling_a.ppt
naghamallella
 
PPT
distributed real time system schedul.ppt
naghamallella
 
PPT
Trusted Computing security _platform.ppt
naghamallella
 
PPT
Trusted Computing _plate form_ model.ppt
naghamallella
 
PPTX
avi _file _formate_ trasport _layer.pptx
naghamallella
 
logic gate presentation for and or n.ppt
naghamallella
 
6_2019_04_09!08_59_48_PM logic gate_.ppt
naghamallella
 
bin packing2 and scheduling for mul.pptx
naghamallella
 
BOOTP computer science for multiproc.ppt
naghamallella
 
trusted computing platform alliancee.ppt
naghamallella
 
trusted computing for security confe.ppt
naghamallella
 
bin packing and scheduling multiproc.ppt
naghamallella
 
multiprocessor _system _presentation.ppt
naghamallella
 
image processing for jpeg presentati.ppt
naghamallella
 
introduction to jpeg for image proce.ppt
naghamallella
 
jpg image processing nagham salim_as.ppt
naghamallella
 
lips _reading_nagham _salim compute.pptx
naghamallella
 
electronic mail security for authent.ppt
naghamallella
 
web _security_ for _confedindality s.ppt
naghamallella
 
lips _reading _in computer_ vision_n.ppt
naghamallella
 
thread_ multiprocessor_ scheduling_a.ppt
naghamallella
 
distributed real time system schedul.ppt
naghamallella
 
Trusted Computing security _platform.ppt
naghamallella
 
Trusted Computing _plate form_ model.ppt
naghamallella
 
avi _file _formate_ trasport _layer.pptx
naghamallella
 
Ad

Recently uploaded (20)

PPTX
Internal Capsule_Divisions_fibres_lesions
muralinath2
 
PPTX
fghvqwhfugqaifbiqufbiquvbfuqvfuqyvfqvfouiqvfq
PERMISONJERWIN
 
DOCX
Echoes_of_Andromeda_Partial (1).docx9989
yakshitkrishnia5a3
 
PPTX
Quality control test for plastic & metal.pptx
shrutipandit17
 
PDF
Drones in Disaster Response: Real-Time Data Collection and Analysis (www.kiu...
publication11
 
PDF
Approximating manifold orbits by means of Machine Learning Techniques
Esther Barrabés Vera
 
PPTX
Nature of Science and the kinds of models used in science
JocelynEvascoRomanti
 
PDF
Systems Biology: Integrating Engineering with Biological Research (www.kiu.a...
publication11
 
PDF
study of microbiologically influenced corrosion of 2205 duplex stainless stee...
ahmadfreak180
 
PPTX
Reticular formation_nuclei_afferent_efferent
muralinath2
 
PDF
High-definition imaging of a filamentary connection between a close quasar pa...
Sérgio Sacani
 
PPTX
ANTIANGINAL DRUGS.pptx m pharm pharmacology
46JaybhayAshwiniHari
 
PPTX
Pengenalan Sel dan organisasi kehidupanpptx
SuntiEkaprawesti1
 
PPT
Grade_9_Science_Atomic_S_t_r_u_cture.ppt
QuintReynoldDoble
 
PDF
The Cosmic Symphony: How Photons Shape the Universe and Our Place Within It
kutatomoshi
 
PPTX
Hericium erinaceus, also known as lion's mane mushroom
TinaDadkhah1
 
PPTX
METABOLIC_SYNDROME Dr Shadab- kgmu lucknow pptx
ShadabAlam169087
 
PDF
Control and coordination Class 10 Chapter 6
LataHolkar
 
PPTX
Evolution of diet breadth in herbivorus insects.pptx
Mr. Suresh R. Jambagi
 
PPTX
Embark on a journey of cell division and it's stages
sakyierhianmontero
 
Internal Capsule_Divisions_fibres_lesions
muralinath2
 
fghvqwhfugqaifbiqufbiquvbfuqvfuqyvfqvfouiqvfq
PERMISONJERWIN
 
Echoes_of_Andromeda_Partial (1).docx9989
yakshitkrishnia5a3
 
Quality control test for plastic & metal.pptx
shrutipandit17
 
Drones in Disaster Response: Real-Time Data Collection and Analysis (www.kiu...
publication11
 
Approximating manifold orbits by means of Machine Learning Techniques
Esther Barrabés Vera
 
Nature of Science and the kinds of models used in science
JocelynEvascoRomanti
 
Systems Biology: Integrating Engineering with Biological Research (www.kiu.a...
publication11
 
study of microbiologically influenced corrosion of 2205 duplex stainless stee...
ahmadfreak180
 
Reticular formation_nuclei_afferent_efferent
muralinath2
 
High-definition imaging of a filamentary connection between a close quasar pa...
Sérgio Sacani
 
ANTIANGINAL DRUGS.pptx m pharm pharmacology
46JaybhayAshwiniHari
 
Pengenalan Sel dan organisasi kehidupanpptx
SuntiEkaprawesti1
 
Grade_9_Science_Atomic_S_t_r_u_cture.ppt
QuintReynoldDoble
 
The Cosmic Symphony: How Photons Shape the Universe and Our Place Within It
kutatomoshi
 
Hericium erinaceus, also known as lion's mane mushroom
TinaDadkhah1
 
METABOLIC_SYNDROME Dr Shadab- kgmu lucknow pptx
ShadabAlam169087
 
Control and coordination Class 10 Chapter 6
LataHolkar
 
Evolution of diet breadth in herbivorus insects.pptx
Mr. Suresh R. Jambagi
 
Embark on a journey of cell division and it's stages
sakyierhianmontero
 
Ad

bin packing 2 for real time scheduli.ppt

  • 1. Spring 2015 Mathematics in Management Science Bin Packing The Problem The Algorithms
  • 2. Different Scheduling Problem Have collection of idpt tasks (all task times ≤ 10). Instead of asking how long to finish job with 3 processors, instead ask, “What is fewest number of processors need to finish job in under 20 min?” A very different question! Example of a bin-packing problem.
  • 3. The Bin Packing Problem Assume have: identical “bins” fixed capacity, and objects (“weights”) of various sizes that must be packed in bins. How can we do this most efficiently (i.e., with fewest bins)?
  • 4. Example A company buys bulk wire in 100 ft spools. They use the wire in a variety of lengths in their product. How should they cut the wire so as to use the fewest spools?
  • 5. Example A wall unit requires boards of lengths: 6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4 Stock boards come in 9ft lengths. How should we cut the boards so as to minimize the cost of material?
  • 6. Variants Two possibilities: 1. Only know next weight to pack. (Think assembly line.) 2. Have full knowledge of all needed sizes/weights. (E.g., a work order that lists everything that is needed.)
  • 7. Variants Two possibilities: 1. Only know next wt to pack. 2. Full knowledge all weights. In (2), it makes sense to first sort the weights in a decreasing list. (Why?) Leads to two variants of every bin- packing algorithm.
  • 8. Variants Two variants of every bin-packing algorithm.
  • 9. The Bin Packing Problem Pack wts w1, w2, …,wn into bins. Each bin has fixed capacity. Use as few bins as possible. A scheduling problem in disguise! unlimited # of procs each with fixed capacity (Goal: minimize # procs)
  • 10. Dictionary Scheduling task task time processor completion time completing a task # of processors Bin Packing item to pack weight of item bin bin size packing an item # of bins
  • 11. The Algorithms Heuristic Algorithms • NF – Next Fit • FF – First Fit • WF – Worst Fit In last 2, bins stay open until they are completely full. Decreasing Versions • NFD – Next Fit D • FFD – First Fit D • WFD – Worst Fit D With these first sort wts into decreasing order, then pack.
  • 12. Next Fit Packing Algortihm Only one bin open at a time! Pack item in current bin. If item will not fit in current bin: close this bin & open a new bin. Continue until all items packed.
  • 13. Example using Next Fit Packing Wts 6, 6, 5, 5, 5, 4, 4, 4, 4, 2, 2, 2, 2, 3, 3, 7, 7, 5, 5, 8, 8, 4, 4, 5
  • 14. Next Fit Packing Algortihm Advantages – Do not need to know all the weights in advance; only need to know the remaining space in the bin. Disadvantages – The bin packed early on may have had room for small items that come later in the list. Best method for assembly-line packing.
  • 15. First Fit & Worst Fit Packing Keep all bins open until full. Then close. To pack an item, look at open bins. FF Place item in first bin in which it fits. WF Place item in bin with the most space (and into which item fits) . Only open new bin if item will not fit in any of the already open bins.
  • 16. Bin Packing Methods Next Fit & First Fit & Worst Fit NF A new bin is opened if the weight to be packed next will not fit in the bin that is currently being filled; the current bin is then closed. FF The next weight to be packed is placed in the lowest-numbered bin already opened into which it will fit. If it does not fit in any open bins, a new bin is opened. WF The next weight to be packed is placed into the open bin with the largest amount of room remaining. If it does not fit in any bins, open a new bin.
  • 17. Bin Packing Methods Next Fit Decreasing (NFD) First Fit Decreasing(FFD) Worse Fit Decreasing(WFD) Decreasing-Time Heuristics NFD, FFD, WFD – Create the priority list by listing the weights in order of decreasing size before applying selected bin-packing method.
  • 18. Example: Next Fit A wall unit requires boards of lengths: 6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4 Stock boards come in 9' lengths(!). How should you cut the boards so as to minimize the cost of material? Use (1) NF and (2) NFD. Next Fit: 6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4 8 4 6 5 4 5 2 2 3 7 5 5 8 4 4 3 1 3 1 1 4 4 0 2 2
  • 19. Example: Next Fit A wall unit requires boards of lengths: 6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4 Stock boards come in 9' lengths(!). How should you cut the boards so as to minimize the cost of material? Use (1) NF and (2) NFD. Next Fit Decreasing: 8, 7, 6, 5, 5, 5, 5, 4, 4, 4, 3, 2, 2, 2 8 4 8 7 6 5 5 5 5 4 4 4 3 2 2 2 1 1 0 2 3 4 4 4 0
  • 20. Example 8 4 6 5 7 4 6 5 3 4 2 8 4 7 2 Pack the following weights: 6, 5, 7, 3, 4, 2 in bins of size 10 using (1) NF and (2) NFD. Next Fit: NFD: 7, 6, 5, 4, 3, 2 3
  • 21. Example: First Fit A wall unit requires boards of lengths: 6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4 Stock boards come in 9' lengths(!). How should you cut the boards so as to minimize the cost of material? Use (1) FF and (2) FFD. First Fit: 6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4 8 4 8 7 5 5 5 4 4 4 3 2 2 2 6 5 1 0 0 0 0 0 0
  • 22. Example: First Fit A wall unit requires boards of lengths: 6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4 Stock boards come in 91 lengths(!). How should you cut the boards so as to minimize the cost of material? Use (1) FF and (2) FFD. First Fit Decreasing: 8, 7, 6, 5, 5, 5, 5, 4, 4, 4, 3, 2, 2, 2 8 4 8 1 7 6 5 5 5 5 4 4 4 3 2 2 2 0 0 0 0 0 0
  • 23. Example 4 Pack the following weights: 6, 5, 7, 3, 4, 2 in bins of size 10 using (1) FF and (2) FFD. First Fit: FFD: 7, 6, 5, 4, 3, 2 1 1 1 0 0 3 8 8 4 3 4 2 7 6 5 3 4 7 2 6 5
  • 24. Example: Worst Fit A wall unit requires boards of lengths: 6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4 Stock boards come in 9' lengths(!). How should you cut the boards so as to minimize the cost of material? Use (1) WF and (2) WFD. Worst Fit: 6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4 8 4 6 5 4 0 4 2 1 2 2 1 3 7 5 2 8 1 5 4 0 5 5 0
  • 25. Example: Worst Fit A wall unit requires boards of lengths: 6, 5, 4, 5, 3, 2, 2, 2, 7, 5, 5, 8, 4, 4 Stock boards come in 91 lengths(!). How should you cut the boards so as to minimize the cost of material? Use (1) WF and (2) WFD. Worst Fit Decreasing: 8, 7, 6, 5, 5, 5, 5, 4, 4, 4, 3, 2, 2, 2 8 4 8 1 7 6 5 5 5 5 4 0 4 0 4 0 3 2 2 2 7 1 1 0
  • 26. Example 4 Pack the following weights: 6, 5, 7, 3, 4, 2 in bins of size 10 using (1) WF and (2) WFD. Worst Fit: WFD: 7, 6, 5, 4, 3, 2 0 2 1 1 1 1 8 8 4 4 2 3 5 7 6 2 3 4 7 6 5
  • 27. Exercise Find a question of the form: Use indicated bin-packing algorithm to place given weight in the supplied, already partially filled, bins. Place wts in the bins and select the next wt to be added in such a way that each of the 3 algorithms (NF, FF, WF) will place the wt in a different bin.