Typical problem and execution method
Pack as many n-dimensional rectangular parallelepipeds as possible into the n-dimensional rectangular parallelepiped. Find the way. n corresponds to 1 to 3. When n is 1, the capacity and value are the same in the knapsack problem.
usage
Init signature: TwoDimPackingClass(self, width, height, items=None)
Docstring:
2D packing problem
Cut out items from the original plate with a guillotine cut(Approximate solution)
input
width, height:The size of the original plate
items:Of the item(side,Vertical)List of
output
Floor area ratio and items included(side,Vertical,x,y)List of
python
from ortoolpy import TwoDimPackingClass
TwoDimPackingClass(500, 300, [(240, 150), (260, 100), \
(100, 200), (240, 150), (160, 200)]).solve()
result
(1.0,
[(240, 150, 0, 0),
(260, 100, 240, 0),
(160, 200, 240, 100),
(100, 200, 400, 100),
(240, 150, 0, 150)])
python
# pandas.DataFrame
from ortoolpy.optimization import TwoDimPacking
TwoDimPacking('data/tdpacking.csv', 500, 300)[1]
width | height | x | y | |
---|---|---|---|---|
0 | 240 | 150 | 0 | 0 |
1 | 260 | 100 | 240 | 0 |
4 | 160 | 200 | 240 | 100 |
2 | 100 | 200 | 400 | 100 |
3 | 240 | 150 | 0 | 150 |
Recommended Posts