SlideShare a Scribd company logo
1 of 27
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

More from naghamallella

logic gate presentation for and or n.ppt
logic gate presentation for and or n.pptlogic gate presentation for and or n.ppt
logic gate presentation for and or n.pptnaghamallella
 
6_2019_04_09!08_59_48_PM logic gate_.ppt
6_2019_04_09!08_59_48_PM logic gate_.ppt6_2019_04_09!08_59_48_PM logic gate_.ppt
6_2019_04_09!08_59_48_PM logic gate_.pptnaghamallella
 
bin packing2 and scheduling for mul.pptx
bin packing2 and scheduling for mul.pptxbin packing2 and scheduling for mul.pptx
bin packing2 and scheduling for mul.pptxnaghamallella
 
BOOTP computer science for multiproc.ppt
BOOTP computer science for multiproc.pptBOOTP computer science for multiproc.ppt
BOOTP computer science for multiproc.pptnaghamallella
 
trusted computing platform alliancee.ppt
trusted computing platform alliancee.ppttrusted computing platform alliancee.ppt
trusted computing platform alliancee.pptnaghamallella
 
trusted computing for security confe.ppt
trusted computing for security confe.ppttrusted computing for security confe.ppt
trusted computing for security confe.pptnaghamallella
 
bin packing and scheduling multiproc.ppt
bin packing and scheduling multiproc.pptbin packing and scheduling multiproc.ppt
bin packing and scheduling multiproc.pptnaghamallella
 
multiprocessor _system _presentation.ppt
multiprocessor _system _presentation.pptmultiprocessor _system _presentation.ppt
multiprocessor _system _presentation.pptnaghamallella
 
image processing for jpeg presentati.ppt
image processing for jpeg presentati.pptimage processing for jpeg presentati.ppt
image processing for jpeg presentati.pptnaghamallella
 
introduction to jpeg for image proce.ppt
introduction to jpeg for image proce.pptintroduction to jpeg for image proce.ppt
introduction to jpeg for image proce.pptnaghamallella
 
jpg image processing nagham salim_as.ppt
jpg image processing nagham salim_as.pptjpg image processing nagham salim_as.ppt
jpg image processing nagham salim_as.pptnaghamallella
 
lips _reading_nagham _salim compute.pptx
lips _reading_nagham _salim compute.pptxlips _reading_nagham _salim compute.pptx
lips _reading_nagham _salim compute.pptxnaghamallella
 
electronic mail security for authent.ppt
electronic mail security for authent.pptelectronic mail security for authent.ppt
electronic mail security for authent.pptnaghamallella
 
web _security_ for _confedindality s.ppt
web _security_ for _confedindality s.pptweb _security_ for _confedindality s.ppt
web _security_ for _confedindality s.pptnaghamallella
 
lips _reading _in computer_ vision_n.ppt
lips _reading _in computer_ vision_n.pptlips _reading _in computer_ vision_n.ppt
lips _reading _in computer_ vision_n.pptnaghamallella
 
thread_ multiprocessor_ scheduling_a.ppt
thread_ multiprocessor_ scheduling_a.pptthread_ multiprocessor_ scheduling_a.ppt
thread_ multiprocessor_ scheduling_a.pptnaghamallella
 
distributed real time system schedul.ppt
distributed real time system schedul.pptdistributed real time system schedul.ppt
distributed real time system schedul.pptnaghamallella
 
Trusted Computing security _platform.ppt
Trusted Computing security _platform.pptTrusted Computing security _platform.ppt
Trusted Computing security _platform.pptnaghamallella
 
Trusted Computing _plate form_ model.ppt
Trusted Computing _plate form_ model.pptTrusted Computing _plate form_ model.ppt
Trusted Computing _plate form_ model.pptnaghamallella
 
avi _file _formate_ trasport _layer.pptx
avi _file _formate_ trasport _layer.pptxavi _file _formate_ trasport _layer.pptx
avi _file _formate_ trasport _layer.pptxnaghamallella
 

More from naghamallella (20)

logic gate presentation for and or n.ppt
logic gate presentation for and or n.pptlogic gate presentation for and or n.ppt
logic gate presentation for and or n.ppt
 
6_2019_04_09!08_59_48_PM logic gate_.ppt
6_2019_04_09!08_59_48_PM logic gate_.ppt6_2019_04_09!08_59_48_PM logic gate_.ppt
6_2019_04_09!08_59_48_PM logic gate_.ppt
 
bin packing2 and scheduling for mul.pptx
bin packing2 and scheduling for mul.pptxbin packing2 and scheduling for mul.pptx
bin packing2 and scheduling for mul.pptx
 
BOOTP computer science for multiproc.ppt
BOOTP computer science for multiproc.pptBOOTP computer science for multiproc.ppt
BOOTP computer science for multiproc.ppt
 
trusted computing platform alliancee.ppt
trusted computing platform alliancee.ppttrusted computing platform alliancee.ppt
trusted computing platform alliancee.ppt
 
trusted computing for security confe.ppt
trusted computing for security confe.ppttrusted computing for security confe.ppt
trusted computing for security confe.ppt
 
bin packing and scheduling multiproc.ppt
bin packing and scheduling multiproc.pptbin packing and scheduling multiproc.ppt
bin packing and scheduling multiproc.ppt
 
multiprocessor _system _presentation.ppt
multiprocessor _system _presentation.pptmultiprocessor _system _presentation.ppt
multiprocessor _system _presentation.ppt
 
image processing for jpeg presentati.ppt
image processing for jpeg presentati.pptimage processing for jpeg presentati.ppt
image processing for jpeg presentati.ppt
 
introduction to jpeg for image proce.ppt
introduction to jpeg for image proce.pptintroduction to jpeg for image proce.ppt
introduction to jpeg for image proce.ppt
 
