Typical problem and execution method
A box with a capacity of $ c (\ gt 0) $ and $ n = $ n = \ {1, \ dots, n \} $ are given. Let the capacity of the luggage $ i \ in N $ be $ w_i (\ gt 0) $. Find an assortment that minimizes the number of boxes needed to pack all your luggage.
usage
Signature: binpacking(c, w)
Docstring:
Bin packing problem
Solve with column generation(Approximate solution)
input
c:Bin size
w:List of luggage sizes
output
Luggage size list for each bottle
python
from ortoolpy import binpacking
binpacking(10, [4, 5, 3, 8, 7, 6, 2, 3])
result
[[8], [7, 3], [5, 3, 2], [4, 6]]
python
# pandas.DataFrame
from ortoolpy.optimization import BinPacking
BinPacking('data/binpacking.csv', 10)
id | size | |
---|---|---|
0 | 0 | 8.0 |
1 | 1 | 7.0 |
2 | 1 | 3.0 |
3 | 2 | 5.0 |
4 | 2 | 3.0 |
5 | 2 | 2.0 |
6 | 3 | 4.0 |
7 | 3 | 6.0 |
Recommended Posts