---+ Ninth lab: Bin Packing ---++ Learning Objective(s) 1 Learn to use two dimensional arrays 1 Be introduced to an NP Complete problem ---++ Overview of the program Bin packing is a standard problem that can be very computational expensive to solve. A description of the problem can be found on [[https://en.wikipedia.org/wiki/Bin_packing_problem][Wikipedia]]. Read it to understand the overall problem. You will be programming a very simple (and typically non-optimal) solution to it. ---++ Details * You will not have more than 100 vehicles and each vehicle will not have more than 100 bins. * The file will be "items.txt" and will reside in the same folder as your code. * The first line is the number of vehicles * The second line is the number of bins per vehicles * The remaining lines (undetermined number of lines) is the size of each item (as a double) * Your items will be "normalized' (i.e. between 0 and 1) with each bin being able to store up to 1.00 worth of units * You are to output the status of each bin in each vehicle along with an analysis (how many vehicles are empty and how many bins are being used but not filled for each vehicle) * The program should be called *BinPacker* * You need to have at least one method besides the main method. * You must use at least one constant * You must use arrays as your primary storage * All normal exceptions should be handled (not thrown) * It is suggested that you use the "first fit" method. It is the easiest ---++ Sample file <pre> 3 4 .5 .6 .2 .3 .7 .3 .1 .4 </pre> ---+++Output <pre>Here is your report: Vehicle 1: 1.000 1.000 0.700 0.400 with 2 bins not full Vehicle 2: 0.000 0.000 0.000 0.000 and is empty Vehicle 3: 0.000 0.000 0.000 0.000 and is empty </pre> ---++ Submission 1 Create an empty zip folder. 1 Place your program (.java file) in it 1 Place your software development report in it. 1 Submit the zip folder on canvas ---++ Optional improvements * Also implement best fit and compare it to first fit in terms of being closer to optimal in the lessons learned. Discuss when each is better than the other. * Also implement worst file (along with best fit) and compare best fit to worst fit in terms of being closer to optimal in the lessons learned. Discuss when each is better than the other.
This topic: CenterForComputing
>
WebHome
>
SyllabiSpring2022
>
CSC121SylS2022
>
CSC121S2022Lab9
Topic revision: r2 - 2022-03-29 - cathybareiss
Copyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback