I am looking to implement the (intractable but) optimal solution to the Bin Packing problem I know that the idea is to examine all possible ordering and find the one that uses the min number of bins but I am stuck on how to actually write the code for that.
Desccription of bin packing problem: The bin packing problem is the problem of packing various objects of certain sizes into a minimum number of bins with a fixed size (where the bin size is usually smaller than the sum of all objects). You are given an array containing the weight of each objects ( n objects)
and an int representing the max capacity that each bin can carry ( all bins are the same size. Assume you have n bins available)
I have the psuedo code but I am stuck how to actually implement it in c++
recurse(int itemID)
if pastLastItem(itemID)
if betterThanBestSolution
bestSolution = currentAssignment
return
for each bin i:
putIntoBin(itemID, i)
recurse(itemID+1)
removeFromBin(itemID, i)
Aucun commentaire:
Enregistrer un commentaire