The following is a checklist which provides a summary of the
assignment. This is meant only as a supplement; please read the original assignment
description.
Frequently Asked Questions:
(This is the only part of this checklist which will change during the
week.)
[Michael 2/24] Below when we ask for "verbose" output in your readme,
we really do want to know for each bin, the list of all items which
were packed into that bin. (Yes, some have realized that for the rest
of the program you could have gotten by with just maintaining the sum
of the weights in each bin, but in a real application you really do
need to know which items to assign to each bin.) If this slows up
your code, you may feel free to comment it out when running on the
larger inputs.
[Michael 2/17] The last line of the second paragraph mentions that you
are to print out the total of the item weights, and then in
parenthesis, says "(best possible number of bins)". Just for the
record, the total of the item weights provides a lower bound
on the best possible number of bins, but not necessarily the exact
best number of bins. (of course finding the exact best answer is NP-hard).
Overview:
We are making a major change in the high-level design of this
assignment. Please use the following guidelines, not those discussed
in the original assignment.
We want you to create one single program, which does the following:
generates a random sequence of N weights between 0 and u, prints out
the total of the weights, calculates and outputs the number of bins
used by the "worst fit" heuristic, and then calculates and outputs the
number of bins used by the "worst fit decreasing"
heuristic. (originally, we asked for two different programs for the
two heuristics, but it will be easier to have a single program which
simulates both heuristics independently on the same input). The
command line syntax is as described, where "a.out 100 .2" would
generate 100 random weights between 0 and .2.
Although we are asking for a single exectuable, we are going to demand
that your priority queue implementation be in a separate file then
your main routine. You should have a header file (perhaps
pq.h) that defines the interface for all of the operations
supported by your priority queue. The actual priority queue
implementation should be in another file (perhaps pq.c). And
finally your main routine and the bin packing heuristics should be
implemented in yet a third file.
Requirements:
Possible Progress Steps:
These are purely suggestions for how you might make progress. You do
not have to follow these steps.
Most important is for you to think a lot about the interface you
set up in pq.h ADT. You will have to think a lot about
exactly what operations the main program will need to rely on.
Once you are happy with your priority queue interface, you can
start by implementing a very simple (but ineffecient) method, such as
using an ordered array. With this working, you can write the client
program and run the heuristics.
Of course, with a poor implementation of priority queues, the
program will be quite slow for large values of N. Fortunately, if
your ADT is designed properly, you can now go and rewrite a more
efficient priority queue implementaiton based on heaps.
cos226 Class Page
wass@cs.princeton.edu
Last modified: February 24, 1999