jpg image processing nagham salim_as.ppt
jpg image processing nagham salim_as.pptjpg image processing nagham salim_as.ppt
jpg image processing nagham salim_as.ppt
 
lips _reading_nagham _salim compute.pptx
lips _reading_nagham _salim compute.pptxlips _reading_nagham _salim compute.pptx
lips _reading_nagham _salim compute.pptx
 
electronic mail security for authent.ppt
electronic mail security for authent.pptelectronic mail security for authent.ppt
electronic mail security for authent.ppt
 
web _security_ for _confedindality s.ppt
web _security_ for _confedindality s.pptweb _security_ for _confedindality s.ppt
web _security_ for _confedindality s.ppt
 
lips _reading _in computer_ vision_n.ppt
lips _reading _in computer_ vision_n.pptlips _reading _in computer_ vision_n.ppt
lips _reading _in computer_ vision_n.ppt
 
thread_ multiprocessor_ scheduling_a.ppt
thread_ multiprocessor_ scheduling_a.pptthread_ multiprocessor_ scheduling_a.ppt
thread_ multiprocessor_ scheduling_a.ppt
 
distributed real time system schedul.ppt
distributed real time system schedul.pptdistributed real time system schedul.ppt
distributed real time system schedul.ppt
 
Trusted Computing security _platform.ppt
Trusted Computing security _platform.pptTrusted Computing security _platform.ppt
Trusted Computing security _platform.ppt
 
Trusted Computing _plate form_ model.ppt
Trusted Computing _plate form_ model.pptTrusted Computing _plate form_ model.ppt
Trusted Computing _plate form_ model.ppt
 
avi _file _formate_ trasport _layer.pptx
avi _file _formate_ trasport _layer.pptxavi _file _formate_ trasport _layer.pptx
avi _file _formate_ trasport _layer.pptx
 

Recently uploaded

Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.Silpa
 
CYTOGENETIC MAP................ ppt.pptx
CYTOGENETIC MAP................ ppt.pptxCYTOGENETIC MAP................ ppt.pptx
CYTOGENETIC MAP................ ppt.pptxSilpa
 
Molecular markers- RFLP, RAPD, AFLP, SNP etc.
Molecular markers- RFLP, RAPD, AFLP, SNP etc.Molecular markers- RFLP, RAPD, AFLP, SNP etc.
Molecular markers- RFLP, RAPD, AFLP, SNP etc.Silpa
 
Use of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxUse of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxRenuJangid3
 
Cyanide resistant respiration pathway.pptx
Cyanide resistant respiration pathway.pptxCyanide resistant respiration pathway.pptx
Cyanide resistant respiration pathway.pptxSilpa
 
Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.Silpa
 
Module for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learningModule for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learninglevieagacer
 
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryFAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryAlex Henderson
 
Digital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptxDigital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptxMohamedFarag457087
 
Thyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate ProfessorThyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate Professormuralinath2
 
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIACURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIADr. TATHAGAT KHOBRAGADE
 
GBSN - Microbiology (Unit 3)Defense Mechanism of the body
GBSN - Microbiology (Unit 3)Defense Mechanism of the body GBSN - Microbiology (Unit 3)Defense Mechanism of the body
GBSN - Microbiology (Unit 3)Defense Mechanism of the body Areesha Ahmad
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bSérgio Sacani
 
Atp synthase , Atp synthase complex 1 to 4.
Atp synthase , Atp synthase complex 1 to 4.Atp synthase , Atp synthase complex 1 to 4.
Atp synthase , Atp synthase complex 1 to 4.Silpa
 
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...Monika Rani
 
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRingsTransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRingsSérgio Sacani
 
module for grade 9 for distance learning
module for grade 9 for distance learningmodule for grade 9 for distance learning
module for grade 9 for distance learninglevieagacer
 

Recently uploaded (20)

Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.
 
CYTOGENETIC MAP................ ppt.pptx
CYTOGENETIC MAP................ ppt.pptxCYTOGENETIC MAP................ ppt.pptx
CYTOGENETIC MAP................ ppt.pptx
 
Molecular markers- RFLP, RAPD, AFLP, SNP etc.
Molecular markers- RFLP, RAPD, AFLP, SNP etc.Molecular markers- RFLP, RAPD, AFLP, SNP etc.
Molecular markers- RFLP, RAPD, AFLP, SNP etc.
 
Use of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxUse of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptx
 
Cyanide resistant respiration pathway.pptx
Cyanide resistant respiration pathway.pptxCyanide resistant respiration pathway.pptx
Cyanide resistant respiration pathway.pptx
 
Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.
 
Module for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learningModule for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learning
 
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryFAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
 
Digital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptxDigital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptx
 
Thyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate ProfessorThyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate Professor
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIACURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
 
GBSN - Microbiology (Unit 3)Defense Mechanism of the body
GBSN - Microbiology (Unit 3)Defense Mechanism of the body GBSN - Microbiology (Unit 3)Defense Mechanism of the body
GBSN - Microbiology (Unit 3)Defense Mechanism of the body
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
 
Atp synthase , Atp synthase complex 1 to 4.
Atp synthase , Atp synthase complex 1 to 4.Atp synthase , Atp synthase complex 1 to 4.
Atp synthase , Atp synthase complex 1 to 4.
 
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...
 
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRingsTransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
 
Clean In Place(CIP).pptx .
Clean In Place(CIP).pptx                 .Clean In Place(CIP).pptx                 .
Clean In Place(CIP).pptx .
 
Site Acceptance Test .
Site Acceptance Test                    .Site Acceptance Test                    .
Site Acceptance Test .
 
module for grade 9 for distance learning
module for grade 9 for distance learningmodule for grade 9 for distance learning
module for grade 9 for distance learning
 

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.