Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 23,513 times

Contents

Downloads

Related Categories

Bin Packing - Bin Packing, What is It?

Nimpo

Bin Packing, What is It?

   Bin Packing is a mathematical way to deal with efficiently fitting Elements into Bins.  Now, a Bin is something that can hold inside itself a certain amount (it's Bin Height).  Every Element is of a certain, non-zero, and positive value ( Element Height).  The goal of every Bin Packing algorithm is to use the least amount of Bins to hold the required number of Elements.

Bin:  A fixed-size container that can hold Elements.
Bin Height:  The specified amount that each Bin can hold.
Element:  An item that is to be placed in a Bin having a certain Element Height.
Element Height:  The amount of Bin space the Element will take up if placed in that Bin.

   Now, why is this useful?  Several real-world problems can be optimized and made to run more efficient by employing this solution.  Image for a moment that you have a package of blank CDs that can hold 80 minutes of music each.  You have 100 songs of varying lengths.  You want to use the least amount of blank CDs to fit all of your songs on.  This is a Bin Packing problem.

Bin: The blank CDs.
Bin Height:  80 (minutes) or 4,800 (seconds).
Element:  One song.
Element Height:  The length of each song in minutes or seconds.

   Other examples include:  Using the least amount of boards to cut out small pieces for a construction project, fitting large files onto small capacity hard drives, etc.

   There is one hitch with a Bin Packing problem, that is a Bin Packing problem is classified as NP-Complete.  This basically means that their is no way of  being guaranteed the best solution without checking every possible solution.  This is not to say that a solution reached by one of the following algorithms is not optimal, it may be.  The classic NP-Complete problem is the Traveling Salesman Problem.  The algorithms presented here do give reasonable, practical solutions however.

Languages I know (from most comfortable with, to least comfortable with): VB.NET, C#, VB6, and C/C++

I'm 18 years old and pursuing a BS in Computer Science at the Colorado School of Mines. My dad introduced me to programming (with Visual Basic 6) when I was about 10. When I was 13 I was accepted and enrolled at Arapahoe Community College for a programming class and continued there during the summers while in high school.


Check me out!

Comments

  • Re: [5540] Bin Packing

    Posted by mishoco on 17 Apr 2008

    Hello,


     I really want to thank you for for this great article. However, I am currently working on my last year project, which is about 2 dimensional&nbs...

  • Re: [5540] Bin Packing

    Posted by Roque on 16 Mar 2008

     hallo, i'm from poland.

    can u please send me a C program code for the best, next and first fit algorithms?

     

    my email: roque@poczta.onet.pl 

    thank you:) ...

  • Re: [5540] Bin Packing

    Posted by MisSya on 16 Sep 2007

    Hi,


    i urgently need the codes too before 19/09/07. pls help me. could you send me the C++ and java version of the codes. Tankyou. send to nuranastacia@yahoo.com

  • Re: [5540] Bin Packing

    Posted by kirby on 12 Sep 2007

    can u plz send me a 'C++' or 'C' program code for first fit algorithms....



    i need it urgently.... i need to submit code as my project by saturday 09/15/07...


    example output...

  • Re: [5540] Bin Packing

    Posted by Nimpo on 11 Sep 2007

    I have just returned from an extended absence from this forum so I realize this is rather late.


    I believe that the First Fit algorithm will always be better than or equivalent to the Next F...