coin-or / prtpy

Number partitioning in Python
MIT License
46 stars 20 forks source link

Bin Completion does not give optimal solution #15

Closed MarvinWalther closed 1 year ago

MarvinWalther commented 1 year ago

The Bin Completion algorithm is suppose to be optimal. However, in the following case, the implementation of this package does not give the optimal solution:

import prtpy
items = [44, 6, 24, 6, 24, 8, 22, 8, 17, 21]
print(prtpy.pack(algorithm=prtpy.packing.bin_completion, binsize=60, items=items))

output:

[[44, 8, 6], [24, 24, 8], [22, 21, 17], [6]]

But the optimal solution is:

[[44, 8, 8], [24, 24, 6, 6], [22, 21, 17]]

This solution can be obtained by using First-Fit-Decreasing:

print(prtpy.pack(algorithm=prtpy.packing.first_fit_decreasing, binsize=60, items=items))
erelsgl commented 1 year ago

@MarvinWalther can you confirm that the issue is solved?

MarvinWalther commented 1 year ago

Yes, that solves the problem.