Test the following bin-packing algorithmsnbspa next fit b


Test the following bin-packing algorithms:
(a) Next fit. (b) Firstfit.?(c) First fit decreasing.
Your program should run as follows:
./TestBinPackingAlgorithms
The should be an integer that corresponds to the number of items you will try to fit into bins. Your program should do the following:
// Generate a vector of N random numbers in the range [0.0, 1.0];
vector random_numbers = GenerateRandomNumbers(N);?
const int number_of_bins_next_fit = NextFitBinPacking(random_numbers);
const int number_of_bins_first_fit = FirstFitBinPacking(random_numbers);
// Sort the random_numbers from larger to smaller
std::sort(random_numbers.begin(), random_numbers.end(),
std::greater());?
const int number_of_bins_first_fit_decreasing = FirstFitBinPacking(random_numbers);

cout << "Number of bins:" << endl;

cout << "Next Fit: " << number_of_bins_next_fit << endl;
cout << "First Fit: " << number_of_bins_first_fit << endl;
cout << "First Fit Decreasing: " << number_of_bins_first_fit_decreasing << endl;
To generate a set of random numbers in the range [0.0, 1.0]:
#include
#include
using namespace std;
srand(time(0)); //use current time as seed for random generator
for (int i = 0; i < N; ++i) {
const double random_variable = (double)rand() % (double)RAND_MAX;
// Push it into the vector of random numbers.
}
You can use a naïve implementation for FirstFit. You don't have to keep track of the items per bin, but just the total number of bins. So each bin can be represented by the amount_of_space_used. An empty bin will have amount_of_space_used = 0.0, whereas for a full bin amount_of_space_used = 1.0;
You should expect FFD to be better than FF, and FF to be better than NF. Report your final results in your readme file.
}
Test for 50, 100, and 500 items.
--For extra credit you can implement FirstFitBinPacking using a more efficient implementation that requires a priority queue--

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Test the following bin-packing algorithmsnbspa next fit b
Reference No:- TGS01494493

Now Priced at $30 (50% Discount)

Recommended (91%)

Rated (4.3/5)