diff --git a/data/irregular/users/2024-08-08_solution.json b/data/irregular/users/2024-08-08_solution.json index 6c68a94c8..150d6700e 100644 --- a/data/irregular/users/2024-08-08_solution.json +++ b/data/irregular/users/2024-08-08_solution.json @@ -5,73 +5,101 @@ "id": 0, "items": [ { - "angle": 0.0, - "id": 1, + "angle": 180.0, + "id": 6, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 1.96850394, + "xe": 19.685039370000002, + "xs": 0.0, + "ye": 0.0, + "ys": 1.1999999927070348e-07 + }, + { + "type": "LineSegment", + "xe": 19.685039380000003, "xs": 19.685039370000002, - "ye": 1.96850394, - "ys": 1.96850394 + "ye": 1.9685039400000015, + "ys": 0.0 }, { "type": "LineSegment", - "xe": 1.96850394, - "xs": 1.96850394, - "ye": 17.71653543, - "ys": 1.96850394 + "xe": 1.9685039500000023, + "xs": 19.685039380000003, + "ye": 1.9685040399999991, + "ys": 1.9685039400000015 }, { "type": "LineSegment", - "xe": 19.685039370000002, - "xs": 1.96850394, - "ye": 17.71653543, - "ys": 17.71653543 + "xe": 1.968503990000002, + "xs": 1.9685039500000023, + "ye": 8.858267820000002, + "ys": 1.9685040399999991 }, { "type": "LineSegment", - "xe": 19.685039370000002, - "xs": 19.685039370000002, - "ye": 19.685039370000002, - "ys": 17.71653543 + "xe": 19.685039420000003, + "xs": 1.968503990000002, + "ye": 8.858267710000002, + "ys": 8.858267820000002 }, { "type": "LineSegment", - "xe": 0.0, - "xs": 19.685039370000002, - "ye": 19.685039370000002, - "ys": 19.685039370000002 + "xe": 19.68503944, + "xs": 19.685039420000003, + "ye": 10.826771650000001, + "ys": 8.858267710000002 }, { "type": "LineSegment", - "xe": 0.0, - "xs": 0.0, - "ye": 0.0, - "ys": 19.685039370000002 + "xe": 1.9685039999999994, + "xs": 19.68503944, + "ye": 10.826771760000002, + "ys": 10.826771650000001 }, { "type": "LineSegment", - "xe": 19.685039370000002, - "xs": 0.0, - "ye": 0.0, - "ys": 0.0 + "xe": 1.9685040399999991, + "xs": 1.9685039999999994, + "ye": 17.716535540000002, + "ys": 10.826771760000002 }, { "type": "LineSegment", - "xe": 19.685039370000002, - "xs": 19.685039370000002, - "ye": 1.96850394, - "ys": 0.0 + "xe": 19.68503948, + "xs": 1.9685040399999991, + "ye": 17.71653543, + "ys": 17.716535540000002 + }, + { + "type": "LineSegment", + "xe": 19.68503949, + "xs": 19.68503948, + "ye": 19.685039370000002, + "ys": 17.71653543 + }, + { + "type": "LineSegment", + "xe": 1.1999999927070348e-07, + "xs": 19.68503949, + "ye": 19.68503949, + "ys": 19.685039370000002 + }, + { + "type": "LineSegment", + "xe": 0.0, + "xs": 1.1999999927070348e-07, + "ye": 1.1999999927070348e-07, + "ys": 19.68503949 } ] } ], "mirror": false, - "x": 0.0, - "y": 0.0 + "x": 19.68503949, + "y": 19.68503949 }, { "angle": 0.0, @@ -81,66 +109,66 @@ "shape": [ { "type": "LineSegment", - "xe": 1.9685039400000015, - "xs": 21.653543310000003, + "xe": 1.9685039500000023, + "xs": 21.653543320000004, "ye": 21.653543310000003, "ys": 21.653543310000003 }, { "type": "LineSegment", - "xe": 1.9685039400000015, - "xs": 1.9685039400000015, + "xe": 1.9685039500000023, + "xs": 1.9685039500000023, "ye": 19.685039370000002, "ys": 21.653543310000003 }, { "type": "LineSegment", - "xe": 19.685039370000002, - "xs": 1.9685039400000015, + "xe": 19.685039380000003, + "xs": 1.9685039500000023, "ye": 19.685039370000002, "ys": 19.685039370000002 }, { "type": "LineSegment", - "xe": 19.685039370000002, - "xs": 19.685039370000002, - "ye": 3.9370078799999995, + "xe": 19.685039380000003, + "xs": 19.685039380000003, + "ye": 3.9370078800000012, "ys": 19.685039370000002 }, { "type": "LineSegment", - "xe": 1.9685039400000015, - "xs": 19.685039370000002, - "ye": 3.9370078799999995, - "ys": 3.9370078799999995 + "xe": 1.9685039500000023, + "xs": 19.685039380000003, + "ye": 3.9370078800000012, + "ys": 3.9370078800000012 }, { "type": "LineSegment", - "xe": 1.9685039400000015, - "xs": 1.9685039400000015, - "ye": 1.96850394, - "ys": 3.9370078799999995 + "xe": 1.9685039500000023, + "xs": 1.9685039500000023, + "ye": 1.9685039400000015, + "ys": 3.9370078800000012 }, { "type": "LineSegment", - "xe": 21.653543310000003, - "xs": 1.9685039400000015, - "ye": 1.96850394, - "ys": 1.96850394 + "xe": 21.653543320000004, + "xs": 1.9685039500000023, + "ye": 1.9685039400000015, + "ys": 1.9685039400000015 }, { "type": "LineSegment", - "xe": 21.653543310000003, - "xs": 21.653543310000003, + "xe": 21.653543320000004, + "xs": 21.653543320000004, "ye": 21.653543310000003, - "ys": 1.96850394 + "ys": 1.9685039400000015 } ] } ], "mirror": false, - "x": 1.9685039400000974, - "y": 1.9685039399999573 + "x": 1.9685039500000983, + "y": 1.9685039399999589 }, { "angle": 0.0, @@ -150,85 +178,85 @@ "shape": [ { "type": "LineSegment", - "xe": 23.622047250000005, - "xs": 41.33858268, + "xe": 23.622047260000006, + "xs": 41.33858269000001, "ye": 1.96850394, "ys": 1.96850394 }, { "type": "LineSegment", - "xe": 23.622047250000005, - "xs": 23.622047250000005, + "xe": 23.622047260000006, + "xs": 23.622047260000006, "ye": 8.85826772, "ys": 1.96850394 }, { "type": "LineSegment", - "xe": 41.33858268, - "xs": 23.622047250000005, + "xe": 41.33858269000001, + "xs": 23.622047260000006, "ye": 8.85826772, "ys": 8.85826772 }, { "type": "LineSegment", - "xe": 41.33858268, - "xs": 41.33858268, + "xe": 41.33858269000001, + "xs": 41.33858269000001, "ye": 10.82677165, "ys": 8.85826772 }, { "type": "LineSegment", - "xe": 23.622047250000005, - "xs": 41.33858268, + "xe": 23.622047260000006, + "xs": 41.33858269000001, "ye": 10.82677165, "ys": 10.82677165 }, { "type": "LineSegment", - "xe": 23.622047250000005, - "xs": 23.622047250000005, + "xe": 23.622047260000006, + "xs": 23.622047260000006, "ye": 17.71653543, "ys": 10.82677165 }, { "type": "LineSegment", - "xe": 41.33858268, - "xs": 23.622047250000005, + "xe": 41.33858269000001, + "xs": 23.622047260000006, "ye": 17.71653543, "ys": 17.71653543 }, { "type": "LineSegment", - "xe": 41.33858268, - "xs": 41.33858268, + "xe": 41.33858269000001, + "xs": 41.33858269000001, "ye": 19.685039370000002, "ys": 17.71653543 }, { "type": "LineSegment", - "xe": 21.653543310000003, - "xs": 41.33858268, + "xe": 21.653543320000004, + "xs": 41.33858269000001, "ye": 19.685039370000002, "ys": 19.685039370000002 }, { "type": "LineSegment", - "xe": 21.653543310000003, - "xs": 21.653543310000003, + "xe": 21.653543320000004, + "xs": 21.653543320000004, "ye": 0.0, "ys": 19.685039370000002 }, { "type": "LineSegment", - "xe": 41.33858268, - "xs": 21.653543310000003, + "xe": 41.33858269000001, + "xs": 21.653543320000004, "ye": 0.0, "ys": 0.0 }, { "type": "LineSegment", - "xe": 41.33858268, - "xs": 41.33858268, + "xe": 41.33858269000001, + "xs": 41.33858269000001, "ye": 1.96850394, "ys": 0.0 } @@ -236,165 +264,165 @@ } ], "mirror": false, - "x": 21.653543310000003, + "x": 21.653543320000004, "y": 0.0 }, { - "angle": 0.0, - "id": 6, + "angle": 180.0, + "id": 1, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 23.622047300000006, - "xs": 43.307086670000004, - "ye": 21.653543430000003, - "ys": 21.653543310000003 - }, - { - "type": "LineSegment", - "xe": 23.622047290000005, - "xs": 23.622047300000006, - "ye": 19.68503949, - "ys": 21.653543430000003 - }, - { - "type": "LineSegment", - "xe": 41.338582720000005, - "xs": 23.622047290000005, - "ye": 19.685039390000004, - "ys": 19.68503949 - }, - { - "type": "LineSegment", - "xe": 41.33858268, - "xs": 41.338582720000005, - "ye": 12.79527561, - "ys": 19.685039390000004 - }, - { - "type": "LineSegment", - "xe": 23.622047250000005, - "xs": 41.33858268, - "ye": 12.79527572, - "ys": 12.79527561 + "xe": 41.33858269000001, + "xs": 23.622047260000006, + "ye": 19.685039370000002, + "ys": 19.685039370000002 }, { "type": "LineSegment", - "xe": 23.622047230000007, - "xs": 23.622047250000005, - "ye": 10.82677178, - "ys": 12.79527572 + "xe": 41.33858269000001, + "xs": 41.33858269000001, + "ye": 3.937007880000003, + "ys": 19.685039370000002 }, { "type": "LineSegment", - "xe": 41.33858267000001, - "xs": 23.622047230000007, - "ye": 10.82677167, - "ys": 10.82677178 + "xe": 23.622047260000006, + "xs": 41.33858269000001, + "ye": 3.937007880000003, + "ys": 3.937007880000003 }, { "type": "LineSegment", - "xe": 41.338582630000005, - "xs": 41.33858267000001, - "ye": 3.93700789, - "ys": 10.82677167 + "xe": 23.622047260000006, + "xs": 23.622047260000006, + "ye": 1.9685039400000015, + "ys": 3.937007880000003 }, { "type": "LineSegment", - "xe": 23.622047190000007, - "xs": 41.338582630000005, - "ye": 3.937008, - "ys": 3.93700789 + "xe": 43.30708663000001, + "xs": 23.622047260000006, + "ye": 1.9685039400000015, + "ys": 1.9685039400000015 }, { "type": "LineSegment", - "xe": 23.622047180000006, - "xs": 23.622047190000007, - "ye": 1.9685040599999999, - "ys": 3.937008 + "xe": 43.30708663000001, + "xs": 43.30708663000001, + "ye": 21.653543310000003, + "ys": 1.9685039400000015 }, { "type": "LineSegment", - "xe": 43.30708655000001, - "xs": 23.622047180000006, - "ye": 1.96850394, - "ys": 1.9685040599999999 + "xe": 23.622047260000006, + "xs": 43.30708663000001, + "ye": 21.653543310000003, + "ys": 21.653543310000003 }, { "type": "LineSegment", - "xe": 43.307086670000004, - "xs": 43.30708655000001, - "ye": 21.653543310000003, - "ys": 1.96850394 + "xe": 23.622047260000006, + "xs": 23.622047260000006, + "ye": 19.685039370000002, + "ys": 21.653543310000003 } ] } ], "mirror": false, - "x": 23.622047180000006, - "y": 1.96850394 + "x": 43.30708663000001, + "y": 21.653543310000003 }, { "angle": 180.0, - "id": 0, + "id": 3, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 45.27559061000001, - "xs": 61.02362210000001, + "xe": 54.133858280000005, + "xs": 61.02362206000001, "ye": 1.9685039400000015, "ys": 1.9685039400000015 }, { "type": "LineSegment", - "xe": 45.27559061000001, - "xs": 45.27559061000001, + "xe": 54.133858280000005, + "xs": 54.133858280000005, "ye": 19.685039370000002, "ys": 1.9685039400000015 }, { "type": "LineSegment", - "xe": 43.307086670000004, - "xs": 45.27559061000001, + "xe": 52.16535435000001, + "xs": 54.133858280000005, "ye": 19.685039370000002, "ys": 19.685039370000002 }, { "type": "LineSegment", - "xe": 43.307086670000004, - "xs": 43.307086670000004, + "xe": 52.16535435000001, + "xs": 52.16535435000001, + "ye": 1.9685039400000015, + "ys": 19.685039370000002 + }, + { + "type": "LineSegment", + "xe": 45.275590570000006, + "xs": 52.16535435000001, + "ye": 1.9685039400000015, + "ys": 1.9685039400000015 + }, + { + "type": "LineSegment", + "xe": 45.275590570000006, + "xs": 45.275590570000006, + "ye": 19.685039370000002, + "ys": 1.9685039400000015 + }, + { + "type": "LineSegment", + "xe": 43.30708663, + "xs": 45.275590570000006, + "ye": 19.685039370000002, + "ys": 19.685039370000002 + }, + { + "type": "LineSegment", + "xe": 43.30708663, + "xs": 43.30708663, "ye": 0.0, "ys": 19.685039370000002 }, { "type": "LineSegment", - "xe": 62.99212604000001, - "xs": 43.307086670000004, + "xe": 62.992126000000006, + "xs": 43.30708663, "ye": 0.0, "ys": 0.0 }, { "type": "LineSegment", - "xe": 62.99212604000001, - "xs": 62.99212604000001, + "xe": 62.992126000000006, + "xs": 62.992126000000006, "ye": 19.685039370000002, "ys": 0.0 }, { "type": "LineSegment", - "xe": 61.02362210000001, - "xs": 62.99212604000001, + "xe": 61.02362206000001, + "xs": 62.992126000000006, "ye": 19.685039370000002, "ys": 19.685039370000002 }, { "type": "LineSegment", - "xe": 61.02362210000001, - "xs": 61.02362210000001, + "xe": 61.02362206000001, + "xs": 61.02362206000001, "ye": 1.9685039400000015, "ys": 19.685039370000002 } @@ -402,202 +430,174 @@ } ], "mirror": false, - "x": 62.992126040000045, - "y": 19.685039369999966 + "x": 62.992126000000006, + "y": 19.685039370000002 }, { - "angle": 180.0, - "id": 5, + "angle": 0.0, + "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 45.27559102000001, - "xs": 45.27559061000001, - "ye": 1.9685039400000015, - "ys": 21.653543310000003 - }, - { - "type": "LineSegment", - "xe": 47.244094960000005, - "xs": 45.27559102000001, - "ye": 1.9685039800000013, - "ys": 1.9685039400000015 - }, - { - "type": "LineSegment", - "xe": 47.24409458000001, - "xs": 47.244094960000005, - "ye": 19.68503941, - "ys": 1.9685039800000013 - }, - { - "type": "LineSegment", - "xe": 54.133858360000005, - "xs": 47.24409458000001, - "ye": 19.685039550000003, - "ys": 19.68503941 - }, - { - "type": "LineSegment", - "xe": 54.13385874000001, - "xs": 54.133858360000005, - "ye": 1.9685041200000022, - "ys": 19.685039550000003 + "xe": 62.992126000000006, + "xs": 47.244094510000004, + "ye": 19.685039370000002, + "ys": 19.685039370000002 }, { "type": "LineSegment", - "xe": 56.102362670000005, - "xs": 54.13385874000001, - "ye": 1.968504160000002, - "ys": 1.9685041200000022 + "xe": 62.992126000000006, + "xs": 62.992126000000006, + "ye": 1.9685039400000015, + "ys": 19.685039370000002 }, { "type": "LineSegment", - "xe": 56.1023623, - "xs": 56.102362670000005, - "ye": 19.685039600000003, - "ys": 1.968504160000002 + "xe": 64.96062994, + "xs": 62.992126000000006, + "ye": 1.9685039400000015, + "ys": 1.9685039400000015 }, { "type": "LineSegment", - "xe": 62.992126080000006, - "xs": 56.1023623, - "ye": 19.68503974, - "ys": 19.685039600000003 + "xe": 64.96062994, + "xs": 64.96062994, + "ye": 21.653543310000003, + "ys": 1.9685039400000015 }, { "type": "LineSegment", - "xe": 62.99212645000001, - "xs": 62.992126080000006, - "ye": 1.9685043100000001, - "ys": 19.68503974 + "xe": 45.275590570000006, + "xs": 64.96062994, + "ye": 21.653543310000003, + "ys": 21.653543310000003 }, { "type": "LineSegment", - "xe": 64.96063039, - "xs": 62.99212645000001, - "ye": 1.96850435, - "ys": 1.9685043100000001 + "xe": 45.275590570000006, + "xs": 45.275590570000006, + "ye": 1.9685039400000015, + "ys": 21.653543310000003 }, { "type": "LineSegment", - "xe": 64.96062998000001, - "xs": 64.96063039, - "ye": 21.653543720000002, - "ys": 1.96850435 + "xe": 47.244094510000004, + "xs": 45.275590570000006, + "ye": 1.9685039400000015, + "ys": 1.9685039400000015 }, { "type": "LineSegment", - "xe": 45.27559061000001, - "xs": 64.96062998000001, - "ye": 21.653543310000003, - "ys": 21.653543720000002 + "xe": 47.244094510000004, + "xs": 47.244094510000004, + "ye": 19.685039370000002, + "ys": 1.9685039400000015 } ] } ], "mirror": false, - "x": 64.96063039, - "y": 21.653543720000002 + "x": 45.27559056999997, + "y": 1.968503940000037 }, { - "angle": 180.0, - "id": 3, + "angle": 0.0, + "id": 5, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 75.78740204, - "xs": 82.67716582, - "ye": 1.9685039400000015, - "ys": 1.9685039400000015 + "xe": 84.64566931, + "xs": 84.64566972, + "ye": 19.68503978, + "ys": 4.1e-07 }, { "type": "LineSegment", - "xe": 75.78740204, - "xs": 75.78740204, - "ye": 19.685039370000002, - "ys": 1.9685039400000015 + "xe": 82.67716537000001, + "xs": 84.64566931, + "ye": 19.68503974, + "ys": 19.68503978 }, { "type": "LineSegment", - "xe": 73.81889811, - "xs": 75.78740204, - "ye": 19.685039370000002, - "ys": 19.685039370000002 + "xe": 82.67716575, + "xs": 82.67716537000001, + "ye": 1.96850431, + "ys": 19.68503974 }, { "type": "LineSegment", - "xe": 73.81889811, - "xs": 73.81889811, - "ye": 1.9685039400000015, - "ys": 19.685039370000002 + "xe": 75.78740197, + "xs": 82.67716575, + "ye": 1.96850417, + "ys": 1.96850431 }, { "type": "LineSegment", - "xe": 66.92913433000001, - "xs": 73.81889811, - "ye": 1.9685039400000015, - "ys": 1.9685039400000015 + "xe": 75.78740159, + "xs": 75.78740197, + "ye": 19.6850396, + "ys": 1.96850417 }, { "type": "LineSegment", - "xe": 66.92913433000001, - "xs": 66.92913433000001, - "ye": 19.685039370000002, - "ys": 1.9685039400000015 + "xe": 73.81889766, + "xs": 75.78740159, + "ye": 19.68503956, + "ys": 19.6850396 }, { "type": "LineSegment", - "xe": 64.96063039, - "xs": 66.92913433000001, - "ye": 19.685039370000002, - "ys": 19.685039370000002 + "xe": 73.81889803, + "xs": 73.81889766, + "ye": 1.96850412, + "ys": 19.68503956 }, { "type": "LineSegment", - "xe": 64.96063039, - "xs": 64.96063039, - "ye": 0.0, - "ys": 19.685039370000002 + "xe": 66.92913425, + "xs": 73.81889803, + "ye": 1.96850398, + "ys": 1.96850412 }, { "type": "LineSegment", - "xe": 84.64566976, - "xs": 64.96063039, - "ye": 0.0, - "ys": 0.0 + "xe": 66.92913388000001, + "xs": 66.92913425, + "ye": 19.68503941, + "ys": 1.96850398 }, { "type": "LineSegment", - "xe": 84.64566976, - "xs": 84.64566976, + "xe": 64.96062994, + "xs": 66.92913388000001, "ye": 19.685039370000002, - "ys": 0.0 + "ys": 19.68503941 }, { "type": "LineSegment", - "xe": 82.67716582, - "xs": 84.64566976, - "ye": 19.685039370000002, + "xe": 64.96063035, + "xs": 64.96062994, + "ye": 0.0, "ys": 19.685039370000002 }, { "type": "LineSegment", - "xe": 82.67716582, - "xs": 82.67716582, - "ye": 1.9685039400000015, - "ys": 19.685039370000002 + "xe": 84.64566972, + "xs": 64.96063035, + "ye": 4.1e-07, + "ys": 0.0 } ] } ], "mirror": false, - "x": 84.64566976, - "y": 19.685039370000002 + "x": 64.96062994, + "y": 0.0 }, { "angle": 180.0, @@ -607,66 +607,66 @@ "shape": [ { "type": "LineSegment", - "xe": 66.92913523, - "xs": 66.92913423, - "ye": 1.968503840000004, - "ys": 21.653543210000002 + "xe": 66.92913525, + "xs": 66.92913425, + "ye": 1.9685042100000025, + "ys": 21.65354358 }, { "type": "LineSegment", - "xe": 68.89763916999999, - "xs": 66.92913523, - "ye": 1.9685039400000015, - "ys": 1.968503840000004 + "xe": 68.89763919, + "xs": 66.92913525, + "ye": 1.9685043100000001, + "ys": 1.9685042100000025 }, { "type": "LineSegment", - "xe": 68.89763827, - "xs": 68.89763916999999, - "ye": 19.685039370000002, - "ys": 1.9685039400000015 + "xe": 68.89763829, + "xs": 68.89763919, + "ye": 19.68503974, + "ys": 1.9685043100000001 }, { "type": "LineSegment", - "xe": 84.64566976, - "xs": 68.89763827, - "ye": 19.685040170000004, - "ys": 19.685039370000002 + "xe": 84.64566978, + "xs": 68.89763829, + "ye": 19.685040540000003, + "ys": 19.68503974 }, { "type": "LineSegment", - "xe": 84.64567066, - "xs": 84.64566976, - "ye": 1.9685047400000037, - "ys": 19.685040170000004 + "xe": 84.64567068, + "xs": 84.64566978, + "ye": 1.9685051100000024, + "ys": 19.685040540000003 }, { "type": "LineSegment", - "xe": 86.6141746, - "xs": 84.64567066, - "ye": 1.9685048400000014, - "ys": 1.9685047400000037 + "xe": 86.61417462, + "xs": 84.64567068, + "ye": 1.96850521, + "ys": 1.9685051100000024 }, { "type": "LineSegment", - "xe": 86.6141736, - "xs": 86.6141746, - "ye": 21.653544210000003, - "ys": 1.9685048400000014 + "xe": 86.61417362, + "xs": 86.61417462, + "ye": 21.653544580000002, + "ys": 1.96850521 }, { "type": "LineSegment", - "xe": 66.92913423, - "xs": 86.6141736, - "ye": 21.653543210000002, - "ys": 21.653544210000003 + "xe": 66.92913425, + "xs": 86.61417362, + "ye": 21.65354358, + "ys": 21.653544580000002 } ] } ], "mirror": false, - "x": 86.6141746, - "y": 21.653544210000003 + "x": 86.61417462, + "y": 21.653544580000002 } ], "shape": [ diff --git a/data/rectangle/tests/bin_packing_with_leftovers_depth/bins.csv b/data/rectangle/tests/bin_packing_with_leftovers_depth/bins.csv new file mode 100644 index 000000000..339717f4d --- /dev/null +++ b/data/rectangle/tests/bin_packing_with_leftovers_depth/bins.csv @@ -0,0 +1,2 @@ +ID,WIDTH,HEIGHT +0,12,10 diff --git a/data/rectangle/tests/bin_packing_with_leftovers_depth/items.csv b/data/rectangle/tests/bin_packing_with_leftovers_depth/items.csv new file mode 100644 index 000000000..f20eae5a0 --- /dev/null +++ b/data/rectangle/tests/bin_packing_with_leftovers_depth/items.csv @@ -0,0 +1,2 @@ +ID,WIDTH,HEIGHT,COPIES,ORIENTED +0,3,2,9,1 diff --git a/data/rectangle/tests/bin_packing_with_leftovers_depth/parameters.csv b/data/rectangle/tests/bin_packing_with_leftovers_depth/parameters.csv new file mode 100644 index 000000000..8b5d00b7b --- /dev/null +++ b/data/rectangle/tests/bin_packing_with_leftovers_depth/parameters.csv @@ -0,0 +1,4 @@ +NAME,VALUE +objective,bin-packing-with-leftovers +leftover_mode,Area +leftover_value_type,Depth diff --git a/data/rectangle/tests/bin_packing_with_leftovers_depth/solution.csv b/data/rectangle/tests/bin_packing_with_leftovers_depth/solution.csv new file mode 100644 index 000000000..d76f8bbff --- /dev/null +++ b/data/rectangle/tests/bin_packing_with_leftovers_depth/solution.csv @@ -0,0 +1,11 @@ +TYPE,ID,COPIES,BIN,X,Y,LX,LY,GROUP_ID +BIN,0,1,0,0,0,12,10, +ITEM,0,1,0,0,0,3,2,0 +ITEM,0,1,0,0,2,3,2,0 +ITEM,0,1,0,0,4,3,2,0 +ITEM,0,1,0,0,6,3,2,0 +ITEM,0,1,0,0,8,3,2,0 +ITEM,0,1,0,3,0,3,2,0 +ITEM,0,1,0,3,2,3,2,0 +ITEM,0,1,0,3,4,3,2,0 +ITEM,0,1,0,3,6,3,2,0 diff --git a/doc/box.rst b/doc/box.rst index 970463daf..5603dc8d6 100644 --- a/doc/box.rst +++ b/doc/box.rst @@ -22,6 +22,7 @@ Features: * Open dimension Y * Open dimension Z * Variable-sized bin packing + * Variable-sized bin packing with leftovers * Select allowed item rotations (among the 6 possible rotations) @@ -59,13 +60,15 @@ An instance is a JSON object with the following fields: * - Field - Description * - ``objective`` - - **Mandatory**. One of ``knapsack``, ``bin-packing``, ``bin-packing-with-leftovers``, ``open-dimension-x``, ``open-dimension-y``, ``open-dimension-z``, ``variable-sized-bin-packing``; see :ref:`objectives` + - **Mandatory**. One of ``knapsack``, ``bin-packing``, ``bin-packing-with-leftovers``, ``open-dimension-x``, ``open-dimension-y``, ``open-dimension-z``, ``variable-sized-bin-packing``, ``variable-sized-bin-packing-with-leftovers``; see :ref:`objectives` * - ``knapsack_goal`` - For the ``knapsack`` objective, the search stops as soon as a solution reaches this profit. Default: none * - ``knapsack_cutoff`` - For the ``knapsack`` objective, the solutions whose profit is below this value are not useful: the search stops as soon as the bound proves that no solution reaches it. Default: none * - ``leftover_mode`` - - How the leftover of the last bin is measured, for the ``bin-packing-with-leftovers`` objective: the volume of the bin minus the volume used, which is the box from the origin of the bin to the items along the dimensions of the mode, and the whole bin along the other dimensions. One of ``XYZ`` (default; the bounding box of the items), ``XY``, ``XZ``, ``YZ``, ``X`` (the length of the bin used along X, times the Y and Z dimensions of the bin), ``Y``, ``Z`` + - The shape of the leftover of a bin, for the ``bin-packing-with-leftovers`` objective (see :ref:`leftovers`): the bin minus the used box, which goes from the origin of the bin to the items along the dimensions of the mode, and covers the whole bin along the other dimensions. One of ``XYZ`` (default; the used box is the bounding box of the items), ``XY``, ``XZ``, ``YZ``, ``X`` (the leftover is the box beyond the items along X), ``Y``, ``Z``, ``XYCut``, ``XZCut``, ``YZCut``, ``XYZCut`` (the leftover of the mode without ``Cut``, cut into boxes), and ``Staircase`` (the bin minus the boxes between its origin and the opposite corner of each item) + * - ``leftover_value_type`` + - How the value of the leftover is computed, for the ``bin-packing-with-leftovers`` objective (see :ref:`leftovers`): ``squared-area`` (default) or ``depth`` * - ``static_stability`` - See :ref:`box-static-stability`. Default: ``false`` * - ``bin_types`` diff --git a/doc/boxstacks.rst b/doc/boxstacks.rst index 22b222a73..dc5992f95 100644 --- a/doc/boxstacks.rst +++ b/doc/boxstacks.rst @@ -21,6 +21,7 @@ Features: * Open dimension X * Open dimension Y * Variable-sized bin packing + * Variable-sized bin packing with leftovers * Item types @@ -97,13 +98,15 @@ An instance is a JSON object with the following fields: * - Field - Description * - ``objective`` - - **Mandatory**. One of ``knapsack``, ``bin-packing``, ``bin-packing-with-leftovers``, ``open-dimension-x``, ``open-dimension-y``, ``variable-sized-bin-packing``; see :ref:`objectives` + - **Mandatory**. One of ``knapsack``, ``bin-packing``, ``bin-packing-with-leftovers``, ``open-dimension-x``, ``open-dimension-y``, ``variable-sized-bin-packing``, ``variable-sized-bin-packing-with-leftovers``; see :ref:`objectives` * - ``knapsack_goal`` - For the ``knapsack`` objective, the search stops as soon as a solution reaches this profit. Default: none * - ``knapsack_cutoff`` - For the ``knapsack`` objective, the solutions whose profit is below this value are not useful: the search stops as soon as the bound proves that no solution reaches it. Default: none * - ``leftover_mode`` - - How the leftover of the last bin is measured, for the ``bin-packing-with-leftovers`` objective: the volume of the bin minus the volume used, which is the whole height of the bin, times the rectangle from the origin of the bin to the stacks along the dimensions of the mode, and the whole bin along the other dimension. One of ``XY`` (default), ``X``, ``Y`` + - The shape of the leftover of a bin, for the ``bin-packing-with-leftovers`` objective (see :ref:`leftovers`): the bin minus the used box, which covers the whole height of the bin, goes from the origin of the bin to the stacks along the dimensions of the mode, and covers the whole bin along the other dimension. One of ``XY`` (default), ``XYCut`` (the leftover of ``XY``, cut into two boxes), ``Staircase`` (the bin minus the boxes between its origin and the opposite corner of each stack, over the whole height), ``X``, ``Y`` + * - ``leftover_value_type`` + - How the value of the leftover is computed, for the ``bin-packing-with-leftovers`` objective (see :ref:`leftovers`): ``squared-area`` (default) or ``depth`` * - ``unloading_constraint`` - See :ref:`boxstacks-unloading-constraints`. Default: ``none`` * - ``no_check_weight_constraints`` diff --git a/doc/examples/box/basic/output.txt b/doc/examples/box/basic/output.txt index 15a7f1ed6..84df26088 100644 --- a/doc/examples/box/basic/output.txt +++ b/doc/examples/box/basic/output.txt @@ -17,68 +17,72 @@ Number of defects: 0 Total item volume: 15487000 Total item profit: 1.5487e+07 Largest item profit: 409860 -Total item weight: 0 +Total item weight: 1.5487e+07 Largest item copies: 20 Smallest item x: 92 Smallest item y: 43 Smallest item z: 25 Total bin volume: 4110480 Total bin weight: inf -Largest bin cost: 37368 +Largest bin cost: 4.11048e+06 Time Profit # items Comment ---- ------ ------- ------- - 0.000 246240 1 TS g 5 d Z q 1 - 0.000 409860 1 TS g 4 d X q 1 - 0.000 492480 2 TS g 4 d X q 1 - 0.001 656100 2 TS g 4 d X q 1 - 0.001 738720 3 TS g 4 d X q 1 - 0.001 902340 3 TS g 4 d X q 1 - 0.001 1.02059e+06 4 TS g 4 d X q 1 - 0.001 1.13884e+06 5 TS g 4 d X q 1 - 0.001 1.25709e+06 6 TS g 4 d X q 1 - 0.001 1.37534e+06 7 TS g 4 d X q 1 - 0.001 1.49359e+06 8 TS g 4 d X q 1 - 0.001 1.57621e+06 9 TS g 4 d X q 1 - 0.001 1.73983e+06 9 TS g 4 d X q 1 - 0.002 1.85808e+06 10 TS g 4 d X q 1 - 0.002 1.97633e+06 11 TS g 4 d X q 1 - 0.002 2.09458e+06 12 TS g 4 d X q 1 - 0.002 2.29554e+06 6 TS g 5 d Z q 1 - 0.002 2.45916e+06 6 TS g 5 d Z q 1 - 0.002 2.7054e+06 7 TS g 5 d Z q 1 - 0.002 2.86902e+06 7 TS g 5 d Z q 1 - 0.002 2.95164e+06 8 TS g 5 d Z q 1 - 0.002 3.11526e+06 8 TS g 5 d Z q 1 - 0.002 3.23351e+06 9 TS g 5 d Z q 1 - 0.002 3.44241e+06 16 TS g 4 d X q 1 - 0.003 3.56066e+06 17 TS g 4 d X q 2 - 0.040 3.5704e+06 16 TS g 4 d Y q 42 + 0.006 246240 1 TS g 5 d Z q 1 + 0.008 409860 1 TS g 5 d Z q 1 + 0.011 656100 2 TS g 5 d Z q 1 + 0.014 819720 2 TS g 5 d Z q 1 + 0.016 1.06596e+06 3 TS g 5 d Z q 1 + 0.020 1.22958e+06 3 TS g 5 d Z q 1 + 0.023 1.47582e+06 4 TS g 5 d Z q 1 + 0.025 1.63944e+06 4 TS g 5 d Z q 1 + 0.028 1.88568e+06 5 TS g 5 d Z q 1 + 0.031 2.0493e+06 5 TS g 5 d Z q 1 + 0.033 2.29554e+06 6 TS g 5 d Z q 1 + 0.036 2.45916e+06 6 TS g 5 d Z q 1 + 0.039 2.7054e+06 7 TS g 5 d Z q 1 + 0.042 2.86902e+06 7 TS g 5 d Z q 1 + 0.046 2.95164e+06 8 TS g 5 d Z q 1 + 0.049 3.11526e+06 8 TS g 5 d Z q 1 + 0.051 3.23351e+06 9 TS g 5 d Z q 1 + 0.054 3.27888e+06 8 TS g 5 d X q 1 + 0.057 3.35176e+06 10 TS g 5 d Z q 2 + 0.061 3.44241e+06 16 TS g 4 d X q 1 + 0.064 3.56066e+06 17 TS g 4 d X q 2 + 0.088 3.5704e+06 16 TS g 4 d Y q 42 Final statistics ---------------- -Time (s): 5.00475 +Time (s): 5.00587 +Is proven infeasible: 0 +Primal bound: 3.5704e+06 +Dual bound: 4.10987e+06 +Gap: 15.1095% Solution -------- -Number of items: 16 / 60 (26.6667%) -Item volume: 3.5704e+06 / 1.5487e+07 (23.0542%) -Item weight: 0 / 0 (-nan%) -Item profit: 3.5704e+06 / 1.5487e+07 (23.0542%) -Number of stacks: 0 -Stack area: 0 -Number of bins: 1 / 1 (100%) -Bin volume: 4110480 / 4110480 (100%) -Bin area: 37368 / 37368 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 37368 -Waste: 516320 -Waste (%): 12.6341 -Full waste: 540080 -Full waste (%): 13.1391 -Volume load: 0.868609 -Area load: 0 -Weight load: 0 -X max: 216 -Y max: 172 -Z max: 110 +Number of items: 16 / 60 (26.6667%) +Item volume: 3.5704e+06 / 1.5487e+07 (23.0542%) +Item weight: 3.5704e+06 / 1.5487e+07 (23.0542%) +Item profit: 3.5704e+06 / 1.5487e+07 (23.0542%) +Number of stacks: 0 +Stack area: 0 +Number of bins: 1 / 1 (100%) +Bin volume: 4110480 / 4110480 (100%) +Bin area: 37368 / 37368 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 4.11048e+06 +Waste: 516320 +Waste (%): 12.6341 +Full waste: 540080 +Full waste (%): 13.1391 +Volume load: 0.868609 +Area load: 0 +Weight load: 0 +X max: 216 +Y max: 172 +Z max: 110 +Leftover value: 5.64538e+08 +Staircase leftover value: 275400 +Total leftover value: 5.64538e+08 +Total staircase leftover value: 275400 diff --git a/doc/examples/box/box_vs_boxstacks/output.txt b/doc/examples/box/box_vs_boxstacks/output.txt index 55399b0c3..117cc1acc 100644 --- a/doc/examples/box/box_vs_boxstacks/output.txt +++ b/doc/examples/box/box_vs_boxstacks/output.txt @@ -17,114 +17,53 @@ Number of defects: 0 Total item volume: 48952000000 Total item profit: 4.8952e+10 Largest item profit: 2.4e+09 -Total item weight: 0 +Total item weight: 4.8952e+10 Largest item copies: 12 Smallest item x: 500 Smallest item y: 400 Smallest item z: 300 Total bin volume: 54000000000 Total bin weight: inf -Largest bin cost: 1.8e+07 +Largest bin cost: 5.4e+10 Time Profit # items Comment ---- ------ ------- ------- - 0.000 2.34e+09 1 TS g 4 d X q 1 - 0.004 2.4e+09 1 TS g 4 d X q 1 - 0.009 4.68e+09 2 TS g 4 d X q 1 - 0.014 4.74e+09 2 TS g 4 d X q 1 - 0.019 7.02e+09 3 TS g 4 d Y q 1 - 0.024 7.08e+09 3 TS g 4 d Y q 1 - 0.029 9.36e+09 4 TS g 4 d Y q 1 - 0.034 9.42e+09 4 TS g 4 d Y q 1 - 0.039 1.0218e+10 5 TS g 4 d Y q 1 - 0.044 1.1232e+10 5 TS g 4 d Y q 1 - 0.049 1.176e+10 5 TS g 4 d Y q 1 - 0.054 1.209e+10 6 TS g 4 d Y q 1 - 0.058 1.2618e+10 6 TS g 4 d Y q 1 - 0.064 1.2948e+10 7 TS g 4 d Y q 1 - 0.068 1.3476e+10 7 TS g 4 d Y q 1 - 0.070 1.428e+10 6 TS g 5 d Y q 1 - 0.075 1.662e+10 7 TS g 5 d Y q 1 - 0.078 1.8492e+10 8 TS g 5 d Y q 1 - 0.082 2.0364e+10 9 TS g 5 d Y q 1 - 0.086 2.2236e+10 10 TS g 5 d Y q 1 - 0.091 2.4108e+10 11 TS g 5 d Y q 1 - 0.094 2.5758e+10 12 TS g 5 d Y q 1 - 0.096 2.6004e+10 12 TS g 5 d X q 1 - 0.100 2.7408e+10 13 TS g 5 d Y q 1 - 0.104 2.7876e+10 13 TS g 5 d X q 1 - 0.108 2.9748e+10 14 TS g 5 d Y q 1 - 0.113 2.9868e+10 15 TS g 5 d Y q 1 - 0.117 3.0606e+10 15 TS g 5 d X q 1 - 0.121 3.1398e+10 15 TS g 5 d X q 1 - 0.123 3.2256e+10 16 TS g 5 d X q 1 - 0.126 3.3048e+10 16 TS g 5 d X q 1 - 0.128 3.3906e+10 17 TS g 5 d X q 1 - 0.132 3.4554e+10 18 TS g 5 d X q 1 - 0.137 3.4674e+10 19 TS g 5 d X q 1 - 0.140 3.4794e+10 20 TS g 5 d X q 1 - 0.144 3.492e+10 21 TS g 5 d X q 1 - 0.147 3.5568e+10 22 TS g 5 d X q 1 - 0.151 3.5778e+10 22 TS g 5 d X q 1 - 0.153 3.6426e+10 23 TS g 5 d X q 1 - 0.157 3.6636e+10 23 TS g 5 d X q 1 - 0.159 3.7284e+10 24 TS g 5 d X q 1 - 0.163 3.7494e+10 24 TS g 5 d X q 1 - 0.165 3.8142e+10 25 TS g 5 d X q 1 - 0.168 3.8352e+10 25 TS g 5 d X q 1 - 0.172 3.9e+10 26 TS g 5 d X q 1 - 0.175 3.921e+10 26 TS g 5 d X q 1 - 0.179 3.9858e+10 27 TS g 5 d X q 1 - 0.182 4.0068e+10 27 TS g 5 d X q 1 - 0.185 4.0716e+10 28 TS g 5 d X q 1 - 0.189 4.0926e+10 28 TS g 5 d X q 1 - 0.192 4.1574e+10 29 TS g 5 d X q 1 - 0.195 4.2222e+10 30 TS g 5 d X q 1 - 0.199 4.287e+10 31 TS g 5 d X q 1 - 0.202 4.2996e+10 32 TS g 5 d X q 1 - 0.207 4.3122e+10 33 TS g 5 d X q 1 - 0.212 4.3248e+10 34 TS g 5 d X q 1 - 0.217 4.3318e+10 35 TS g 5 d X q 1 - 0.220 4.3388e+10 36 TS g 5 d X q 1 - 0.222 4.3458e+10 37 TS g 5 d X q 1 - 0.227 4.3528e+10 38 TS g 5 d X q 1 - 0.232 4.3776e+10 34 TS g 5 d Z q 1 - 0.237 4.4176e+10 39 TS g 5 d X q 1 - 0.242 4.4824e+10 40 TS g 5 d X q 1 - 0.246 4.5472e+10 41 TS g 5 d X q 1 - 0.249 4.612e+10 42 TS g 5 d X q 1 - 0.253 4.6768e+10 43 TS g 5 d X q 1 - 0.257 4.6888e+10 44 TS g 5 d X q 1 - 0.263 4.6938e+10 44 TS g 5 d Z q 1 - 0.267 4.7008e+10 45 TS g 5 d X q 1 - 0.271 4.7656e+10 46 TS g 4 d X q 2 - 0.277 4.8304e+10 47 TS g 4 d X q 2 - 0.282 4.8952e+10 48 TS g 4 d X q 2 + 0.718 4.552e+10 44 TSMS n 1 + 0.728 4.8192e+10 40 TSMS n 4 + 0.729 4.8952e+10 48 TSMS n 4 Final statistics ---------------- -Time (s): 10.005 +Time (s): 0.735098 +Is proven infeasible: 0 +Primal bound: 4.8952e+10 +Dual bound: 4.8952e+10 +Gap: 0% Solution -------- -Number of items: 48 / 48 (100%) -Item volume: 4.8952e+10 / 4.8952e+10 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 4.8952e+10 / 4.8952e+10 (100%) -Number of stacks: 0 -Stack area: 0 -Number of bins: 1 / 1 (100%) -Bin volume: 54000000000 / 54000000000 (100%) -Bin area: 18000000 / 18000000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 1.8e+07 -Waste: 5048000000 -Waste (%): 9.34815 -Full waste: 5048000000 -Full waste (%): 9.34815 -Volume load: 0.906519 -Area load: 0 -Weight load: 0 -X max: 7500 -Y max: 2400 -Z max: 3000 +Number of items: 48 / 48 (100%) +Item volume: 4.8952e+10 / 4.8952e+10 (100%) +Item weight: 4.8952e+10 / 4.8952e+10 (100%) +Item profit: 4.8952e+10 / 4.8952e+10 (100%) +Number of stacks: 0 +Stack area: 0 +Number of bins: 1 / 1 (100%) +Bin volume: 54000000000 / 54000000000 (100%) +Bin area: 18000000 / 18000000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 5.4e+10 +Waste: 5048000000 +Waste (%): 9.34815 +Full waste: 5048000000 +Full waste (%): 9.34815 +Volume load: 0.906519 +Area load: 0 +Weight load: 0 +X max: 7500 +Y max: 2400 +Z max: 3000 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 0 +Total staircase leftover value: 0 diff --git a/doc/examples/box/box_vs_boxstacks/solution.csv b/doc/examples/box/box_vs_boxstacks/solution.csv index 0a301776c..8c8567563 100644 --- a/doc/examples/box/box_vs_boxstacks/solution.csv +++ b/doc/examples/box/box_vs_boxstacks/solution.csv @@ -1,50 +1,50 @@ TYPE,ID,COPIES,BIN,X,Y,Z,LX,LY,LZ,ROTATION BIN,0,1,0,0,0,0,7500,2400,3000, -ITEM,0,1,0,0,0,0,1300,1200,1500,XYZ -ITEM,0,1,0,0,0,1500,1300,1200,1500,XYZ -ITEM,0,1,0,0,1200,0,1300,1200,1500,XYZ -ITEM,0,1,0,0,1200,1500,1300,1200,1500,XYZ -ITEM,1,1,0,1300,0,0,1300,1200,550,XYZ -ITEM,1,1,0,1300,0,550,1300,1200,550,XYZ -ITEM,1,1,0,1300,0,1100,1300,1200,550,XYZ -ITEM,1,1,0,1300,0,1650,1300,1200,550,XYZ -ITEM,3,1,0,1300,0,2200,1200,1200,450,XYZ -ITEM,7,1,0,1300,0,2650,500,400,350,XYZ -ITEM,1,1,0,1300,1200,0,1300,1200,550,XYZ -ITEM,1,1,0,1300,1200,550,1300,1200,550,XYZ -ITEM,1,1,0,1300,1200,1100,1300,1200,550,XYZ -ITEM,1,1,0,1300,1200,1650,1300,1200,550,XYZ -ITEM,6,1,0,1300,1200,2200,600,500,400,XYZ -ITEM,6,1,0,1300,1200,2600,600,500,400,XYZ -ITEM,7,1,0,1300,400,2650,500,400,350,XYZ -ITEM,7,1,0,1300,800,2650,500,400,350,XYZ -ITEM,8,1,0,1300,1700,2200,700,600,300,XYZ -ITEM,6,1,0,1300,1700,2500,600,500,400,XYZ -ITEM,7,1,0,1800,0,2650,500,400,350,XYZ -ITEM,8,1,0,1800,400,2650,700,600,300,XYZ -ITEM,6,1,0,1900,1200,2200,600,500,400,XYZ -ITEM,8,1,0,1900,1200,2600,700,600,300,XYZ -ITEM,8,1,0,1900,1800,2500,700,600,300,XYZ -ITEM,3,1,0,2500,0,2200,1200,1200,450,XYZ -ITEM,4,1,0,2600,0,0,1250,1200,1600,XYZ -ITEM,4,1,0,2600,1200,0,1250,1200,1600,XYZ -ITEM,5,1,0,2600,1200,1600,1250,1200,1100,XYZ -ITEM,3,1,0,2600,0,1600,1200,1200,450,XYZ -ITEM,5,1,0,3800,0,1600,1250,1200,1100,XYZ -ITEM,4,1,0,3850,0,0,1250,1200,1600,XYZ -ITEM,4,1,0,3850,1200,0,1250,1200,1600,XYZ -ITEM,5,1,0,3850,1200,1600,1250,1200,1100,XYZ -ITEM,5,1,0,5050,0,1600,1250,1200,1100,XYZ -ITEM,2,1,0,5100,0,0,1200,1200,1300,XYZ -ITEM,2,1,0,5100,1200,0,1200,1200,1300,XYZ -ITEM,2,1,0,5100,1200,1300,1200,1200,1300,XYZ +ITEM,3,1,0,0,0,0,1200,1200,450,XYZ +ITEM,3,1,0,0,0,450,1200,1200,450,XYZ +ITEM,3,1,0,0,0,900,1200,1200,450,XYZ +ITEM,2,1,0,0,1200,0,1200,1200,1300,XYZ +ITEM,3,1,0,1200,0,0,1200,1200,450,XYZ +ITEM,3,1,0,1200,0,450,1200,1200,450,XYZ +ITEM,3,1,0,1200,0,900,1200,1200,450,XYZ +ITEM,3,1,0,1200,1200,0,1200,1200,450,XYZ +ITEM,3,1,0,1200,1200,450,1200,1200,450,XYZ +ITEM,3,1,0,1200,1200,900,1200,1200,450,XYZ +ITEM,4,1,0,0,0,1350,1250,1200,1600,XYZ +ITEM,4,1,0,0,1200,1350,1250,1200,1600,XYZ +ITEM,4,1,0,1250,0,1350,1250,1200,1600,XYZ +ITEM,4,1,0,1250,1200,1350,1250,1200,1600,XYZ +ITEM,0,1,0,2500,0,0,1300,1200,1500,XYZ +ITEM,0,1,0,2500,0,1500,1300,1200,1500,XYZ +ITEM,0,1,0,2500,1200,0,1300,1200,1500,XYZ +ITEM,0,1,0,2500,1200,1500,1300,1200,1500,XYZ +ITEM,1,1,0,5000,0,0,1300,1200,550,XYZ +ITEM,1,1,0,5000,0,550,1300,1200,550,XYZ +ITEM,1,1,0,5000,0,1100,1300,1200,550,XYZ +ITEM,1,1,0,5000,0,1650,1300,1200,550,XYZ ITEM,2,1,0,6300,0,0,1200,1200,1300,XYZ ITEM,3,1,0,6300,0,1300,1200,1200,450,XYZ ITEM,3,1,0,6300,0,1750,1200,1200,450,XYZ -ITEM,3,1,0,6300,0,2200,1200,1200,450,XYZ -ITEM,3,1,0,6300,1200,0,1200,1200,450,XYZ -ITEM,3,1,0,6300,1200,450,1200,1200,450,XYZ -ITEM,3,1,0,6300,1200,900,1200,1200,450,XYZ -ITEM,3,1,0,6300,1200,1350,1200,1200,450,XYZ -ITEM,3,1,0,6300,1200,1800,1200,1200,450,XYZ -ITEM,3,1,0,6300,1200,2250,1200,1200,450,XYZ +ITEM,5,1,0,5000,1200,0,1250,1200,1100,XYZ +ITEM,5,1,0,5000,1200,1100,1250,1200,1100,XYZ +ITEM,5,1,0,6250,1200,0,1250,1200,1100,XYZ +ITEM,5,1,0,6250,1200,1100,1250,1200,1100,XYZ +ITEM,1,1,0,4900,0,2450,1300,1200,550,XYZ +ITEM,1,1,0,4900,1200,2450,1300,1200,550,XYZ +ITEM,1,1,0,6200,0,2450,1300,1200,550,XYZ +ITEM,1,1,0,6200,1200,2450,1300,1200,550,XYZ +ITEM,2,1,0,3800,0,0,1200,1200,1300,XYZ +ITEM,2,1,0,3800,1200,0,1200,1200,1300,XYZ +ITEM,6,1,0,4300,0,2600,600,500,400,XYZ +ITEM,6,1,0,4300,500,2600,600,500,400,XYZ +ITEM,6,1,0,4300,1000,2600,600,500,400,XYZ +ITEM,6,1,0,4300,1500,2600,600,500,400,XYZ +ITEM,7,1,0,3900,2000,2300,500,400,350,XYZ +ITEM,7,1,0,3900,2000,2650,500,400,350,XYZ +ITEM,7,1,0,4400,2000,2300,500,400,350,XYZ +ITEM,7,1,0,4400,2000,2650,500,400,350,XYZ +ITEM,8,1,0,4200,0,2300,700,600,300,XYZ +ITEM,8,1,0,4200,600,2300,700,600,300,XYZ +ITEM,8,1,0,4200,1200,2300,700,600,300,XYZ +ITEM,3,1,0,3800,0,1850,1200,1200,450,XYZ +ITEM,8,1,0,4300,1800,2000,700,600,300,XYZ diff --git a/doc/examples/box/maximum_weight_above_no/output.txt b/doc/examples/box/maximum_weight_above_no/output.txt index 7c499491c..799b49cb1 100644 --- a/doc/examples/box/maximum_weight_above_no/output.txt +++ b/doc/examples/box/maximum_weight_above_no/output.txt @@ -32,7 +32,7 @@ Largest bin cost: 6000 Final statistics ---------------- -Time (s): 0.00140142 +Time (s): 0.00448965 Is proven infeasible: 0 Primal bound: 1 Dual bound: 1 @@ -63,5 +63,5 @@ Y max: 20 Z max: 30 Leftover value: 0 Staircase leftover value: 0 -Total leftover value: 0 -Total staircase leftover value: 0 +Total leftover value: 3.24e+08 +Total staircase leftover value: 54000 diff --git a/doc/examples/box/maximum_weight_above_yes/output.txt b/doc/examples/box/maximum_weight_above_yes/output.txt index 769e19e3e..34724c874 100644 --- a/doc/examples/box/maximum_weight_above_yes/output.txt +++ b/doc/examples/box/maximum_weight_above_yes/output.txt @@ -28,11 +28,11 @@ Largest bin cost: 6000 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.079 2 50.00 SVC it 0 + 0.082 2 50.00 SVC it 0 Final statistics ---------------- -Time (s): 0.124009 +Time (s): 0.145214 Is proven infeasible: 0 Primal bound: 2 Dual bound: 1 @@ -61,7 +61,7 @@ Weight load: 0 X max: 10 Y max: 10 Z max: 20 -Leftover value: 4000 +Leftover value: 1.6e+07 Staircase leftover value: 4000 -Total leftover value: 6000 -Total staircase leftover value: 6000 +Total leftover value: 3.08e+08 +Total staircase leftover value: 54000 diff --git a/doc/examples/box/maximum_weight_no/output.txt b/doc/examples/box/maximum_weight_no/output.txt index b9646625c..eacf27180 100644 --- a/doc/examples/box/maximum_weight_no/output.txt +++ b/doc/examples/box/maximum_weight_no/output.txt @@ -24,36 +24,44 @@ Smallest item y: 10 Smallest item z: 10 Total bin volume: 40000 Total bin weight: inf -Largest bin cost: 400 +Largest bin cost: 4000 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 1 0.00 TS g 0 d X q 1 + 0.001 1 0.00 TS g 0 d X q 1 Final statistics ---------------- -Time (s): 0.00168401 +Time (s): 0.00411849 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 4 / 4 (100%) -Item volume: 4000 / 4000 (100%) -Item weight: 400 / 400 (100%) -Item profit: 4000 / 4000 (100%) -Number of stacks: 0 -Stack area: 0 -Number of bins: 1 / 10 (10%) -Bin volume: 4000 / 40000 (10%) -Bin area: 400 / 4000 (10%) -Bin weight: inf / inf (-nan%) -Bin cost: 400 -Waste: 0 -Waste (%): 0 -Full waste: 0 -Full waste (%): 0 -Volume load: 0.1 -Area load: 0 -Weight load: 0 -X max: 20 -Y max: 20 -Z max: 10 +Number of items: 4 / 4 (100%) +Item volume: 4000 / 4000 (100%) +Item weight: 400 / 400 (100%) +Item profit: 4000 / 4000 (100%) +Number of stacks: 0 +Stack area: 0 +Number of bins: 1 / 10 (10%) +Bin volume: 4000 / 40000 (10%) +Bin area: 400 / 4000 (10%) +Bin weight: inf / inf (-nan%) +Bin cost: 4000 +Waste: 0 +Waste (%): 0 +Full waste: 0 +Full waste (%): 0 +Volume load: 0.1 +Area load: 0 +Weight load: 0 +X max: 20 +Y max: 20 +Z max: 10 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 1.44e+08 +Total staircase leftover value: 36000 diff --git a/doc/examples/box/maximum_weight_yes/output.txt b/doc/examples/box/maximum_weight_yes/output.txt index 582aaf594..0e99f5620 100644 --- a/doc/examples/box/maximum_weight_yes/output.txt +++ b/doc/examples/box/maximum_weight_yes/output.txt @@ -24,36 +24,44 @@ Smallest item y: 10 Smallest item z: 10 Total bin volume: 40000 Total bin weight: 2000 -Largest bin cost: 400 +Largest bin cost: 4000 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 50.00 TS g 0 d X q 1 + 0.001 2 50.00 TS g 0 d X q 1 Final statistics ---------------- -Time (s): 0.000955456 +Time (s): 0.00843129 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- -Number of items: 4 / 4 (100%) -Item volume: 4000 / 4000 (100%) -Item weight: 400 / 400 (100%) -Item profit: 4000 / 4000 (100%) -Number of stacks: 0 -Stack area: 0 -Number of bins: 2 / 10 (20%) -Bin volume: 8000 / 40000 (20%) -Bin area: 800 / 4000 (20%) -Bin weight: 400 / 2000 (20%) -Bin cost: 800 -Waste: 2000 -Waste (%): 33.3333 -Full waste: 4000 -Full waste (%): 50 -Volume load: 0.1 -Area load: 0 -Weight load: 0.2 -X max: 20 -Y max: 10 -Z max: 10 +Number of items: 4 / 4 (100%) +Item volume: 4000 / 4000 (100%) +Item weight: 400 / 400 (100%) +Item profit: 4000 / 4000 (100%) +Number of stacks: 0 +Stack area: 0 +Number of bins: 2 / 10 (20%) +Bin volume: 8000 / 40000 (20%) +Bin area: 800 / 4000 (20%) +Bin weight: 400 / 2000 (20%) +Bin cost: 8000 +Waste: 2000 +Waste (%): 33.3333 +Full waste: 4000 +Full waste (%): 50 +Volume load: 0.1 +Area load: 0 +Weight load: 0.2 +X max: 20 +Y max: 10 +Z max: 10 +Leftover value: 4e+06 +Staircase leftover value: 2000 +Total leftover value: 1.36e+08 +Total staircase leftover value: 36000 diff --git a/doc/examples/box/rotation_no/output.txt b/doc/examples/box/rotation_no/output.txt index 6ce39f1c7..6cfd034f3 100644 --- a/doc/examples/box/rotation_no/output.txt +++ b/doc/examples/box/rotation_no/output.txt @@ -17,43 +17,51 @@ Number of defects: 0 Total item volume: 840 Total item profit: 840 Largest item profit: 600 -Total item weight: 0 +Total item weight: 840 Largest item copies: 1 Smallest item x: 10 Smallest item y: 4 Smallest item z: 6 Total bin volume: 2000 Total bin weight: inf -Largest bin cost: 100 +Largest bin cost: 1000 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 58.00 TS g 0 d Y q 1 + 0.000 2 58.00 Final statistics ---------------- -Time (s): 0.00149094 +Time (s): 0.00268583 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- -Number of items: 2 / 2 (100%) -Item volume: 840 / 840 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 840 / 840 (100%) -Number of stacks: 0 -Stack area: 0 -Number of bins: 2 / 2 (100%) -Bin volume: 2000 / 2000 (100%) -Bin area: 200 / 200 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 200 -Waste: 400 -Waste (%): 32.2581 -Full waste: 1160 -Full waste (%): 58 -Volume load: 0.42 -Area load: 0 -Weight load: 0 -X max: 10 -Y max: 4 -Z max: 6 +Number of items: 2 / 2 (100%) +Item volume: 840 / 840 (100%) +Item weight: 840 / 840 (100%) +Item profit: 840 / 840 (100%) +Number of stacks: 0 +Stack area: 0 +Number of bins: 2 / 2 (100%) +Bin volume: 2000 / 2000 (100%) +Bin area: 200 / 200 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 2000 +Waste: 400 +Waste (%): 32.2581 +Full waste: 1160 +Full waste (%): 58 +Volume load: 0.42 +Area load: 0 +Weight load: 0 +X max: 10 +Y max: 4 +Z max: 6 +Leftover value: 577600 +Staircase leftover value: 760 +Total leftover value: 737600 +Total staircase leftover value: 1160 diff --git a/doc/examples/box/rotation_yes/output.txt b/doc/examples/box/rotation_yes/output.txt index 2b6233a8f..3bfce0d83 100644 --- a/doc/examples/box/rotation_yes/output.txt +++ b/doc/examples/box/rotation_yes/output.txt @@ -17,43 +17,51 @@ Number of defects: 0 Total item volume: 840 Total item profit: 840 Largest item profit: 600 -Total item weight: 0 +Total item weight: 840 Largest item copies: 1 Smallest item x: 10 Smallest item y: 4 Smallest item z: 4 Total bin volume: 2000 Total bin weight: inf -Largest bin cost: 100 +Largest bin cost: 1000 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 1 16.00 TS g 0 d X q 1 + 0.001 1 16.00 TS g 0 d X q 1 Final statistics ---------------- -Time (s): 0.00083359 +Time (s): 0.00399987 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 2 / 2 (100%) -Item volume: 840 / 840 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 840 / 840 (100%) -Number of stacks: 0 -Stack area: 0 -Number of bins: 1 / 2 (50%) -Bin volume: 1000 / 2000 (50%) -Bin area: 100 / 200 (50%) -Bin weight: inf / inf (-nan%) -Bin cost: 100 -Waste: 160 -Waste (%): 16 -Full waste: 160 -Full waste (%): 16 -Volume load: 0.42 -Area load: 0 -Weight load: 0 -X max: 10 -Y max: 10 -Z max: 10 +Number of items: 2 / 2 (100%) +Item volume: 840 / 840 (100%) +Item weight: 840 / 840 (100%) +Item profit: 840 / 840 (100%) +Number of stacks: 0 +Stack area: 0 +Number of bins: 1 / 2 (50%) +Bin volume: 1000 / 2000 (50%) +Bin area: 100 / 200 (50%) +Bin weight: inf / inf (-nan%) +Bin cost: 1000 +Waste: 160 +Waste (%): 16 +Full waste: 160 +Full waste (%): 16 +Volume load: 0.42 +Area load: 0 +Weight load: 0 +X max: 10 +Y max: 10 +Z max: 10 +Leftover value: 0 +Staircase leftover value: 160 +Total leftover value: 1e+06 +Total staircase leftover value: 1160 diff --git a/doc/examples/box/static_stability_no/output.txt b/doc/examples/box/static_stability_no/output.txt index c5f1d3ad2..b664ec93d 100644 --- a/doc/examples/box/static_stability_no/output.txt +++ b/doc/examples/box/static_stability_no/output.txt @@ -28,12 +28,12 @@ Largest bin cost: 2000 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.005 2 62.80 TS g 1 d Z q 1 - 0.005 1 25.60 TS g 1 d Z q 2 + 0.001 2 62.80 TS g 0 d X q 1 + 0.004 1 25.60 SVC it 0 Final statistics ---------------- -Time (s): 0.0146918 +Time (s): 0.00764766 Is proven infeasible: 0 Primal bound: 1 Dual bound: 1 @@ -62,7 +62,7 @@ Weight load: 0 X max: 10 Y max: 10 Z max: 18 -Leftover value: 200 +Leftover value: 40000 Staircase leftover value: 200 -Total leftover value: 200 -Total staircase leftover value: 200 +Total leftover value: 3.604e+07 +Total staircase leftover value: 18200 diff --git a/doc/examples/box/static_stability_yes/output.txt b/doc/examples/box/static_stability_yes/output.txt index 61f654865..298774001 100644 --- a/doc/examples/box/static_stability_yes/output.txt +++ b/doc/examples/box/static_stability_yes/output.txt @@ -29,11 +29,11 @@ Largest bin cost: 2000 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.003 2 62.80 TS g 1 d Z q 1 + 0.006 2 62.80 TS g 0 d Y q 1 Final statistics ---------------- -Time (s): 0.297788 +Time (s): 0.110594 Is proven infeasible: 0 Primal bound: 2 Dual bound: 1 @@ -62,7 +62,7 @@ Weight load: 0 X max: 9 Y max: 3 Z max: 12 -Leftover value: 1676 +Leftover value: 2.80898e+06 Staircase leftover value: 1676 -Total leftover value: 2476 -Total staircase leftover value: 2512 +Total leftover value: 3.5449e+07 +Total staircase leftover value: 18512 diff --git a/doc/examples/box/static_stability_yes/solution.csv b/doc/examples/box/static_stability_yes/solution.csv index e8679cec3..3d46c2384 100644 --- a/doc/examples/box/static_stability_yes/solution.csv +++ b/doc/examples/box/static_stability_yes/solution.csv @@ -1,7 +1,7 @@ TYPE,ID,COPIES,BIN,X,Y,Z,LX,LY,LZ,ROTATION BIN,0,1,0,0,0,0,10,10,20, ITEM,1,1,0,0,0,0,10,7,6,XYZ -ITEM,0,1,0,0,7,0,9,3,12,XYZ ITEM,1,1,0,0,0,6,10,7,6,XYZ +ITEM,0,1,0,0,7,0,9,3,12,XYZ BIN,0,1,1,0,0,0,10,10,20, ITEM,0,1,1,0,0,0,9,3,12,XYZ diff --git a/doc/examples/boxstacks/axle_weight_no/output.txt b/doc/examples/boxstacks/axle_weight_no/output.txt index 316a0b1e6..3948790b8 100644 --- a/doc/examples/boxstacks/axle_weight_no/output.txt +++ b/doc/examples/boxstacks/axle_weight_no/output.txt @@ -24,31 +24,39 @@ Total bin weight: inf Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.010 1 52.26 iteration 0 + 0.035 1 52.26 SSK it 0 Final statistics ---------------- -Time (s): 0.0105685 +Time (s): 0.0351971 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 38 / 38 (100%) -Item volume: 4.56e+10 / 4.56e+10 (100%) -Item weight: 38000 / 38000 (100%) -Item profit: 4.56e+10 / 4.56e+10 (100%) -Number of stacks: 15 -Stack area: 18000000 -Number of bins: 1 / 2 (50%) -Bin volume: 95526000000 / 191052000000 (50%) -Bin area: 32940000 / 65880000 (50%) -Bin weight: inf / inf (-nan%) -Bin cost: 3.294e+07 -Waste: 22329600000 -Waste (%): 32.8717 -Full waste: 49926000000 -Full waste (%): 52.2643 -Volume load: 0.238678 -Area load: 0.273224 -Weight load: 0 -X max: 9600 -Y max: 2000 +Number of items: 38 / 38 (100%) +Item volume: 4.56e+10 / 4.56e+10 (100%) +Item weight: 38000 / 38000 (100%) +Item profit: 4.56e+10 / 4.56e+10 (100%) +Number of stacks: 15 +Stack area: 18000000 +Number of bins: 1 / 2 (50%) +Bin volume: 95526000000 / 191052000000 (50%) +Bin area: 32940000 / 65880000 (50%) +Bin weight: inf / inf (-nan%) +Bin cost: 9.5526e+10 +Waste: 10080000000 +Waste (%): 18.1034 +Full waste: 49926000000 +Full waste (%): 52.2643 +Volume load: 0.238678 +Area load: 0.273224 +Weight load: 0 +X max: 9600 +Y max: 2000 +Leftover value: 1.5877e+21 +Staircase leftover value: 43326000000 +Total leftover value: 1.07129e+22 +Total staircase leftover value: 138852000000 diff --git a/doc/examples/boxstacks/axle_weight_no/solution.csv b/doc/examples/boxstacks/axle_weight_no/solution.csv index 140cbcca0..3990d5200 100644 --- a/doc/examples/boxstacks/axle_weight_no/solution.csv +++ b/doc/examples/boxstacks/axle_weight_no/solution.csv @@ -1,55 +1,55 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,13500,2440,2900, -STACK,0,1,0,0,0,0,0,1200,1000,1200, -ITEM,0,1,0,0,0,0,0,1200,1000,1200,0 -STACK,1,1,0,1,0,1000,0,1200,1000,2000, -ITEM,0,1,0,1,0,1000,0,1200,1000,1200,0 -ITEM,1,1,0,1,0,1000,1200,1200,1000,800,0 -STACK,2,1,0,2,1200,0,0,1200,1000,2400, -ITEM,0,1,0,2,1200,0,0,1200,1000,1200,0 -ITEM,0,1,0,2,1200,0,1200,1200,1000,1200,0 -STACK,3,1,0,3,1200,1000,0,1200,1000,2400, -ITEM,0,1,0,3,1200,1000,0,1200,1000,1200,0 -ITEM,0,1,0,3,1200,1000,1200,1200,1000,1200,0 -STACK,4,1,0,4,2400,0,0,1200,1000,2400, -ITEM,0,1,0,4,2400,0,0,1200,1000,1200,0 -ITEM,0,1,0,4,2400,0,1200,1200,1000,1200,0 -STACK,5,1,0,5,2400,1000,0,1200,1000,2400, -ITEM,0,1,0,5,2400,1000,0,1200,1000,1200,0 -ITEM,0,1,0,5,2400,1000,1200,1200,1000,1200,0 -STACK,6,1,0,6,3600,0,0,1200,1000,2800, -ITEM,0,1,0,6,3600,0,0,1200,1000,1200,0 -ITEM,1,1,0,6,3600,0,1200,1200,1000,800,0 -ITEM,1,1,0,6,3600,0,2000,1200,1000,800,0 -STACK,7,1,0,7,3600,1000,0,1200,1000,2800, -ITEM,0,1,0,7,3600,1000,0,1200,1000,1200,0 -ITEM,1,1,0,7,3600,1000,1200,1200,1000,800,0 -ITEM,1,1,0,7,3600,1000,2000,1200,1000,800,0 -STACK,8,1,0,8,4800,0,0,1200,1000,2800, -ITEM,0,1,0,8,4800,0,0,1200,1000,1200,0 -ITEM,1,1,0,8,4800,0,1200,1200,1000,800,0 -ITEM,1,1,0,8,4800,0,2000,1200,1000,800,0 -STACK,9,1,0,9,4800,1000,0,1200,1000,2800, -ITEM,0,1,0,9,4800,1000,0,1200,1000,1200,0 -ITEM,1,1,0,9,4800,1000,1200,1200,1000,800,0 -ITEM,1,1,0,9,4800,1000,2000,1200,1000,800,0 -STACK,10,1,0,10,6000,0,0,1200,1000,2800, -ITEM,0,1,0,10,6000,0,0,1200,1000,1200,0 -ITEM,1,1,0,10,6000,0,1200,1200,1000,800,0 -ITEM,1,1,0,10,6000,0,2000,1200,1000,800,0 -STACK,11,1,0,11,6000,1000,0,1200,1000,2800, -ITEM,0,1,0,11,6000,1000,0,1200,1000,1200,0 -ITEM,1,1,0,11,6000,1000,1200,1200,1000,800,0 -ITEM,1,1,0,11,6000,1000,2000,1200,1000,800,0 -STACK,12,1,0,12,7200,0,0,1200,1000,2800, -ITEM,0,1,0,12,7200,0,0,1200,1000,1200,0 -ITEM,1,1,0,12,7200,0,1200,1200,1000,800,0 -ITEM,1,1,0,12,7200,0,2000,1200,1000,800,0 -STACK,13,1,0,13,7200,1000,0,1200,1000,2800, -ITEM,0,1,0,13,7200,1000,0,1200,1000,1200,0 -ITEM,1,1,0,13,7200,1000,1200,1200,1000,800,0 -ITEM,1,1,0,13,7200,1000,2000,1200,1000,800,0 -STACK,14,1,0,14,8400,0,0,1200,1000,2800, -ITEM,0,1,0,14,8400,0,0,1200,1000,1200,0 -ITEM,1,1,0,14,8400,0,1200,1200,1000,800,0 -ITEM,1,1,0,14,8400,0,2000,1200,1000,800,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,13500,2440,2900,, +STACK,0,1,0,0,0,0,0,1200,1000,1200,, +ITEM,0,1,0,0,0,0,0,1200,1000,1200,0,XYZ +STACK,1,1,0,1,0,1000,0,1200,1000,2000,, +ITEM,0,1,0,1,0,1000,0,1200,1000,1200,0,XYZ +ITEM,1,1,0,1,0,1000,1200,1200,1000,800,0,XYZ +STACK,2,1,0,2,1200,0,0,1200,1000,2400,, +ITEM,0,1,0,2,1200,0,0,1200,1000,1200,0,XYZ +ITEM,0,1,0,2,1200,0,1200,1200,1000,1200,0,XYZ +STACK,3,1,0,3,1200,1000,0,1200,1000,2400,, +ITEM,0,1,0,3,1200,1000,0,1200,1000,1200,0,XYZ +ITEM,0,1,0,3,1200,1000,1200,1200,1000,1200,0,XYZ +STACK,4,1,0,4,2400,0,0,1200,1000,2400,, +ITEM,0,1,0,4,2400,0,0,1200,1000,1200,0,XYZ +ITEM,0,1,0,4,2400,0,1200,1200,1000,1200,0,XYZ +STACK,5,1,0,5,2400,1000,0,1200,1000,2400,, +ITEM,0,1,0,5,2400,1000,0,1200,1000,1200,0,XYZ +ITEM,0,1,0,5,2400,1000,1200,1200,1000,1200,0,XYZ +STACK,6,1,0,6,3600,0,0,1200,1000,2800,, +ITEM,0,1,0,6,3600,0,0,1200,1000,1200,0,XYZ +ITEM,1,1,0,6,3600,0,1200,1200,1000,800,0,XYZ +ITEM,1,1,0,6,3600,0,2000,1200,1000,800,0,XYZ +STACK,7,1,0,7,3600,1000,0,1200,1000,2800,, +ITEM,0,1,0,7,3600,1000,0,1200,1000,1200,0,XYZ +ITEM,1,1,0,7,3600,1000,1200,1200,1000,800,0,XYZ +ITEM,1,1,0,7,3600,1000,2000,1200,1000,800,0,XYZ +STACK,8,1,0,8,4800,0,0,1200,1000,2800,, +ITEM,0,1,0,8,4800,0,0,1200,1000,1200,0,XYZ +ITEM,1,1,0,8,4800,0,1200,1200,1000,800,0,XYZ +ITEM,1,1,0,8,4800,0,2000,1200,1000,800,0,XYZ +STACK,9,1,0,9,4800,1000,0,1200,1000,2800,, +ITEM,0,1,0,9,4800,1000,0,1200,1000,1200,0,XYZ +ITEM,1,1,0,9,4800,1000,1200,1200,1000,800,0,XYZ +ITEM,1,1,0,9,4800,1000,2000,1200,1000,800,0,XYZ +STACK,10,1,0,10,6000,0,0,1200,1000,2800,, +ITEM,0,1,0,10,6000,0,0,1200,1000,1200,0,XYZ +ITEM,1,1,0,10,6000,0,1200,1200,1000,800,0,XYZ +ITEM,1,1,0,10,6000,0,2000,1200,1000,800,0,XYZ +STACK,11,1,0,11,6000,1000,0,1200,1000,2800,, +ITEM,0,1,0,11,6000,1000,0,1200,1000,1200,0,XYZ +ITEM,1,1,0,11,6000,1000,1200,1200,1000,800,0,XYZ +ITEM,1,1,0,11,6000,1000,2000,1200,1000,800,0,XYZ +STACK,12,1,0,12,7200,0,0,1200,1000,2800,, +ITEM,0,1,0,12,7200,0,0,1200,1000,1200,0,XYZ +ITEM,1,1,0,12,7200,0,1200,1200,1000,800,0,XYZ +ITEM,1,1,0,12,7200,0,2000,1200,1000,800,0,XYZ +STACK,13,1,0,13,7200,1000,0,1200,1000,2800,, +ITEM,0,1,0,13,7200,1000,0,1200,1000,1200,0,XYZ +ITEM,1,1,0,13,7200,1000,1200,1200,1000,800,0,XYZ +ITEM,1,1,0,13,7200,1000,2000,1200,1000,800,0,XYZ +STACK,14,1,0,14,8400,0,0,1200,1000,2800,, +ITEM,0,1,0,14,8400,0,0,1200,1000,1200,0,XYZ +ITEM,1,1,0,14,8400,0,1200,1200,1000,800,0,XYZ +ITEM,1,1,0,14,8400,0,2000,1200,1000,800,0,XYZ diff --git a/doc/examples/boxstacks/axle_weight_yes/output.txt b/doc/examples/boxstacks/axle_weight_yes/output.txt index 8f7053ccb..5b9ecb309 100644 --- a/doc/examples/boxstacks/axle_weight_yes/output.txt +++ b/doc/examples/boxstacks/axle_weight_yes/output.txt @@ -24,31 +24,39 @@ Total bin weight: inf Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.424 2 76.13 iteration 0 + 0.147 2 76.13 SSK it 1 Final statistics ---------------- -Time (s): 0.424695 +Time (s): 10.0581 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 1 +Gap: 50% Solution -------- -Number of items: 38 / 38 (100%) -Item volume: 4.56e+10 / 4.56e+10 (100%) -Item weight: 38000 / 38000 (100%) -Item profit: 4.56e+10 / 4.56e+10 (100%) -Number of stacks: 16 -Stack area: 19200000 -Number of bins: 2 / 2 (100%) -Bin volume: 191052000000 / 191052000000 (100%) -Bin area: 65880000 / 65880000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 6.588e+07 -Waste: 58417200000 -Waste (%): 56.1611 -Full waste: 145452000000 -Full waste (%): 76.1322 -Volume load: 0.238678 -Area load: 0.291439 -Weight load: 0 -X max: 1200 -Y max: 1000 +Number of items: 38 / 38 (100%) +Item volume: 4.56e+10 / 4.56e+10 (100%) +Item weight: 38000 / 38000 (100%) +Item profit: 4.56e+10 / 4.56e+10 (100%) +Number of stacks: 21 +Stack area: 25200000 +Number of bins: 2 / 2 (100%) +Bin volume: 191052000000 / 191052000000 (100%) +Bin area: 65880000 / 65880000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 1.91052e+11 +Waste: 77766000000 +Waste (%): 63.0368 +Full waste: 145452000000 +Full waste (%): 76.1322 +Volume load: 0.238678 +Area load: 0.382514 +Weight load: 0 +X max: 9600 +Y max: 1000 +Leftover value: 4.58139e+21 +Staircase leftover value: 67686000000 +Total leftover value: 4.9411e+21 +Total staircase leftover value: 86652000000 diff --git a/doc/examples/boxstacks/axle_weight_yes/solution.csv b/doc/examples/boxstacks/axle_weight_yes/solution.csv index c01ceaa07..bcc0dce20 100644 --- a/doc/examples/boxstacks/axle_weight_yes/solution.csv +++ b/doc/examples/boxstacks/axle_weight_yes/solution.csv @@ -1,57 +1,62 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,13500,2440,2900, -STACK,0,1,0,0,0,0,0,1200,1000,2400, -ITEM,1,1,0,0,0,0,0,1200,1000,800,0 -ITEM,1,1,0,0,0,0,800,1200,1000,800,0 -ITEM,1,1,0,0,0,0,1600,1200,1000,800,0 -STACK,1,1,0,1,1200,0,0,1200,1000,2400, -ITEM,1,1,0,1,1200,0,0,1200,1000,800,0 -ITEM,1,1,0,1,1200,0,800,1200,1000,800,0 -ITEM,1,1,0,1,1200,0,1600,1200,1000,800,0 -STACK,2,1,0,2,2400,0,0,1200,1000,2400, -ITEM,1,1,0,2,2400,0,0,1200,1000,800,0 -ITEM,1,1,0,2,2400,0,800,1200,1000,800,0 -ITEM,1,1,0,2,2400,0,1600,1200,1000,800,0 -STACK,3,1,0,3,3600,0,0,1200,1000,2400, -ITEM,1,1,0,3,3600,0,0,1200,1000,800,0 -ITEM,1,1,0,3,3600,0,800,1200,1000,800,0 -ITEM,1,1,0,3,3600,0,1600,1200,1000,800,0 -STACK,4,1,0,4,4800,0,0,1200,1000,2400, -ITEM,1,1,0,4,4800,0,0,1200,1000,800,0 -ITEM,1,1,0,4,4800,0,800,1200,1000,800,0 -ITEM,1,1,0,4,4800,0,1600,1200,1000,800,0 -STACK,5,1,0,5,6000,0,0,1200,1000,2000, -ITEM,0,1,0,5,6000,0,0,1200,1000,1200,0 -ITEM,1,1,0,5,6000,0,1200,1200,1000,800,0 -STACK,6,1,0,6,7200,1000,0,1200,1000,2400, -ITEM,0,1,0,6,7200,1000,0,1200,1000,1200,0 -ITEM,0,1,0,6,7200,1000,1200,1200,1000,1200,0 -STACK,7,1,0,7,7200,0,0,1200,1000,2400, -ITEM,0,1,0,7,7200,0,0,1200,1000,1200,0 -ITEM,0,1,0,7,7200,0,1200,1200,1000,1200,0 -STACK,8,1,0,8,8400,0,0,1200,1000,2400, -ITEM,0,1,0,8,8400,0,0,1200,1000,1200,0 -ITEM,0,1,0,8,8400,0,1200,1200,1000,1200,0 -STACK,9,1,0,9,8400,1000,0,1200,1000,2400, -ITEM,0,1,0,9,8400,1000,0,1200,1000,1200,0 -ITEM,0,1,0,9,8400,1000,1200,1200,1000,1200,0 -STACK,10,1,0,10,9600,0,0,1200,1000,2400, -ITEM,0,1,0,10,9600,0,0,1200,1000,1200,0 -ITEM,0,1,0,10,9600,0,1200,1200,1000,1200,0 -STACK,11,1,0,11,9600,1000,0,1200,1000,2400, -ITEM,0,1,0,11,9600,1000,0,1200,1000,1200,0 -ITEM,0,1,0,11,9600,1000,1200,1200,1000,1200,0 -STACK,12,1,0,12,10800,0,0,1200,1000,2400, -ITEM,0,1,0,12,10800,0,0,1200,1000,1200,0 -ITEM,0,1,0,12,10800,0,1200,1200,1000,1200,0 -STACK,13,1,0,13,10800,1000,0,1200,1000,2400, -ITEM,0,1,0,13,10800,1000,0,1200,1000,1200,0 -ITEM,0,1,0,13,10800,1000,1200,1200,1000,1200,0 -STACK,14,1,0,14,12000,0,0,1200,1000,2000, -ITEM,0,1,0,14,12000,0,0,1200,1000,1200,0 -ITEM,1,1,0,14,12000,0,1200,1200,1000,800,0 -BIN,0,1,1,-1,0,0,0,13500,2440,2900, -STACK,0,1,1,0,0,0,0,1200,1000,2800, -ITEM,0,1,1,0,0,0,0,1200,1000,1200,0 -ITEM,1,1,1,0,0,0,1200,1200,1000,800,0 -ITEM,1,1,1,0,0,0,2000,1200,1000,800,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,13500,2440,2900,, +STACK,0,1,0,0,0,0,0,1200,1000,2400,, +ITEM,0,1,0,0,0,0,0,1200,1000,1200,0,XYZ +ITEM,0,1,0,0,0,0,1200,1200,1000,1200,0,XYZ +STACK,1,1,0,1,0,1000,0,1200,1000,2800,, +ITEM,0,1,0,1,0,1000,0,1200,1000,1200,0,XYZ +ITEM,1,1,0,1,0,1000,1200,1200,1000,800,0,XYZ +ITEM,1,1,0,1,0,1000,2000,1200,1000,800,0,XYZ +STACK,2,1,0,2,1200,0,0,1200,1000,2400,, +ITEM,0,1,0,2,1200,0,0,1200,1000,1200,0,XYZ +ITEM,0,1,0,2,1200,0,1200,1200,1000,1200,0,XYZ +STACK,3,1,0,3,2400,0,0,1200,1000,800,, +ITEM,1,1,0,3,2400,0,0,1200,1000,800,0,XYZ +STACK,4,1,0,4,3600,0,0,1200,1000,800,, +ITEM,1,1,0,4,3600,0,0,1200,1000,800,0,XYZ +STACK,5,1,0,5,4800,0,0,1200,1000,800,, +ITEM,1,1,0,5,4800,0,0,1200,1000,800,0,XYZ +STACK,6,1,0,6,6000,0,0,1200,1000,800,, +ITEM,1,1,0,6,6000,0,0,1200,1000,800,0,XYZ +STACK,7,1,0,7,7200,0,0,1200,1000,800,, +ITEM,1,1,0,7,7200,0,0,1200,1000,800,0,XYZ +STACK,8,1,0,8,8400,0,0,1200,1000,800,, +ITEM,1,1,0,8,8400,0,0,1200,1000,800,0,XYZ +STACK,9,1,0,9,9600,0,0,1200,1000,1200,, +ITEM,0,1,0,9,9600,0,0,1200,1000,1200,0,XYZ +STACK,10,1,0,10,10800,0,0,1200,1000,2400,, +ITEM,0,1,0,10,10800,0,0,1200,1000,1200,0,XYZ +ITEM,0,1,0,10,10800,0,1200,1200,1000,1200,0,XYZ +STACK,11,1,0,11,12000,1000,0,1200,1000,2400,, +ITEM,0,1,0,11,12000,1000,0,1200,1000,1200,0,XYZ +ITEM,0,1,0,11,12000,1000,1200,1200,1000,1200,0,XYZ +STACK,12,1,0,12,12000,0,0,1200,1000,2800,, +ITEM,0,1,0,12,12000,0,0,1200,1000,1200,0,XYZ +ITEM,1,1,0,12,12000,0,1200,1200,1000,800,0,XYZ +ITEM,1,1,0,12,12000,0,2000,1200,1000,800,0,XYZ +BIN,0,1,1,-1,0,0,0,13500,2440,2900,, +STACK,0,1,1,0,0,0,0,1200,1000,800,, +ITEM,1,1,1,0,0,0,0,1200,1000,800,0,XYZ +STACK,1,1,1,1,1200,0,0,1200,1000,1200,, +ITEM,0,1,1,1,1200,0,0,1200,1000,1200,0,XYZ +STACK,2,1,1,2,2400,0,0,1200,1000,1200,, +ITEM,0,1,1,2,2400,0,0,1200,1000,1200,0,XYZ +STACK,3,1,1,3,3600,0,0,1200,1000,2400,, +ITEM,0,1,1,3,3600,0,0,1200,1000,1200,0,XYZ +ITEM,0,1,1,3,3600,0,1200,1200,1000,1200,0,XYZ +STACK,4,1,1,4,4800,0,0,1200,1000,2800,, +ITEM,0,1,1,4,4800,0,0,1200,1000,1200,0,XYZ +ITEM,1,1,1,4,4800,0,1200,1200,1000,800,0,XYZ +ITEM,1,1,1,4,4800,0,2000,1200,1000,800,0,XYZ +STACK,5,1,1,5,6000,0,0,1200,1000,2800,, +ITEM,0,1,1,5,6000,0,0,1200,1000,1200,0,XYZ +ITEM,1,1,1,5,6000,0,1200,1200,1000,800,0,XYZ +ITEM,1,1,1,5,6000,0,2000,1200,1000,800,0,XYZ +STACK,6,1,1,6,7200,0,0,1200,1000,2800,, +ITEM,0,1,1,6,7200,0,0,1200,1000,1200,0,XYZ +ITEM,1,1,1,6,7200,0,1200,1200,1000,800,0,XYZ +ITEM,1,1,1,6,7200,0,2000,1200,1000,800,0,XYZ +STACK,7,1,1,7,8400,0,0,1200,1000,2800,, +ITEM,0,1,1,7,8400,0,0,1200,1000,1200,0,XYZ +ITEM,1,1,1,7,8400,0,1200,1200,1000,800,0,XYZ +ITEM,1,1,1,7,8400,0,2000,1200,1000,800,0,XYZ diff --git a/doc/examples/boxstacks/basic/output.txt b/doc/examples/boxstacks/basic/output.txt index cba90d00a..a16d7f1f8 100644 --- a/doc/examples/boxstacks/basic/output.txt +++ b/doc/examples/boxstacks/basic/output.txt @@ -24,31 +24,39 @@ Total bin weight: inf Time Profit # items Comment ---- ------ ------- ------- - 0.002 5e+10 25 SOR it 0 + 0.015 5e+10 25 SOR X it 0 q 2 Final statistics ---------------- -Time (s): 0.00260734 +Time (s): 0.0342582 +Is proven infeasible: 0 +Primal bound: 5e+10 +Dual bound: 5.4e+10 +Gap: 8% Solution -------- -Number of items: 25 / 30 (83.3333%) -Item volume: 5e+10 / 6e+10 (83.3333%) -Item weight: 0 / 0 (-nan%) -Item profit: 5e+10 / 6e+10 (83.3333%) -Number of stacks: 9 -Stack area: 18000000 -Number of bins: 1 / 1 (100%) -Bin volume: 54000000000 / 54000000000 (100%) -Bin area: 18000000 / 18000000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 1.8e+07 -Waste: 4000000000 -Waste (%): 7.40741 -Full waste: 4000000000 -Full waste (%): 7.40741 -Volume load: 0.925926 -Area load: 1 -Weight load: 0 -X max: 7500 -Y max: 2400 +Number of items: 25 / 30 (83.3333%) +Item volume: 5e+10 / 6e+10 (83.3333%) +Item weight: 0 / 0 (-nan%) +Item profit: 5e+10 / 6e+10 (83.3333%) +Number of stacks: 9 +Stack area: 18000000 +Number of bins: 1 / 1 (100%) +Bin volume: 54000000000 / 54000000000 (100%) +Bin area: 18000000 / 18000000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 5.4e+10 +Waste: 4000000000 +Waste (%): 7.40741 +Full waste: 4000000000 +Full waste (%): 7.40741 +Volume load: 0.925926 +Area load: 1 +Weight load: 0 +X max: 7500 +Y max: 2400 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 0 +Total staircase leftover value: 0 diff --git a/doc/examples/boxstacks/basic/solution.csv b/doc/examples/boxstacks/basic/solution.csv index b24cdd24a..136d989f1 100644 --- a/doc/examples/boxstacks/basic/solution.csv +++ b/doc/examples/boxstacks/basic/solution.csv @@ -1,36 +1,36 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,7500,2400,3000, -STACK,0,1,0,0,0,0,0,2500,800,3000, -ITEM,0,1,0,0,0,0,0,2500,800,750,0 -ITEM,0,1,0,0,0,0,750,2500,800,750,0 -ITEM,0,1,0,0,0,0,1500,2500,800,750,0 -ITEM,0,1,0,0,0,0,2250,2500,800,750,0 -STACK,1,1,0,1,0,800,0,2500,800,3000, -ITEM,0,1,0,1,0,800,0,2500,800,750,0 -ITEM,0,1,0,1,0,800,750,2500,800,750,0 -ITEM,0,1,0,1,0,800,1500,2500,800,750,0 -ITEM,0,1,0,1,0,800,2250,2500,800,750,0 -STACK,2,1,0,2,0,1600,0,2500,800,3000, -ITEM,1,1,0,2,0,1600,0,2500,800,1000,0 -ITEM,1,1,0,2,0,1600,1000,2500,800,1000,0 -ITEM,1,1,0,2,0,1600,2000,2500,800,1000,0 -STACK,3,1,0,3,2500,0,0,2500,800,3000, -ITEM,1,1,0,3,2500,0,0,2500,800,1000,0 -ITEM,1,1,0,3,2500,0,1000,2500,800,1000,0 -ITEM,1,1,0,3,2500,0,2000,2500,800,1000,0 -STACK,4,1,0,4,2500,800,0,2500,800,3000, -ITEM,1,1,0,4,2500,800,0,2500,800,1000,0 -ITEM,1,1,0,4,2500,800,1000,2500,800,1000,0 -ITEM,1,1,0,4,2500,800,2000,2500,800,1000,0 -STACK,5,1,0,5,2500,1600,0,2500,800,2500, -ITEM,2,1,0,5,2500,1600,0,2500,800,1250,0 -ITEM,2,1,0,5,2500,1600,1250,2500,800,1250,0 -STACK,6,1,0,6,5000,0,0,2500,800,2500, -ITEM,2,1,0,6,5000,0,0,2500,800,1250,0 -ITEM,2,1,0,6,5000,0,1250,2500,800,1250,0 -STACK,7,1,0,7,5000,800,0,2500,800,2500, -ITEM,2,1,0,7,5000,800,0,2500,800,1250,0 -ITEM,2,1,0,7,5000,800,1250,2500,800,1250,0 -STACK,8,1,0,8,5000,1600,0,2500,800,2500, -ITEM,2,1,0,8,5000,1600,0,2500,800,1250,0 -ITEM,2,1,0,8,5000,1600,1250,2500,800,1250,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,7500,2400,3000,, +STACK,0,1,0,0,0,0,0,2500,800,3000,, +ITEM,0,1,0,0,0,0,0,2500,800,750,0,XYZ +ITEM,0,1,0,0,0,0,750,2500,800,750,0,XYZ +ITEM,0,1,0,0,0,0,1500,2500,800,750,0,XYZ +ITEM,0,1,0,0,0,0,2250,2500,800,750,0,XYZ +STACK,1,1,0,1,0,800,0,2500,800,3000,, +ITEM,0,1,0,1,0,800,0,2500,800,750,0,XYZ +ITEM,0,1,0,1,0,800,750,2500,800,750,0,XYZ +ITEM,0,1,0,1,0,800,1500,2500,800,750,0,XYZ +ITEM,0,1,0,1,0,800,2250,2500,800,750,0,XYZ +STACK,2,1,0,2,0,1600,0,2500,800,3000,, +ITEM,1,1,0,2,0,1600,0,2500,800,1000,0,XYZ +ITEM,1,1,0,2,0,1600,1000,2500,800,1000,0,XYZ +ITEM,1,1,0,2,0,1600,2000,2500,800,1000,0,XYZ +STACK,3,1,0,3,2500,0,0,2500,800,3000,, +ITEM,1,1,0,3,2500,0,0,2500,800,1000,0,XYZ +ITEM,1,1,0,3,2500,0,1000,2500,800,1000,0,XYZ +ITEM,1,1,0,3,2500,0,2000,2500,800,1000,0,XYZ +STACK,4,1,0,4,2500,800,0,2500,800,3000,, +ITEM,1,1,0,4,2500,800,0,2500,800,1000,0,XYZ +ITEM,1,1,0,4,2500,800,1000,2500,800,1000,0,XYZ +ITEM,1,1,0,4,2500,800,2000,2500,800,1000,0,XYZ +STACK,5,1,0,5,2500,1600,0,2500,800,2500,, +ITEM,2,1,0,5,2500,1600,0,2500,800,1250,0,XYZ +ITEM,2,1,0,5,2500,1600,1250,2500,800,1250,0,XYZ +STACK,6,1,0,6,5000,0,0,2500,800,2500,, +ITEM,2,1,0,6,5000,0,0,2500,800,1250,0,XYZ +ITEM,2,1,0,6,5000,0,1250,2500,800,1250,0,XYZ +STACK,7,1,0,7,5000,800,0,2500,800,2500,, +ITEM,2,1,0,7,5000,800,0,2500,800,1250,0,XYZ +ITEM,2,1,0,7,5000,800,1250,2500,800,1250,0,XYZ +STACK,8,1,0,8,5000,1600,0,2500,800,2500,, +ITEM,2,1,0,8,5000,1600,0,2500,800,1250,0,XYZ +ITEM,2,1,0,8,5000,1600,1250,2500,800,1250,0,XYZ diff --git a/doc/examples/boxstacks/box_vs_boxstacks/output.txt b/doc/examples/boxstacks/box_vs_boxstacks/output.txt index 34d0e09a1..9b876d0fe 100644 --- a/doc/examples/boxstacks/box_vs_boxstacks/output.txt +++ b/doc/examples/boxstacks/box_vs_boxstacks/output.txt @@ -24,31 +24,39 @@ Total bin weight: inf Time Profit # items Comment ---- ------ ------- ------- - 0.064 4.7688e+10 36 SOR it 0 + 0.008 4.7688e+10 36 SOR X it 0 q 2 Final statistics ---------------- -Time (s): 0.103086 +Time (s): 10.044 +Is proven infeasible: 0 +Primal bound: 4.7688e+10 +Dual bound: 4.8952e+10 +Gap: 2.65056% Solution -------- -Number of items: 36 / 48 (75%) -Item volume: 4.7688e+10 / 4.8952e+10 (97.4179%) -Item weight: 0 / 0 (-nan%) -Item profit: 4.7688e+10 / 4.8952e+10 (97.4179%) -Number of stacks: 12 -Stack area: 18000000 -Number of bins: 1 / 1 (100%) -Bin volume: 54000000000 / 54000000000 (100%) -Bin area: 18000000 / 18000000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 1.8e+07 -Waste: 6312000000 -Waste (%): 11.6889 -Full waste: 6312000000 -Full waste (%): 11.6889 -Volume load: 0.883111 -Area load: 1 -Weight load: 0 -X max: 7500 -Y max: 2400 +Number of items: 36 / 48 (75%) +Item volume: 4.7688e+10 / 4.8952e+10 (97.4179%) +Item weight: 0 / 0 (-nan%) +Item profit: 4.7688e+10 / 4.8952e+10 (97.4179%) +Number of stacks: 12 +Stack area: 18000000 +Number of bins: 1 / 1 (100%) +Bin volume: 54000000000 / 54000000000 (100%) +Bin area: 18000000 / 18000000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 5.4e+10 +Waste: 6312000000 +Waste (%): 11.6889 +Full waste: 6312000000 +Full waste (%): 11.6889 +Volume load: 0.883111 +Area load: 1 +Weight load: 0 +X max: 7500 +Y max: 2400 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 0 +Total staircase leftover value: 0 diff --git a/doc/examples/boxstacks/box_vs_boxstacks/solution.csv b/doc/examples/boxstacks/box_vs_boxstacks/solution.csv index d74a343f3..67796d107 100644 --- a/doc/examples/boxstacks/box_vs_boxstacks/solution.csv +++ b/doc/examples/boxstacks/box_vs_boxstacks/solution.csv @@ -1,50 +1,50 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,7500,2400,3000, -STACK,0,1,0,0,0,0,0,1300,1200,3000, -ITEM,0,1,0,0,0,0,0,1300,1200,1500,0 -ITEM,0,1,0,0,0,0,1500,1300,1200,1500,0 -STACK,1,1,0,1,0,1200,0,1300,1200,3000, -ITEM,0,1,0,1,0,1200,0,1300,1200,1500,0 -ITEM,0,1,0,1,0,1200,1500,1300,1200,1500,0 -STACK,2,1,0,2,1300,0,0,1300,1200,2750, -ITEM,1,1,0,2,1300,0,0,1300,1200,550,0 -ITEM,1,1,0,2,1300,0,550,1300,1200,550,0 -ITEM,1,1,0,2,1300,0,1100,1300,1200,550,0 -ITEM,1,1,0,2,1300,0,1650,1300,1200,550,0 -ITEM,1,1,0,2,1300,0,2200,1300,1200,550,0 -STACK,3,1,0,3,1300,1200,0,1200,1200,2700, -ITEM,3,1,0,3,1300,1200,0,1200,1200,450,0 -ITEM,3,1,0,3,1300,1200,450,1200,1200,450,0 -ITEM,3,1,0,3,1300,1200,900,1200,1200,450,0 -ITEM,3,1,0,3,1300,1200,1350,1200,1200,450,0 -ITEM,3,1,0,3,1300,1200,1800,1200,1200,450,0 -ITEM,3,1,0,3,1300,1200,2250,1200,1200,450,0 -STACK,4,1,0,4,2500,1200,0,1200,1200,2700, -ITEM,3,1,0,4,2500,1200,0,1200,1200,450,0 -ITEM,3,1,0,4,2500,1200,450,1200,1200,450,0 -ITEM,3,1,0,4,2500,1200,900,1200,1200,450,0 -ITEM,3,1,0,4,2500,1200,1350,1200,1200,450,0 -ITEM,3,1,0,4,2500,1200,1800,1200,1200,450,0 -ITEM,3,1,0,4,2500,1200,2250,1200,1200,450,0 -STACK,5,1,0,5,2600,0,0,1250,1200,2700, -ITEM,4,1,0,5,2600,0,0,1250,1200,1600,0 -ITEM,5,1,0,5,2600,0,1600,1250,1200,1100,0 -STACK,6,1,0,6,3700,1200,0,1250,1200,2700, -ITEM,4,1,0,6,3700,1200,0,1250,1200,1600,0 -ITEM,5,1,0,6,3700,1200,1600,1250,1200,1100,0 -STACK,7,1,0,7,3850,0,0,1250,1200,2700, -ITEM,4,1,0,7,3850,0,0,1250,1200,1600,0 -ITEM,5,1,0,7,3850,0,1600,1250,1200,1100,0 -STACK,8,1,0,8,4950,1200,0,1250,1200,2700, -ITEM,4,1,0,8,4950,1200,0,1250,1200,1600,0 -ITEM,5,1,0,8,4950,1200,1600,1250,1200,1100,0 -STACK,9,1,0,9,5100,0,0,1200,1200,2600, -ITEM,2,1,0,9,5100,0,0,1200,1200,1300,0 -ITEM,2,1,0,9,5100,0,1300,1200,1200,1300,0 -STACK,10,1,0,10,6300,0,0,1200,1200,2600, -ITEM,2,1,0,10,6300,0,0,1200,1200,1300,0 -ITEM,2,1,0,10,6300,0,1300,1200,1200,1300,0 -STACK,11,1,0,11,6200,1200,0,1300,1200,1650, -ITEM,1,1,0,11,6200,1200,0,1300,1200,550,0 -ITEM,1,1,0,11,6200,1200,550,1300,1200,550,0 -ITEM,1,1,0,11,6200,1200,1100,1300,1200,550,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,7500,2400,3000,, +STACK,0,1,0,0,0,0,0,1300,1200,3000,, +ITEM,0,1,0,0,0,0,0,1300,1200,1500,0,XYZ +ITEM,0,1,0,0,0,0,1500,1300,1200,1500,0,XYZ +STACK,1,1,0,1,0,1200,0,1300,1200,2750,, +ITEM,1,1,0,1,0,1200,0,1300,1200,550,0,XYZ +ITEM,1,1,0,1,0,1200,550,1300,1200,550,0,XYZ +ITEM,1,1,0,1,0,1200,1100,1300,1200,550,0,XYZ +ITEM,1,1,0,1,0,1200,1650,1300,1200,550,0,XYZ +ITEM,1,1,0,1,0,1200,2200,1300,1200,550,0,XYZ +STACK,2,1,0,2,1300,0,0,1200,1200,2700,, +ITEM,3,1,0,2,1300,0,0,1200,1200,450,0,XYZ +ITEM,3,1,0,2,1300,0,450,1200,1200,450,0,XYZ +ITEM,3,1,0,2,1300,0,900,1200,1200,450,0,XYZ +ITEM,3,1,0,2,1300,0,1350,1200,1200,450,0,XYZ +ITEM,3,1,0,2,1300,0,1800,1200,1200,450,0,XYZ +ITEM,3,1,0,2,1300,0,2250,1200,1200,450,0,XYZ +STACK,3,1,0,3,1300,1200,0,1200,1200,2700,, +ITEM,3,1,0,3,1300,1200,0,1200,1200,450,0,XYZ +ITEM,3,1,0,3,1300,1200,450,1200,1200,450,0,XYZ +ITEM,3,1,0,3,1300,1200,900,1200,1200,450,0,XYZ +ITEM,3,1,0,3,1300,1200,1350,1200,1200,450,0,XYZ +ITEM,3,1,0,3,1300,1200,1800,1200,1200,450,0,XYZ +ITEM,3,1,0,3,1300,1200,2250,1200,1200,450,0,XYZ +STACK,4,1,0,4,2500,0,0,1250,1200,2700,, +ITEM,4,1,0,4,2500,0,0,1250,1200,1600,0,XYZ +ITEM,5,1,0,4,2500,0,1600,1250,1200,1100,0,XYZ +STACK,5,1,0,5,2500,1200,0,1250,1200,2700,, +ITEM,4,1,0,5,2500,1200,0,1250,1200,1600,0,XYZ +ITEM,5,1,0,5,2500,1200,1600,1250,1200,1100,0,XYZ +STACK,6,1,0,6,3750,0,0,1250,1200,2700,, +ITEM,4,1,0,6,3750,0,0,1250,1200,1600,0,XYZ +ITEM,5,1,0,6,3750,0,1600,1250,1200,1100,0,XYZ +STACK,7,1,0,7,3750,1200,0,1250,1200,2700,, +ITEM,4,1,0,7,3750,1200,0,1250,1200,1600,0,XYZ +ITEM,5,1,0,7,3750,1200,1600,1250,1200,1100,0,XYZ +STACK,8,1,0,8,5000,0,0,1200,1200,2600,, +ITEM,2,1,0,8,5000,0,0,1200,1200,1300,0,XYZ +ITEM,2,1,0,8,5000,0,1300,1200,1200,1300,0,XYZ +STACK,9,1,0,9,5000,1200,0,1200,1200,2600,, +ITEM,2,1,0,9,5000,1200,0,1200,1200,1300,0,XYZ +ITEM,2,1,0,9,5000,1200,1300,1200,1200,1300,0,XYZ +STACK,10,1,0,10,6200,0,0,1300,1200,2600,, +ITEM,0,1,0,10,6200,0,0,1300,1200,1500,0,XYZ +ITEM,1,1,0,10,6200,0,1500,1300,1200,550,0,XYZ +ITEM,1,1,0,10,6200,0,2050,1300,1200,550,0,XYZ +STACK,11,1,0,11,6200,1200,0,1300,1200,2050,, +ITEM,0,1,0,11,6200,1200,0,1300,1200,1500,0,XYZ +ITEM,1,1,0,11,6200,1200,1500,1300,1200,550,0,XYZ diff --git a/doc/examples/boxstacks/maximum_stack_density_no/output.txt b/doc/examples/boxstacks/maximum_stack_density_no/output.txt index ec74f7b9f..8b001c0a5 100644 --- a/doc/examples/boxstacks/maximum_stack_density_no/output.txt +++ b/doc/examples/boxstacks/maximum_stack_density_no/output.txt @@ -24,31 +24,39 @@ Total bin weight: inf Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.001 1 0.00 iteration 0 + 0.002 1 0.00 SVC it 0 Final statistics ---------------- -Time (s): 0.00108898 +Time (s): 0.00420832 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 18 / 18 (100%) -Item volume: 5.4e+10 / 5.4e+10 (100%) -Item weight: 1.44e+07 / 1.44e+07 (100%) -Item profit: 5.4e+10 / 5.4e+10 (100%) -Number of stacks: 6 -Stack area: 18000000 -Number of bins: 1 / 4 (25%) -Bin volume: 54000000000 / 216000000000 (25%) -Bin area: 18000000 / 72000000 (25%) -Bin weight: inf / inf (-nan%) -Bin cost: 1.8e+07 -Waste: 0 -Waste (%): 0 -Full waste: 0 -Full waste (%): 0 -Volume load: 0.25 -Area load: 0.25 -Weight load: 0 -X max: 7500 -Y max: 2400 +Number of items: 18 / 18 (100%) +Item volume: 5.4e+10 / 5.4e+10 (100%) +Item weight: 1.44e+07 / 1.44e+07 (100%) +Item profit: 5.4e+10 / 5.4e+10 (100%) +Number of stacks: 6 +Stack area: 18000000 +Number of bins: 1 / 4 (25%) +Bin volume: 54000000000 / 216000000000 (25%) +Bin area: 18000000 / 72000000 (25%) +Bin weight: inf / inf (-nan%) +Bin cost: 5.4e+10 +Waste: 0 +Waste (%): 0 +Full waste: 0 +Full waste (%): 0 +Volume load: 0.25 +Area load: 0.25 +Weight load: 0 +X max: 7500 +Y max: 2400 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 8.748e+21 +Total staircase leftover value: 162000000000 diff --git a/doc/examples/boxstacks/maximum_stack_density_no/solution.csv b/doc/examples/boxstacks/maximum_stack_density_no/solution.csv index eff6b15f4..b56fb6232 100644 --- a/doc/examples/boxstacks/maximum_stack_density_no/solution.csv +++ b/doc/examples/boxstacks/maximum_stack_density_no/solution.csv @@ -1,26 +1,26 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,7500,2400,3000, -STACK,0,1,0,0,0,0,0,2500,1200,3000, -ITEM,0,1,0,0,0,0,0,2500,1200,1000,0 -ITEM,0,1,0,0,0,0,1000,2500,1200,1000,0 -ITEM,0,1,0,0,0,0,2000,2500,1200,1000,0 -STACK,1,1,0,1,0,1200,0,2500,1200,3000, -ITEM,0,1,0,1,0,1200,0,2500,1200,1000,0 -ITEM,0,1,0,1,0,1200,1000,2500,1200,1000,0 -ITEM,0,1,0,1,0,1200,2000,2500,1200,1000,0 -STACK,2,1,0,2,2500,0,0,2500,1200,3000, -ITEM,0,1,0,2,2500,0,0,2500,1200,1000,0 -ITEM,0,1,0,2,2500,0,1000,2500,1200,1000,0 -ITEM,0,1,0,2,2500,0,2000,2500,1200,1000,0 -STACK,3,1,0,3,2500,1200,0,2500,1200,3000, -ITEM,1,1,0,3,2500,1200,0,2500,1200,1000,0 -ITEM,1,1,0,3,2500,1200,1000,2500,1200,1000,0 -ITEM,1,1,0,3,2500,1200,2000,2500,1200,1000,0 -STACK,4,1,0,4,5000,0,0,2500,1200,3000, -ITEM,1,1,0,4,5000,0,0,2500,1200,1000,0 -ITEM,1,1,0,4,5000,0,1000,2500,1200,1000,0 -ITEM,1,1,0,4,5000,0,2000,2500,1200,1000,0 -STACK,5,1,0,5,5000,1200,0,2500,1200,3000, -ITEM,1,1,0,5,5000,1200,0,2500,1200,1000,0 -ITEM,1,1,0,5,5000,1200,1000,2500,1200,1000,0 -ITEM,1,1,0,5,5000,1200,2000,2500,1200,1000,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,7500,2400,3000,, +STACK,0,1,0,0,0,0,0,2500,1200,3000,, +ITEM,0,1,0,0,0,0,0,2500,1200,1000,0,XYZ +ITEM,0,1,0,0,0,0,1000,2500,1200,1000,0,XYZ +ITEM,0,1,0,0,0,0,2000,2500,1200,1000,0,XYZ +STACK,1,1,0,1,0,1200,0,2500,1200,3000,, +ITEM,0,1,0,1,0,1200,0,2500,1200,1000,0,XYZ +ITEM,0,1,0,1,0,1200,1000,2500,1200,1000,0,XYZ +ITEM,0,1,0,1,0,1200,2000,2500,1200,1000,0,XYZ +STACK,2,1,0,2,2500,0,0,2500,1200,3000,, +ITEM,0,1,0,2,2500,0,0,2500,1200,1000,0,XYZ +ITEM,0,1,0,2,2500,0,1000,2500,1200,1000,0,XYZ +ITEM,0,1,0,2,2500,0,2000,2500,1200,1000,0,XYZ +STACK,3,1,0,3,2500,1200,0,2500,1200,3000,, +ITEM,1,1,0,3,2500,1200,0,2500,1200,1000,0,XYZ +ITEM,1,1,0,3,2500,1200,1000,2500,1200,1000,0,XYZ +ITEM,1,1,0,3,2500,1200,2000,2500,1200,1000,0,XYZ +STACK,4,1,0,4,5000,0,0,2500,1200,3000,, +ITEM,1,1,0,4,5000,0,0,2500,1200,1000,0,XYZ +ITEM,1,1,0,4,5000,0,1000,2500,1200,1000,0,XYZ +ITEM,1,1,0,4,5000,0,2000,2500,1200,1000,0,XYZ +STACK,5,1,0,5,5000,1200,0,2500,1200,3000,, +ITEM,1,1,0,5,5000,1200,0,2500,1200,1000,0,XYZ +ITEM,1,1,0,5,5000,1200,1000,2500,1200,1000,0,XYZ +ITEM,1,1,0,5,5000,1200,2000,2500,1200,1000,0,XYZ diff --git a/doc/examples/boxstacks/maximum_stack_density_yes/output.txt b/doc/examples/boxstacks/maximum_stack_density_yes/output.txt index 810185ddc..f5ef39cf5 100644 --- a/doc/examples/boxstacks/maximum_stack_density_yes/output.txt +++ b/doc/examples/boxstacks/maximum_stack_density_yes/output.txt @@ -24,31 +24,39 @@ Total bin weight: inf Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.004 2 50.00 iteration 0 + 0.004 2 50.00 SVC it 0 Final statistics ---------------- -Time (s): 0.00391748 +Time (s): 0.00423416 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 1 +Gap: 50% Solution -------- -Number of items: 18 / 18 (100%) -Item volume: 5.4e+10 / 5.4e+10 (100%) -Item weight: 1.44e+07 / 1.44e+07 (100%) -Item profit: 5.4e+10 / 5.4e+10 (100%) -Number of stacks: 9 -Stack area: 27000000 -Number of bins: 2 / 4 (50%) -Bin volume: 108000000000 / 216000000000 (50%) -Bin area: 36000000 / 72000000 (50%) -Bin weight: inf / inf (-nan%) -Bin cost: 3.6e+07 -Waste: 36000000000 -Waste (%): 40 -Full waste: 54000000000 -Full waste (%): 50 -Volume load: 0.25 -Area load: 0.375 -Weight load: 0 -X max: 5000 -Y max: 2400 +Number of items: 18 / 18 (100%) +Item volume: 5.4e+10 / 5.4e+10 (100%) +Item weight: 1.44e+07 / 1.44e+07 (100%) +Item profit: 5.4e+10 / 5.4e+10 (100%) +Number of stacks: 9 +Stack area: 27000000 +Number of bins: 2 / 4 (50%) +Bin volume: 108000000000 / 216000000000 (50%) +Bin area: 36000000 / 72000000 (50%) +Bin weight: inf / inf (-nan%) +Bin cost: 1.08e+11 +Waste: 36000000000 +Waste (%): 40 +Full waste: 54000000000 +Full waste (%): 50 +Volume load: 0.25 +Area load: 0.375 +Weight load: 0 +X max: 5000 +Y max: 2400 +Leftover value: 3.24e+20 +Staircase leftover value: 27000000000 +Total leftover value: 6.156e+21 +Total staircase leftover value: 135000000000 diff --git a/doc/examples/boxstacks/maximum_stack_density_yes/solution.csv b/doc/examples/boxstacks/maximum_stack_density_yes/solution.csv index afbd542b6..f3b603fb5 100644 --- a/doc/examples/boxstacks/maximum_stack_density_yes/solution.csv +++ b/doc/examples/boxstacks/maximum_stack_density_yes/solution.csv @@ -1,30 +1,30 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,7500,2400,3000, -STACK,0,1,0,0,0,0,0,2500,1200,2000, -ITEM,0,1,0,0,0,0,0,2500,1200,1000,0 -ITEM,0,1,0,0,0,0,1000,2500,1200,1000,0 -STACK,1,1,0,1,0,1200,0,2500,1200,2000, -ITEM,0,1,0,1,0,1200,0,2500,1200,1000,0 -ITEM,0,1,0,1,0,1200,1000,2500,1200,1000,0 -STACK,2,1,0,2,2500,0,0,2500,1200,2000, -ITEM,0,1,0,2,2500,0,0,2500,1200,1000,0 -ITEM,0,1,0,2,2500,0,1000,2500,1200,1000,0 -STACK,3,1,0,3,2500,1200,0,2500,1200,2000, -ITEM,0,1,0,3,2500,1200,0,2500,1200,1000,0 -ITEM,0,1,0,3,2500,1200,1000,2500,1200,1000,0 -STACK,4,1,0,4,5000,0,0,2500,1200,2000, -ITEM,1,1,0,4,5000,0,0,2500,1200,1000,0 -ITEM,1,1,0,4,5000,0,1000,2500,1200,1000,0 -STACK,5,1,0,5,5000,1200,0,2500,1200,2000, -ITEM,1,1,0,5,5000,1200,0,2500,1200,1000,0 -ITEM,1,1,0,5,5000,1200,1000,2500,1200,1000,0 -BIN,0,1,1,-1,0,0,0,7500,2400,3000, -STACK,0,1,1,0,0,0,0,2500,1200,2000, -ITEM,0,1,1,0,0,0,0,2500,1200,1000,0 -ITEM,1,1,1,0,0,0,1000,2500,1200,1000,0 -STACK,1,1,1,1,0,1200,0,2500,1200,2000, -ITEM,1,1,1,1,0,1200,0,2500,1200,1000,0 -ITEM,1,1,1,1,0,1200,1000,2500,1200,1000,0 -STACK,2,1,1,2,2500,0,0,2500,1200,2000, -ITEM,1,1,1,2,2500,0,0,2500,1200,1000,0 -ITEM,1,1,1,2,2500,0,1000,2500,1200,1000,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,7500,2400,3000,, +STACK,0,1,0,0,0,0,0,2500,1200,2000,, +ITEM,0,1,0,0,0,0,0,2500,1200,1000,0,XYZ +ITEM,0,1,0,0,0,0,1000,2500,1200,1000,0,XYZ +STACK,1,1,0,1,0,1200,0,2500,1200,2000,, +ITEM,0,1,0,1,0,1200,0,2500,1200,1000,0,XYZ +ITEM,0,1,0,1,0,1200,1000,2500,1200,1000,0,XYZ +STACK,2,1,0,2,2500,0,0,2500,1200,2000,, +ITEM,0,1,0,2,2500,0,0,2500,1200,1000,0,XYZ +ITEM,0,1,0,2,2500,0,1000,2500,1200,1000,0,XYZ +STACK,3,1,0,3,2500,1200,0,2500,1200,2000,, +ITEM,0,1,0,3,2500,1200,0,2500,1200,1000,0,XYZ +ITEM,0,1,0,3,2500,1200,1000,2500,1200,1000,0,XYZ +STACK,4,1,0,4,5000,0,0,2500,1200,2000,, +ITEM,1,1,0,4,5000,0,0,2500,1200,1000,0,XYZ +ITEM,1,1,0,4,5000,0,1000,2500,1200,1000,0,XYZ +STACK,5,1,0,5,5000,1200,0,2500,1200,2000,, +ITEM,1,1,0,5,5000,1200,0,2500,1200,1000,0,XYZ +ITEM,1,1,0,5,5000,1200,1000,2500,1200,1000,0,XYZ +BIN,0,1,1,-1,0,0,0,7500,2400,3000,, +STACK,0,1,1,0,0,0,0,2500,1200,2000,, +ITEM,0,1,1,0,0,0,0,2500,1200,1000,0,XYZ +ITEM,1,1,1,0,0,0,1000,2500,1200,1000,0,XYZ +STACK,1,1,1,1,0,1200,0,2500,1200,2000,, +ITEM,1,1,1,1,0,1200,0,2500,1200,1000,0,XYZ +ITEM,1,1,1,1,0,1200,1000,2500,1200,1000,0,XYZ +STACK,2,1,1,2,2500,0,0,2500,1200,2000,, +ITEM,1,1,1,2,2500,0,0,2500,1200,1000,0,XYZ +ITEM,1,1,1,2,2500,0,1000,2500,1200,1000,0,XYZ diff --git a/doc/examples/boxstacks/maximum_stackability_no/output.txt b/doc/examples/boxstacks/maximum_stackability_no/output.txt index 149cec9fa..13a804d45 100644 --- a/doc/examples/boxstacks/maximum_stackability_no/output.txt +++ b/doc/examples/boxstacks/maximum_stackability_no/output.txt @@ -24,31 +24,39 @@ Total bin weight: inf Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.001 1 20.00 iteration 0 + 0.002 1 20.00 SVC it 0 Final statistics ---------------- -Time (s): 0.00110704 +Time (s): 0.00428273 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 7 / 7 (100%) -Item volume: 4.32e+10 / 4.32e+10 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 4.32e+10 / 4.32e+10 (100%) -Number of stacks: 2 -Stack area: 14400000 -Number of bins: 1 / 2 (50%) -Bin volume: 54000000000 / 108000000000 (50%) -Bin area: 18000000 / 36000000 (50%) -Bin weight: inf / inf (-nan%) -Bin cost: 1.8e+07 -Waste: 0 -Waste (%): 0 -Full waste: 10800000000 -Full waste (%): 20 -Volume load: 0.4 -Area load: 0.4 -Weight load: 0 -X max: 6000 -Y max: 2400 +Number of items: 7 / 7 (100%) +Item volume: 4.32e+10 / 4.32e+10 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 4.32e+10 / 4.32e+10 (100%) +Number of stacks: 2 +Stack area: 14400000 +Number of bins: 1 / 2 (50%) +Bin volume: 54000000000 / 108000000000 (50%) +Bin area: 18000000 / 36000000 (50%) +Bin weight: inf / inf (-nan%) +Bin cost: 5.4e+10 +Waste: 0 +Waste (%): 0 +Full waste: 10800000000 +Full waste (%): 20 +Volume load: 0.4 +Area load: 0.4 +Weight load: 0 +X max: 6000 +Y max: 2400 +Leftover value: 1.1664e+20 +Staircase leftover value: 10800000000 +Total leftover value: 3.03264e+21 +Total staircase leftover value: 64800000000 diff --git a/doc/examples/boxstacks/maximum_stackability_no/solution.csv b/doc/examples/boxstacks/maximum_stackability_no/solution.csv index 15664a541..2afc9d3b6 100644 --- a/doc/examples/boxstacks/maximum_stackability_no/solution.csv +++ b/doc/examples/boxstacks/maximum_stackability_no/solution.csv @@ -1,11 +1,11 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,7500,2400,3000, -STACK,0,1,0,0,0,0,0,3000,2400,3000, -ITEM,0,1,0,0,0,0,0,3000,2400,1200,0 -ITEM,0,1,0,0,0,0,1200,3000,2400,1200,0 -ITEM,1,1,0,0,0,0,2400,3000,2400,600,0 -STACK,1,1,0,1,3000,0,0,3000,2400,3000, -ITEM,0,1,0,1,3000,0,0,3000,2400,1200,0 -ITEM,1,1,0,1,3000,0,1200,3000,2400,600,0 -ITEM,1,1,0,1,3000,0,1800,3000,2400,600,0 -ITEM,1,1,0,1,3000,0,2400,3000,2400,600,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,7500,2400,3000,, +STACK,0,1,0,0,0,0,0,3000,2400,3000,, +ITEM,0,1,0,0,0,0,0,3000,2400,1200,0,XYZ +ITEM,0,1,0,0,0,0,1200,3000,2400,1200,0,XYZ +ITEM,1,1,0,0,0,0,2400,3000,2400,600,0,XYZ +STACK,1,1,0,1,3000,0,0,3000,2400,3000,, +ITEM,0,1,0,1,3000,0,0,3000,2400,1200,0,XYZ +ITEM,1,1,0,1,3000,0,1200,3000,2400,600,0,XYZ +ITEM,1,1,0,1,3000,0,1800,3000,2400,600,0,XYZ +ITEM,1,1,0,1,3000,0,2400,3000,2400,600,0,XYZ diff --git a/doc/examples/boxstacks/maximum_stackability_yes/output.txt b/doc/examples/boxstacks/maximum_stackability_yes/output.txt index a10d0d051..085f89243 100644 --- a/doc/examples/boxstacks/maximum_stackability_yes/output.txt +++ b/doc/examples/boxstacks/maximum_stackability_yes/output.txt @@ -24,31 +24,39 @@ Total bin weight: inf Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.004 2 60.00 iteration 0 + 0.010 2 60.00 SVC it 0 Final statistics ---------------- -Time (s): 0.00472797 +Time (s): 0.0126708 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 1 +Gap: 50% Solution -------- -Number of items: 7 / 7 (100%) -Item volume: 4.32e+10 / 4.32e+10 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 4.32e+10 / 4.32e+10 (100%) -Number of stacks: 3 -Stack area: 21600000 -Number of bins: 2 / 2 (100%) -Bin volume: 108000000000 / 108000000000 (100%) -Bin area: 36000000 / 36000000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 3.6e+07 -Waste: 32400000000 -Waste (%): 42.8571 -Full waste: 64800000000 -Full waste (%): 60 -Volume load: 0.4 -Area load: 0.6 -Weight load: 0 -X max: 3000 -Y max: 2400 +Number of items: 7 / 7 (100%) +Item volume: 4.32e+10 / 4.32e+10 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 4.32e+10 / 4.32e+10 (100%) +Number of stacks: 3 +Stack area: 21600000 +Number of bins: 2 / 2 (100%) +Bin volume: 108000000000 / 108000000000 (100%) +Bin area: 36000000 / 36000000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 1.08e+11 +Waste: 32400000000 +Waste (%): 42.8571 +Full waste: 64800000000 +Full waste (%): 60 +Volume load: 0.4 +Area load: 0.6 +Weight load: 0 +X max: 3000 +Y max: 2400 +Leftover value: 1.04976e+21 +Staircase leftover value: 32400000000 +Total leftover value: 1.1664e+21 +Total staircase leftover value: 43200000000 diff --git a/doc/examples/boxstacks/maximum_stackability_yes/solution.csv b/doc/examples/boxstacks/maximum_stackability_yes/solution.csv index 5915e6dd7..57f8b3801 100644 --- a/doc/examples/boxstacks/maximum_stackability_yes/solution.csv +++ b/doc/examples/boxstacks/maximum_stackability_yes/solution.csv @@ -1,13 +1,13 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,7500,2400,3000, -STACK,0,1,0,0,0,0,0,3000,2400,3000, -ITEM,0,1,0,0,0,0,0,3000,2400,1200,0 -ITEM,0,1,0,0,0,0,1200,3000,2400,1200,0 -ITEM,1,1,0,0,0,0,2400,3000,2400,600,0 -STACK,1,1,0,1,3000,0,0,3000,2400,2400, -ITEM,0,1,0,1,3000,0,0,3000,2400,1200,0 -ITEM,1,1,0,1,3000,0,1200,3000,2400,600,0 -ITEM,1,1,0,1,3000,0,1800,3000,2400,600,0 -BIN,0,1,1,-1,0,0,0,7500,2400,3000, -STACK,0,1,1,0,0,0,0,3000,2400,600, -ITEM,1,1,1,0,0,0,0,3000,2400,600,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,7500,2400,3000,, +STACK,0,1,0,0,0,0,0,3000,2400,3000,, +ITEM,0,1,0,0,0,0,0,3000,2400,1200,0,XYZ +ITEM,0,1,0,0,0,0,1200,3000,2400,1200,0,XYZ +ITEM,1,1,0,0,0,0,2400,3000,2400,600,0,XYZ +STACK,1,1,0,1,3000,0,0,3000,2400,2400,, +ITEM,0,1,0,1,3000,0,0,3000,2400,1200,0,XYZ +ITEM,1,1,0,1,3000,0,1200,3000,2400,600,0,XYZ +ITEM,1,1,0,1,3000,0,1800,3000,2400,600,0,XYZ +BIN,0,1,1,-1,0,0,0,7500,2400,3000,, +STACK,0,1,1,0,0,0,0,3000,2400,600,, +ITEM,1,1,1,0,0,0,0,3000,2400,600,0,XYZ diff --git a/doc/examples/boxstacks/maximum_weight_above_no/output.txt b/doc/examples/boxstacks/maximum_weight_above_no/output.txt index 3ccc66542..3a3a46c32 100644 --- a/doc/examples/boxstacks/maximum_weight_above_no/output.txt +++ b/doc/examples/boxstacks/maximum_weight_above_no/output.txt @@ -24,31 +24,39 @@ Total bin weight: inf Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.001 1 20.00 iteration 0 + 0.002 1 20.00 SVC it 0 Final statistics ---------------- -Time (s): 0.00150348 +Time (s): 0.00473652 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 5 / 5 (100%) -Item volume: 4.32e+10 / 4.32e+10 (100%) -Item weight: 140 / 140 (100%) -Item profit: 4.32e+10 / 4.32e+10 (100%) -Number of stacks: 2 -Stack area: 14400000 -Number of bins: 1 / 2 (50%) -Bin volume: 54000000000 / 108000000000 (50%) -Bin area: 18000000 / 36000000 (50%) -Bin weight: inf / inf (-nan%) -Bin cost: 1.8e+07 -Waste: 0 -Waste (%): 0 -Full waste: 10800000000 -Full waste (%): 20 -Volume load: 0.4 -Area load: 0.4 -Weight load: 0 -X max: 6000 -Y max: 2400 +Number of items: 5 / 5 (100%) +Item volume: 4.32e+10 / 4.32e+10 (100%) +Item weight: 140 / 140 (100%) +Item profit: 4.32e+10 / 4.32e+10 (100%) +Number of stacks: 2 +Stack area: 14400000 +Number of bins: 1 / 2 (50%) +Bin volume: 54000000000 / 108000000000 (50%) +Bin area: 18000000 / 36000000 (50%) +Bin weight: inf / inf (-nan%) +Bin cost: 5.4e+10 +Waste: 0 +Waste (%): 0 +Full waste: 10800000000 +Full waste (%): 20 +Volume load: 0.4 +Area load: 0.4 +Weight load: 0 +X max: 6000 +Y max: 2400 +Leftover value: 1.1664e+20 +Staircase leftover value: 10800000000 +Total leftover value: 3.03264e+21 +Total staircase leftover value: 64800000000 diff --git a/doc/examples/boxstacks/maximum_weight_above_no/solution.csv b/doc/examples/boxstacks/maximum_weight_above_no/solution.csv index b560d8fca..0cff65f2d 100644 --- a/doc/examples/boxstacks/maximum_weight_above_no/solution.csv +++ b/doc/examples/boxstacks/maximum_weight_above_no/solution.csv @@ -1,9 +1,9 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,7500,2400,3000, -STACK,0,1,0,0,0,0,0,3000,2400,3000, -ITEM,1,1,0,0,0,0,0,3000,2400,1000,0 -ITEM,1,1,0,0,0,0,1000,3000,2400,1000,0 -ITEM,1,1,0,0,0,0,2000,3000,2400,1000,0 -STACK,1,1,0,1,3000,0,0,3000,2400,3000, -ITEM,0,1,0,1,3000,0,0,3000,2400,1500,0 -ITEM,0,1,0,1,3000,0,1500,3000,2400,1500,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,7500,2400,3000,, +STACK,0,1,0,0,0,0,0,3000,2400,3000,, +ITEM,1,1,0,0,0,0,0,3000,2400,1000,0,XYZ +ITEM,1,1,0,0,0,0,1000,3000,2400,1000,0,XYZ +ITEM,1,1,0,0,0,0,2000,3000,2400,1000,0,XYZ +STACK,1,1,0,1,3000,0,0,3000,2400,3000,, +ITEM,0,1,0,1,3000,0,0,3000,2400,1500,0,XYZ +ITEM,0,1,0,1,3000,0,1500,3000,2400,1500,0,XYZ diff --git a/doc/examples/boxstacks/maximum_weight_above_yes/output.txt b/doc/examples/boxstacks/maximum_weight_above_yes/output.txt index 3a514301a..80d5de6ef 100644 --- a/doc/examples/boxstacks/maximum_weight_above_yes/output.txt +++ b/doc/examples/boxstacks/maximum_weight_above_yes/output.txt @@ -24,31 +24,39 @@ Total bin weight: inf Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.001 2 60.00 iteration 0 + 0.004 2 60.00 SVC it 0 Final statistics ---------------- -Time (s): 0.00144244 +Time (s): 0.00441764 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 1 +Gap: 50% Solution -------- -Number of items: 5 / 5 (100%) -Item volume: 4.32e+10 / 4.32e+10 (100%) -Item weight: 140 / 140 (100%) -Item profit: 4.32e+10 / 4.32e+10 (100%) -Number of stacks: 3 -Stack area: 21600000 -Number of bins: 2 / 2 (100%) -Bin volume: 108000000000 / 108000000000 (100%) -Bin area: 36000000 / 36000000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 3.6e+07 -Waste: 32400000000 -Waste (%): 42.8571 -Full waste: 64800000000 -Full waste (%): 60 -Volume load: 0.4 -Area load: 0.6 -Weight load: 0 -X max: 3000 -Y max: 2400 +Number of items: 5 / 5 (100%) +Item volume: 4.32e+10 / 4.32e+10 (100%) +Item weight: 140 / 140 (100%) +Item profit: 4.32e+10 / 4.32e+10 (100%) +Number of stacks: 3 +Stack area: 21600000 +Number of bins: 2 / 2 (100%) +Bin volume: 108000000000 / 108000000000 (100%) +Bin area: 36000000 / 36000000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 1.08e+11 +Waste: 32400000000 +Waste (%): 42.8571 +Full waste: 64800000000 +Full waste (%): 60 +Volume load: 0.4 +Area load: 0.6 +Weight load: 0 +X max: 3000 +Y max: 2400 +Leftover value: 1.04976e+21 +Staircase leftover value: 32400000000 +Total leftover value: 1.1664e+21 +Total staircase leftover value: 43200000000 diff --git a/doc/examples/boxstacks/maximum_weight_above_yes/solution.csv b/doc/examples/boxstacks/maximum_weight_above_yes/solution.csv index 04946b50e..4b26e045d 100644 --- a/doc/examples/boxstacks/maximum_weight_above_yes/solution.csv +++ b/doc/examples/boxstacks/maximum_weight_above_yes/solution.csv @@ -1,11 +1,11 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,7500,2400,3000, -STACK,0,1,0,0,0,0,0,3000,2400,2500, -ITEM,0,1,0,0,0,0,0,3000,2400,1500,0 -ITEM,1,1,0,0,0,0,1500,3000,2400,1000,0 -STACK,1,1,0,1,3000,0,0,3000,2400,2500, -ITEM,0,1,0,1,3000,0,0,3000,2400,1500,0 -ITEM,1,1,0,1,3000,0,1500,3000,2400,1000,0 -BIN,0,1,1,-1,0,0,0,7500,2400,3000, -STACK,0,1,1,0,0,0,0,3000,2400,1000, -ITEM,1,1,1,0,0,0,0,3000,2400,1000,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,7500,2400,3000,, +STACK,0,1,0,0,0,0,0,3000,2400,2500,, +ITEM,0,1,0,0,0,0,0,3000,2400,1500,0,XYZ +ITEM,1,1,0,0,0,0,1500,3000,2400,1000,0,XYZ +STACK,1,1,0,1,3000,0,0,3000,2400,2500,, +ITEM,0,1,0,1,3000,0,0,3000,2400,1500,0,XYZ +ITEM,1,1,0,1,3000,0,1500,3000,2400,1000,0,XYZ +BIN,0,1,1,-1,0,0,0,7500,2400,3000,, +STACK,0,1,1,0,0,0,0,3000,2400,1000,, +ITEM,1,1,1,0,0,0,0,3000,2400,1000,0,XYZ diff --git a/doc/examples/boxstacks/nesting_height_no/output.txt b/doc/examples/boxstacks/nesting_height_no/output.txt index c0c187cdc..8fa7a1b81 100644 --- a/doc/examples/boxstacks/nesting_height_no/output.txt +++ b/doc/examples/boxstacks/nesting_height_no/output.txt @@ -24,31 +24,39 @@ Total bin weight: inf Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.001 2 64.44 iteration 0 + 0.005 2 64.44 SVC it 0 Final statistics ---------------- -Time (s): 0.00170042 +Time (s): 0.00689559 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- -Number of items: 12 / 12 (100%) -Item volume: 3.84e+10 / 3.84e+10 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 3.84e+10 / 3.84e+10 (100%) -Number of stacks: 12 -Stack area: 24000000 -Number of bins: 2 / 4 (50%) -Bin volume: 108000000000 / 216000000000 (50%) -Bin area: 36000000 / 72000000 (50%) -Bin weight: inf / inf (-nan%) -Bin cost: 3.6e+07 -Waste: 58800000000 -Waste (%): 60.4938 -Full waste: 69600000000 -Full waste (%): 64.4444 -Volume load: 0.177778 -Area load: 0.333333 -Weight load: 0 -X max: 6000 -Y max: 2000 +Number of items: 12 / 12 (100%) +Item volume: 3.84e+10 / 3.84e+10 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 3.84e+10 / 3.84e+10 (100%) +Number of stacks: 12 +Stack area: 24000000 +Number of bins: 2 / 4 (50%) +Bin volume: 108000000000 / 216000000000 (50%) +Bin area: 36000000 / 72000000 (50%) +Bin weight: inf / inf (-nan%) +Bin cost: 1.08e+11 +Waste: 51600000000 +Waste (%): 57.3333 +Full waste: 69600000000 +Full waste (%): 64.4444 +Volume load: 0.177778 +Area load: 0.333333 +Weight load: 0 +X max: 6000 +Y max: 2000 +Leftover value: 3.24e+20 +Staircase leftover value: 18000000000 +Total leftover value: 6.48e+21 +Total staircase leftover value: 144000000000 diff --git a/doc/examples/boxstacks/nesting_height_no/solution.csv b/doc/examples/boxstacks/nesting_height_no/solution.csv index 805e4775c..2832fc08d 100644 --- a/doc/examples/boxstacks/nesting_height_no/solution.csv +++ b/doc/examples/boxstacks/nesting_height_no/solution.csv @@ -1,27 +1,27 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,7500,2400,3000, -STACK,0,1,0,0,0,0,0,2000,1000,1600, -ITEM,0,1,0,0,0,0,0,2000,1000,1600,0 -STACK,1,1,0,1,0,1000,0,2000,1000,1600, -ITEM,0,1,0,1,0,1000,0,2000,1000,1600,0 -STACK,2,1,0,2,2000,0,0,2000,1000,1600, -ITEM,0,1,0,2,2000,0,0,2000,1000,1600,0 -STACK,3,1,0,3,2000,1000,0,2000,1000,1600, -ITEM,0,1,0,3,2000,1000,0,2000,1000,1600,0 -STACK,4,1,0,4,4000,0,0,2000,1000,1600, -ITEM,0,1,0,4,4000,0,0,2000,1000,1600,0 -STACK,5,1,0,5,4000,1000,0,2000,1000,1600, -ITEM,0,1,0,5,4000,1000,0,2000,1000,1600,0 -BIN,0,1,1,-1,0,0,0,7500,2400,3000, -STACK,0,1,1,0,0,0,0,2000,1000,1600, -ITEM,1,1,1,0,0,0,0,2000,1000,1600,0 -STACK,1,1,1,1,0,1000,0,2000,1000,1600, -ITEM,1,1,1,1,0,1000,0,2000,1000,1600,0 -STACK,2,1,1,2,2000,0,0,2000,1000,1600, -ITEM,1,1,1,2,2000,0,0,2000,1000,1600,0 -STACK,3,1,1,3,2000,1000,0,2000,1000,1600, -ITEM,1,1,1,3,2000,1000,0,2000,1000,1600,0 -STACK,4,1,1,4,4000,0,0,2000,1000,1600, -ITEM,1,1,1,4,4000,0,0,2000,1000,1600,0 -STACK,5,1,1,5,4000,1000,0,2000,1000,1600, -ITEM,1,1,1,5,4000,1000,0,2000,1000,1600,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,7500,2400,3000,, +STACK,0,1,0,0,0,0,0,2000,1000,1600,, +ITEM,1,1,0,0,0,0,0,2000,1000,1600,0,XYZ +STACK,1,1,0,1,0,1000,0,2000,1000,1600,, +ITEM,1,1,0,1,0,1000,0,2000,1000,1600,0,XYZ +STACK,2,1,0,2,2000,0,0,2000,1000,1600,, +ITEM,1,1,0,2,2000,0,0,2000,1000,1600,0,XYZ +STACK,3,1,0,3,2000,1000,0,2000,1000,1600,, +ITEM,1,1,0,3,2000,1000,0,2000,1000,1600,0,XYZ +STACK,4,1,0,4,4000,0,0,2000,1000,1600,, +ITEM,1,1,0,4,4000,0,0,2000,1000,1600,0,XYZ +STACK,5,1,0,5,4000,1000,0,2000,1000,1600,, +ITEM,1,1,0,5,4000,1000,0,2000,1000,1600,0,XYZ +BIN,0,1,1,-1,0,0,0,7500,2400,3000,, +STACK,0,1,1,0,0,0,0,2000,1000,1600,, +ITEM,0,1,1,0,0,0,0,2000,1000,1600,0,XYZ +STACK,1,1,1,1,0,1000,0,2000,1000,1600,, +ITEM,0,1,1,1,0,1000,0,2000,1000,1600,0,XYZ +STACK,2,1,1,2,2000,0,0,2000,1000,1600,, +ITEM,0,1,1,2,2000,0,0,2000,1000,1600,0,XYZ +STACK,3,1,1,3,2000,1000,0,2000,1000,1600,, +ITEM,0,1,1,3,2000,1000,0,2000,1000,1600,0,XYZ +STACK,4,1,1,4,4000,0,0,2000,1000,1600,, +ITEM,0,1,1,4,4000,0,0,2000,1000,1600,0,XYZ +STACK,5,1,1,5,4000,1000,0,2000,1000,1600,, +ITEM,0,1,1,5,4000,1000,0,2000,1000,1600,0,XYZ diff --git a/doc/examples/boxstacks/nesting_height_yes/output.txt b/doc/examples/boxstacks/nesting_height_yes/output.txt index bd7a988bd..d1a2fdc43 100644 --- a/doc/examples/boxstacks/nesting_height_yes/output.txt +++ b/doc/examples/boxstacks/nesting_height_yes/output.txt @@ -24,31 +24,39 @@ Total bin weight: inf Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.001 1 28.89 iteration 0 + 0.001 1 28.89 SVC it 0 Final statistics ---------------- -Time (s): 0.00118456 +Time (s): 0.00437484 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 12 / 12 (100%) -Item volume: 3.84e+10 / 3.84e+10 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 3.84e+10 / 3.84e+10 (100%) -Number of stacks: 6 -Stack area: 12000000 -Number of bins: 1 / 4 (25%) -Bin volume: 54000000000 / 216000000000 (25%) -Bin area: 18000000 / 72000000 (25%) -Bin weight: inf / inf (-nan%) -Bin cost: 1.8e+07 -Waste: 4800000000 -Waste (%): 11.1111 -Full waste: 15600000000 -Full waste (%): 28.8889 -Volume load: 0.177778 -Area load: 0.166667 -Weight load: 0 -X max: 6000 -Y max: 2000 +Number of items: 12 / 12 (100%) +Item volume: 3.84e+10 / 3.84e+10 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 3.84e+10 / 3.84e+10 (100%) +Number of stacks: 6 +Stack area: 12000000 +Number of bins: 1 / 4 (25%) +Bin volume: 54000000000 / 216000000000 (25%) +Bin area: 18000000 / 72000000 (25%) +Bin weight: inf / inf (-nan%) +Bin cost: 5.4e+10 +Waste: -2400000000 +Waste (%): -6.66667 +Full waste: 15600000000 +Full waste (%): 28.8889 +Volume load: 0.177778 +Area load: 0.166667 +Weight load: 0 +X max: 6000 +Y max: 2000 +Leftover value: 3.24e+20 +Staircase leftover value: 18000000000 +Total leftover value: 9.072e+21 +Total staircase leftover value: 180000000000 diff --git a/doc/examples/boxstacks/nesting_height_yes/solution.csv b/doc/examples/boxstacks/nesting_height_yes/solution.csv index 57357bb7f..ffb0ec810 100644 --- a/doc/examples/boxstacks/nesting_height_yes/solution.csv +++ b/doc/examples/boxstacks/nesting_height_yes/solution.csv @@ -1,20 +1,20 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,7500,2400,3000, -STACK,0,1,0,0,0,0,0,2000,1000,3000, -ITEM,0,1,0,0,0,0,0,2000,1000,1600,0 -ITEM,1,1,0,0,0,0,1400,2000,1000,1600,0 -STACK,1,1,0,1,0,1000,0,2000,1000,3000, -ITEM,0,1,0,1,0,1000,0,2000,1000,1600,0 -ITEM,1,1,0,1,0,1000,1400,2000,1000,1600,0 -STACK,2,1,0,2,2000,0,0,2000,1000,3000, -ITEM,0,1,0,2,2000,0,0,2000,1000,1600,0 -ITEM,1,1,0,2,2000,0,1400,2000,1000,1600,0 -STACK,3,1,0,3,2000,1000,0,2000,1000,3000, -ITEM,0,1,0,3,2000,1000,0,2000,1000,1600,0 -ITEM,1,1,0,3,2000,1000,1400,2000,1000,1600,0 -STACK,4,1,0,4,4000,0,0,2000,1000,3000, -ITEM,0,1,0,4,4000,0,0,2000,1000,1600,0 -ITEM,1,1,0,4,4000,0,1400,2000,1000,1600,0 -STACK,5,1,0,5,4000,1000,0,2000,1000,3000, -ITEM,0,1,0,5,4000,1000,0,2000,1000,1600,0 -ITEM,1,1,0,5,4000,1000,1400,2000,1000,1600,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,7500,2400,3000,, +STACK,0,1,0,0,0,0,0,2000,1000,3000,, +ITEM,1,1,0,0,0,0,0,2000,1000,1600,0,XYZ +ITEM,1,1,0,0,0,0,1400,2000,1000,1600,0,XYZ +STACK,1,1,0,1,0,1000,0,2000,1000,3000,, +ITEM,1,1,0,1,0,1000,0,2000,1000,1600,0,XYZ +ITEM,1,1,0,1,0,1000,1400,2000,1000,1600,0,XYZ +STACK,2,1,0,2,2000,0,0,2000,1000,3000,, +ITEM,1,1,0,2,2000,0,0,2000,1000,1600,0,XYZ +ITEM,1,1,0,2,2000,0,1400,2000,1000,1600,0,XYZ +STACK,3,1,0,3,2000,1000,0,2000,1000,3000,, +ITEM,0,1,0,3,2000,1000,0,2000,1000,1600,0,XYZ +ITEM,0,1,0,3,2000,1000,1400,2000,1000,1600,0,XYZ +STACK,4,1,0,4,4000,0,0,2000,1000,3000,, +ITEM,0,1,0,4,4000,0,0,2000,1000,1600,0,XYZ +ITEM,0,1,0,4,4000,0,1400,2000,1000,1600,0,XYZ +STACK,5,1,0,5,4000,1000,0,2000,1000,3000,, +ITEM,0,1,0,5,4000,1000,0,2000,1000,1600,0,XYZ +ITEM,0,1,0,5,4000,1000,1400,2000,1000,1600,0,XYZ diff --git a/doc/examples/boxstacks/rotation_no/output.txt b/doc/examples/boxstacks/rotation_no/output.txt index 25e911694..110f3d320 100644 --- a/doc/examples/boxstacks/rotation_no/output.txt +++ b/doc/examples/boxstacks/rotation_no/output.txt @@ -24,31 +24,39 @@ Total bin weight: inf Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.001 2 50.00 iteration 0 + 0.004 2 50.00 SVC it 0 Final statistics ---------------- -Time (s): 0.00116339 +Time (s): 0.00455014 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- -Number of items: 18 / 18 (100%) -Item volume: 5.4e+10 / 5.4e+10 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 5.4e+10 / 5.4e+10 (100%) -Number of stacks: 6 -Stack area: 18000000 -Number of bins: 2 / 2 (100%) -Bin volume: 108000000000 / 108000000000 (100%) -Bin area: 36000000 / 36000000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 3.6e+07 -Waste: 51840000000 -Waste (%): 48.9796 -Full waste: 54000000000 -Full waste (%): 50 -Volume load: 0.5 -Area load: 0.5 -Weight load: 0 -X max: 7200 -Y max: 1250 +Number of items: 18 / 18 (100%) +Item volume: 5.4e+10 / 5.4e+10 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 5.4e+10 / 5.4e+10 (100%) +Number of stacks: 6 +Stack area: 18000000 +Number of bins: 2 / 2 (100%) +Bin volume: 108000000000 / 108000000000 (100%) +Bin area: 36000000 / 36000000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 1.08e+11 +Waste: 27000000000 +Waste (%): 33.3333 +Full waste: 54000000000 +Full waste (%): 50 +Volume load: 0.5 +Area load: 0.5 +Weight load: 0 +X max: 7200 +Y max: 1250 +Leftover value: 7.29e+20 +Staircase leftover value: 27000000000 +Total leftover value: 1.458e+21 +Total staircase leftover value: 54000000000 diff --git a/doc/examples/boxstacks/rotation_no/solution.csv b/doc/examples/boxstacks/rotation_no/solution.csv index bfdebc4e6..b1ddcf675 100644 --- a/doc/examples/boxstacks/rotation_no/solution.csv +++ b/doc/examples/boxstacks/rotation_no/solution.csv @@ -1,14 +1,14 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,2,0,-1,0,0,0,7500,2400,3000, -STACK,0,2,0,0,0,0,0,2400,1250,3000, -ITEM,0,2,0,0,0,0,0,2400,1250,1000,0 -ITEM,0,2,0,0,0,0,1000,2400,1250,1000,0 -ITEM,0,2,0,0,0,0,2000,2400,1250,1000,0 -STACK,1,2,0,1,2400,0,0,2400,1250,3000, -ITEM,0,2,0,1,2400,0,0,2400,1250,1000,0 -ITEM,0,2,0,1,2400,0,1000,2400,1250,1000,0 -ITEM,0,2,0,1,2400,0,2000,2400,1250,1000,0 -STACK,2,2,0,2,4800,0,0,2400,1250,3000, -ITEM,0,2,0,2,4800,0,0,2400,1250,1000,0 -ITEM,0,2,0,2,4800,0,1000,2400,1250,1000,0 -ITEM,0,2,0,2,4800,0,2000,2400,1250,1000,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,2,0,-1,0,0,0,7500,2400,3000,, +STACK,0,2,0,0,0,0,0,2400,1250,3000,, +ITEM,0,2,0,0,0,0,0,2400,1250,1000,0,XYZ +ITEM,0,2,0,0,0,0,1000,2400,1250,1000,0,XYZ +ITEM,0,2,0,0,0,0,2000,2400,1250,1000,0,XYZ +STACK,1,2,0,1,2400,0,0,2400,1250,3000,, +ITEM,0,2,0,1,2400,0,0,2400,1250,1000,0,XYZ +ITEM,0,2,0,1,2400,0,1000,2400,1250,1000,0,XYZ +ITEM,0,2,0,1,2400,0,2000,2400,1250,1000,0,XYZ +STACK,2,2,0,2,4800,0,0,2400,1250,3000,, +ITEM,0,2,0,2,4800,0,0,2400,1250,1000,0,XYZ +ITEM,0,2,0,2,4800,0,1000,2400,1250,1000,0,XYZ +ITEM,0,2,0,2,4800,0,2000,2400,1250,1000,0,XYZ diff --git a/doc/examples/boxstacks/rotation_yes/output.txt b/doc/examples/boxstacks/rotation_yes/output.txt index b955c7a88..9ce3ea91b 100644 --- a/doc/examples/boxstacks/rotation_yes/output.txt +++ b/doc/examples/boxstacks/rotation_yes/output.txt @@ -24,31 +24,39 @@ Total bin weight: inf Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.001 1 0.00 iteration 0 + 0.001 1 0.00 SVC it 0 Final statistics ---------------- -Time (s): 0.00139917 +Time (s): 0.00390071 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 18 / 18 (100%) -Item volume: 5.4e+10 / 5.4e+10 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 5.4e+10 / 5.4e+10 (100%) -Number of stacks: 6 -Stack area: 18000000 -Number of bins: 1 / 2 (50%) -Bin volume: 54000000000 / 108000000000 (50%) -Bin area: 18000000 / 36000000 (50%) -Bin weight: inf / inf (-nan%) -Bin cost: 1.8e+07 -Waste: 0 -Waste (%): 0 -Full waste: 0 -Full waste (%): 0 -Volume load: 0.5 -Area load: 0.5 -Weight load: 0 -X max: 7500 -Y max: 2400 +Number of items: 18 / 18 (100%) +Item volume: 5.4e+10 / 5.4e+10 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 5.4e+10 / 5.4e+10 (100%) +Number of stacks: 6 +Stack area: 18000000 +Number of bins: 1 / 2 (50%) +Bin volume: 54000000000 / 108000000000 (50%) +Bin area: 18000000 / 36000000 (50%) +Bin weight: inf / inf (-nan%) +Bin cost: 5.4e+10 +Waste: 0 +Waste (%): 0 +Full waste: 0 +Full waste (%): 0 +Volume load: 0.5 +Area load: 0.5 +Weight load: 0 +X max: 7500 +Y max: 2400 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 2.916e+21 +Total staircase leftover value: 54000000000 diff --git a/doc/examples/boxstacks/rotation_yes/solution.csv b/doc/examples/boxstacks/rotation_yes/solution.csv index b58017999..8554c9eb8 100644 --- a/doc/examples/boxstacks/rotation_yes/solution.csv +++ b/doc/examples/boxstacks/rotation_yes/solution.csv @@ -1,26 +1,26 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,7500,2400,3000, -STACK,0,1,0,0,0,0,0,1250,2400,3000, -ITEM,0,1,0,0,0,0,0,1250,2400,1000,0 -ITEM,0,1,0,0,0,0,1000,1250,2400,1000,0 -ITEM,0,1,0,0,0,0,2000,1250,2400,1000,0 -STACK,1,1,0,1,1250,0,0,1250,2400,3000, -ITEM,0,1,0,1,1250,0,0,1250,2400,1000,0 -ITEM,0,1,0,1,1250,0,1000,1250,2400,1000,0 -ITEM,0,1,0,1,1250,0,2000,1250,2400,1000,0 -STACK,2,1,0,2,2500,0,0,1250,2400,3000, -ITEM,0,1,0,2,2500,0,0,1250,2400,1000,0 -ITEM,0,1,0,2,2500,0,1000,1250,2400,1000,0 -ITEM,0,1,0,2,2500,0,2000,1250,2400,1000,0 -STACK,3,1,0,3,3750,0,0,1250,2400,3000, -ITEM,0,1,0,3,3750,0,0,1250,2400,1000,0 -ITEM,0,1,0,3,3750,0,1000,1250,2400,1000,0 -ITEM,0,1,0,3,3750,0,2000,1250,2400,1000,0 -STACK,4,1,0,4,5000,0,0,1250,2400,3000, -ITEM,0,1,0,4,5000,0,0,1250,2400,1000,0 -ITEM,0,1,0,4,5000,0,1000,1250,2400,1000,0 -ITEM,0,1,0,4,5000,0,2000,1250,2400,1000,0 -STACK,5,1,0,5,6250,0,0,1250,2400,3000, -ITEM,0,1,0,5,6250,0,0,1250,2400,1000,0 -ITEM,0,1,0,5,6250,0,1000,1250,2400,1000,0 -ITEM,0,1,0,5,6250,0,2000,1250,2400,1000,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,7500,2400,3000,, +STACK,0,1,0,0,0,0,0,1250,2400,3000,, +ITEM,0,1,0,0,0,0,0,1250,2400,1000,0,YXZ +ITEM,0,1,0,0,0,0,1000,1250,2400,1000,0,YXZ +ITEM,0,1,0,0,0,0,2000,1250,2400,1000,0,YXZ +STACK,1,1,0,1,1250,0,0,1250,2400,3000,, +ITEM,0,1,0,1,1250,0,0,1250,2400,1000,0,YXZ +ITEM,0,1,0,1,1250,0,1000,1250,2400,1000,0,YXZ +ITEM,0,1,0,1,1250,0,2000,1250,2400,1000,0,YXZ +STACK,2,1,0,2,2500,0,0,1250,2400,3000,, +ITEM,0,1,0,2,2500,0,0,1250,2400,1000,0,YXZ +ITEM,0,1,0,2,2500,0,1000,1250,2400,1000,0,YXZ +ITEM,0,1,0,2,2500,0,2000,1250,2400,1000,0,YXZ +STACK,3,1,0,3,3750,0,0,1250,2400,3000,, +ITEM,0,1,0,3,3750,0,0,1250,2400,1000,0,YXZ +ITEM,0,1,0,3,3750,0,1000,1250,2400,1000,0,YXZ +ITEM,0,1,0,3,3750,0,2000,1250,2400,1000,0,YXZ +STACK,4,1,0,4,5000,0,0,1250,2400,3000,, +ITEM,0,1,0,4,5000,0,0,1250,2400,1000,0,YXZ +ITEM,0,1,0,4,5000,0,1000,1250,2400,1000,0,YXZ +ITEM,0,1,0,4,5000,0,2000,1250,2400,1000,0,YXZ +STACK,5,1,0,5,6250,0,0,1250,2400,3000,, +ITEM,0,1,0,5,6250,0,0,1250,2400,1000,0,YXZ +ITEM,0,1,0,5,6250,0,1000,1250,2400,1000,0,YXZ +ITEM,0,1,0,5,6250,0,2000,1250,2400,1000,0,YXZ diff --git a/doc/examples/boxstacks/unloading_no/output.txt b/doc/examples/boxstacks/unloading_no/output.txt index d85451d15..2242ae4bd 100644 --- a/doc/examples/boxstacks/unloading_no/output.txt +++ b/doc/examples/boxstacks/unloading_no/output.txt @@ -9,6 +9,9 @@ BoxStacks Instance -------- Objective: BinPackingWithLeftovers +Leftover mode: XY +Leftover value type: SquaredArea +Leftover all bins: 1 Number of item types: 3 Number of items: 3 Number of bin types: 1 @@ -24,31 +27,37 @@ Total bin weight: inf Time Waste Waste (%) Comment ---- ----- --------- ------- - 0.001 29300000000 67.82 iteration 0 + 0.010 29300000000 67.82 SVC it 0 + 0.097 29300000000 67.82 SVC it 17 Final statistics ---------------- -Time (s): 5.0029 +Time (s): 5.00052 +Is proven infeasible: 0 Solution -------- -Number of items: 3 / 3 (100%) -Item volume: 1.39e+10 / 1.39e+10 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 1.39e+10 / 1.39e+10 (100%) -Number of stacks: 3 -Stack area: 13900000 -Number of bins: 1 / 2 (50%) -Bin volume: 54000000000 / 108000000000 (50%) -Bin area: 18000000 / 36000000 (50%) -Bin weight: inf / inf (-nan%) -Bin cost: 1.8e+07 -Waste: 29300000000 -Waste (%): 67.8241 -Full waste: 40100000000 -Full waste (%): 74.2593 -Volume load: 0.128704 -Area load: 0.386111 -Weight load: 0 -X max: 6000 -Y max: 2400 +Number of items: 3 / 3 (100%) +Item volume: 1.39e+10 / 1.39e+10 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 1.39e+10 / 1.39e+10 (100%) +Number of stacks: 3 +Stack area: 13900000 +Number of bins: 1 / 2 (50%) +Bin volume: 54000000000 / 108000000000 (50%) +Bin area: 18000000 / 36000000 (50%) +Bin weight: inf / inf (-nan%) +Bin cost: 5.4e+10 +Waste: 29300000000 +Waste (%): 67.8241 +Full waste: 40100000000 +Full waste (%): 74.2593 +Volume load: 0.128704 +Area load: 0.386111 +Weight load: 0 +X max: 6000 +Y max: 2400 +Leftover value: 1.1664e+20 +Staircase leftover value: 12300000000 +Total leftover value: 3.03264e+21 +Total staircase leftover value: 66300000000 diff --git a/doc/examples/boxstacks/unloading_no/solution.csv b/doc/examples/boxstacks/unloading_no/solution.csv index dba539250..7dd9df1b5 100644 --- a/doc/examples/boxstacks/unloading_no/solution.csv +++ b/doc/examples/boxstacks/unloading_no/solution.csv @@ -1,8 +1,8 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,7500,2400,3000, -STACK,0,1,0,0,0,0,0,3000,2400,1000, -ITEM,1,1,0,0,0,0,0,3000,2400,1000,1 -STACK,1,1,0,1,3000,0,0,2500,1000,1000, -ITEM,2,1,0,1,3000,0,0,2500,1000,1000,2 -STACK,2,1,0,2,3000,1000,0,3000,1400,1000, -ITEM,0,1,0,2,3000,1000,0,3000,1400,1000,0 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,7500,2400,3000,, +STACK,0,1,0,0,0,0,0,3000,2400,1000,, +ITEM,1,1,0,0,0,0,0,3000,2400,1000,1,XYZ +STACK,1,1,0,1,3000,0,0,3000,1400,1000,, +ITEM,0,1,0,1,3000,0,0,3000,1400,1000,0,XYZ +STACK,2,1,0,2,3000,1400,0,2500,1000,1000,, +ITEM,2,1,0,2,3000,1400,0,2500,1000,1000,2,XYZ diff --git a/doc/examples/boxstacks/unloading_yes/output.txt b/doc/examples/boxstacks/unloading_yes/output.txt index 813882e17..5d262cfbc 100644 --- a/doc/examples/boxstacks/unloading_yes/output.txt +++ b/doc/examples/boxstacks/unloading_yes/output.txt @@ -9,6 +9,9 @@ BoxStacks Instance -------- Objective: BinPackingWithLeftovers +Leftover mode: XY +Leftover value type: SquaredArea +Leftover all bins: 1 Number of item types: 3 Number of items: 3 Number of bin types: 1 @@ -24,31 +27,36 @@ Total bin weight: inf Time Waste Waste (%) Comment ---- ----- --------- ------- - 0.001 58100000000 80.69 iteration 0 + 0.009 47600000000 77.40 SVC it 0 Final statistics ---------------- -Time (s): 5.00187 +Time (s): 5.00061 +Is proven infeasible: 0 Solution -------- -Number of items: 3 / 3 (100%) -Item volume: 1.39e+10 / 1.39e+10 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 1.39e+10 / 1.39e+10 (100%) -Number of stacks: 3 -Stack area: 13900000 -Number of bins: 2 / 2 (100%) -Bin volume: 108000000000 / 108000000000 (100%) -Bin area: 36000000 / 36000000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 3.6e+07 -Waste: 58100000000 -Waste (%): 80.6944 -Full waste: 94100000000 -Full waste (%): 87.1296 -Volume load: 0.128704 -Area load: 0.386111 -Weight load: 0 -X max: 2500 -Y max: 1000 +Number of items: 3 / 3 (100%) +Item volume: 1.39e+10 / 1.39e+10 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 1.39e+10 / 1.39e+10 (100%) +Number of stacks: 3 +Stack area: 13900000 +Number of bins: 2 / 2 (100%) +Bin volume: 108000000000 / 108000000000 (100%) +Bin area: 36000000 / 36000000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 1.08e+11 +Waste: 47600000000 +Waste (%): 77.3984 +Full waste: 94100000000 +Full waste (%): 87.1296 +Volume load: 0.128704 +Area load: 0.386111 +Weight load: 0 +X max: 2500 +Y max: 1000 +Leftover value: 2.16225e+21 +Staircase leftover value: 46500000000 +Total leftover value: 2.27889e+21 +Total staircase leftover value: 66300000000 diff --git a/doc/examples/boxstacks/unloading_yes/solution.csv b/doc/examples/boxstacks/unloading_yes/solution.csv index 61a54f082..de1b7394c 100644 --- a/doc/examples/boxstacks/unloading_yes/solution.csv +++ b/doc/examples/boxstacks/unloading_yes/solution.csv @@ -1,9 +1,9 @@ -TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID -BIN,0,1,0,-1,0,0,0,7500,2400,3000, -STACK,0,1,0,0,0,0,0,3000,2400,1000, -ITEM,1,1,0,0,0,0,0,3000,2400,1000,1 -STACK,1,1,0,1,3000,0,0,3000,1400,1000, -ITEM,0,1,0,1,3000,0,0,3000,1400,1000,0 -BIN,0,1,1,-1,0,0,0,7500,2400,3000, -STACK,0,1,1,0,0,0,0,2500,1000,1000, -ITEM,2,1,1,0,0,0,0,2500,1000,1000,2 +TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION +BIN,0,1,0,-1,0,0,0,7500,2400,3000,, +STACK,0,1,0,0,0,0,0,3000,2400,1000,, +ITEM,1,1,0,0,0,0,0,3000,2400,1000,1,XYZ +STACK,1,1,0,1,3000,0,0,3000,1400,1000,, +ITEM,0,1,0,1,3000,0,0,3000,1400,1000,0,XYZ +BIN,0,1,1,-1,0,0,0,7500,2400,3000,, +STACK,0,1,1,0,0,0,0,2500,1000,1000,, +ITEM,2,1,1,0,0,0,0,2500,1000,1000,2,XYZ diff --git a/doc/examples/irregular/basic/output.txt b/doc/examples/irregular/basic/output.txt index 68b7bd228..b8d0245ee 100644 --- a/doc/examples/irregular/basic/output.txt +++ b/doc/examples/irregular/basic/output.txt @@ -30,28 +30,35 @@ Largest bin cost: 28800 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.009 2 50.69 TS g 1 d 0 q 1 - 0.968 1 1.39 TS g 1 d 0 q 94 + 0.004 2 50.69 TS g 0 d 0 q 1 + 0.309 1 1.39 TS g 1 d 0 q 94 Final statistics ---------------- -Time (s): 0.977268 +Time (s): 0.311707 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 17 / 17 (100%) -Item area: 28400 / 28400 (100%) -Item profit: 28400 / 28400 (100%) -Number of bins: 1 / 3 (33.3333%) -Bin area: 28800 / 86400 (33.3333%) -Bin cost: 28800 -Full waste: 400 -Full waste (%): 1.38889 -X min: 0 -Y min: 0 -X max: 180 -Y max: 160 -Density X: 0.986111 -Density Y: 0.986111 -ODXY area: 28800 -Leftover value: 0 +Number of items: 17 / 17 (100%) +Item area: 28400 / 28400 (100%) +Item profit: 28400 / 28400 (100%) +Number of bins: 1 / 3 (33.3333%) +Bin area: 28800 / 86400 (33.3333%) +Bin cost: 28800 +Full waste: 400 +Full waste (%): 1.38889 +X min: 0 +Y min: 0 +X max: 180 +Y max: 160 +Density X: 0.986111 +Density Y: 0.986111 +ODXY area: 28800 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 1.65888e+09 +Total staircase leftover value: 57600 diff --git a/doc/examples/irregular/defects_no/output.txt b/doc/examples/irregular/defects_no/output.txt index 39bdf0520..e83fe81d4 100644 --- a/doc/examples/irregular/defects_no/output.txt +++ b/doc/examples/irregular/defects_no/output.txt @@ -30,27 +30,34 @@ Largest bin cost: 3600 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.004 1 11.11 TS g 0 d 0 q 1 + 0.001 1 11.11 TS g 1 d 0 q 1 Final statistics ---------------- -Time (s): 0.00677509 +Time (s): 0.00340319 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 2 / 2 (100%) -Item area: 3200 / 3200 (100%) -Item profit: 3200 / 3200 (100%) -Number of bins: 1 / 2 (50%) -Bin area: 3600 / 7200 (50%) -Bin cost: 3600 -Full waste: 400 -Full waste (%): 11.1111 -X min: 0 -Y min: 0 -X max: 60 -Y max: 60 -Density X: 0.888889 -Density Y: 0.888889 -ODXY area: 3600 -Leftover value: 0 +Number of items: 2 / 2 (100%) +Item area: 3200 / 3200 (100%) +Item profit: 3200 / 3200 (100%) +Number of bins: 1 / 2 (50%) +Bin area: 3600 / 7200 (50%) +Bin cost: 3600 +Full waste: 400 +Full waste (%): 11.1111 +X min: 0 +Y min: 0 +X max: 60 +Y max: 60 +Density X: 0.888889 +Density Y: 0.888889 +ODXY area: 3600 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 1.296e+07 +Total staircase leftover value: 3600 diff --git a/doc/examples/irregular/defects_yes/output.txt b/doc/examples/irregular/defects_yes/output.txt index 76dd0b466..5e602b3e9 100644 --- a/doc/examples/irregular/defects_yes/output.txt +++ b/doc/examples/irregular/defects_yes/output.txt @@ -34,23 +34,30 @@ Largest bin cost: 3600 Final statistics ---------------- -Time (s): 0.0181937 +Time (s): 5.00045 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 1 +Gap: 50% Solution -------- -Number of items: 2 / 2 (100%) -Item area: 3200 / 3200 (100%) -Item profit: 3200 / 3200 (100%) -Number of bins: 2 / 2 (100%) -Bin area: 7200 / 7200 (100%) -Bin cost: 7200 -Full waste: 4000 -Full waste (%): 55.5556 -X min: 0 -Y min: 0 -X max: 40 -Y max: 60 -Density X: 0.533333 -Density Y: 0.444444 -ODXY area: 2400 -Leftover value: 1200 +Number of items: 2 / 2 (100%) +Item area: 3200 / 3200 (100%) +Item profit: 3200 / 3200 (100%) +Number of bins: 2 / 2 (100%) +Bin area: 7200 / 7200 (100%) +Bin cost: 7200 +Full waste: 4000 +Full waste (%): 55.5556 +X min: 0 +Y min: 0 +X max: 40 +Y max: 60 +Density X: 0.533333 +Density Y: 0.444444 +ODXY area: 2400 +Leftover value: 1.44e+06 +Staircase leftover value: 1200 +Total leftover value: 1.53e+06 +Total staircase leftover value: 1500 diff --git a/doc/examples/irregular/holes_no/output.txt b/doc/examples/irregular/holes_no/output.txt index d67bc57e1..b0762d521 100644 --- a/doc/examples/irregular/holes_no/output.txt +++ b/doc/examples/irregular/holes_no/output.txt @@ -34,23 +34,30 @@ Largest bin cost: 1600 Final statistics ---------------- -Time (s): 0.00592841 +Time (s): 0.00286338 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- -Number of items: 2 / 2 (100%) -Item area: 1622 / 1622 (100%) -Item profit: 1622 / 1622 (100%) -Number of bins: 2 / 2 (100%) -Bin area: 3200 / 3200 (100%) -Bin cost: 3200 -Full waste: 1578 -Full waste (%): 49.3125 -X min: 0 -Y min: 0 -X max: 12 -Y max: 12 -Density X: 0.779808 -Density Y: 0.779808 -ODXY area: 144 -Leftover value: 1456 +Number of items: 2 / 2 (100%) +Item area: 1622 / 1622 (100%) +Item profit: 1622 / 1622 (100%) +Number of bins: 2 / 2 (100%) +Bin area: 3200 / 3200 (100%) +Bin cost: 3200 +Full waste: 1578 +Full waste (%): 49.3125 +X min: 0 +Y min: 0 +X max: 12 +Y max: 12 +Density X: 0.779808 +Density Y: 0.779808 +ODXY area: 144 +Leftover value: 2.11994e+06 +Staircase leftover value: 1456 +Total leftover value: 2.11994e+06 +Total staircase leftover value: 1456 diff --git a/doc/examples/irregular/holes_yes/output.txt b/doc/examples/irregular/holes_yes/output.txt index 213a9899a..9c5230801 100644 --- a/doc/examples/irregular/holes_yes/output.txt +++ b/doc/examples/irregular/holes_yes/output.txt @@ -30,27 +30,34 @@ Largest bin cost: 1600 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.001 1 11.12 TS g 0 d 0 q 1 + 0.001 1 11.12 TS g 1 d 0 q 1 Final statistics ---------------- -Time (s): 0.00397906 +Time (s): 0.00281737 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 2 / 2 (100%) -Item area: 1422 / 1422 (100%) -Item profit: 1422 / 1422 (100%) -Number of bins: 1 / 2 (50%) -Bin area: 1600 / 3200 (50%) -Bin cost: 1600 -Full waste: 178 -Full waste (%): 11.125 -X min: 0 -Y min: 0 -X max: 40 -Y max: 40 -Density X: 0.88875 -Density Y: 0.88875 -ODXY area: 1600 -Leftover value: 0 +Number of items: 2 / 2 (100%) +Item area: 1422 / 1422 (100%) +Item profit: 1422 / 1422 (100%) +Number of bins: 1 / 2 (50%) +Bin area: 1600 / 3200 (50%) +Bin cost: 1600 +Full waste: 178 +Full waste (%): 11.125 +X min: 0 +Y min: 0 +X max: 40 +Y max: 40 +Density X: 0.88875 +Density Y: 0.88875 +ODXY area: 1600 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 2.56e+06 +Total staircase leftover value: 1600 diff --git a/doc/examples/irregular/irregular_bin/output.txt b/doc/examples/irregular/irregular_bin/output.txt index 6bd3d129a..c3af879a8 100644 --- a/doc/examples/irregular/irregular_bin/output.txt +++ b/doc/examples/irregular/irregular_bin/output.txt @@ -30,97 +30,103 @@ Largest bin cost: 14882.1 Time Profit # items Comment ---- ------ ------- ------- - 0.005 27 1 TS g 5 d 0 q 1 - 0.005 53 1 TS g 5 d 0 q 1 - 0.008 91 1 TS g 5 d 0 q 1 - 0.012 318 1 TS g 5 d 0 q 1 - 0.017 320 1 TS g 5 d 0 q 1 - 0.021 379 1 TS g 5 d 0 q 1 - 0.025 387 2 TS g 5 d 4 q 1 - 0.028 406 2 TS g 5 d 0 q 1 - 0.031 411 2 TS g 5 d 3 q 1 - 0.033 436 2 TS g 4 d 7 q 1 - 0.037 591 2 TS g 5 d 7 q 1 - 0.039 699 2 TS g 5 d 7 q 1 - 0.042 708 3 TS g 5 d 7 q 1 - 0.046 709 3 TS g 5 d 7 q 1 - 0.050 712 3 TS g 5 d 7 q 1 - 0.052 726 3 TS g 5 d 3 q 1 - 0.056 790 3 TS g 5 d 3 q 1 - 0.059 889 3 TS g 5 d 3 q 1 - 0.064 895 3 TS g 5 d 3 q 1 + 0.004 27 1 TS g 5 d 4 q 1 + 0.004 53 1 TS g 5 d 4 q 1 + 0.009 320 1 TS g 5 d 4 q 1 + 0.011 379 1 TS g 5 d 4 q 1 + 0.015 387 2 TS g 5 d 4 q 1 + 0.018 395 2 TS g 4 d 4 q 1 + 0.022 397 2 TS g 5 d 4 q 1 + 0.027 403 3 TS g 4 d 0 q 1 + 0.029 413 3 TS g 4 d 4 q 1 + 0.034 470 2 TS g 5 d 4 q 1 + 0.038 697 2 TS g 5 d 4 q 1 + 0.043 699 2 TS g 5 d 4 q 1 + 0.048 705 3 TS g 5 d 0 q 1 + 0.051 706 3 TS g 5 d 0 q 1 + 0.055 715 3 TS g 5 d 4 q 1 + 0.058 724 3 TS g 5 d 0 q 1 + 0.063 893 3 TS g 5 d 4 q 1 0.068 968 3 TS g 5 d 4 q 1 - 0.074 976 4 TS g 5 d 4 q 1 - 0.078 986 4 TS g 5 d 4 q 1 - 0.080 1025 4 TS g 5 d 4 q 1 - 0.084 1059 4 TS g 5 d 4 q 1 - 0.089 1067 5 TS g 5 d 4 q 1 - 0.094 1077 5 TS g 5 d 4 q 1 - 0.099 1086 5 TS g 5 d 4 q 1 - 0.105 1094 6 TS g 5 d 4 q 1 - 0.109 1104 6 TS g 5 d 4 q 1 - 0.112 1110 7 TS g 5 d 4 q 1 - 0.115 1111 7 TS g 5 d 4 q 1 - 0.121 1117 8 TS g 5 d 4 q 1 - 0.127 1118 8 TS g 5 d 4 q 1 - 0.132 1126 9 TS g 5 d 4 q 1 - 0.137 1134 10 TS g 5 d 4 q 1 - 0.143 1138 18 TS g 5 d 0 q 1 - 0.159 1140 7 TS g 5 d 0 q 2 - 0.161 1158 8 TS g 5 d 0 q 2 - 0.168 1165 9 TS g 5 d 0 q 2 - 0.171 1166 9 TS g 5 d 0 q 2 - 0.178 1173 9 TS g 5 d 0 q 2 - 0.183 1179 9 TS g 5 d 0 q 2 - 0.188 1184 9 TS g 5 d 0 q 2 - 0.195 1187 10 TS g 5 d 0 q 2 - 0.200 1188 10 TS g 5 d 0 q 2 - 0.205 1195 10 TS g 5 d 0 q 2 - 0.211 1200 10 TS g 5 d 0 q 2 - 0.216 1206 10 TS g 5 d 0 q 2 - 0.221 1208 11 TS g 5 d 0 q 2 - 0.227 1210 11 TS g 5 d 0 q 2 - 0.232 1211 12 TS g 5 d 0 q 2 - 0.238 1218 12 TS g 5 d 0 q 2 - 0.244 1227 13 TS g 5 d 0 q 2 - 0.250 1234 14 TS g 5 d 0 q 2 - 0.255 1240 15 TS g 5 d 0 q 2 - 0.262 1241 15 TS g 5 d 0 q 2 - 0.272 1248 16 TS g 5 d 0 q 2 - 0.277 1255 17 TS g 5 d 0 q 2 - 0.387 1257 13 TS g 5 d 4 q 13 - 0.389 1258 14 TS g 5 d 4 q 13 - 0.439 1260 13 TS g 5 d 4 q 19 - 0.440 1262 13 TS g 5 d 4 q 19 - 0.448 1266 14 TS g 5 d 4 q 19 + 0.073 976 4 TS g 5 d 4 q 1 + 0.077 986 4 TS g 5 d 4 q 1 + 0.083 1025 4 TS g 5 d 4 q 1 + 0.087 1059 4 TS g 5 d 4 q 1 + 0.092 1067 5 TS g 5 d 4 q 1 + 0.096 1077 5 TS g 5 d 4 q 1 + 0.101 1086 5 TS g 5 d 4 q 1 + 0.107 1094 6 TS g 5 d 4 q 1 + 0.113 1104 6 TS g 5 d 4 q 1 + 0.119 1110 7 TS g 5 d 4 q 1 + 0.124 1111 7 TS g 5 d 4 q 1 + 0.130 1117 8 TS g 5 d 4 q 1 + 0.136 1118 8 TS g 5 d 4 q 1 + 0.141 1126 9 TS g 5 d 4 q 1 + 0.146 1134 10 TS g 5 d 4 q 1 + 0.152 1138 18 TS g 5 d 0 q 1 + 0.166 1148 7 TS g 5 d 4 q 3 + 0.167 1158 8 TS g 5 d 0 q 2 + 0.173 1162 9 TS g 5 d 4 q 3 + 0.179 1165 9 TS g 5 d 0 q 2 + 0.186 1166 9 TS g 5 d 0 q 2 + 0.192 1173 9 TS g 5 d 0 q 2 + 0.199 1179 9 TS g 5 d 0 q 2 + 0.205 1184 9 TS g 5 d 0 q 2 + 0.211 1187 10 TS g 5 d 0 q 2 + 0.217 1188 10 TS g 5 d 0 q 2 + 0.223 1195 10 TS g 5 d 0 q 2 + 0.229 1200 10 TS g 5 d 0 q 2 + 0.234 1206 10 TS g 5 d 0 q 2 + 0.240 1208 11 TS g 5 d 0 q 2 + 0.246 1210 11 TS g 5 d 0 q 2 + 0.252 1211 12 TS g 5 d 0 q 2 + 0.258 1218 12 TS g 5 d 0 q 2 + 0.265 1227 13 TS g 5 d 0 q 2 + 0.271 1234 14 TS g 5 d 0 q 2 + 0.277 1240 15 TS g 5 d 0 q 2 + 0.283 1241 15 TS g 5 d 0 q 2 + 0.289 1248 16 TS g 5 d 0 q 2 + 0.296 1255 17 TS g 5 d 0 q 2 + 0.361 1257 13 TS g 5 d 4 q 13 + 0.362 1258 14 TS g 5 d 4 q 13 + 0.401 1260 13 TS g 5 d 4 q 19 + 0.402 1262 13 TS g 5 d 4 q 19 + 0.411 1266 14 TS g 5 d 4 q 19 0.466 1270 17 TS g 5 d 0 q 13 - 0.667 1272 15 TS g 5 d 0 q 28 - 0.670 1278 16 TS g 5 d 0 q 28 - 1.490 1282 16 TS g 5 d 0 q 94 - 2.705 1285 15 TS g 5 d 0 q 211 - 2.716 1286 15 TS g 5 d 0 q 211 - 7.422 1291 16 TS g 5 d 4 q 711 - 7.759 1292 16 TS g 5 d 0 q 711 + 0.576 1272 15 TS g 5 d 0 q 28 + 0.578 1278 16 TS g 5 d 0 q 28 + 1.016 1282 16 TS g 5 d 0 q 94 + 1.773 1285 15 TS g 5 d 0 q 211 + 1.779 1286 15 TS g 5 d 0 q 211 + 4.932 1292 16 TS g 5 d 0 q 711 + 8.810 1295 16 TS g 5 d 4 q 1066 Final statistics ---------------- -Time (s): 10.0102 +Time (s): 10.0119 +Is proven infeasible: 0 +Primal bound: 1295 +Dual bound: 1535 +Gap: 18.5328% Solution -------- -Number of items: 16 / 28 (57.1429%) -Item area: 13463.4 / 29548 (45.5646%) -Item profit: 1292 / 2810 (45.9786%) -Number of bins: 1 / 1 (100%) -Bin area: 14882 / 14882 (100%) -Bin cost: 14882.1 -Full waste: 1418.71 -Full waste (%): 9.533 -X min: 0.3378 -Y min: 0.0363114 -X max: 136.539 -Y max: 128.211 -Density X: 0.768231 -Density Y: 0.76102 -ODXY area: 17457.6 -Leftover value: 204.936 +Number of items: 16 / 28 (57.1429%) +Item area: 13477.5 / 29548 (45.6124%) +Item profit: 1295 / 2810 (46.0854%) +Number of bins: 1 / 1 (100%) +Bin area: 14882 / 14882 (100%) +Bin cost: 14882.1 +Full waste: 1404.58 +Full waste (%): 9.43801 +X min: 0.3378 +Y min: 0.0363114 +X max: 137.861 +Y max: 128.24 +Density X: 0.761664 +Density Y: 0.761653 +ODXY area: 17630.9 +Leftover value: 997.887 +Staircase leftover value: 797.572 +Total leftover value: 997.887 +Total staircase leftover value: 797.572 diff --git a/doc/examples/irregular/irregular_bin/solution.json b/doc/examples/irregular/irregular_bin/solution.json index 3d9e453d5..70ab32705 100644 --- a/doc/examples/irregular/irregular_bin/solution.json +++ b/doc/examples/irregular/irregular_bin/solution.json @@ -56,43 +56,43 @@ "type": "LineSegment", "xe": 58.0008, "xs": 25.5589, - "ye": 1.2992114295536192, + "ye": 1.2992114295536195, "ys": 18.541811429553622 }, { "type": "LineSegment", "xe": 86.6413, "xs": 58.0008, - "ye": 0.036311429553619386, - "ys": 1.2992114295536192 + "ye": 0.03631142955361964, + "ys": 1.2992114295536195 }, { "type": "LineSegment", "xe": 96.7925, "xs": 86.6413, - "ye": 1.8468114295536193, - "ys": 0.036311429553619386 + "ye": 1.8468114295536195, + "ys": 0.03631142955361964 }, { "type": "LineSegment", "xe": 101.4436, "xs": 96.7925, - "ye": 3.2445114295536195, - "ys": 1.8468114295536193 + "ye": 3.24451142955362, + "ys": 1.8468114295536195 }, { "type": "LineSegment", "xe": 18.9964, "xs": 101.4436, "ye": 90.31741142955362, - "ys": 3.2445114295536195 + "ys": 3.24451142955362 } ] } ], "mirror": false, "x": 0.3378, - "y": 0.036311429553619386 + "y": 0.03631142955361964 }, { "angle": 0.0, @@ -109,86 +109,114 @@ }, { "type": "LineSegment", - "xe": 91.53339687315061, + "xe": 91.5333968731506, "xs": 88.19159687315062, "ye": 68.27778399070603, "ys": 75.50198399070602 }, { "type": "LineSegment", - "xe": 19.45679687315061, - "xs": 91.53339687315061, + "xe": 19.4567968731506, + "xs": 91.5333968731506, "ye": 89.83118399070602, "ys": 68.27778399070603 }, { "type": "LineSegment", - "xe": 101.9040968731506, - "xs": 19.45679687315061, - "ye": 2.7583839907060237, + "xe": 101.90409687315059, + "xs": 19.4567968731506, + "ye": 2.7583839907060224, "ys": 89.83118399070602 }, { "type": "LineSegment", - "xe": 119.4074968731506, - "xs": 101.9040968731506, - "ye": 8.018183990706024, - "ys": 2.7583839907060237 + "xe": 119.40749687315059, + "xs": 101.90409687315059, + "ye": 8.018183990706023, + "ys": 2.7583839907060224 }, { "type": "LineSegment", "xe": 128.8341968731506, - "xs": 119.4074968731506, - "ye": 10.851083990706025, - "ys": 8.018183990706024 + "xs": 119.40749687315059, + "ye": 10.851083990706023, + "ys": 8.018183990706023 }, { "type": "LineSegment", "xe": 93.01079687315061, "xs": 128.8341968731506, "ye": 67.83608399070602, - "ys": 10.851083990706025 + "ys": 10.851083990706023 } ] } ], "mirror": false, - "x": 19.45679687315061, - "y": 2.7583839907060237 + "x": 19.4567968731506, + "y": 2.7583839907060224 }, { "angle": 0.0, - "id": 12, + "id": 19, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 0.4412, - "xs": 0.3378, - "ye": 95.8660213606842, - "ys": 110.10082136068421 + "xe": 130.71979999999996, + "xs": 128.046, + "ye": 12.908485845833864, + "ys": 12.104885845833865 }, { "type": "LineSegment", - "xe": 19.099700000000002, - "xs": 0.4412, - "ye": 90.2865213606842, - "ys": 95.8660213606842 + "xe": 134.30519999999999, + "xs": 130.71979999999996, + "ye": 21.298285845833867, + "ys": 12.908485845833864 }, { "type": "LineSegment", - "xe": 0.3378, - "xs": 19.099700000000002, - "ye": 110.10082136068421, - "ys": 90.2865213606842 + "xe": 137.861, + "xs": 134.30519999999999, + "ye": 34.20628584583387, + "ys": 21.298285845833867 + }, + { + "type": "LineSegment", + "xe": 137.75539999999998, + "xs": 137.861, + "ye": 44.94898584583386, + "ys": 34.20628584583387 + }, + { + "type": "LineSegment", + "xe": 112.11239999999998, + "xs": 137.75539999999998, + "ye": 63.14208584583386, + "ys": 44.94898584583386 + }, + { + "type": "LineSegment", + "xe": 92.22269999999997, + "xs": 112.11239999999998, + "ye": 69.08978584583387, + "ys": 63.14208584583386 + }, + { + "type": "LineSegment", + "xe": 128.046, + "xs": 92.22269999999997, + "ye": 12.104885845833865, + "ys": 69.08978584583387 } ] } ], "mirror": false, - "x": 0.3378, - "y": 90.2865213606842 + "x": 92.22269999999997, + "y": 12.104885845833865 }, { "angle": 0.0, @@ -198,66 +226,66 @@ "shape": [ { "type": "LineSegment", - "xe": 21.8424, - "xs": 83.421, - "ye": 126.68288759295527, - "ys": 82.99448759295527 + "xe": 22.168506437508736, + "xs": 83.74710643750875, + "ye": 126.26027950023939, + "ys": 82.57187950023939 }, { "type": "LineSegment", - "xe": 3.9051, - "xs": 21.8424, - "ye": 126.26858759295527, - "ys": 126.68288759295527 + "xe": 4.231206437508737, + "xs": 22.168506437508736, + "ye": 125.8459795002394, + "ys": 126.26027950023939 }, { "type": "LineSegment", - "xe": 0.3378, - "xs": 3.9051, - "ye": 114.35378759295527, - "ys": 126.26858759295527 + "xe": 0.6639064375087375, + "xs": 4.231206437508737, + "ye": 113.9311795002394, + "ys": 125.8459795002394 }, { "type": "LineSegment", - "xe": 0.3689, - "xs": 0.3378, - "ye": 110.06828759295527, - "ys": 114.35378759295527 + "xe": 0.6950064375087375, + "xs": 0.6639064375087375, + "ye": 109.6456795002394, + "ys": 113.9311795002394 }, { "type": "LineSegment", - "xe": 19.1306, - "xs": 0.3689, - "ye": 90.25388759295527, - "ys": 110.06828759295527 + "xe": 19.456706437508736, + "xs": 0.6950064375087375, + "ye": 89.83127950023939, + "ys": 109.6456795002394 }, { "type": "LineSegment", - "xe": 91.2071, - "xs": 19.1306, - "ye": 68.70048759295527, - "ys": 90.25388759295527 + "xe": 91.53320643750874, + "xs": 19.456706437508736, + "ye": 68.2778795002394, + "ys": 89.83127950023939 }, { "type": "LineSegment", - "xe": 87.86540000000001, - "xs": 91.2071, - "ye": 75.92478759295527, - "ys": 68.70048759295527 + "xe": 88.19150643750875, + "xs": 91.53320643750874, + "ye": 75.5021795002394, + "ys": 68.2778795002394 }, { "type": "LineSegment", - "xe": 83.421, - "xs": 87.86540000000001, - "ye": 82.99448759295527, - "ys": 75.92478759295527 + "xe": 83.74710643750875, + "xs": 88.19150643750875, + "ye": 82.57187950023939, + "ys": 75.5021795002394 } ] } ], "mirror": false, - "x": 0.3378, - "y": 68.70048759295527 + "x": 0.6639064375087375, + "y": 68.2778795002394 }, { "angle": 0.0, @@ -267,503 +295,468 @@ "shape": [ { "type": "LineSegment", - "xe": 21.794804784157023, - "xs": 55.42040478415702, - "ye": 126.71665514901913, - "ys": 127.49355514901913 + "xe": 21.53374792475701, + "xs": 55.15934792475701, + "ye": 126.710623999928, + "ys": 127.487523999928 }, { "type": "LineSegment", - "xe": 83.37340478415703, - "xs": 21.794804784157023, - "ye": 83.02825514901913, - "ys": 126.71665514901913 + "xe": 83.11234792475702, + "xs": 21.53374792475701, + "ye": 83.022223999928, + "ys": 126.710623999928 }, { "type": "LineSegment", - "xe": 55.42040478415702, - "xs": 83.37340478415703, - "ye": 127.49355514901913, - "ys": 83.02825514901913 + "xe": 55.15934792475701, + "xs": 83.11234792475702, + "ye": 127.487523999928, + "ys": 83.022223999928 } ] } ], "mirror": false, - "x": 21.794804784157023, - "y": 83.02825514901913 + "x": 21.53374792475701, + "y": 83.022223999928 }, { "angle": 0.0, - "id": 18, + "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 85.1213198146622, - "xs": 83.3736198146622, - "ye": 81.78810402015608, - "ys": 83.02810402015608 + "xe": 110.38084855830463, + "xs": 107.89214855830464, + "ye": 73.52668703500468, + "ys": 87.4487870350047 }, { "type": "LineSegment", - "xe": 63.889019814662205, - "xs": 85.1213198146622, - "ye": 127.68920402015608, - "ys": 81.78810402015608 + "xe": 119.75444855830465, + "xs": 110.38084855830463, + "ye": 59.13918703500469, + "ys": 73.52668703500468 }, { "type": "LineSegment", - "xe": 55.420719814662206, - "xs": 63.889019814662205, - "ye": 127.49340402015608, - "ys": 127.68920402015608 + "xe": 130.81224855830465, + "xs": 119.75444855830465, + "ye": 49.874987035004686, + "ys": 59.13918703500469 }, { "type": "LineSegment", - "xe": 83.3736198146622, - "xs": 55.420719814662206, - "ye": 83.02810402015608, - "ys": 127.49340402015608 + "xe": 137.83024855830465, + "xs": 130.81224855830465, + "ye": 46.14498703500469, + "ys": 49.874987035004686 + }, + { + "type": "LineSegment", + "xe": 108.51794855830464, + "xs": 137.83024855830465, + "ye": 91.5076870350047, + "ys": 46.14498703500469 + }, + { + "type": "LineSegment", + "xe": 107.89214855830464, + "xs": 108.51794855830464, + "ye": 87.4487870350047, + "ys": 91.5076870350047 } ] } ], "mirror": false, - "x": 55.420719814662206, - "y": 81.78810402015608 + "x": 107.89214855830464, + "y": 46.14498703500469 }, { "angle": 0.0, - "id": 19, + "id": 24, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 122.73705054230912, - "xs": 120.06325054230912, - "ye": 25.6068040201561, - "ys": 24.8032040201561 - }, - { - "type": "LineSegment", - "xe": 126.32245054230913, - "xs": 122.73705054230912, - "ye": 33.9966040201561, - "ys": 25.6068040201561 + "xe": 89.67366706292206, + "xs": 120.16816706292207, + "ye": 104.29320475794282, + "ys": 104.99760475794282 }, { "type": "LineSegment", - "xe": 129.8782505423091, - "xs": 126.32245054230913, - "ye": 46.9046040201561, - "ys": 33.9966040201561 + "xe": 86.10656706292207, + "xs": 89.67366706292206, + "ye": 92.37840475794282, + "ys": 104.29320475794282 }, { "type": "LineSegment", - "xe": 129.77265054230912, - "xs": 129.8782505423091, - "ye": 57.6473040201561, - "ys": 46.9046040201561 + "xe": 86.20516706292207, + "xs": 86.10656706292207, + "ye": 78.79760475794282, + "ys": 92.37840475794282 }, { "type": "LineSegment", - "xe": 104.12965054230912, - "xs": 129.77265054230912, - "ye": 75.8404040201561, - "ys": 57.6473040201561 + "xe": 95.77406706292207, + "xs": 86.20516706292207, + "ye": 76.75140475794282, + "ys": 78.79760475794282 }, { "type": "LineSegment", - "xe": 84.23995054230912, - "xs": 104.12965054230912, - "ye": 81.78810402015611, - "ys": 75.8404040201561 - }, - { - "type": "LineSegment", - "xe": 120.06325054230912, - "xs": 84.23995054230912, - "ye": 24.8032040201561, - "ys": 81.78810402015611 + "xe": 120.16816706292207, + "xs": 95.77406706292207, + "ye": 104.99760475794282, + "ys": 76.75140475794282 } ] } ], "mirror": false, - "x": 84.23995054230912, - "y": 24.8032040201561 + "x": 86.10656706292207, + "y": 76.75140475794282 }, { "angle": 0.0, - "id": 24, + "id": 12, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 88.07416729656808, - "xs": 118.56866729656808, - "ye": 108.59054285374086, - "ys": 109.29494285374086 + "xe": 99.63895417736471, + "xs": 99.53555417736472, + "ye": 66.87207256909265, + "ys": 81.10687256909264 }, { "type": "LineSegment", - "xe": 84.50706729656808, - "xs": 88.07416729656808, - "ye": 96.67574285374086, - "ys": 108.59054285374086 + "xe": 118.29745417736471, + "xs": 99.63895417736471, + "ye": 61.29257256909265, + "ys": 66.87207256909265 }, { "type": "LineSegment", - "xe": 84.60566729656809, - "xs": 84.50706729656808, - "ye": 83.09494285374086, - "ys": 96.67574285374086 - }, - { - "type": "LineSegment", - "xe": 94.17456729656809, - "xs": 84.60566729656809, - "ye": 81.04874285374086, - "ys": 83.09494285374086 - }, - { - "type": "LineSegment", - "xe": 118.56866729656808, - "xs": 94.17456729656809, - "ye": 109.29494285374086, - "ys": 81.04874285374086 + "xe": 99.53555417736472, + "xs": 118.29745417736471, + "ye": 81.10687256909264, + "ys": 61.29257256909265 } ] } ], "mirror": false, - "x": 84.50706729656808, - "y": 81.04874285374086 + "x": 99.53555417736472, + "y": 61.29257256909265 }, { "angle": 0.0, - "id": 27, + "id": 18, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 68.7081930877793, - "xs": 92.1001930877793, - "ye": 117.77713594290229, - "ys": 112.77483594290229 + "xe": 84.86028713860729, + "xs": 83.1125871386073, + "ye": 81.78207342976839, + "ys": 83.02207342976838 + }, + { + "type": "LineSegment", + "xe": 63.62798713860729, + "xs": 84.86028713860729, + "ye": 127.68317342976839, + "ys": 81.78207342976839 }, { "type": "LineSegment", - "xe": 77.7072930877793, - "xs": 68.7081930877793, - "ye": 97.81613594290229, - "ys": 117.77713594290229 + "xe": 55.15968713860729, + "xs": 63.62798713860729, + "ye": 127.48737342976838, + "ys": 127.68317342976839 }, { "type": "LineSegment", - "xe": 92.1001930877793, - "xs": 77.7072930877793, - "ye": 112.77483594290229, - "ys": 97.81613594290229 + "xe": 83.1125871386073, + "xs": 55.15968713860729, + "ye": 83.02207342976838, + "ys": 127.48737342976838 } ] } ], "mirror": false, - "x": 68.7081930877793, - "y": 97.81613594290229 + "x": 55.15968713860729, + "y": 81.78207342976839 }, { "angle": 0.0, - "id": 15, + "id": 10, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 67.49452880987823, - "xs": 86.34792880987823, - "ye": 122.54236810549396, - "ys": 128.20806810549396 - }, - { - "type": "LineSegment", - "xe": 69.80742880987823, - "xs": 67.49452880987823, - "ye": 117.54206810549397, - "ys": 122.54236810549396 + "xe": 126.32697203362997, + "xs": 123.86597203362997, + "ye": 63.94705927109189, + "ys": 77.71235927109188 }, { "type": "LineSegment", - "xe": 87.82422880987824, - "xs": 69.80742880987823, - "ye": 120.75546810549397, - "ys": 117.54206810549397 + "xe": 137.75807203362996, + "xs": 126.32697203362997, + "ye": 46.40125927109189, + "ys": 63.94705927109189 }, { "type": "LineSegment", - "xe": 89.12282880987823, - "xs": 87.82422880987824, - "ye": 123.79426810549397, - "ys": 120.75546810549397 - }, - { - "type": "LineSegment", - "xe": 86.34792880987823, - "xs": 89.12282880987823, - "ye": 128.20806810549396, - "ys": 123.79426810549397 + "xe": 123.86597203362997, + "xs": 137.75807203362996, + "ye": 77.71235927109188, + "ys": 46.40125927109189 } ] } ], "mirror": false, - "x": 67.49452880987823, - "y": 117.54206810549397 + "x": 123.86597203362997, + "y": 46.40125927109189 }, { "angle": 0.0, - "id": 4, + "id": 3, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 96.7997471511833, - "xs": 86.4945471511833, - "ye": 110.8921554023378, - "ys": 128.2114554023378 + "xe": 113.88117008830956, + "xs": 113.80177008830955, + "ye": 86.66748281598555, + "ys": 97.62588281598556 + }, + { + "type": "LineSegment", + "xe": 114.73617008830955, + "xs": 113.88117008830956, + "ye": 81.88458281598555, + "ys": 86.66748281598555 + }, + { + "type": "LineSegment", + "xe": 116.60467008830955, + "xs": 114.73617008830955, + "ye": 78.99298281598556, + "ys": 81.88458281598555 }, { "type": "LineSegment", - "xe": 112.0211471511833, - "xs": 96.7997471511833, - "ye": 113.6068554023378, - "ys": 110.8921554023378 + "xe": 119.01797008830955, + "xs": 116.60467008830955, + "ye": 94.64148281598555, + "ys": 78.99298281598556 }, { "type": "LineSegment", - "xe": 86.4945471511833, - "xs": 112.0211471511833, - "ye": 128.2114554023378, - "ys": 113.6068554023378 + "xe": 113.80177008830955, + "xs": 119.01797008830955, + "ye": 97.62588281598556, + "ys": 94.64148281598555 } ] } ], "mirror": false, - "x": 86.4945471511833, - "y": 110.8921554023378 + "x": 113.80177008830955, + "y": 78.99298281598556 }, { "angle": 0.0, - "id": 23, + "id": 2, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 101.65260680074947, - "xs": 111.22160680074947, - "ye": 89.70764805799138, - "ys": 87.66124805799137 + "xe": 118.05219396375304, + "xs": 125.52589396375303, + "ye": 100.04361509815826, + "ys": 88.47791509815826 }, { "type": "LineSegment", - "xe": 101.74710680074946, - "xs": 101.65260680074947, - "ye": 76.69054805799138, - "ys": 89.70764805799138 + "xe": 123.02249396375304, + "xs": 118.05219396375304, + "ye": 72.24191509815826, + "ys": 100.04361509815826 }, { "type": "LineSegment", - "xe": 111.22160680074947, - "xs": 101.74710680074946, - "ye": 87.66124805799137, - "ys": 76.69054805799138 + "xe": 125.52589396375303, + "xs": 123.02249396375304, + "ye": 88.47791509815826, + "ys": 72.24191509815826 } ] } ], "mirror": false, - "x": 101.65260680074947, - "y": 76.69054805799138 + "x": 118.05219396375304, + "y": 72.24191509815826 }, { "angle": 0.0, - "id": 5, + "id": 23, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 112.06211441032411, - "xs": 112.22011441032411, - "ye": 100.9187827803861, - "ys": 101.9438827803861 - }, - { - "type": "LineSegment", - "xe": 112.28571441032412, - "xs": 112.06211441032411, - "ye": 70.0845827803861, - "ys": 100.9187827803861 - }, - { - "type": "LineSegment", - "xe": 117.50191441032412, - "xs": 112.28571441032412, - "ye": 67.1002827803861, - "ys": 70.0845827803861 + "xe": 79.89564312672083, + "xs": 89.46464312672083, + "ye": 105.64142461299306, + "ys": 103.59502461299306 }, { "type": "LineSegment", - "xe": 122.3393144103241, - "xs": 117.50191441032412, - "ye": 98.4671827803861, - "ys": 67.1002827803861 + "xe": 79.99014312672082, + "xs": 79.89564312672083, + "ye": 92.62432461299306, + "ys": 105.64142461299306 }, { "type": "LineSegment", - "xe": 112.22011441032411, - "xs": 122.3393144103241, - "ye": 101.9438827803861, - "ys": 98.4671827803861 + "xe": 89.46464312672083, + "xs": 79.99014312672082, + "ye": 103.59502461299306, + "ys": 92.62432461299306 } ] } ], "mirror": false, - "x": 112.06211441032411, - "y": 67.1002827803861 + "x": 79.89564312672083, + "y": 92.62432461299306 }, { "angle": 0.0, - "id": 2, + "id": 27, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 120.77257191907643, - "xs": 128.24627191907643, - "ye": 88.30803632801144, - "ys": 76.74233632801143 + "xe": 66.79599553844376, + "xs": 90.18799553844376, + "ye": 121.34068019673504, + "ys": 116.33838019673505 }, { "type": "LineSegment", - "xe": 125.74287191907642, - "xs": 120.77257191907643, - "ye": 60.506336328011436, - "ys": 88.30803632801144 + "xe": 75.79509553844376, + "xs": 66.79599553844376, + "ye": 101.37968019673504, + "ys": 121.34068019673504 }, { "type": "LineSegment", - "xe": 128.24627191907643, - "xs": 125.74287191907642, - "ye": 76.74233632801143, - "ys": 60.506336328011436 + "xe": 90.18799553844376, + "xs": 75.79509553844376, + "ye": 116.33838019673505, + "ys": 101.37968019673504 } ] } ], "mirror": false, - "x": 120.77257191907643, - "y": 60.506336328011436 + "x": 66.79599553844376, + "y": 101.37968019673504 }, { "angle": 0.0, - "id": 3, + "id": 1, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 125.15650208516173, - "xs": 125.07710208516173, - "ye": 20.124101134627217, - "ys": 31.082501134627215 - }, - { - "type": "LineSegment", - "xe": 126.01150208516172, - "xs": 125.15650208516173, - "ye": 15.341201134627216, - "ys": 20.124101134627217 + "xe": 98.32851351961378, + "xs": 82.69431351961379, + "ye": 104.49312519750058, + "ys": 127.24242519750058 }, { "type": "LineSegment", - "xe": 127.88000208516172, - "xs": 126.01150208516172, - "ye": 12.449601134627216, - "ys": 15.341201134627216 + "xe": 101.50111351961378, + "xs": 98.32851351961378, + "ye": 105.05892519750057, + "ys": 104.49312519750058 }, { "type": "LineSegment", - "xe": 130.2933020851617, - "xs": 127.88000208516172, - "ye": 28.098101134627214, - "ys": 12.449601134627216 + "xe": 91.19601351961379, + "xs": 101.50111351961378, + "ye": 122.37832519750057, + "ys": 105.05892519750057 }, { "type": "LineSegment", - "xe": 125.07710208516173, - "xs": 130.2933020851617, - "ye": 31.082501134627215, - "ys": 28.098101134627214 + "xe": 82.69431351961379, + "xs": 91.19601351961379, + "ye": 127.24242519750058, + "ys": 122.37832519750057 } ] } ], "mirror": false, - "x": 125.07710208516173, - "y": 12.449601134627216 + "x": 82.69431351961379, + "y": 104.49312519750058 }, { "angle": 0.0, - "id": 8, + "id": 4, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 136.53912229834404, - "xs": 130.94882229834406, - "ye": 48.59789219085053, - "ys": 12.349492190850537 - }, - { - "type": "LineSegment", - "xe": 130.17822229834405, - "xs": 136.53912229834404, - "ye": 27.351892190850535, - "ys": 48.59789219085053 + "xe": 98.01374001962394, + "xs": 87.70854001962394, + "ye": 110.92020205854111, + "ys": 128.23950205854112 }, { "type": "LineSegment", - "xe": 130.28572229834404, - "xs": 130.17822229834405, - "ye": 12.577192190850537, - "ys": 27.351892190850535 + "xe": 113.23514001962394, + "xs": 98.01374001962394, + "ye": 113.6349020585411, + "ys": 110.92020205854111 }, { "type": "LineSegment", - "xe": 130.94882229834406, - "xs": 130.28572229834404, - "ye": 12.349492190850537, - "ys": 12.577192190850537 + "xe": 87.70854001962394, + "xs": 113.23514001962394, + "ye": 128.23950205854112, + "ys": 113.6349020585411 } ] } ], "mirror": false, - "x": 130.17822229834405, - "y": 12.349492190850537 + "x": 87.70854001962394, + "y": 110.92020205854111 } ], "shape": [ diff --git a/doc/examples/irregular/item_bin_spacing_no/output.txt b/doc/examples/irregular/item_bin_spacing_no/output.txt index 9aba51da4..1bdb59505 100644 --- a/doc/examples/irregular/item_bin_spacing_no/output.txt +++ b/doc/examples/irregular/item_bin_spacing_no/output.txt @@ -20,6 +20,8 @@ Number of circular items: 0 Item-item minimum spacing: 0 Open dim. XY aspect ratio: -1 Leftover mode: BottomLeft +Leftover value type: SquaredArea +Leftover all bins: 1 Total item area: 16000 Smallest item area: 1600 Largest item area: 1600 @@ -31,28 +33,32 @@ Largest bin cost: 16000 Time # bins Leftover Comment ---- ------ -------- ------- - 0.001 2 13600 TS g 1 d 0 q 1 - 0.002 1 0 TS g 1 d 0 q 2 + 0.005 2 1.8496e+08 TS g 1 d 0 q 1 + 0.006 1 0 TS g 1 d 0 q 2 Final statistics ---------------- -Time (s): 10.0011 +Time (s): 10.0009 +Is proven infeasible: 0 Solution -------- -Number of items: 10 / 10 (100%) -Item area: 16000 / 16000 (100%) -Item profit: 16000 / 16000 (100%) -Number of bins: 1 / 3 (33.3333%) -Bin area: 16000 / 48000 (33.3333%) -Bin cost: 16000 -Full waste: 0 -Full waste (%): 0 -X min: 0 -Y min: 0 -X max: 160 -Y max: 100 -Density X: 1 -Density Y: 1 -ODXY area: 16000 -Leftover value: 0 +Number of items: 10 / 10 (100%) +Item area: 16000 / 16000 (100%) +Item profit: 16000 / 16000 (100%) +Number of bins: 1 / 3 (33.3333%) +Bin area: 16000 / 48000 (33.3333%) +Bin cost: 16000 +Full waste: 0 +Full waste (%): 0 +X min: 0 +Y min: 0 +X max: 160 +Y max: 100 +Density X: 1 +Density Y: 1 +ODXY area: 16000 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 5.12e+08 +Total staircase leftover value: 32000 diff --git a/doc/examples/irregular/item_bin_spacing_yes/output.txt b/doc/examples/irregular/item_bin_spacing_yes/output.txt index e8b06479f..d1a55fe3a 100644 --- a/doc/examples/irregular/item_bin_spacing_yes/output.txt +++ b/doc/examples/irregular/item_bin_spacing_yes/output.txt @@ -20,6 +20,8 @@ Number of circular items: 0 Item-item minimum spacing: 0 Open dim. XY aspect ratio: -1 Leftover mode: BottomLeft +Leftover value type: SquaredArea +Leftover all bins: 1 Total item area: 16000 Smallest item area: 1600 Largest item area: 1600 @@ -31,29 +33,33 @@ Largest bin cost: 16000 Time # bins Leftover Comment ---- ------ -------- ------- - 0.001 2 5791 TS g 1 d 0 q 1 - 0.002 2 7451 TS g 1 d 0 q 1 - 0.002 2 9111 TS g 1 d 0 q 1 + 0.007 2 3.35357e+07 TS g 1 d 0 q 1 + 0.008 2 5.55174e+07 TS g 1 d 0 q 1 + 0.016 2 8.30103e+07 TS g 1 d 0 q 1 Final statistics ---------------- -Time (s): 10.0012 +Time (s): 10.0009 +Is proven infeasible: 0 Solution -------- -Number of items: 10 / 10 (100%) -Item area: 16000 / 16000 (100%) -Item profit: 16000 / 16000 (100%) -Number of bins: 2 / 3 (66.6667%) -Bin area: 32000 / 48000 (66.6667%) -Bin cost: 32000 -Full waste: 16000 -Full waste (%): 50 -X min: 3 -Y min: 3 -X max: 83 -Y max: 83 -Density X: 0.658436 -Density Y: 0.546448 -ODXY area: 6400 -Leftover value: 9111 +Number of items: 10 / 10 (100%) +Item area: 16000 / 16000 (100%) +Item profit: 16000 / 16000 (100%) +Number of bins: 2 / 3 (66.6667%) +Bin area: 32000 / 48000 (66.6667%) +Bin cost: 32000 +Full waste: 16000 +Full waste (%): 50 +X min: 3 +Y min: 3 +X max: 83 +Y max: 83 +Density X: 0.658436 +Density Y: 0.546448 +ODXY area: 6400 +Leftover value: 8.30103e+07 +Staircase leftover value: 9111 +Total leftover value: 3.72546e+08 +Total staircase leftover value: 30902 diff --git a/doc/examples/irregular/item_defect_spacing_no/output.txt b/doc/examples/irregular/item_defect_spacing_no/output.txt index 571c4bdc0..be9beaa13 100644 --- a/doc/examples/irregular/item_defect_spacing_no/output.txt +++ b/doc/examples/irregular/item_defect_spacing_no/output.txt @@ -20,6 +20,8 @@ Number of circular items: 0 Item-item minimum spacing: 0 Open dim. XY aspect ratio: -1 Leftover mode: BottomLeft +Leftover value type: SquaredArea +Leftover all bins: 1 Total item area: 18400 Smallest item area: 800 Largest item area: 800 @@ -31,31 +33,35 @@ Largest bin cost: 19200 Time # bins Leftover Comment ---- ------ -------- ------- - 0.001 2 9600 TS g 1 d 0 q 1 - 0.002 2 14400 TS g 1 d 0 q 1 - 0.005 2 16000 TS g 0 d 0 q 2 - 0.007 2 17600 TS g 0 d 0 q 3 - 0.147 1 0 SSK it 4 + 0.002 2 1.6384e+08 TS g 1 d 0 q 1 + 0.002 2 2.0736e+08 TS g 0 d 0 q 1 + 0.011 2 2.56e+08 TS g 0 d 0 q 2 + 0.017 2 3.0976e+08 TS g 1 d 0 q 3 + 0.030 1 0 TS g 1 d 0 q 9 Final statistics ---------------- -Time (s): 8.00076 +Time (s): 8.0056 +Is proven infeasible: 0 Solution -------- -Number of items: 23 / 23 (100%) -Item area: 18400 / 18400 (100%) -Item profit: 18400 / 18400 (100%) -Number of bins: 1 / 3 (33.3333%) -Bin area: 19200 / 57600 (33.3333%) -Bin cost: 19200 -Full waste: 800 -Full waste (%): 4.16667 -X min: 0 -Y min: 0 -X max: 160 -Y max: 120 -Density X: 0.958333 -Density Y: 0.958333 -ODXY area: 19200 -Leftover value: 0 +Number of items: 23 / 23 (100%) +Item area: 18400 / 18400 (100%) +Item profit: 18400 / 18400 (100%) +Number of bins: 1 / 3 (33.3333%) +Bin area: 19200 / 57600 (33.3333%) +Bin cost: 19200 +Full waste: 800 +Full waste (%): 4.16667 +X min: 0 +Y min: 0 +X max: 160 +Y max: 120 +Density X: 0.958333 +Density Y: 0.958333 +ODXY area: 19200 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 7.3728e+08 +Total staircase leftover value: 38400 diff --git a/doc/examples/irregular/item_defect_spacing_no/solution.json b/doc/examples/irregular/item_defect_spacing_no/solution.json index 62774e0ce..aace6110b 100644 --- a/doc/examples/irregular/item_defect_spacing_no/solution.json +++ b/doc/examples/irregular/item_defect_spacing_no/solution.json @@ -32,41 +32,41 @@ "id": 0, "items": [ { - "angle": 180.0, + "angle": 90.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 0.0, + "xe": 40.0, "xs": 40.0, - "ye": 120.0, - "ys": 120.0 + "ye": 40.0, + "ys": 0.0 }, { "type": "LineSegment", - "xe": 40.0, - "xs": 0.0, - "ye": 80.0, - "ys": 120.0 + "xe": 0.0, + "xs": 40.0, + "ye": 0.0, + "ys": 40.0 }, { "type": "LineSegment", "xe": 40.0, - "xs": 40.0, - "ye": 120.0, - "ys": 80.0 + "xs": 0.0, + "ye": 0.0, + "ys": 0.0 } ] } ], "mirror": false, "x": 40.0, - "y": 120.0 + "y": 0.0 }, { - "angle": 180.0, + "angle": 270.0, "id": 0, "item_shapes": [ { @@ -74,56 +74,56 @@ { "type": "LineSegment", "xe": 0.0, - "xs": 40.0, - "ye": 40.0, + "xs": 0.0, + "ye": 0.0, "ys": 40.0 }, { "type": "LineSegment", "xe": 40.0, "xs": 0.0, - "ye": 0.0, - "ys": 40.0 + "ye": 40.0, + "ys": 0.0 }, { "type": "LineSegment", - "xe": 40.0, + "xe": 0.0, "xs": 40.0, "ye": 40.0, - "ys": 0.0 + "ys": 40.0 } ] } ], "mirror": false, - "x": 40.0, + "x": 0.0, "y": 40.0 }, { - "angle": 180.0, + "angle": 90.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 0.0, + "xe": 40.0, "xs": 40.0, "ye": 80.0, - "ys": 80.0 + "ys": 40.0 }, { "type": "LineSegment", - "xe": 40.0, - "xs": 0.0, + "xe": 0.0, + "xs": 40.0, "ye": 40.0, "ys": 80.0 }, { "type": "LineSegment", "xe": 40.0, - "xs": 40.0, - "ye": 80.0, + "xs": 0.0, + "ye": 40.0, "ys": 40.0 } ] @@ -131,34 +131,34 @@ ], "mirror": false, "x": 40.0, - "y": 80.0 + "y": 40.0 }, { - "angle": 0.0, + "angle": 270.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 40.0, + "xe": 0.0, "xs": 0.0, - "ye": 80.0, + "ye": 40.0, "ys": 80.0 }, { "type": "LineSegment", - "xe": 0.0, - "xs": 40.0, - "ye": 120.0, - "ys": 80.0 + "xe": 40.0, + "xs": 0.0, + "ye": 80.0, + "ys": 40.0 }, { "type": "LineSegment", "xe": 0.0, - "xs": 0.0, + "xs": 40.0, "ye": 80.0, - "ys": 120.0 + "ys": 80.0 } ] } @@ -168,7 +168,7 @@ "y": 80.0 }, { - "angle": 180.0, + "angle": 90.0, "id": 0, "item_shapes": [ { @@ -176,56 +176,90 @@ { "type": "LineSegment", "xe": 40.0, - "xs": 80.0, + "xs": 40.0, "ye": 120.0, - "ys": 120.0 + "ys": 80.0 }, { "type": "LineSegment", - "xe": 80.0, + "xe": 0.0, "xs": 40.0, "ye": 80.0, "ys": 120.0 }, { "type": "LineSegment", - "xe": 80.0, - "xs": 80.0, + "xe": 40.0, + "xs": 0.0, + "ye": 80.0, + "ys": 80.0 + } + ] + } + ], + "mirror": false, + "x": 40.0, + "y": 80.0 + }, + { + "angle": 270.0, + "id": 0, + "item_shapes": [ + { + "shape": [ + { + "type": "LineSegment", + "xe": 0.0, + "xs": 0.0, + "ye": 80.0, + "ys": 120.0 + }, + { + "type": "LineSegment", + "xe": 40.0, + "xs": 0.0, "ye": 120.0, "ys": 80.0 + }, + { + "type": "LineSegment", + "xe": 0.0, + "xs": 40.0, + "ye": 120.0, + "ys": 120.0 } ] } ], "mirror": false, - "x": 80.0, + "x": 0.0, "y": 120.0 }, { - "angle": 180.0, + "angle": 90.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 40.0, + "xe": 80.0, "xs": 80.0, "ye": 40.0, - "ys": 40.0 + "ys": 0.0 }, { "type": "LineSegment", - "xe": 80.0, - "xs": 40.0, + "xe": 40.0, + "xs": 80.0, "ye": 0.0, "ys": 40.0 }, { "type": "LineSegment", "xe": 80.0, - "xs": 80.0, - "ye": 40.0, + "xs": 40.0, + "ye": 0.0, "ys": 0.0 } ] @@ -233,41 +267,41 @@ ], "mirror": false, "x": 80.0, - "y": 40.0 + "y": 0.0 }, { - "angle": 0.0, + "angle": 270.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 80.0, + "xe": 40.0, "xs": 40.0, - "ye": 80.0, - "ys": 80.0 + "ye": 0.0, + "ys": 40.0 }, { "type": "LineSegment", - "xe": 40.0, - "xs": 80.0, - "ye": 120.0, - "ys": 80.0 + "xe": 80.0, + "xs": 40.0, + "ye": 40.0, + "ys": 0.0 }, { "type": "LineSegment", "xe": 40.0, - "xs": 40.0, - "ye": 80.0, - "ys": 120.0 + "xs": 80.0, + "ye": 40.0, + "ys": 40.0 } ] } ], "mirror": false, "x": 40.0, - "y": 80.0 + "y": 40.0 }, { "angle": 180.0, @@ -304,7 +338,7 @@ "y": 80.0 }, { - "angle": 180.0, + "angle": 90.0, "id": 0, "item_shapes": [ { @@ -312,98 +346,64 @@ { "type": "LineSegment", "xe": 80.0, - "xs": 120.0, + "xs": 80.0, "ye": 120.0, - "ys": 120.0 + "ys": 80.0 }, { "type": "LineSegment", - "xe": 120.0, + "xe": 40.0, "xs": 80.0, "ye": 80.0, "ys": 120.0 }, { "type": "LineSegment", - "xe": 120.0, - "xs": 120.0, - "ye": 120.0, + "xe": 80.0, + "xs": 40.0, + "ye": 80.0, "ys": 80.0 } ] } ], "mirror": false, - "x": 120.0, - "y": 120.0 + "x": 80.0, + "y": 80.0 }, { - "angle": 0.0, + "angle": 270.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 120.0, - "xs": 80.0, + "xe": 40.0, + "xs": 40.0, "ye": 80.0, - "ys": 80.0 + "ys": 120.0 }, { "type": "LineSegment", "xe": 80.0, - "xs": 120.0, + "xs": 40.0, "ye": 120.0, "ys": 80.0 }, { "type": "LineSegment", - "xe": 80.0, + "xe": 40.0, "xs": 80.0, - "ye": 80.0, + "ye": 120.0, "ys": 120.0 } ] } ], "mirror": false, - "x": 80.0, - "y": 80.0 - }, - { - "angle": 0.0, - "id": 0, - "item_shapes": [ - { - "shape": [ - { - "type": "LineSegment", - "xe": 40.0, - "xs": 0.0, - "ye": 40.0, - "ys": 40.0 - }, - { - "type": "LineSegment", - "xe": 0.0, - "xs": 40.0, - "ye": 80.0, - "ys": 40.0 - }, - { - "type": "LineSegment", - "xe": 0.0, - "xs": 0.0, - "ye": 40.0, - "ys": 80.0 - } - ] - } - ], - "mirror": false, - "x": 0.0, - "y": 40.0 + "x": 40.0, + "y": 120.0 }, { "angle": 0.0, @@ -413,22 +413,22 @@ "shape": [ { "type": "LineSegment", - "xe": 40.0, - "xs": 0.0, + "xe": 120.0, + "xs": 80.0, "ye": 0.0, "ys": 0.0 }, { "type": "LineSegment", - "xe": 0.0, - "xs": 40.0, + "xe": 80.0, + "xs": 120.0, "ye": 40.0, "ys": 0.0 }, { "type": "LineSegment", - "xe": 0.0, - "xs": 0.0, + "xe": 80.0, + "xs": 80.0, "ye": 0.0, "ys": 40.0 } @@ -436,8 +436,8 @@ } ], "mirror": false, - "x": 0.0, - "y": -0.0 + "x": 80.0, + "y": 0.0 }, { "angle": 180.0, @@ -449,29 +449,29 @@ "type": "LineSegment", "xe": 80.0, "xs": 120.0, - "ye": 80.0, - "ys": 80.0 + "ye": 40.0, + "ys": 40.0 }, { "type": "LineSegment", "xe": 120.0, "xs": 80.0, - "ye": 40.0, - "ys": 80.0 + "ye": 0.0, + "ys": 40.0 }, { "type": "LineSegment", "xe": 120.0, "xs": 120.0, - "ye": 80.0, - "ys": 40.0 + "ye": 40.0, + "ys": 0.0 } ] } ], "mirror": false, "x": 120.0, - "y": 80.0 + "y": 40.0 }, { "angle": 0.0, @@ -508,41 +508,41 @@ "y": 40.0 }, { - "angle": 180.0, + "angle": 0.0, "id": 0, "item_shapes": [ { "shape": [ - { - "type": "LineSegment", - "xe": 80.0, - "xs": 120.0, - "ye": 40.0, - "ys": 40.0 - }, { "type": "LineSegment", "xe": 120.0, "xs": 80.0, - "ye": 0.0, - "ys": 40.0 + "ye": 80.0, + "ys": 80.0 }, { "type": "LineSegment", - "xe": 120.0, + "xe": 80.0, "xs": 120.0, - "ye": 40.0, - "ys": 0.0 + "ye": 120.0, + "ys": 80.0 + }, + { + "type": "LineSegment", + "xe": 80.0, + "xs": 80.0, + "ye": 80.0, + "ys": 120.0 } ] } ], "mirror": false, - "x": 120.0, - "y": 40.0 + "x": 80.0, + "y": 80.0 }, { - "angle": 0.0, + "angle": 180.0, "id": 0, "item_shapes": [ { @@ -550,101 +550,101 @@ { "type": "LineSegment", "xe": 80.0, - "xs": 40.0, - "ye": 0.0, - "ys": 0.0 + "xs": 120.0, + "ye": 80.0, + "ys": 80.0 }, { "type": "LineSegment", - "xe": 40.0, + "xe": 120.0, "xs": 80.0, "ye": 40.0, - "ys": 0.0 + "ys": 80.0 }, { "type": "LineSegment", - "xe": 40.0, - "xs": 40.0, - "ye": 0.0, + "xe": 120.0, + "xs": 120.0, + "ye": 80.0, "ys": 40.0 } ] } ], "mirror": false, - "x": 40.0, - "y": -0.0 + "x": 120.0, + "y": 80.0 }, { - "angle": 0.0, + "angle": 180.0, "id": 0, "item_shapes": [ { "shape": [ - { - "type": "LineSegment", - "xe": 120.0, - "xs": 80.0, - "ye": 0.0, - "ys": 0.0 - }, { "type": "LineSegment", "xe": 80.0, "xs": 120.0, - "ye": 40.0, - "ys": 0.0 + "ye": 120.0, + "ys": 120.0 }, { "type": "LineSegment", - "xe": 80.0, + "xe": 120.0, "xs": 80.0, - "ye": 0.0, - "ys": 40.0 + "ye": 80.0, + "ys": 120.0 + }, + { + "type": "LineSegment", + "xe": 120.0, + "xs": 120.0, + "ye": 120.0, + "ys": 80.0 } ] } ], "mirror": false, - "x": 80.0, - "y": -0.0 + "x": 120.0, + "y": 120.0 }, { - "angle": 180.0, + "angle": 0.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 120.0, - "xs": 160.0, - "ye": 80.0, - "ys": 80.0 + "xe": 160.0, + "xs": 120.0, + "ye": 0.0, + "ys": 0.0 }, { "type": "LineSegment", - "xe": 160.0, - "xs": 120.0, + "xe": 120.0, + "xs": 160.0, "ye": 40.0, - "ys": 80.0 + "ys": 0.0 }, { "type": "LineSegment", - "xe": 160.0, - "xs": 160.0, - "ye": 80.0, + "xe": 120.0, + "xs": 120.0, + "ye": 0.0, "ys": 40.0 } ] } ], "mirror": false, - "x": 160.0, - "y": 80.0 + "x": 120.0, + "y": 0.0 }, { - "angle": 270.0, + "angle": 180.0, "id": 0, "item_shapes": [ { @@ -652,30 +652,30 @@ { "type": "LineSegment", "xe": 120.0, - "xs": 120.0, - "ye": 80.0, - "ys": 120.0 + "xs": 160.0, + "ye": 40.0, + "ys": 40.0 }, { "type": "LineSegment", "xe": 160.0, "xs": 120.0, - "ye": 120.0, - "ys": 80.0 + "ye": 0.0, + "ys": 40.0 }, { "type": "LineSegment", - "xe": 120.0, + "xe": 160.0, "xs": 160.0, - "ye": 120.0, - "ys": 120.0 + "ye": 40.0, + "ys": 0.0 } ] } ], "mirror": false, - "x": 120.0, - "y": 120.0 + "x": 160.0, + "y": 40.0 }, { "angle": 0.0, @@ -712,98 +712,98 @@ "y": 40.0 }, { - "angle": 180.0, + "angle": 0.0, "id": 0, "item_shapes": [ { "shape": [ - { - "type": "LineSegment", - "xe": 120.0, - "xs": 160.0, - "ye": 40.0, - "ys": 40.0 - }, { "type": "LineSegment", "xe": 160.0, "xs": 120.0, - "ye": 0.0, - "ys": 40.0 + "ye": 80.0, + "ys": 80.0 }, { "type": "LineSegment", - "xe": 160.0, + "xe": 120.0, "xs": 160.0, - "ye": 40.0, - "ys": 0.0 + "ye": 120.0, + "ys": 80.0 + }, + { + "type": "LineSegment", + "xe": 120.0, + "xs": 120.0, + "ye": 80.0, + "ys": 120.0 } ] } ], "mirror": false, - "x": 160.0, - "y": 40.0 + "x": 120.0, + "y": 80.0 }, { - "angle": 0.0, + "angle": 180.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 160.0, - "xs": 120.0, - "ye": 0.0, - "ys": 0.0 + "xe": 120.0, + "xs": 160.0, + "ye": 80.0, + "ys": 80.0 }, { "type": "LineSegment", - "xe": 120.0, - "xs": 160.0, + "xe": 160.0, + "xs": 120.0, "ye": 40.0, - "ys": 0.0 + "ys": 80.0 }, { "type": "LineSegment", - "xe": 120.0, - "xs": 120.0, - "ye": 0.0, + "xe": 160.0, + "xs": 160.0, + "ye": 80.0, "ys": 40.0 } ] } ], "mirror": false, - "x": 120.0, - "y": -0.0 + "x": 160.0, + "y": 80.0 }, { - "angle": 90.0, + "angle": 180.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 160.0, + "xe": 120.0, "xs": 160.0, "ye": 120.0, - "ys": 80.0 + "ys": 120.0 }, { "type": "LineSegment", - "xe": 120.0, - "xs": 160.0, + "xe": 160.0, + "xs": 120.0, "ye": 80.0, "ys": 120.0 }, { "type": "LineSegment", "xe": 160.0, - "xs": 120.0, - "ye": 80.0, + "xs": 160.0, + "ye": 120.0, "ys": 80.0 } ] @@ -811,7 +811,7 @@ ], "mirror": false, "x": 160.0, - "y": 80.0 + "y": 120.0 } ], "shape": [ diff --git a/doc/examples/irregular/item_defect_spacing_yes/output.txt b/doc/examples/irregular/item_defect_spacing_yes/output.txt index 6eff59752..7358b3b16 100644 --- a/doc/examples/irregular/item_defect_spacing_yes/output.txt +++ b/doc/examples/irregular/item_defect_spacing_yes/output.txt @@ -20,6 +20,8 @@ Number of circular items: 0 Item-item minimum spacing: 0 Open dim. XY aspect ratio: -1 Leftover mode: BottomLeft +Leftover value type: SquaredArea +Leftover all bins: 1 Total item area: 18400 Smallest item area: 800 Largest item area: 800 @@ -31,29 +33,34 @@ Largest bin cost: 19200 Time # bins Leftover Comment ---- ------ -------- ------- - 0.002 2 12800 TS g 0 d 0 q 1 - 0.003 2 14400 TS g 0 d 0 q 1 - 0.019 2 16000 SSK it 0 + 0.003 2 1.6384e+08 TS g 0 d 0 q 1 + 0.004 2 2.0736e+08 TS g 1 d 0 q 1 + 0.016 2 2.0736e+08 TS g 0 d 0 q 2 + 0.026 2 2.56e+08 TS g 1 d 0 q 3 Final statistics ---------------- -Time (s): 8.00226 +Time (s): 8.00847 +Is proven infeasible: 0 Solution -------- -Number of items: 23 / 23 (100%) -Item area: 18400 / 18400 (100%) -Item profit: 18400 / 18400 (100%) -Number of bins: 2 / 3 (66.6667%) -Bin area: 38400 / 57600 (66.6667%) -Bin cost: 38400 -Full waste: 20000 -Full waste (%): 52.0833 -X min: 0 -Y min: 0 -X max: 80 -Y max: 40 -Density X: 0.638889 -Density Y: 0.71875 -ODXY area: 3200 -Leftover value: 16000 +Number of items: 23 / 23 (100%) +Item area: 18400 / 18400 (100%) +Item profit: 18400 / 18400 (100%) +Number of bins: 2 / 3 (66.6667%) +Bin area: 38400 / 57600 (66.6667%) +Bin cost: 38400 +Full waste: 20000 +Full waste (%): 52.0833 +X min: 0 +Y min: 0 +X max: 40 +Y max: 80 +Density X: 0.766667 +Density Y: 0.575 +ODXY area: 3200 +Leftover value: 2.56e+08 +Staircase leftover value: 16000 +Total leftover value: 6.2464e+08 +Total staircase leftover value: 35799.9 diff --git a/doc/examples/irregular/item_defect_spacing_yes/solution.json b/doc/examples/irregular/item_defect_spacing_yes/solution.json index a2ada759c..3c41f2828 100644 --- a/doc/examples/irregular/item_defect_spacing_yes/solution.json +++ b/doc/examples/irregular/item_defect_spacing_yes/solution.json @@ -32,242 +32,276 @@ "id": 0, "items": [ { - "angle": 180.0, + "angle": 0.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 120.0, - "xs": 160.0, - "ye": 120.0, - "ys": 120.0 + "xe": 40.0, + "xs": 0.0, + "ye": 0.0, + "ys": 0.0 }, { "type": "LineSegment", - "xe": 160.0, - "xs": 120.0, - "ye": 80.0, - "ys": 120.0 + "xe": 0.0, + "xs": 40.0, + "ye": 40.0, + "ys": 0.0 }, { "type": "LineSegment", - "xe": 160.0, - "xs": 160.0, - "ye": 120.0, - "ys": 80.0 + "xe": 0.0, + "xs": 0.0, + "ye": 0.0, + "ys": 40.0 } ] } ], "mirror": false, - "x": 160.0, - "y": 120.0 + "x": 0.0, + "y": 0.0 }, { - "angle": 0.0, + "angle": 270.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 160.0, - "xs": 120.0, - "ye": 80.0, + "xe": 0.0, + "xs": 0.0, + "ye": 40.0, "ys": 80.0 }, { "type": "LineSegment", - "xe": 120.0, - "xs": 160.0, - "ye": 120.0, - "ys": 80.0 + "xe": 40.0, + "xs": 0.0, + "ye": 80.0, + "ys": 40.0 }, { "type": "LineSegment", - "xe": 120.0, - "xs": 120.0, + "xe": 0.0, + "xs": 40.0, "ye": 80.0, - "ys": 120.0 + "ys": 80.0 } ] } ], "mirror": false, - "x": 120.0, + "x": 0.0, "y": 80.0 }, { - "angle": 180.0, + "angle": 0.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 120.0, - "xs": 160.0, + "xe": 40.0, + "xs": 0.0, "ye": 80.0, "ys": 80.0 }, { "type": "LineSegment", - "xe": 160.0, - "xs": 120.0, - "ye": 40.0, + "xe": 0.0, + "xs": 40.0, + "ye": 120.0, "ys": 80.0 }, { "type": "LineSegment", - "xe": 160.0, - "xs": 160.0, + "xe": 0.0, + "xs": 0.0, "ye": 80.0, - "ys": 40.0 + "ys": 120.0 } ] } ], "mirror": false, - "x": 160.0, + "x": 0.0, "y": 80.0 }, { - "angle": 0.0, + "angle": 180.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 160.0, - "xs": 120.0, - "ye": 40.0, - "ys": 40.0 + "xe": 0.0, + "xs": 40.0, + "ye": 120.0, + "ys": 120.0 }, { "type": "LineSegment", - "xe": 120.0, - "xs": 160.0, + "xe": 40.0, + "xs": 0.0, "ye": 80.0, - "ys": 40.0 + "ys": 120.0 }, { "type": "LineSegment", - "xe": 120.0, - "xs": 120.0, - "ye": 40.0, + "xe": 40.0, + "xs": 40.0, + "ye": 120.0, "ys": 80.0 } ] } ], "mirror": false, - "x": 120.0, - "y": 40.0 + "x": 40.0, + "y": 120.0 }, { - "angle": 180.0, + "angle": 90.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 120.0, - "xs": 160.0, - "ye": 40.0, - "ys": 40.0 + "xe": 65.00139657811859, + "xs": 65.00139657811859, + "ye": 105.00139657811859, + "ys": 65.00139657811859 }, { "type": "LineSegment", - "xe": 160.0, - "xs": 120.0, - "ye": 0.0, - "ys": 40.0 + "xe": 25.001396578118587, + "xs": 65.00139657811859, + "ye": 65.00139657811859, + "ys": 105.00139657811859 }, { "type": "LineSegment", - "xe": 160.0, - "xs": 160.0, - "ye": 40.0, - "ys": 0.0 + "xe": 65.00139657811859, + "xs": 25.001396578118587, + "ye": 65.00139657811859, + "ys": 65.00139657811859 } ] } ], "mirror": false, - "x": 160.0, - "y": 40.0 + "x": 65.00139657811859, + "y": 65.00139657811859 }, { - "angle": 0.0, + "angle": 270.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 160.0, - "xs": 120.0, - "ye": 0.0, - "ys": 0.0 + "xe": 40.0, + "xs": 40.0, + "ye": 80.0, + "ys": 120.0 }, { "type": "LineSegment", - "xe": 120.0, - "xs": 160.0, + "xe": 80.0, + "xs": 40.0, + "ye": 120.0, + "ys": 80.0 + }, + { + "type": "LineSegment", + "xe": 40.0, + "xs": 80.0, + "ye": 120.0, + "ys": 120.0 + } + ] + } + ], + "mirror": false, + "x": 40.0, + "y": 120.0 + }, + { + "angle": 90.0, + "id": 0, + "item_shapes": [ + { + "shape": [ + { + "type": "LineSegment", + "xe": 80.0, + "xs": 80.0, "ye": 40.0, "ys": 0.0 }, { "type": "LineSegment", - "xe": 120.0, - "xs": 120.0, + "xe": 40.0, + "xs": 80.0, "ye": 0.0, "ys": 40.0 + }, + { + "type": "LineSegment", + "xe": 80.0, + "xs": 40.0, + "ye": 0.0, + "ys": 0.0 } ] } ], "mirror": false, - "x": 120.0, - "y": -0.0 + "x": 80.0, + "y": 0.0 }, { - "angle": 180.0, + "angle": 270.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 80.0, - "xs": 120.0, - "ye": 120.0, - "ys": 120.0 + "xe": 65.00139657811859, + "xs": 65.00139657811859, + "ye": 25.001396578118587, + "ys": 65.00139657811859 }, { "type": "LineSegment", - "xe": 120.0, - "xs": 80.0, - "ye": 80.0, - "ys": 120.0 + "xe": 105.00139657811859, + "xs": 65.00139657811859, + "ye": 65.00139657811859, + "ys": 25.001396578118587 }, { "type": "LineSegment", - "xe": 120.0, - "xs": 120.0, - "ye": 120.0, - "ys": 80.0 + "xe": 65.00139657811859, + "xs": 105.00139657811859, + "ye": 65.00139657811859, + "ys": 65.00139657811859 } ] } ], "mirror": false, - "x": 120.0, - "y": 120.0 + "x": 65.00139657811859, + "y": 65.00139657811859 }, { "angle": 0.0, @@ -277,31 +311,31 @@ "shape": [ { "type": "LineSegment", - "xe": 120.0, - "xs": 80.0, - "ye": 80.0, - "ys": 80.0 + "xe": 105.00139657811859, + "xs": 65.00139657811859, + "ye": 65.00139657811859, + "ys": 65.00139657811859 }, { "type": "LineSegment", - "xe": 80.0, - "xs": 120.0, - "ye": 120.0, - "ys": 80.0 + "xe": 65.00139657811859, + "xs": 105.00139657811859, + "ye": 105.00139657811859, + "ys": 65.00139657811859 }, { "type": "LineSegment", - "xe": 80.0, - "xs": 80.0, - "ye": 80.0, - "ys": 120.0 + "xe": 65.00139657811859, + "xs": 65.00139657811859, + "ye": 65.00139657811859, + "ys": 105.00139657811859 } ] } ], "mirror": false, - "x": 80.0, - "y": 80.0 + "x": 65.00139657811859, + "y": 65.00139657811859 }, { "angle": 180.0, @@ -311,31 +345,31 @@ "shape": [ { "type": "LineSegment", - "xe": 80.0, - "xs": 120.0, - "ye": 80.0, - "ys": 80.0 + "xe": 65.00139657811862, + "xs": 105.00139657811862, + "ye": 105.00139657811857, + "ys": 105.00139657811857 }, { "type": "LineSegment", - "xe": 120.0, - "xs": 80.0, - "ye": 40.0, - "ys": 80.0 + "xe": 105.00139657811862, + "xs": 65.00139657811862, + "ye": 65.00139657811857, + "ys": 105.00139657811857 }, { "type": "LineSegment", - "xe": 120.0, - "xs": 120.0, - "ye": 80.0, - "ys": 40.0 + "xe": 105.00139657811862, + "xs": 105.00139657811862, + "ye": 105.00139657811857, + "ys": 65.00139657811857 } ] } ], "mirror": false, - "x": 120.0, - "y": 80.0 + "x": 105.00139657811862, + "y": 105.00139657811857 }, { "angle": 0.0, @@ -347,29 +381,29 @@ "type": "LineSegment", "xe": 120.0, "xs": 80.0, - "ye": 40.0, - "ys": 40.0 + "ye": 0.0, + "ys": 0.0 }, { "type": "LineSegment", "xe": 80.0, "xs": 120.0, - "ye": 80.0, - "ys": 40.0 + "ye": 40.0, + "ys": 0.0 }, { "type": "LineSegment", "xe": 80.0, "xs": 80.0, - "ye": 40.0, - "ys": 80.0 + "ye": 0.0, + "ys": 40.0 } ] } ], "mirror": false, "x": 80.0, - "y": 40.0 + "y": 0.0 }, { "angle": 180.0, @@ -406,7 +440,7 @@ "y": 40.0 }, { - "angle": 0.0, + "angle": 90.0, "id": 0, "item_shapes": [ { @@ -414,64 +448,30 @@ { "type": "LineSegment", "xe": 120.0, - "xs": 80.0, - "ye": 0.0, - "ys": 0.0 + "xs": 120.0, + "ye": 80.0, + "ys": 40.0 }, { "type": "LineSegment", "xe": 80.0, "xs": 120.0, "ye": 40.0, - "ys": 0.0 + "ys": 80.0 }, { "type": "LineSegment", - "xe": 80.0, + "xe": 120.0, "xs": 80.0, - "ye": 0.0, + "ye": 40.0, "ys": 40.0 } ] } ], "mirror": false, - "x": 80.0, - "y": -0.0 - }, - { - "angle": 180.0, - "id": 0, - "item_shapes": [ - { - "shape": [ - { - "type": "LineSegment", - "xe": 40.0, - "xs": 80.0, - "ye": 120.0, - "ys": 120.0 - }, - { - "type": "LineSegment", - "xe": 80.0, - "xs": 40.0, - "ye": 80.0, - "ys": 120.0 - }, - { - "type": "LineSegment", - "xe": 80.0, - "xs": 80.0, - "ye": 120.0, - "ys": 80.0 - } - ] - } - ], - "mirror": false, - "x": 80.0, - "y": 120.0 + "x": 120.0, + "y": 40.0 }, { "angle": 0.0, @@ -481,22 +481,22 @@ "shape": [ { "type": "LineSegment", - "xe": 80.0, - "xs": 40.0, + "xe": 145.0013965781186, + "xs": 105.00139657811862, "ye": 80.0, "ys": 80.0 }, { "type": "LineSegment", - "xe": 40.0, - "xs": 80.0, + "xe": 105.00139657811862, + "xs": 145.0013965781186, "ye": 120.0, "ys": 80.0 }, { "type": "LineSegment", - "xe": 40.0, - "xs": 40.0, + "xe": 105.00139657811862, + "xs": 105.00139657811862, "ye": 80.0, "ys": 120.0 } @@ -504,76 +504,76 @@ } ], "mirror": false, - "x": 40.0, + "x": 105.00139657811862, "y": 80.0 }, { - "angle": 90.0, + "angle": 180.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 80.0, - "xs": 80.0, - "ye": 50.08286258265349, - "ys": 10.08286258265349 + "xe": 105.0013965781186, + "xs": 145.0013965781186, + "ye": 120.00000000000001, + "ys": 120.00000000000001 }, { "type": "LineSegment", - "xe": 40.0, - "xs": 80.0, - "ye": 10.08286258265349, - "ys": 50.08286258265349 + "xe": 145.0013965781186, + "xs": 105.0013965781186, + "ye": 80.00000000000001, + "ys": 120.00000000000001 }, { "type": "LineSegment", - "xe": 80.0, - "xs": 40.0, - "ye": 10.08286258265349, - "ys": 10.08286258265349 + "xe": 145.0013965781186, + "xs": 145.0013965781186, + "ye": 120.00000000000001, + "ys": 80.00000000000001 } ] } ], "mirror": false, - "x": 80.0, - "y": 10.08286258265349 + "x": 145.0013965781186, + "y": 120.00000000000001 }, { - "angle": 180.0, + "angle": 0.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 29.91713741734651, - "xs": 69.91713741734651, - "ye": 80.0, - "ys": 80.0 + "xe": 160.0, + "xs": 120.0, + "ye": 0.0, + "ys": 0.0 }, { "type": "LineSegment", - "xe": 69.91713741734651, - "xs": 29.91713741734651, + "xe": 120.0, + "xs": 160.0, "ye": 40.0, - "ys": 80.0 + "ys": 0.0 }, { "type": "LineSegment", - "xe": 69.91713741734651, - "xs": 69.91713741734651, - "ye": 80.0, + "xe": 120.0, + "xs": 120.0, + "ye": 0.0, "ys": 40.0 } ] } ], "mirror": false, - "x": 69.91713741734651, - "y": 80.0 + "x": 120.0, + "y": 0.0 }, { "angle": 180.0, @@ -583,31 +583,31 @@ "shape": [ { "type": "LineSegment", - "xe": 0.0, - "xs": 40.0, - "ye": 120.0, - "ys": 120.0 + "xe": 120.0, + "xs": 160.0, + "ye": 40.0, + "ys": 40.0 }, { "type": "LineSegment", - "xe": 40.0, - "xs": 0.0, - "ye": 80.0, - "ys": 120.0 + "xe": 160.0, + "xs": 120.0, + "ye": 0.0, + "ys": 40.0 }, { "type": "LineSegment", - "xe": 40.0, - "xs": 40.0, - "ye": 120.0, - "ys": 80.0 + "xe": 160.0, + "xs": 160.0, + "ye": 40.0, + "ys": 0.0 } ] } ], "mirror": false, - "x": 40.0, - "y": 120.0 + "x": 160.0, + "y": 40.0 }, { "angle": 0.0, @@ -617,99 +617,65 @@ "shape": [ { "type": "LineSegment", - "xe": 40.0, - "xs": 0.0, - "ye": 80.0, - "ys": 80.0 - }, - { - "type": "LineSegment", - "xe": 0.0, - "xs": 40.0, - "ye": 120.0, - "ys": 80.0 + "xe": 160.0, + "xs": 120.0, + "ye": 40.0, + "ys": 40.0 }, { "type": "LineSegment", - "xe": 0.0, - "xs": 0.0, + "xe": 120.0, + "xs": 160.0, "ye": 80.0, - "ys": 120.0 - } - ] - } - ], - "mirror": false, - "x": -0.0, - "y": 80.0 - }, - { - "angle": 270.0, - "id": 0, - "item_shapes": [ - { - "shape": [ - { - "type": "LineSegment", - "xe": -1.4708234630234074e-12, - "xs": -1.4708234630234074e-12, - "ye": 29.917137417347988, - "ys": 69.91713741734799 - }, - { - "type": "LineSegment", - "xe": 39.99999999999853, - "xs": -1.4708234630234074e-12, - "ye": 69.91713741734799, - "ys": 29.917137417347988 + "ys": 40.0 }, { "type": "LineSegment", - "xe": -1.4708234630234074e-12, - "xs": 39.99999999999853, - "ye": 69.91713741734799, - "ys": 69.91713741734799 + "xe": 120.0, + "xs": 120.0, + "ye": 40.0, + "ys": 80.0 } ] } ], "mirror": false, - "x": -1.4708234630234074e-12, - "y": 69.91713741734799 + "x": 120.0, + "y": 40.0 }, { - "angle": 0.0, + "angle": 180.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 50.08286258265202, - "xs": 10.08286258265202, - "ye": 1.4779288903810084e-12, - "ys": 1.4779288903810084e-12 + "xe": 120.0, + "xs": 160.0, + "ye": 79.99999999999999, + "ys": 79.99999999999999 }, { "type": "LineSegment", - "xe": 10.08286258265202, - "xs": 50.08286258265202, - "ye": 40.00000000000148, - "ys": 1.4779288903810084e-12 + "xe": 160.0, + "xs": 120.0, + "ye": 39.999999999999986, + "ys": 79.99999999999999 }, { "type": "LineSegment", - "xe": 10.08286258265202, - "xs": 10.08286258265202, - "ye": 1.4779288903810084e-12, - "ys": 40.00000000000148 + "xe": 160.0, + "xs": 160.0, + "ye": 79.99999999999999, + "ys": 39.999999999999986 } ] } ], "mirror": false, - "x": 10.08286258265202, - "y": 1.4779288903810084e-12 + "x": 160.0, + "y": 79.99999999999999 } ], "shape": [ @@ -748,7 +714,7 @@ "id": 1, "items": [ { - "angle": 0.0, + "angle": 90.0, "id": 0, "item_shapes": [ { @@ -756,90 +722,124 @@ { "type": "LineSegment", "xe": 40.0, - "xs": 0.0, - "ye": 0.0, + "xs": 40.0, + "ye": 40.0, "ys": 0.0 }, { "type": "LineSegment", "xe": 0.0, "xs": 40.0, - "ye": 40.0, - "ys": 0.0 + "ye": 0.0, + "ys": 40.0 }, { "type": "LineSegment", - "xe": 0.0, + "xe": 40.0, "xs": 0.0, "ye": 0.0, - "ys": 40.0 + "ys": 0.0 } ] } ], "mirror": false, - "x": 0.0, + "x": 40.0, "y": 0.0 }, { - "angle": 180.0, + "angle": 270.0, "id": 0, "item_shapes": [ { "shape": [ + { + "type": "LineSegment", + "xe": 0.0, + "xs": 0.0, + "ye": 0.0, + "ys": 40.0 + }, + { + "type": "LineSegment", + "xe": 40.0, + "xs": 0.0, + "ye": 40.0, + "ys": 0.0 + }, { "type": "LineSegment", "xe": 0.0, "xs": 40.0, "ye": 40.0, "ys": 40.0 - }, + } + ] + } + ], + "mirror": false, + "x": 0.0, + "y": 40.0 + }, + { + "angle": 0.0, + "id": 0, + "item_shapes": [ + { + "shape": [ { "type": "LineSegment", "xe": 40.0, "xs": 0.0, - "ye": 0.0, + "ye": 40.0, "ys": 40.0 }, { "type": "LineSegment", - "xe": 40.0, + "xe": 0.0, "xs": 40.0, + "ye": 80.0, + "ys": 40.0 + }, + { + "type": "LineSegment", + "xe": 0.0, + "xs": 0.0, "ye": 40.0, - "ys": 0.0 + "ys": 80.0 } ] } ], "mirror": false, - "x": 40.0, + "x": 0.0, "y": 40.0 }, { - "angle": 0.0, + "angle": 180.0, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 80.0, + "xe": 0.0, "xs": 40.0, - "ye": 0.0, - "ys": 0.0 + "ye": 80.0, + "ys": 80.0 }, { "type": "LineSegment", "xe": 40.0, - "xs": 80.0, + "xs": 0.0, "ye": 40.0, - "ys": 0.0 + "ys": 80.0 }, { "type": "LineSegment", "xe": 40.0, "xs": 40.0, - "ye": 0.0, + "ye": 80.0, "ys": 40.0 } ] @@ -847,7 +847,7 @@ ], "mirror": false, "x": 40.0, - "y": 0.0 + "y": 80.0 } ], "shape": [ diff --git a/doc/examples/irregular/item_item_spacing_no/output.txt b/doc/examples/irregular/item_item_spacing_no/output.txt index cf594bcdf..ecbefac4d 100644 --- a/doc/examples/irregular/item_item_spacing_no/output.txt +++ b/doc/examples/irregular/item_item_spacing_no/output.txt @@ -20,6 +20,8 @@ Number of circular items: 0 Item-item minimum spacing: 0 Open dim. XY aspect ratio: -1 Leftover mode: BottomLeft +Leftover value type: SquaredArea +Leftover all bins: 1 Total item area: 16000 Smallest item area: 1600 Largest item area: 1600 @@ -31,28 +33,32 @@ Largest bin cost: 16000 Time # bins Leftover Comment ---- ------ -------- ------- - 0.001 2 13600 TS g 1 d 0 q 1 - 0.009 1 0 TS g 1 d 0 q 2 + 0.006 2 1.8496e+08 TS g 1 d 0 q 1 + 0.007 1 0 TS g 0 d 0 q 2 Final statistics ---------------- -Time (s): 10.0013 +Time (s): 10.0009 +Is proven infeasible: 0 Solution -------- -Number of items: 10 / 10 (100%) -Item area: 16000 / 16000 (100%) -Item profit: 16000 / 16000 (100%) -Number of bins: 1 / 3 (33.3333%) -Bin area: 16000 / 48000 (33.3333%) -Bin cost: 16000 -Full waste: 0 -Full waste (%): 0 -X min: 0 -Y min: 0 -X max: 160 -Y max: 100 -Density X: 1 -Density Y: 1 -ODXY area: 16000 -Leftover value: 0 +Number of items: 10 / 10 (100%) +Item area: 16000 / 16000 (100%) +Item profit: 16000 / 16000 (100%) +Number of bins: 1 / 3 (33.3333%) +Bin area: 16000 / 48000 (33.3333%) +Bin cost: 16000 +Full waste: 0 +Full waste (%): 0 +X min: 0 +Y min: 0 +X max: 160 +Y max: 100 +Density X: 1 +Density Y: 1 +ODXY area: 16000 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 5.12e+08 +Total staircase leftover value: 32000 diff --git a/doc/examples/irregular/item_item_spacing_yes/output.txt b/doc/examples/irregular/item_item_spacing_yes/output.txt index 762f4c806..ba4469c23 100644 --- a/doc/examples/irregular/item_item_spacing_yes/output.txt +++ b/doc/examples/irregular/item_item_spacing_yes/output.txt @@ -20,6 +20,8 @@ Number of circular items: 0 Item-item minimum spacing: 3 Open dim. XY aspect ratio: -1 Leftover mode: BottomLeft +Leftover value type: SquaredArea +Leftover all bins: 1 Total item area: 16000 Smallest item area: 1600 Largest item area: 1600 @@ -31,29 +33,33 @@ Largest bin cost: 16000 Time # bins Leftover Comment ---- ------ -------- ------- - 0.001 2 5293 TS g 0 d 0 q 1 - 0.002 2 6953 TS g 0 d 0 q 1 - 0.002 2 8613 TS g 0 d 0 q 1 + 0.006 2 2.80158e+07 TS g 1 d 0 q 1 + 0.006 2 4.83442e+07 TS g 1 d 0 q 1 + 0.016 2 7.41838e+07 TS g 1 d 0 q 1 Final statistics ---------------- -Time (s): 10.0007 +Time (s): 10.0008 +Is proven infeasible: 0 Solution -------- -Number of items: 10 / 10 (100%) -Item area: 16000 / 16000 (100%) -Item profit: 16000 / 16000 (100%) -Number of bins: 2 / 3 (66.6667%) -Bin area: 32000 / 48000 (66.6667%) -Bin cost: 32000 -Full waste: 16000 -Full waste (%): 50 -X min: 0 -Y min: 0 -X max: 89 -Y max: 83 -Density X: 0.64257 -Density Y: 0.546448 -ODXY area: 7387 -Leftover value: 8613 +Number of items: 10 / 10 (100%) +Item area: 16000 / 16000 (100%) +Item profit: 16000 / 16000 (100%) +Number of bins: 2 / 3 (66.6667%) +Bin area: 32000 / 48000 (66.6667%) +Bin cost: 32000 +Full waste: 16000 +Full waste (%): 50 +X min: 0 +Y min: 0 +X max: 89 +Y max: 83 +Density X: 0.64257 +Density Y: 0.546448 +ODXY area: 7387 +Leftover value: 7.41838e+07 +Staircase leftover value: 8613 +Total leftover value: 3.53176e+08 +Total staircase leftover value: 29408 diff --git a/doc/examples/irregular/mirroring_no/output.txt b/doc/examples/irregular/mirroring_no/output.txt index b609086a1..77d816ed5 100644 --- a/doc/examples/irregular/mirroring_no/output.txt +++ b/doc/examples/irregular/mirroring_no/output.txt @@ -30,27 +30,34 @@ Largest bin cost: 4800 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.002 2 51.62 TS g 0 d 0 q 1 + 0.001 2 51.62 TS g 1 d 0 q 1 Final statistics ---------------- -Time (s): 0.0157571 +Time (s): 0.0130667 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- -Number of items: 3 / 3 (100%) -Item area: 4644 / 4644 (100%) -Item profit: 4644 / 4644 (100%) -Number of bins: 2 / 2 (100%) -Bin area: 9600 / 9600 (100%) -Bin cost: 9600 -Full waste: 4956 -Full waste (%): 51.625 -X min: 0 -Y min: 0 -X max: 40 -Y max: 60 -Density X: 0.645 -Density Y: 0.48375 -ODXY area: 2400 -Leftover value: 2400 +Number of items: 3 / 3 (100%) +Item area: 4644 / 4644 (100%) +Item profit: 4644 / 4644 (100%) +Number of bins: 2 / 2 (100%) +Bin area: 9600 / 9600 (100%) +Bin cost: 9600 +Full waste: 4956 +Full waste (%): 51.625 +X min: 0 +Y min: 0 +X max: 38 +Y max: 38 +Density X: 0.655932 +Density Y: 0.592347 +ODXY area: 1444 +Leftover value: 1.12627e+07 +Staircase leftover value: 3356 +Total leftover value: 1.12627e+07 +Total staircase leftover value: 3356 diff --git a/doc/examples/irregular/mirroring_no/solution.json b/doc/examples/irregular/mirroring_no/solution.json index 38eddfa9c..0017d5ac9 100644 --- a/doc/examples/irregular/mirroring_no/solution.json +++ b/doc/examples/irregular/mirroring_no/solution.json @@ -61,44 +61,58 @@ }, { "angle": 0.0, - "id": 1, + "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 58.0, - "xs": 20.0, + "xe": 80.0, + "xs": 40.0, + "ye": 0.0, + "ys": 0.0 + }, + { + "type": "LineSegment", + "xe": 80.0, + "xs": 80.0, + "ye": 20.0, + "ys": 0.0 + }, + { + "type": "LineSegment", + "xe": 60.0, + "xs": 80.0, "ye": 20.0, "ys": 20.0 }, { "type": "LineSegment", - "xe": 58.0, - "xs": 58.0, - "ye": 58.0, + "xe": 60.0, + "xs": 60.0, + "ye": 60.0, "ys": 20.0 }, { "type": "LineSegment", - "xe": 20.0, - "xs": 58.0, - "ye": 58.0, - "ys": 58.0 + "xe": 40.0, + "xs": 60.0, + "ye": 60.0, + "ys": 60.0 }, { "type": "LineSegment", - "xe": 20.0, - "xs": 20.0, - "ye": 20.0, - "ys": 58.0 + "xe": 40.0, + "xs": 40.0, + "ye": 0.0, + "ys": 60.0 } ] } ], "mirror": false, - "x": 20.0, - "y": 20.0 + "x": 40.0, + "y": 0.0 } ], "shape": [ @@ -138,51 +152,37 @@ "items": [ { "angle": 0.0, - "id": 0, + "id": 1, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 40.0, + "xe": 38.0, "xs": 0.0, "ye": 0.0, "ys": 0.0 }, { "type": "LineSegment", - "xe": 40.0, - "xs": 40.0, - "ye": 20.0, + "xe": 38.0, + "xs": 38.0, + "ye": 38.0, "ys": 0.0 }, - { - "type": "LineSegment", - "xe": 20.0, - "xs": 40.0, - "ye": 20.0, - "ys": 20.0 - }, - { - "type": "LineSegment", - "xe": 20.0, - "xs": 20.0, - "ye": 60.0, - "ys": 20.0 - }, { "type": "LineSegment", "xe": 0.0, - "xs": 20.0, - "ye": 60.0, - "ys": 60.0 + "xs": 38.0, + "ye": 38.0, + "ys": 38.0 }, { "type": "LineSegment", "xe": 0.0, "xs": 0.0, "ye": 0.0, - "ys": 60.0 + "ys": 38.0 } ] } diff --git a/doc/examples/irregular/mirroring_yes/output.txt b/doc/examples/irregular/mirroring_yes/output.txt index 8d1a3d6e2..d38f814ce 100644 --- a/doc/examples/irregular/mirroring_yes/output.txt +++ b/doc/examples/irregular/mirroring_yes/output.txt @@ -34,23 +34,30 @@ Largest bin cost: 4800 Final statistics ---------------- -Time (s): 0.00290785 +Time (s): 0.00344093 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 3 / 3 (100%) -Item area: 4644 / 4644 (100%) -Item profit: 4644 / 4644 (100%) -Number of bins: 1 / 2 (50%) -Bin area: 4800 / 9600 (50%) -Bin cost: 4800 -Full waste: 156 -Full waste (%): 3.25 -X min: 0 -Y min: 0 -X max: 80 -Y max: 60 -Density X: 0.9675 -Density Y: 0.9675 -ODXY area: 4800 -Leftover value: 0 +Number of items: 3 / 3 (100%) +Item area: 4644 / 4644 (100%) +Item profit: 4644 / 4644 (100%) +Number of bins: 1 / 2 (50%) +Bin area: 4800 / 9600 (50%) +Bin cost: 4800 +Full waste: 156 +Full waste (%): 3.25 +X min: 0 +Y min: 0 +X max: 80 +Y max: 60 +Density X: 0.9675 +Density Y: 0.9675 +ODXY area: 4800 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 2.304e+07 +Total staircase leftover value: 4800 diff --git a/doc/examples/irregular/rotation_continuous/output.txt b/doc/examples/irregular/rotation_continuous/output.txt index 4ce933406..88526d1d9 100644 --- a/doc/examples/irregular/rotation_continuous/output.txt +++ b/doc/examples/irregular/rotation_continuous/output.txt @@ -30,43 +30,110 @@ Largest bin cost: 90000 Time XY X Y Comment ---- -- - - ------- - 0.017 49000 217.858 221.359 TS SF it 0 g 0 d 0 q 1 - 0.035 48024.9 217.858 219.146 TS SF it 1 g 0 d 0 q 1 - 0.056 47069.2 210.266 216.954 TS SF it 2 g 1 d 0 q 1 - 0.074 42834.4 206.965 197.383 TS SF it 3 g 1 d 0 q 1 - 0.092 40521.2 201.299 197.383 TS SF it 4 g 0 d 0 q 1 - 0.107 39714.9 198.156 199.286 TS SF it 5 g 0 d 0 q 1 - 0.121 38924.5 196.104 197.293 TS SF it 6 g 0 d 0 q 1 - 0.135 38149.9 186.63 195.32 TS SF it 7 g 0 d 0 q 1 - 0.148 36452.6 189.645 190.926 TS SF it 8 g 0 d 0 q 1 - 0.164 35727.2 180.406 189.016 TS SF it 9 g 0 d 0 q 1 - 0.179 34099.8 180.978 184.661 TS SF it 10 g 0 d 0 q 1 - 0.193 33419.6 180.978 182.81 TS SF it 11 g 1 d 0 q 1 - 0.210 32754.6 180.978 180.982 TS SF it 12 g 1 d 0 q 1 - 0.357 32102.8 175.363 179.172 TS SF it 13 g 1 d 0 q 4 - 0.535 31133.4 176.447 169.152 TS SF it 14 g 0 d 0 q 6 - 3.027 29846.2 170.974 172.761 TS SF it 15 g 1 d 0 q 63 - 7.912 29252.3 169.576 171.033 TS SF it 16 g 0 d 0 q 94 + 0.000 78400 280 200 TS SF columns + 0.003 78243.3 279.72 227.123 LS-DT SF it 0 it 0 + 0.009 63530.7 252.053 249.874 LS-DT SF it 1 it 0 + 0.018 62981.6 250.961 249.874 LS-DT SF it 2 it 0 + 0.027 62708.8 250.417 249.874 LS-DT SF it 3 it 0 + 0.034 62572.8 250.146 249.874 LS-DT SF it 4 it 0 + 0.043 42525.1 206.216 188.715 TS SF it 1 g 0 d 0 q 1 + 0.060 41411.6 203.498 201.13 LS-DT SF it 23 it 0 + 0.061 39784.4 199.46 199.907 LS-DT SF it 24 it 0 + 0.070 35613.2 183.482 188.715 TS SF it 2 g 1 d 0 q 1 + 0.089 35126.7 186.376 187.421 LS-DT SF it 47 it 0 + 0.090 34930.8 186.376 186.898 LS-DT SF it 48 it 0 + 0.099 33665.8 183.482 181.943 TS SF it 3 g 1 d 0 q 1 + 0.113 33622.9 180.255 183.365 LS-DT SF it 57 it 0 + 0.115 33013.8 180.202 181.697 LS-DT SF it 58 it 0 + 0.122 32995.8 174.053 181.647 TS SF it 4 g 1 d 0 q 1 + 0.130 32742.3 180.202 180.948 LS-DT SF it 59 it 0 + 0.138 32607.3 180.202 180.575 LS-DT SF it 60 it 0 + 0.147 32540 180.202 180.389 LS-DT SF it 61 it 0 + 0.155 32475 180.202 180.208 LS-DT SF it 62 it 0 + 0.163 32410.1 180.028 180.028 LS-DT SF it 63 it 0 + 0.171 32345.3 179.786 179.848 LS-DT SF it 64 it 0 + 0.179 32280.6 179.101 179.668 LS-DT SF it 65 it 0 + 0.186 32178.7 179.101 179.384 LS-DT SF it 66 it 0 + 0.194 32114.3 179.101 179.205 LS-DT SF it 67 it 0 + 0.200 31974.5 179.025 178.771 LS-DT SF it 68 it 0 + 0.206 31958.9 178.792 178.771 LS-DT SF it 69 it 0 + 0.212 31902.8 178.614 178.614 LS-DT SF it 70 it 0 + 0.221 31839 178.435 178.435 LS-DT SF it 71 it 0 + 0.229 31775.4 178.257 178.257 LS-DT SF it 72 it 0 + 0.234 31711.9 178.078 178.078 LS-DT SF it 73 it 0 + 0.241 31648.5 177.9 177.9 LS-DT SF it 74 it 0 + 0.251 31585.2 176.514 177.722 LS-DT SF it 75 it 0 + 0.260 31332.7 176.514 177.011 LS-DT SF it 76 it 0 + 0.270 31207.2 176.514 176.656 LS-DT SF it 77 it 0 + 0.278 31144.7 176.479 176.479 LS-DT SF it 78 it 0 + 0.287 31082.4 176.302 176.302 LS-DT SF it 79 it 0 + 0.296 31020.3 176.126 176.126 LS-DT SF it 80 it 0 + 0.304 30942.1 175.95 175.904 LS-DT SF it 81 it 0 + 0.313 30896.4 175.774 175.774 LS-DT SF it 82 it 0 + 0.321 30834.6 175.598 175.598 LS-DT SF it 83 it 0 + 0.329 30773 175.422 175.422 LS-DT SF it 84 it 0 + 0.337 30711.5 175.247 175.247 LS-DT SF it 85 it 0 + 0.345 30650.1 175.072 175.072 LS-DT SF it 86 it 0 + 0.354 30588.8 174.897 174.574 LS-DT SF it 87 it 0 + 0.363 30497.1 174.634 174.539 LS-DT SF it 88 it 0 + 0.374 30390.5 173.841 174.329 LS-DT SF it 89 it 0 + 0.376 30305.4 173.841 174.085 LS-DT SF it 90 it 0 + 0.385 30244.9 173.841 173.91 LS-DT SF it 91 it 0 + 0.392 30184.4 173.737 173.737 LS-DT SF it 92 it 0 + 0.401 30124.1 173.563 173.563 LS-DT SF it 93 it 0 + 0.411 30063.8 173.389 173.27 LS-DT SF it 94 it 0 + 0.419 30003.7 173.216 173.216 LS-DT SF it 95 it 0 + 0.434 29943.8 173.043 173.043 LS-DT SF it 96 it 0 + 0.437 29883.9 172.782 172.87 LS-DT SF it 97 it 0 + 0.445 29824.2 172.697 172.697 LS-DT SF it 98 it 0 + 0.456 29764.5 172.524 172.524 LS-DT SF it 99 it 0 + 0.467 29705 172.352 172.352 LS-DT SF it 100 it 0 + 0.475 29645.7 172.179 172.179 LS-DT SF it 101 it 0 + 0.478 29586.4 172.007 171.271 LS-DT SF it 102 it 0 + 0.486 29459.8 171.638 171.271 LS-DT SF it 103 it 0 + 0.495 29341.8 171.455 171.271 LS-DT SF it 104 it 0 + 0.502 29333.7 171.283 171.271 LS-DT SF it 105 it 0 + 0.511 29277.5 171.111 170.89 LS-DT SF it 106 it 0 + 0.519 29219 170.94 170.89 LS-DT SF it 107 it 0 + 0.530 29162.2 170.769 170.769 LS-DT SF it 108 it 0 + 0.537 29103.9 170.599 170.599 LS-DT SF it 109 it 0 + 0.546 29045.7 170.425 170.428 LS-DT SF it 110 it 0 + 0.554 28987.6 170.258 170.134 LS-DT SF it 111 it 0 + 0.562 28929.7 170.087 169.964 LS-DT SF it 112 it 0 + 0.572 28871.8 169.917 169.917 LS-DT SF it 113 it 0 + 0.601 28814.1 169.747 169.747 LS-DT SF it 114 it 0 + 0.605 28756.5 169.577 169.577 LS-DT SF it 115 it 0 + 0.618 28699 169.408 169.408 LS-DT SF it 116 it 0 + 0.622 28641.7 169.239 169.239 LS-DT SF it 117 it 0 + 0.629 28572.2 169.069 169.069 LS-DT SF it 118 it 0 + 0.639 28527.3 168.9 168.9 LS-DT SF it 119 it 0 + 0.648 28470.3 168.731 168.731 LS-DT SF it 120 it 0 + 0.657 28413.3 168.563 168.563 LS-DT SF it 121 it 0 + 0.920 28356.5 168.394 167.54 LS-DT SF it 122 it 0 Final statistics ---------------- -Time (s): 10.0034 +Time (s): 10.0017 +Is proven infeasible: 0 Solution -------- -Number of items: 7 / 7 (100%) -Item area: 17193.8 / 17193.8 (100%) -Item profit: 17193.8 / 17193.8 (100%) -Number of bins: 1 / 1 (100%) -Bin area: 90000 / 90000 (100%) -Bin cost: 90000 -Full waste: 72806.2 -Full waste (%): 80.8958 -X min: -3.55271e-15 -Y min: 0 -X max: 169.576 -Y max: 171.033 -Density X: 0.337975 -Density Y: 0.335096 -ODXY area: 29252.3 -Leftover value: 60996.9 +Number of items: 7 / 7 (100%) +Item area: 17193.8 / 17193.8 (100%) +Item profit: 17193.8 / 17193.8 (100%) +Number of bins: 1 / 1 (100%) +Bin area: 90000 / 90000 (100%) +Bin cost: 90000 +Full waste: 72806.2 +Full waste (%): 80.8958 +X min: 0 +Y min: 0 +X max: 168.394 +Y max: 167.54 +Density X: 0.340348 +Density Y: 0.342082 +ODXY area: 28356.5 +Leftover value: 3.81766e+09 +Staircase leftover value: 62126.7 +Total leftover value: 3.81766e+09 +Total staircase leftover value: 62126.7 diff --git a/doc/examples/irregular/rotation_continuous/solution.json b/doc/examples/irregular/rotation_continuous/solution.json index 0b35a6c69..4cb0b8491 100644 --- a/doc/examples/irregular/rotation_continuous/solution.json +++ b/doc/examples/irregular/rotation_continuous/solution.json @@ -5,859 +5,859 @@ "id": 0, "items": [ { - "angle": 23.629377730656813, + "angle": 113.62937773065681, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 6.298581677452557, - "xs": 0.5725983343138736, - "ye": 64.63203698567787, - "ys": 62.12691927305471 + "xe": 103.76196981764309, + "xs": 106.26708753026625, + "ye": 6.29858167745256, + "ys": 0.5725983343138807 }, { "type": "LineSegment", - "xe": 3.7218891730401467, - "xs": 6.298581677452557, - "ye": 36.21684464535217, - "ys": 64.63203698567787 + "xe": 132.17716215796878, + "xs": 103.76196981764309, + "ye": 3.7218891730401467, + "ys": 6.29858167745256 }, { "type": "LineSegment", - "xe": 12.88346252206204, - "xs": 3.7218891730401467, - "ye": 40.22503298554925, - "ys": 36.21684464535217 + "xe": 128.1689738177717, + "xs": 132.17716215796878, + "ye": 12.88346252206204, + "ys": 3.7218891730401467 }, { "type": "LineSegment", - "xe": 0.0, - "xs": 12.88346252206204, - "ye": 7.300628762501823, - "ys": 40.22503298554925 + "xe": 161.09337804081915, + "xs": 128.1689738177717, + "ye": 0.0, + "ys": 12.88346252206204 }, { "type": "LineSegment", - "xe": 25.194326709810206, - "xs": 0.0, - "ye": 18.323146698043786, - "ys": 7.300628762501823 + "xe": 150.07086010527718, + "xs": 161.09337804081915, + "ye": 25.194326709810206, + "ys": 0.0 }, { "type": "LineSegment", - "xe": 33.21070339020436, - "xs": 25.194326709810206, - "ye": 0.0, - "ys": 18.323146698043786 + "xe": 168.39400680332096, + "xs": 150.07086010527718, + "ye": 33.21070339020436, + "ys": 25.194326709810206 }, { "type": "LineSegment", - "xe": 46.9530634137372, - "xs": 33.21070339020436, - "ye": 6.012282510295615, - "ys": 0.0 + "xe": 162.38172429302534, + "xs": 168.39400680332096, + "ye": 46.9530634137372, + "ys": 33.21070339020436 }, { "type": "LineSegment", - "xe": 38.936686733343045, - "xs": 46.9530634137372, - "ye": 24.3354292083394, - "ys": 6.012282510295615 + "xe": 144.05857759498156, + "xs": 162.38172429302534, + "ye": 38.936686733343045, + "ys": 46.9530634137372 }, { "type": "LineSegment", - "xe": 64.13101344315325, - "xs": 38.936686733343045, - "ye": 35.35794714388136, - "ys": 24.3354292083394 + "xe": 133.0360596594396, + "xs": 144.05857759498156, + "ye": 64.13101344315325, + "ys": 38.936686733343045 }, { "type": "LineSegment", - "xe": 31.206609220105825, - "xs": 64.13101344315325, - "ye": 48.241409665943394, - "ys": 35.35794714388136 + "xe": 120.15259713737757, + "xs": 133.0360596594396, + "ye": 31.206609220105825, + "ys": 64.13101344315325 }, { "type": "LineSegment", - "xe": 40.36818256912772, - "xs": 31.206609220105825, - "ye": 52.249598006140474, - "ys": 48.241409665943394 + "xe": 116.14440879718049, + "xs": 120.15259713737757, + "ye": 40.36818256912772, + "ys": 31.206609220105825 }, { "type": "LineSegment", - "xe": 17.750548363729923, - "xs": 40.36818256912772, - "ye": 69.64227241092422, - "ys": 52.249598006140474 + "xe": 98.75173439239674, + "xs": 116.14440879718049, + "ye": 17.750548363729926, + "ys": 40.36818256912772 }, { "type": "LineSegment", - "xe": 23.476531706868606, - "xs": 17.750548363729923, - "ye": 72.1473901235474, - "ys": 69.64227241092422 + "xe": 96.24661667977357, + "xs": 98.75173439239674, + "ye": 23.476531706868606, + "ys": 17.750548363729926 }, { "type": "LineSegment", - "xe": 7.105427357601002e-15, - "xs": 23.476531706868606, - "ye": 94.62187474536674, - "ys": 72.1473901235474 + "xe": 73.77213205795422, + "xs": 96.24661667977357, + "ye": 1.4210854715202004e-14, + "ys": 23.476531706868606 }, { "type": "LineSegment", - "xe": 0.5725983343138736, - "xs": 7.105427357601002e-15, - "ye": 62.12691927305471, - "ys": 94.62187474536674 + "xe": 106.26708753026625, + "xs": 73.77213205795422, + "ye": 0.5725983343138807, + "ys": 1.4210854715202004e-14 } ] } ], "mirror": false, - "x": 32.065506721576625, - "y": 21.329287953191592 + "x": 147.06471885012937, + "y": 32.065506721576625 }, { - "angle": 246.3706222693432, + "angle": 336.3706222693432, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 69.6422724109242, - "xs": 72.14739012354738, - "ye": 105.38340654987235, - "ys": 111.10938989301103 + "xe": 64.145282583264, + "xs": 58.419299240125326, + "ye": 70.86999032111962, + "ys": 73.3751080337428 }, { "type": "LineSegment", - "xe": 52.249598006140474, - "xs": 69.6422724109242, - "ye": 128.00104075527014, - "ys": 105.38340654987235 + "xe": 41.5276483778662, + "xs": 64.145282583264, + "ye": 53.47731591633588, + "ys": 70.86999032111962 }, { "type": "LineSegment", - "xe": 48.241409665943394, - "xs": 52.249598006140474, - "ye": 118.83946740624826, - "ys": 128.00104075527014 + "xe": 50.68922172688809, + "xs": 41.5276483778662, + "ye": 49.4691275761388, + "ys": 53.47731591633588 }, { "type": "LineSegment", - "xe": 35.35794714388137, - "xs": 48.241409665943394, - "ye": 151.7638716292957, - "ys": 118.83946740624826 + "xe": 17.764817503840668, + "xs": 50.68922172688809, + "ye": 36.585665054076784, + "ys": 49.4691275761388 }, { "type": "LineSegment", - "xe": 24.335429208339395, - "xs": 35.35794714388137, - "ye": 126.56954491948548, - "ys": 151.7638716292957 + "xe": 42.95914421365086, + "xs": 17.764817503840668, + "ye": 25.563147118534808, + "ys": 36.585665054076784 }, { "type": "LineSegment", - "xe": 6.012282510295616, - "xs": 24.335429208339395, - "ye": 134.58592159987964, - "ys": 126.56954491948548 + "xe": 34.9427675332567, + "xs": 42.95914421365086, + "ye": 7.240000420491029, + "ys": 25.563147118534808 }, { "type": "LineSegment", - "xe": -3.552713678800501e-15, - "xs": 6.012282510295616, - "ye": 120.84356157634681, - "ys": 134.58592159987964 + "xe": 48.68512755678953, + "xs": 34.9427675332567, + "ye": 1.227717910195409, + "ys": 7.240000420491029 }, { "type": "LineSegment", - "xe": 18.323146698043775, - "xs": -3.552713678800501e-15, - "ye": 112.82718489595266, - "ys": 120.84356157634681 + "xe": 56.7015042371837, + "xs": 48.68512755678953, + "ye": 19.550864608239188, + "ys": 1.227717910195409 }, { "type": "LineSegment", - "xe": 7.300628762501802, - "xs": 18.323146698043775, - "ye": 87.63285818614246, - "ys": 112.82718489595266 + "xe": 81.8958309469939, + "xs": 56.7015042371837, + "ye": 8.528346672697213, + "ys": 19.550864608239188 }, { "type": "LineSegment", - "xe": 40.225032985549234, - "xs": 7.300628762501802, - "ye": 100.51632070820447, - "ys": 87.63285818614246 + "xe": 69.01236842493188, + "xs": 81.8958309469939, + "ye": 41.45275089574464, + "ys": 8.528346672697213 }, { "type": "LineSegment", - "xe": 36.21684464535215, - "xs": 40.225032985549234, - "ye": 91.3547473591826, - "ys": 100.51632070820447 + "xe": 78.17394177395376, + "xs": 69.01236842493188, + "ye": 37.44456255554756, + "ys": 41.45275089574464 }, { "type": "LineSegment", - "xe": 64.63203698567786, - "xs": 36.21684464535215, - "ye": 93.93143986359499, - "ys": 91.3547473591826 + "xe": 75.59724926954136, + "xs": 78.17394177395376, + "ye": 65.85975489587327, + "ys": 37.44456255554756 }, { "type": "LineSegment", - "xe": 62.12691927305468, - "xs": 64.63203698567786, - "ye": 88.2054565204563, - "ys": 93.93143986359499 + "xe": 81.32323261268004, + "xs": 75.59724926954136, + "ye": 63.3546371832501, + "ys": 65.85975489587327 }, { "type": "LineSegment", - "xe": 94.6218747453667, - "xs": 62.12691927305468, - "ye": 87.63285818614241, - "ys": 88.2054565204563 + "xe": 81.89583094699393, + "xs": 81.32323261268004, + "ye": 95.8495926555621, + "ys": 63.3546371832501 }, { "type": "LineSegment", - "xe": 72.14739012354738, - "xs": 94.6218747453667, - "ye": 111.10938989301103, - "ys": 87.63285818614241 + "xe": 58.419299240125326, + "xs": 81.89583094699393, + "ye": 73.3751080337428, + "ys": 95.8495926555621 } ] } ], "mirror": false, - "x": 21.329287953191585, - "y": 119.69836490771907 + "x": 49.83032422541728, + "y": 22.557005863386998 }, { - "angle": 66.37062226934319, + "angle": 156.37062226934313, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 34.19015261027294, - "xs": 31.685034897649764, - "ye": 153.28248509686873, - "ys": 147.55650175373003 + "xe": 99.286689395866, + "xs": 105.01267273900469, + "ye": 34.82712652339808, + "ys": 32.3220088107749 }, { "type": "LineSegment", - "xe": 51.58282701505669, - "xs": 34.19015261027294, - "ye": 130.66485089147093, - "ys": 153.28248509686873 + "xe": 121.90432360126383, + "xs": 99.286689395866, + "ye": 52.2198009281818, + "ys": 34.82712652339808 }, { "type": "LineSegment", - "xe": 55.59101535525377, - "xs": 51.58282701505669, - "ye": 139.82642424049283, - "ys": 130.66485089147093 + "xe": 112.74275025224193, + "xs": 121.90432360126383, + "ye": 56.227989268378884, + "ys": 52.2198009281818 }, { "type": "LineSegment", - "xe": 68.4744778773158, - "xs": 55.59101535525377, - "ye": 106.90202001744541, - "ys": 139.82642424049283 + "xe": 145.66715447528938, + "xs": 112.74275025224193, + "ye": 69.11145179044088, + "ys": 56.227989268378884 }, { "type": "LineSegment", - "xe": 79.49699581285776, - "xs": 68.4744778773158, - "ye": 132.0963467272556, - "ys": 106.90202001744541 + "xe": 120.47282776547918, + "xs": 145.66715447528938, + "ye": 80.13396972598288, + "ys": 69.11145179044088 }, { "type": "LineSegment", - "xe": 97.82014251090155, - "xs": 79.49699581285776, - "ye": 124.07997004686145, - "ys": 132.0963467272556 + "xe": 128.48920444587336, + "xs": 120.47282776547918, + "ye": 98.45711642402665, + "ys": 80.13396972598288 }, { "type": "LineSegment", - "xe": 103.83242502119717, - "xs": 97.82014251090155, - "ye": 137.8223300703943, - "ys": 124.07997004686145 + "xe": 114.74684442234053, + "xs": 128.48920444587336, + "ye": 104.46939893432227, + "ys": 98.45711642402665 }, { "type": "LineSegment", - "xe": 85.50927832315338, - "xs": 103.83242502119717, - "ye": 145.83870675078845, - "ys": 137.8223300703943 + "xe": 106.73046774194636, + "xs": 114.74684442234053, + "ye": 86.1462522362785, + "ys": 104.46939893432227 }, { "type": "LineSegment", - "xe": 96.53179625869534, - "xs": 85.50927832315338, - "ye": 171.03303346059863, - "ys": 145.83870675078845 + "xe": 81.53614103213616, + "xs": 106.73046774194636, + "ye": 97.1687701718205, + "ys": 86.1462522362785 }, { "type": "LineSegment", - "xe": 63.60739203564792, - "xs": 96.53179625869534, - "ye": 158.1495709385366, - "ys": 171.03303346059863 + "xe": 94.41960355419816, + "xs": 81.53614103213616, + "ye": 64.24436594877307, + "ys": 97.1687701718205 }, { "type": "LineSegment", - "xe": 67.615580375845, - "xs": 63.60739203564792, - "ye": 167.3111442875585, - "ys": 158.1495709385366 + "xe": 85.25803020517628, + "xs": 94.41960355419816, + "ye": 68.25255428897015, + "ys": 64.24436594877307 }, { "type": "LineSegment", - "xe": 39.20038803551929, - "xs": 67.615580375845, - "ye": 164.73445178314608, - "ys": 167.3111442875585 + "xe": 87.83472270958865, + "xs": 85.25803020517628, + "ye": 39.83736194864444, + "ys": 68.25255428897015 }, { "type": "LineSegment", - "xe": 41.705505748142464, - "xs": 39.20038803551929, - "ye": 170.46043512628478, - "ys": 164.73445178314608 + "xe": 82.10873936644997, + "xs": 87.83472270958865, + "ye": 42.34247966126762, + "ys": 39.83736194864444 }, { "type": "LineSegment", - "xe": 9.210550275830443, - "xs": 41.705505748142464, - "ye": 171.03303346059863, - "ys": 170.46043512628478 + "xe": 81.53614103213606, + "xs": 82.10873936644997, + "ye": 9.847524188955603, + "ys": 42.34247966126762 }, { "type": "LineSegment", - "xe": 31.685034897649764, - "xs": 9.210550275830443, - "ye": 147.55650175373003, - "ys": 171.03303346059863 + "xe": 105.01267273900469, + "xs": 81.53614103213606, + "ye": 32.3220088107749, + "ys": 9.847524188955603 } ] } ], "mirror": false, - "x": 82.50313706800557, - "y": 138.96752673902202 + "x": 113.60164775371277, + "y": 83.14011098113069 }, { - "angle": 66.37062226934319, + "angle": 156.37062226934313, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 34.19313108360583, - "xs": 31.688013370982652, - "ye": 70.63083590414965, - "ys": 64.90485256101097 + "xe": 17.750548363729948, + "xs": 23.476531706868627, + "ye": 36.57934488760053, + "ys": 34.07422717497735 }, { "type": "LineSegment", - "xe": 51.585805488389575, - "xs": 34.19313108360583, - "ye": 48.013201698751864, - "ys": 70.63083590414965 + "xe": 40.36818256912776, + "xs": 17.750548363729948, + "ye": 53.972019292384246, + "ys": 36.57934488760053 }, { "type": "LineSegment", - "xe": 55.593993828586655, - "xs": 51.585805488389575, - "ye": 57.17477504777375, - "ys": 48.013201698751864 + "xe": 31.206609220105875, + "xs": 40.36818256912776, + "ye": 57.98020763258133, + "ys": 53.972019292384246 }, { "type": "LineSegment", - "xe": 68.4774563506487, - "xs": 55.593993828586655, - "ye": 24.250370824726332, - "ys": 57.17477504777375 + "xe": 64.13101344315331, + "xs": 31.206609220105875, + "ye": 70.86367015464333, + "ys": 57.98020763258133 }, { "type": "LineSegment", - "xe": 79.49997428619065, - "xs": 68.4774563506487, - "ye": 49.44469753453653, - "ys": 24.250370824726332 + "xe": 38.93668673334312, + "xs": 64.13101344315331, + "ye": 81.88618809018533, + "ys": 70.86367015464333 }, { "type": "LineSegment", - "xe": 97.82312098423444, - "xs": 79.49997428619065, - "ye": 41.42832085414238, - "ys": 49.44469753453653 + "xe": 46.953063413737304, + "xs": 38.93668673334312, + "ye": 100.20933478822909, + "ys": 81.88618809018533 }, { "type": "LineSegment", - "xe": 103.83540349453006, - "xs": 97.82312098423444, - "ye": 55.17068087767521, - "ys": 41.42832085414238 + "xe": 33.21070339020447, + "xs": 46.953063413737304, + "ye": 106.22161729852473, + "ys": 100.20933478822909 }, { "type": "LineSegment", - "xe": 85.51225679648627, - "xs": 103.83540349453006, - "ye": 63.18705755806937, - "ys": 55.17068087767521 + "xe": 25.194326709810294, + "xs": 33.21070339020447, + "ye": 87.89847060048095, + "ys": 106.22161729852473 }, { "type": "LineSegment", - "xe": 96.53477473202823, - "xs": 85.51225679648627, - "ye": 88.38138426787957, - "ys": 63.18705755806937 + "xe": 1.0658141036401503e-13, + "xs": 25.194326709810294, + "ye": 98.92098853602295, + "ys": 87.89847060048095 }, { "type": "LineSegment", - "xe": 63.61037050898081, - "xs": 96.53477473202823, - "ye": 75.49792174581754, - "ys": 88.38138426787957 + "xe": 12.883462522062104, + "xs": 1.0658141036401503e-13, + "ye": 65.99658431297551, + "ys": 98.92098853602295 }, { "type": "LineSegment", - "xe": 67.61855884917789, - "xs": 63.61037050898081, - "ye": 84.65949509483943, - "ys": 75.49792174581754 + "xe": 3.7218891730402177, + "xs": 12.883462522062104, + "ye": 70.00477265317261, + "ys": 65.99658431297551 }, { "type": "LineSegment", - "xe": 39.20336650885218, - "xs": 67.61855884917789, - "ye": 82.08280259042702, - "ys": 84.65949509483943 + "xe": 6.298581677452589, + "xs": 3.7218891730402177, + "ye": 41.58958031284689, + "ys": 70.00477265317261 }, { "type": "LineSegment", - "xe": 41.70848422147535, - "xs": 39.20336650885218, - "ye": 87.8087859335657, - "ys": 82.08280259042702 + "xe": 0.5725983343139092, + "xs": 6.298581677452589, + "ye": 44.094698025470066, + "ys": 41.58958031284689 }, { "type": "LineSegment", - "xe": 9.21352874916333, - "xs": 41.70848422147535, - "ye": 88.38138426787957, - "ys": 87.8087859335657 + "xe": 0.0, + "xs": 0.5725983343139092, + "ye": 11.599742553158052, + "ys": 44.094698025470066 }, { "type": "LineSegment", - "xe": 31.688013370982652, - "xs": 9.21352874916333, - "ye": 64.90485256101097, - "ys": 88.38138426787957 + "xe": 23.476531706868627, + "xs": 0.0, + "ye": 34.07422717497735, + "ys": 11.599742553158052 } ] } ], "mirror": false, - "x": 82.50611554133846, - "y": 56.31587754630295 + "x": 32.06550672157671, + "y": 84.89232934533314 }, { - "angle": 113.62937773065681, + "angle": 293.6293777306568, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 78.06753074357277, - "xs": 80.57264845619595, - "ye": 6.29858167745256, - "ys": 0.5725983343138807 + "xe": 124.6472480139168, + "xs": 122.1421303012936, + "ye": 161.24165618599136, + "ys": 166.96763952913005 }, { "type": "LineSegment", - "xe": 106.48272308389849, - "xs": 78.06753074357277, - "ye": 3.7218891730401467, - "ys": 6.29858167745256 + "xe": 96.23205567359108, + "xs": 124.6472480139168, + "ye": 163.81834869040378, + "ys": 161.24165618599136 }, { "type": "LineSegment", - "xe": 102.47453474370141, - "xs": 106.48272308389849, - "ye": 12.88346252206204, - "ys": 3.7218891730401467 + "xe": 100.24024401378816, + "xs": 96.23205567359108, + "ye": 154.6567753413819, + "ys": 163.81834869040378 }, { "type": "LineSegment", - "xe": 135.39893896674883, - "xs": 102.47453474370141, - "ye": 0.0, - "ys": 12.88346252206204 + "xe": 67.31583979074074, + "xs": 100.24024401378816, + "ye": 167.5402378634439, + "ys": 154.6567753413819 }, { "type": "LineSegment", - "xe": 124.37642103120687, - "xs": 135.39893896674883, - "ye": 25.194326709810206, - "ys": 0.0 + "xe": 78.3383577262827, + "xs": 67.31583979074074, + "ye": 142.34591115363372, + "ys": 167.5402378634439 }, { "type": "LineSegment", - "xe": 142.69956772925065, - "xs": 124.37642103120687, - "ye": 33.21070339020436, - "ys": 25.194326709810206 + "xe": 60.01521102823891, + "xs": 78.3383577262827, + "ye": 134.32953447323956, + "ys": 142.34591115363372 }, { "type": "LineSegment", - "xe": 136.68728521895505, - "xs": 142.69956772925065, - "ye": 46.9530634137372, - "ys": 33.21070339020436 + "xe": 66.02749353853453, + "xs": 60.01521102823891, + "ye": 120.58717444970672, + "ys": 134.32953447323956 }, { "type": "LineSegment", - "xe": 118.36413852091125, - "xs": 136.68728521895505, - "ye": 38.936686733343045, - "ys": 46.9530634137372 + "xe": 84.35064023657831, + "xs": 66.02749353853453, + "ye": 128.60355113010087, + "ys": 120.58717444970672 }, { "type": "LineSegment", - "xe": 107.3416205853693, - "xs": 118.36413852091125, - "ye": 64.13101344315325, - "ys": 38.936686733343045 + "xe": 95.37315817212027, + "xs": 84.35064023657831, + "ye": 103.40922442029067, + "ys": 128.60355113010087 }, { "type": "LineSegment", - "xe": 94.45815806330725, - "xs": 107.3416205853693, - "ye": 31.206609220105825, - "ys": 64.13101344315325 + "xe": 108.25662069418232, + "xs": 95.37315817212027, + "ye": 136.3336286433381, + "ys": 103.40922442029067 }, { "type": "LineSegment", - "xe": 90.44996972311019, - "xs": 94.45815806330725, - "ye": 40.36818256912772, - "ys": 31.206609220105825 + "xe": 112.2648090343794, + "xs": 108.25662069418232, + "ye": 127.17205529431621, + "ys": 136.3336286433381 }, { "type": "LineSegment", - "xe": 73.05729531832642, - "xs": 90.44996972311019, - "ye": 17.750548363729926, - "ys": 40.36818256912772 + "xe": 129.65748343916314, + "xs": 112.2648090343794, + "ye": 149.789689499714, + "ys": 127.17205529431621 }, { "type": "LineSegment", - "xe": 70.55217760570326, - "xs": 73.05729531832642, - "ye": 23.476531706868606, - "ys": 17.750548363729926 + "xe": 132.1626011517863, + "xs": 129.65748343916314, + "ye": 144.0637061565753, + "ys": 149.789689499714 }, { "type": "LineSegment", - "xe": 48.07769298388392, - "xs": 70.55217760570326, - "ye": 1.4210854715202004e-14, - "ys": 23.476531706868606 + "xe": 154.63708577360563, + "xs": 132.1626011517863, + "ye": 167.5402378634439, + "ys": 144.0637061565753 }, { "type": "LineSegment", - "xe": 80.57264845619595, - "xs": 48.07769298388392, - "ye": 0.5725983343138807, - "ys": 1.4210854715202004e-14 + "xe": 122.1421303012936, + "xs": 154.63708577360563, + "ye": 166.96763952913005, + "ys": 167.5402378634439 } ] } ], "mirror": false, - "x": 121.37027977605906, - "y": 32.065506721576625 + "x": 81.3444989814305, + "y": 135.4747311418673 }, { - "angle": 225.0, + "angle": 203.6293777306568, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 150.93756268948394, - "xs": 155.35698007189987, - "ye": 57.94382910777095, - "ys": 62.363246490186874 + "xe": 161.88418143916073, + "xs": 167.6101647822994, + "ye": 79.45937126333605, + "ys": 81.96448897595923 }, { "type": "LineSegment", - "xe": 142.98261140113527, - "xs": 150.93756268948394, - "ye": 85.34421687874968, - "ys": 57.94382910777095 + "xe": 164.46087394357312, + "xs": 161.88418143916073, + "ye": 107.87456360366176, + "ys": 79.45937126333605 }, { "type": "LineSegment", - "xe": 135.9115435892698, - "xs": 142.98261140113527, - "ye": 78.2731490668842, - "ys": 85.34421687874968 + "xe": 155.29930059455126, + "xs": 164.46087394357312, + "ye": 103.86637526346468, + "ys": 107.87456360366176 }, { "type": "LineSegment", - "xe": 135.91154358926983, - "xs": 135.9115435892698, - "ye": 113.62848812621158, - "ys": 78.2731490668842 + "xe": 168.18276311661327, + "xs": 155.29930059455126, + "ye": 136.7907794865121, + "ys": 103.86637526346468 }, { "type": "LineSegment", - "xe": 116.46610710663975, - "xs": 135.91154358926983, - "ye": 94.18305164358152, - "ys": 113.62848812621158 + "xe": 142.9884364068031, + "xs": 168.18276311661327, + "ye": 125.76826155097015, + "ys": 136.7907794865121 }, { "type": "LineSegment", - "xe": 102.3239714829088, - "xs": 116.46610710663975, - "ye": 108.32518726731247, - "ys": 94.18305164358152 + "xe": 134.97205972640893, + "xs": 142.9884364068031, + "ye": 144.09140824901394, + "ys": 125.76826155097015 }, { "type": "LineSegment", - "xe": 91.71736976511059, - "xs": 102.3239714829088, - "ye": 97.71858554951426, - "ys": 108.32518726731247 + "xe": 121.22969970287609, + "xs": 134.97205972640893, + "ye": 138.07912573871832, + "ys": 144.09140824901394 }, { "type": "LineSegment", - "xe": 105.85950538884154, - "xs": 91.71736976511059, - "ye": 83.57644992578331, - "ys": 97.71858554951426 + "xe": 129.24607638327024, + "xs": 121.22969970287609, + "ye": 119.75597904067453, + "ys": 138.07912573871832 }, { "type": "LineSegment", - "xe": 86.41406890621148, - "xs": 105.85950538884154, - "ye": 64.13101344315325, - "ys": 83.57644992578331 + "xe": 104.05174967346004, + "xs": 129.24607638327024, + "ye": 108.73346110513258, + "ys": 119.75597904067453 }, { "type": "LineSegment", - "xe": 121.76940796553886, - "xs": 86.41406890621148, - "ye": 64.13101344315325, - "ys": 64.13101344315325 + "xe": 136.97615389650747, + "xs": 104.05174967346004, + "ye": 95.84999858307054, + "ys": 108.73346110513258 }, { "type": "LineSegment", - "xe": 114.69834015367337, - "xs": 121.76940796553886, - "ye": 57.059945631287775, - "ys": 64.13101344315325 + "xe": 127.81458054748556, + "xs": 136.97615389650747, + "ye": 91.84181024287346, + "ys": 95.84999858307054 }, { "type": "LineSegment", - "xe": 142.0987279246521, - "xs": 114.69834015367337, - "ye": 49.10499434293911, - "ys": 57.059945631287775 + "xe": 150.43221475288334, + "xs": 127.81458054748556, + "ye": 74.4491358380897, + "ys": 91.84181024287346 }, { "type": "LineSegment", - "xe": 137.67931054223618, - "xs": 142.0987279246521, - "ye": 44.685576960523186, - "ys": 49.10499434293911 + "xe": 144.70623140974467, + "xs": 150.43221475288334, + "ye": 71.94401812546653, + "ys": 74.4491358380897 }, { "type": "LineSegment", - "xe": 167.73134874266444, - "xs": 137.67931054223618, - "ye": 32.311208289758596, - "ys": 44.685576960523186 + "xe": 168.18276311661327, + "xs": 144.70623140974467, + "ye": 49.4695335036472, + "ys": 71.94401812546653 }, { "type": "LineSegment", - "xe": 155.35698007189987, - "xs": 167.73134874266444, - "ye": 62.363246490186874, - "ys": 32.311208289758596 + "xe": 167.6101647822994, + "xs": 168.18276311661327, + "ye": 81.96448897595923, + "ys": 49.4695335036472 } ] } ], "mirror": false, - "x": 111.16280624774065, - "y": 88.87975078468241 + "x": 136.11725639503666, + "y": 122.76212029582234 }, { - "angle": 203.6293777306568, + "angle": 241.18920625702694, "id": 0, "item_shapes": [ { "shape": [ { "type": "LineSegment", - "xe": 163.27759157672307, - "xs": 169.00357491986173, - "ye": 106.40099647492077, - "ys": 108.90611418754395 + "xe": 68.33255363809639, + "xs": 71.34454582417237, + "ye": 116.92675973907903, + "ys": 122.40310916830808 }, { "type": "LineSegment", - "xe": 165.85428408113546, - "xs": 163.27759157672307, - "ye": 134.81618881524648, - "ys": 106.40099647492077 + "xe": 53.05353873054737, + "xs": 68.33255363809639, + "ye": 141.02269722768685, + "ys": 116.92675973907903 }, { "type": "LineSegment", - "xe": 156.6927107321136, - "xs": 165.85428408113546, - "ye": 130.8080004750494, - "ys": 134.81618881524648 + "xe": 48.23435123282581, + "xs": 53.05353873054737, + "ye": 132.26053814092037, + "ys": 141.02269722768685 }, { "type": "LineSegment", - "xe": 169.57617325417561, - "xs": 156.6927107321136, - "ye": 163.73240469809681, - "ys": 130.8080004750494 + "xe": 38.376922260213554, + "xs": 48.23435123282581, + "ye": 166.21390460214045, + "ys": 132.26053814092037 }, { "type": "LineSegment", - "xe": 144.38184654436543, - "xs": 169.57617325417561, - "ye": 152.70988676255487, - "ys": 163.73240469809681 + "xe": 25.124156641479253, + "xs": 38.376922260213554, + "ye": 142.11796711353267, + "ys": 166.21390460214045 }, { "type": "LineSegment", - "xe": 136.36546986397127, - "xs": 144.38184654436543, - "ye": 171.03303346059866, - "ys": 152.70988676255487 + "xe": 7.599838467946318, + "xs": 25.124156641479253, + "ye": 151.7563421089758, + "ys": 142.11796711353267 }, { "type": "LineSegment", - "xe": 122.62310984043843, - "xs": 136.36546986397127, - "ye": 165.02075095030304, - "ys": 171.03303346059866 + "xe": 0.3710572213639729, + "xs": 7.599838467946318, + "ye": 138.6131034788261, + "ys": 151.7563421089758 }, { "type": "LineSegment", - "xe": 130.63948652083258, - "xs": 122.62310984043843, - "ye": 146.69760425225925, - "ys": 165.02075095030304 + "xe": 17.895375394896902, + "xs": 0.3710572213639729, + "ye": 128.97472848338296, + "ys": 138.6131034788261 }, { "type": "LineSegment", - "xe": 105.44515981102238, - "xs": 130.63948652083258, - "ye": 135.6750863167173, - "ys": 146.69760425225925 + "xe": 4.642609776162601, + "xs": 17.895375394896902, + "ye": 104.87879099477519, + "ys": 128.97472848338296 }, { "type": "LineSegment", - "xe": 138.3695640340698, - "xs": 105.44515981102238, - "ye": 122.79162379465527, - "ys": 135.6750863167173 + "xe": 38.59597623738268, + "xs": 4.642609776162601, + "ye": 114.73621996738744, + "ys": 104.87879099477519 }, { "type": "LineSegment", - "xe": 129.2079906850479, - "xs": 138.3695640340698, - "ye": 118.78343545445819, - "ys": 122.79162379465527 + "xe": 33.776788739661114, + "xs": 38.59597623738268, + "ye": 105.97406088062097, + "ys": 114.73621996738744 }, { "type": "LineSegment", - "xe": 151.82562489044568, - "xs": 129.2079906850479, - "ye": 101.39076104967442, - "ys": 118.78343545445819 + "xe": 62.30856926594443, + "xs": 33.776788739661114, + "ye": 105.97406088062095, + "ys": 105.97406088062097 }, { "type": "LineSegment", - "xe": 146.09964154730702, - "xs": 151.82562489044568, - "ye": 98.88564333705125, - "ys": 101.39076104967442 + "xe": 59.296577079868456, + "xs": 62.30856926594443, + "ye": 100.49771145139191, + "ys": 105.97406088062095 }, { "type": "LineSegment", - "xe": 169.57617325417561, - "xs": 146.09964154730702, - "ye": 76.41115871523192, - "ys": 98.88564333705125 + "xe": 91.6070387123198, + "xs": 59.296577079868456, + "ye": 96.9928478166853, + "ys": 100.49771145139191 }, { "type": "LineSegment", - "xe": 169.00357491986173, - "xs": 169.57617325417561, - "ye": 108.90611418754395, - "ys": 76.41115871523192 + "xe": 71.34454582417237, + "xs": 91.6070387123198, + "ye": 122.40310916830808, + "ys": 96.9928478166853 } ] } ], "mirror": false, - "x": 137.510666532599, - "y": 149.70374550740706 + "x": 21.509766018188078, + "y": 135.54634779845782 } ], "shape": [ { "type": "LineSegment", "xe": 0.0, - "xs": 169.57617325417561, - "ye": 171.03303346059866, - "ys": 171.03303346059866 + "xs": 168.39400680332096, + "ye": 167.5402378634439, + "ys": 167.5402378634439 }, { "type": "LineSegment", "xe": 0.0, "xs": 0.0, "ye": 0.0, - "ys": 171.03303346059866 + "ys": 167.5402378634439 }, { "type": "LineSegment", - "xe": 169.57617325417561, + "xe": 168.39400680332096, "xs": 0.0, "ye": 0.0, "ys": 0.0 }, { "type": "LineSegment", - "xe": 169.57617325417561, - "xs": 169.57617325417561, - "ye": 171.03303346059866, + "xe": 168.39400680332096, + "xs": 168.39400680332096, + "ye": 167.5402378634439, "ys": 0.0 } ] diff --git a/doc/examples/irregular/rotation_no/output.txt b/doc/examples/irregular/rotation_no/output.txt index 2f2d47534..2c1814b5a 100644 --- a/doc/examples/irregular/rotation_no/output.txt +++ b/doc/examples/irregular/rotation_no/output.txt @@ -30,27 +30,34 @@ Largest bin cost: 3600 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.001 2 55.56 TS g 0 d 0 q 1 + 0.001 2 55.56 TS g 1 d 0 q 1 Final statistics ---------------- -Time (s): 0.00896853 +Time (s): 0.00861115 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- -Number of items: 2 / 2 (100%) -Item area: 3200 / 3200 (100%) -Item profit: 3200 / 3200 (100%) -Number of bins: 2 / 2 (100%) -Bin area: 7200 / 7200 (100%) -Bin cost: 7200 -Full waste: 4000 -Full waste (%): 55.5556 -X min: 0 -Y min: 0 -X max: 40 -Y max: 60 -Density X: 0.533333 -Density Y: 0.444444 -ODXY area: 2400 -Leftover value: 1200 +Number of items: 2 / 2 (100%) +Item area: 3200 / 3200 (100%) +Item profit: 3200 / 3200 (100%) +Number of bins: 2 / 2 (100%) +Bin area: 7200 / 7200 (100%) +Bin cost: 7200 +Full waste: 4000 +Full waste (%): 55.5556 +X min: 0 +Y min: 0 +X max: 40 +Y max: 60 +Density X: 0.533333 +Density Y: 0.444444 +ODXY area: 2400 +Leftover value: 1.44e+06 +Staircase leftover value: 1200 +Total leftover value: 2.88e+06 +Total staircase leftover value: 2400 diff --git a/doc/examples/irregular/rotation_yes/output.txt b/doc/examples/irregular/rotation_yes/output.txt index 304e4e7f6..8290cacde 100644 --- a/doc/examples/irregular/rotation_yes/output.txt +++ b/doc/examples/irregular/rotation_yes/output.txt @@ -34,23 +34,30 @@ Largest bin cost: 3600 Final statistics ---------------- -Time (s): 0.00488532 +Time (s): 0.00308202 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 2 / 2 (100%) -Item area: 3200 / 3200 (100%) -Item profit: 3200 / 3200 (100%) -Number of bins: 1 / 2 (50%) -Bin area: 3600 / 7200 (50%) -Bin cost: 3600 -Full waste: 400 -Full waste (%): 11.1111 -X min: 0 -Y min: 0 -X max: 60 -Y max: 60 -Density X: 0.888889 -Density Y: 0.888889 -ODXY area: 3600 -Leftover value: 0 +Number of items: 2 / 2 (100%) +Item area: 3200 / 3200 (100%) +Item profit: 3200 / 3200 (100%) +Number of bins: 1 / 2 (50%) +Bin area: 3600 / 7200 (50%) +Bin cost: 3600 +Full waste: 400 +Full waste (%): 11.1111 +X min: 0 +Y min: 0 +X max: 60 +Y max: 60 +Density X: 0.888889 +Density Y: 0.888889 +ODXY area: 3600 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 1.296e+07 +Total staircase leftover value: 3600 diff --git a/doc/examples/onedimensional/basic/output.txt b/doc/examples/onedimensional/basic/output.txt index 55dd83735..cb6063c7a 100644 --- a/doc/examples/onedimensional/basic/output.txt +++ b/doc/examples/onedimensional/basic/output.txt @@ -21,13 +21,16 @@ Largest bin cost: 1000 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.001 20 10.51 TS g 0 q 1 - 0.001 19 5.80 SVC it 0 - 0.066 18 0.57 CG n 17 + 0.006 19 5.80 SVC it 0 + 0.106 18 0.57 CG n 17 Final statistics ---------------- -Time (s): 0.0661582 +Time (s): 0.109836 +Is proven infeasible: 0 +Primal bound: 18 +Dual bound: 18 +Gap: 0% Solution -------- @@ -37,7 +40,7 @@ Item profit: 17898 / 17898 (100%) Number of bins: 18 / 100 (18%) Bin length: 18000 / 100000 (18%) Bin cost: 18000 -Waste: 83 -Waste (%): 0.461598 +Waste: 85 +Waste (%): 0.472669 Full waste: 102 Full waste (%): 0.566667 diff --git a/doc/examples/onedimensional/basic/solution.csv b/doc/examples/onedimensional/basic/solution.csv index 36d135d6c..4394b7229 100644 --- a/doc/examples/onedimensional/basic/solution.csv +++ b/doc/examples/onedimensional/basic/solution.csv @@ -1,71 +1,71 @@ TYPE,ID,COPIES,BIN,X,LX BIN,0,1,0,0,1000 -ITEM,50,1,0,0,491 -ITEM,51,1,0,491,499 +ITEM,3,1,0,0,211 +ITEM,23,1,0,211,331 +ITEM,44,1,0,542,457 BIN,0,1,1,0,1000 -ITEM,48,1,1,0,479 -ITEM,49,1,1,479,487 +ITEM,50,1,1,0,491 +ITEM,51,1,1,491,499 BIN,0,1,2,0,1000 -ITEM,15,1,2,0,277 -ITEM,17,1,2,277,283 -ITEM,41,1,2,560,439 +ITEM,48,1,2,0,479 +ITEM,49,1,2,479,487 BIN,0,1,3,0,1000 -ITEM,0,1,3,0,193 -ITEM,30,1,3,193,373 -ITEM,40,1,3,566,433 +ITEM,5,1,3,0,227 +ITEM,32,1,3,227,383 +ITEM,33,1,3,610,389 BIN,0,1,4,0,1000 -ITEM,2,1,4,0,199 -ITEM,24,1,4,199,337 -ITEM,46,1,4,536,463 +ITEM,15,1,4,0,277 +ITEM,17,1,4,277,283 +ITEM,41,1,4,560,439 BIN,0,1,5,0,1000 -ITEM,9,1,5,0,241 -ITEM,26,1,5,241,349 -ITEM,36,1,5,590,409 +ITEM,1,1,5,0,197 +ITEM,27,1,5,197,353 +ITEM,43,1,5,550,449 BIN,0,1,6,0,1000 -ITEM,7,1,6,0,233 -ITEM,25,1,6,233,347 -ITEM,37,1,6,580,419 +ITEM,0,1,6,0,193 +ITEM,30,1,6,193,373 +ITEM,40,1,6,566,433 BIN,0,1,7,0,1000 -ITEM,4,1,7,0,223 -ITEM,31,1,7,223,379 -ITEM,34,1,7,602,397 +ITEM,9,1,7,0,241 +ITEM,26,1,7,241,349 +ITEM,36,1,7,590,409 BIN,0,1,8,0,1000 -ITEM,14,1,8,0,271 -ITEM,19,1,8,271,307 -ITEM,38,1,8,578,421 +ITEM,13,1,8,0,269 +ITEM,20,1,8,269,311 +ITEM,37,1,8,580,419 BIN,0,1,9,0,1000 -ITEM,3,1,9,0,211 -ITEM,23,1,9,211,331 -ITEM,44,1,9,542,457 +ITEM,7,1,9,0,233 +ITEM,29,1,9,233,367 +ITEM,34,1,9,600,397 BIN,0,1,10,0,1000 ITEM,6,1,10,0,229 -ITEM,29,1,10,229,367 -ITEM,35,1,10,596,401 +ITEM,24,1,10,229,337 +ITEM,39,1,10,566,431 BIN,0,1,11,0,1000 -ITEM,10,1,11,0,251 -ITEM,21,1,11,251,313 -ITEM,39,1,11,564,431 +ITEM,2,1,11,0,199 +ITEM,31,1,11,199,379 +ITEM,38,1,11,578,421 BIN,0,1,12,0,1000 -ITEM,12,1,12,0,263 -ITEM,13,1,12,263,269 -ITEM,47,1,12,532,467 +ITEM,11,1,12,0,257 +ITEM,16,1,12,257,281 +ITEM,45,1,12,538,461 BIN,0,1,13,0,1000 -ITEM,1,1,13,0,197 -ITEM,28,1,13,197,359 -ITEM,42,1,13,556,443 +ITEM,10,1,13,0,251 +ITEM,25,1,13,251,347 +ITEM,35,1,13,598,401 BIN,0,1,14,0,1000 -ITEM,5,1,14,0,227 -ITEM,32,1,14,227,383 -ITEM,33,1,14,610,389 +ITEM,12,1,14,0,263 +ITEM,14,1,14,263,271 +ITEM,46,1,14,534,463 BIN,0,1,15,0,1000 -ITEM,11,1,15,0,257 -ITEM,16,1,15,257,281 -ITEM,45,1,15,538,461 +ITEM,8,1,15,0,239 +ITEM,22,1,15,239,317 +ITEM,42,1,15,556,443 BIN,0,1,16,0,1000 -ITEM,20,1,16,0,311 -ITEM,22,1,16,311,317 -ITEM,27,1,16,628,353 +ITEM,19,1,16,0,307 +ITEM,21,1,16,307,313 +ITEM,28,1,16,620,359 BIN,0,1,17,0,1000 -ITEM,8,1,17,0,239 -ITEM,18,1,17,239,293 -ITEM,43,1,17,532,449 +ITEM,4,1,17,0,223 +ITEM,18,1,17,223,293 +ITEM,47,1,17,516,467 diff --git a/doc/examples/onedimensional/maximum_stackability_no/output.txt b/doc/examples/onedimensional/maximum_stackability_no/output.txt index ffe72db66..2e9484d7a 100644 --- a/doc/examples/onedimensional/maximum_stackability_no/output.txt +++ b/doc/examples/onedimensional/maximum_stackability_no/output.txt @@ -21,11 +21,15 @@ Largest bin cost: 500 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 0.00 SVC it 0 + 0.001 2 0.00 SVC it 0 Final statistics ---------------- -Time (s): 0.00981821 +Time (s): 0.00404927 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- diff --git a/doc/examples/onedimensional/maximum_stackability_yes/output.txt b/doc/examples/onedimensional/maximum_stackability_yes/output.txt index 085ea5e35..a2dde9d72 100644 --- a/doc/examples/onedimensional/maximum_stackability_yes/output.txt +++ b/doc/examples/onedimensional/maximum_stackability_yes/output.txt @@ -25,7 +25,11 @@ Largest bin cost: 500 Final statistics ---------------- -Time (s): 5.00676 +Time (s): 0.00747721 +Is proven infeasible: 0 +Primal bound: 3 +Dual bound: 3 +Gap: 0% Solution -------- diff --git a/doc/examples/onedimensional/maximum_weight_after_no/output.txt b/doc/examples/onedimensional/maximum_weight_after_no/output.txt index e05f71551..3087af5e5 100644 --- a/doc/examples/onedimensional/maximum_weight_after_no/output.txt +++ b/doc/examples/onedimensional/maximum_weight_after_no/output.txt @@ -25,7 +25,8 @@ Largest bin cost: 500 Final statistics ---------------- -Time (s): 5.01685 +Time (s): 5.00597 +Is proven infeasible: 0 Solution -------- diff --git a/doc/examples/onedimensional/maximum_weight_after_yes/output.txt b/doc/examples/onedimensional/maximum_weight_after_yes/output.txt index 067bf7a51..539e9268a 100644 --- a/doc/examples/onedimensional/maximum_weight_after_yes/output.txt +++ b/doc/examples/onedimensional/maximum_weight_after_yes/output.txt @@ -22,11 +22,12 @@ Largest bin cost: 500 Time Waste Waste (%) Comment ---- ----- --------- ------- 0.001 280 22.58 SVC it 0 - 0.002 200 17.24 SVC it 1 + 0.001 200 17.24 SVC it 1 Final statistics ---------------- -Time (s): 5.00722 +Time (s): 5.00351 +Is proven infeasible: 0 Solution -------- diff --git a/doc/examples/onedimensional/maximum_weight_no/output.txt b/doc/examples/onedimensional/maximum_weight_no/output.txt index 588fa6952..2f8f2c788 100644 --- a/doc/examples/onedimensional/maximum_weight_no/output.txt +++ b/doc/examples/onedimensional/maximum_weight_no/output.txt @@ -21,11 +21,15 @@ Largest bin cost: 800 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 1 0.00 SVC it 0 + 0.000 1 0.00 Final statistics ---------------- -Time (s): 0.000591389 +Time (s): 0.00952082 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- diff --git a/doc/examples/onedimensional/maximum_weight_yes/output.txt b/doc/examples/onedimensional/maximum_weight_yes/output.txt index b98b57ead..a62066eb3 100644 --- a/doc/examples/onedimensional/maximum_weight_yes/output.txt +++ b/doc/examples/onedimensional/maximum_weight_yes/output.txt @@ -25,7 +25,11 @@ Largest bin cost: 800 Final statistics ---------------- -Time (s): 0.000746039 +Time (s): 0.00691703 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- diff --git a/doc/examples/onedimensional/nesting_length_no/output.txt b/doc/examples/onedimensional/nesting_length_no/output.txt index 64d127e53..29131cef7 100644 --- a/doc/examples/onedimensional/nesting_length_no/output.txt +++ b/doc/examples/onedimensional/nesting_length_no/output.txt @@ -21,11 +21,15 @@ Largest bin cost: 500 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 44.00 SVC it 0 + 0.001 2 44.00 SVC it 0 Final statistics ---------------- -Time (s): 0.000644734 +Time (s): 0.00293308 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- diff --git a/doc/examples/onedimensional/nesting_length_yes/output.txt b/doc/examples/onedimensional/nesting_length_yes/output.txt index 30ce96972..a36decc7a 100644 --- a/doc/examples/onedimensional/nesting_length_yes/output.txt +++ b/doc/examples/onedimensional/nesting_length_yes/output.txt @@ -21,11 +21,15 @@ Largest bin cost: 500 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 1 -12.00 SVC it 0 + 0.000 1 2.00 SVC it 0 Final statistics ---------------- -Time (s): 0.000627353 +Time (s): 0.00365059 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- @@ -35,7 +39,7 @@ Item profit: 560 / 560 (100%) Number of bins: 1 / 10 (10%) Bin length: 500 / 5000 (10%) Bin cost: 500 -Waste: -70 -Waste (%): -14.2857 -Full waste: -60 -Full waste (%): -12 +Waste: 0 +Waste (%): 0 +Full waste: 10 +Full waste (%): 2 diff --git a/doc/examples/rectangle/basic/output.txt b/doc/examples/rectangle/basic/output.txt index b957263a9..7e2828d77 100644 --- a/doc/examples/rectangle/basic/output.txt +++ b/doc/examples/rectangle/basic/output.txt @@ -9,6 +9,9 @@ Rectangle Instance -------- Objective: BinPackingWithLeftovers +Leftover mode: Area +Leftover value type: SquaredArea +Leftover all bins: 1 Number of item types: 2 Number of items: 20 Number of bin types: 1 @@ -17,8 +20,8 @@ Number of groups: 1 Number of defects: 0 Unloading constraint: None Total item area: 975000 -Total item width: 5500 -Total item height: 3500 +Mean item width: 275 +Mean item height: 175 Smallest item width: 150 Smallest item height: 150 Total item profit: 975000 @@ -31,32 +34,44 @@ Largest bin cost: 500000 Time # bins Leftover Comment ---- ------ -------- ------- - 0.000 3 162500 TS g 0 d X q 1 - 0.001 3 207500 TS g 0 d X q 1 - 0.001 3 275000 TS g 0 d X q 1 - 0.001 3 462500 TS g 0 d X q 2 - 0.002 2 0 TS g 0 d X q 9 + 0.006 3 2.64062e+10 TS g 0 d X q 1 + 0.007 3 4e+10 TS g 0 d Y q 1 + 0.012 3 4.30562e+10 TS g 0 d X q 1 + 0.017 3 1.225e+11 TS g 1 d Y q 2 + 0.021 3 1.50156e+11 TS g 1 d Y q 2 + 0.025 3 2.13906e+11 TS g 1 d X q 2 + 0.029 3 2.13906e+11 TS g 1 d X q 3 + 0.032 3 2.13906e+11 TS g 0 d X q 6 + 0.035 3 2.13906e+11 TS g 0 d Y q 13 + 0.039 3 2.13906e+11 TS g 1 d X q 9 + 0.043 2 0 TS g 0 d X q 9 + 0.047 2 0 TS g 1 d X q 19 + 0.058 2 0 TS g 0 d X q 63 Final statistics ---------------- -Time (s): 5.00498 +Time (s): 5.00503 +Is proven infeasible: 0 Solution -------- -Number of items: 20 / 20 (100%) -Item area: 975000 / 975000 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 975000 / 975000 (100%) -Number of bins: 2 / 10 (20%) -Bin area: 1000000 / 5000000 (20%) -Bin weight: inf / inf (-nan%) -Bin cost: 1e+06 -Waste: 25000 -Waste (%): 2.5 -Full waste: 25000 -Full waste (%): 2.5 -Area load: 0.195 -Weight load: 0 -X max: 1000 -Y max: 500 -Leftover value: 0 +Number of items: 20 / 20 (100%) +Item area: 975000 / 975000 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 975000 / 975000 (100%) +Number of bins: 2 / 10 (20%) +Bin area: 1000000 / 5000000 (20%) +Bin weight: inf / inf (-nan%) +Bin cost: 1e+06 +Waste: 25000 +Waste (%): 2.5 +Full waste: 25000 +Full waste (%): 2.5 +Area load: 0.195 +Weight load: 0 +X max: 1000 +Y max: 500 +Leftover value: 0 +Staircase leftover value: 20000 +Total leftover value: 2e+12 +Total staircase leftover value: 4020000 diff --git a/doc/examples/rectangle/basic/solution.csv b/doc/examples/rectangle/basic/solution.csv index 9afd63191..e836ed505 100644 --- a/doc/examples/rectangle/basic/solution.csv +++ b/doc/examples/rectangle/basic/solution.csv @@ -1,23 +1,23 @@ TYPE,ID,COPIES,BIN,X,Y,LX,LY,GROUP_ID BIN,0,1,0,0,0,1000,500, -ITEM,0,1,0,0,0,300,200,0 -ITEM,0,1,0,0,200,200,300,0 -ITEM,0,1,0,200,200,200,300,0 -ITEM,0,1,0,300,0,300,200,0 -ITEM,0,1,0,400,200,200,300,0 -ITEM,1,1,0,600,0,250,150,0 -ITEM,1,1,0,600,150,250,150,0 -ITEM,1,1,0,600,300,250,150,0 -ITEM,1,1,0,850,0,150,250,0 -ITEM,1,1,0,850,250,150,250,0 +ITEM,1,1,0,0,0,150,250,0 +ITEM,1,1,0,0,250,150,250,0 +ITEM,1,1,0,150,0,150,250,0 +ITEM,1,1,0,150,250,150,250,0 +ITEM,1,1,0,300,0,150,250,0 +ITEM,1,1,0,300,250,150,250,0 +ITEM,1,1,0,450,0,250,150,0 +ITEM,1,1,0,450,150,250,150,0 +ITEM,0,1,0,450,300,300,200,0 +ITEM,0,1,0,700,0,300,200,0 +ITEM,1,1,0,750,200,250,150,0 +ITEM,1,1,0,750,350,250,150,0 BIN,0,1,1,0,0,1000,500, ITEM,0,1,1,0,0,300,200,0 ITEM,0,1,1,0,200,200,300,0 ITEM,0,1,1,200,200,200,300,0 ITEM,0,1,1,300,0,300,200,0 ITEM,0,1,1,400,200,200,300,0 -ITEM,1,1,1,600,0,150,250,0 -ITEM,1,1,1,600,250,150,250,0 -ITEM,1,1,1,750,0,250,150,0 -ITEM,1,1,1,750,150,250,150,0 -ITEM,1,1,1,750,300,250,150,0 +ITEM,0,1,1,600,0,200,300,0 +ITEM,0,1,1,600,300,300,200,0 +ITEM,0,1,1,800,0,200,300,0 diff --git a/doc/examples/rectangle/defects_no/output.txt b/doc/examples/rectangle/defects_no/output.txt index 89a43fe16..3ead1b441 100644 --- a/doc/examples/rectangle/defects_no/output.txt +++ b/doc/examples/rectangle/defects_no/output.txt @@ -9,6 +9,9 @@ Rectangle Instance -------- Objective: BinPackingWithLeftovers +Leftover mode: Area +Leftover value type: SquaredArea +Leftover all bins: 1 Number of item types: 1 Number of items: 3 Number of bin types: 2 @@ -17,8 +20,8 @@ Number of groups: 1 Number of defects: 0 Unloading constraint: None Total item area: 240000 -Total item width: 1200 -Total item height: 600 +Mean item width: 400 +Mean item height: 200 Smallest item width: 400 Smallest item height: 200 Total item profit: 240000 @@ -31,28 +34,32 @@ Largest bin cost: 400000 Time # bins Leftover Comment ---- ------ -------- ------- - 0.000 1 80000 TS g 0 d Any q 1 + 0.004 1 6.4e+09 TS g 0 d Any q 1 Final statistics ---------------- -Time (s): 5.00175 +Time (s): 5.001 +Is proven infeasible: 0 Solution -------- -Number of items: 3 / 3 (100%) -Item area: 240000 / 240000 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 240000 / 240000 (100%) -Number of bins: 1 / 2 (50%) -Bin area: 400000 / 800000 (50%) -Bin weight: inf / inf (-nan%) -Bin cost: 400000 -Waste: 80000 -Waste (%): 25 -Full waste: 160000 -Full waste (%): 40 -Area load: 0.3 -Weight load: 0 -X max: 800 -Y max: 400 -Leftover value: 80000 +Number of items: 3 / 3 (100%) +Item area: 240000 / 240000 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 240000 / 240000 (100%) +Number of bins: 1 / 2 (50%) +Bin area: 400000 / 800000 (50%) +Bin weight: inf / inf (-nan%) +Bin cost: 400000 +Waste: 80000 +Waste (%): 25 +Full waste: 160000 +Full waste (%): 40 +Area load: 0.3 +Weight load: 0 +X max: 800 +Y max: 400 +Leftover value: 6.4e+09 +Staircase leftover value: 160000 +Total leftover value: 1.664e+11 +Total staircase leftover value: 560000 diff --git a/doc/examples/rectangle/defects_yes/output.txt b/doc/examples/rectangle/defects_yes/output.txt index bcbf5870b..b3760fe71 100644 --- a/doc/examples/rectangle/defects_yes/output.txt +++ b/doc/examples/rectangle/defects_yes/output.txt @@ -9,6 +9,9 @@ Rectangle Instance -------- Objective: BinPackingWithLeftovers +Leftover mode: Area +Leftover value type: SquaredArea +Leftover all bins: 1 Number of item types: 1 Number of items: 3 Number of bin types: 2 @@ -17,8 +20,8 @@ Number of groups: 1 Number of defects: 1 Unloading constraint: None Total item area: 240000 -Total item width: 1200 -Total item height: 600 +Mean item width: 400 +Mean item height: 200 Smallest item width: 400 Smallest item height: 200 Total item profit: 240000 @@ -31,28 +34,32 @@ Largest bin cost: 400000 Time # bins Leftover Comment ---- ------ -------- ------- - 0.000 2 320000 TS g 1 d Any q 1 + 0.004 2 1.024e+11 TS g 0 d Any q 1 Final statistics ---------------- -Time (s): 5.00275 +Time (s): 5.00145 +Is proven infeasible: 0 Solution -------- -Number of items: 3 / 3 (100%) -Item area: 240000 / 240000 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 240000 / 240000 (100%) -Number of bins: 2 / 2 (100%) -Bin area: 800000 / 800000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 800000 -Waste: 240000 -Waste (%): 50 -Full waste: 560000 -Full waste (%): 70 -Area load: 0.3 -Weight load: 0 -X max: 400 -Y max: 200 -Leftover value: 320000 +Number of items: 3 / 3 (100%) +Item area: 240000 / 240000 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 240000 / 240000 (100%) +Number of bins: 2 / 2 (100%) +Bin area: 800000 / 800000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 800000 +Waste: 240000 +Waste (%): 50 +Full waste: 560000 +Full waste (%): 70 +Area load: 0.3 +Weight load: 0 +X max: 400 +Y max: 200 +Leftover value: 1.024e+11 +Staircase leftover value: 320000 +Total leftover value: 1.6e+11 +Total staircase leftover value: 560000 diff --git a/doc/examples/rectangle/examples.json b/doc/examples/rectangle/examples.json index 356020554..fa62bad7d 100644 --- a/doc/examples/rectangle/examples.json +++ b/doc/examples/rectangle/examples.json @@ -13,6 +13,7 @@ {"name": "guillotine_vs_non_guillotine", "title": "Guillotine vs non-guillotine: non-guillotine patterns"}, {"name": "objective_bin_packing_with_leftovers", "title": "Objectives: bin packing with leftovers"}, {"name": "objective_variable_sized_bin_packing", "title": "Objectives: variable-sized bin packing"}, + {"name": "objective_variable_sized_bin_packing_with_leftovers", "title": "Objectives: variable-sized bin packing with leftovers"}, {"name": "objective_open_dimension_x", "title": "Objectives: open dimension X"}, {"name": "objective_knapsack", "title": "Objectives: knapsack"}, {"name": "modes_40_items", "title": "Optimization modes: 40 items"}, diff --git a/doc/examples/rectangle/guillotine_vs_non_guillotine/output.txt b/doc/examples/rectangle/guillotine_vs_non_guillotine/output.txt index 4b3b6df04..5a50e0edf 100644 --- a/doc/examples/rectangle/guillotine_vs_non_guillotine/output.txt +++ b/doc/examples/rectangle/guillotine_vs_non_guillotine/output.txt @@ -17,8 +17,8 @@ Number of groups: 1 Number of defects: 0 Unloading constraint: None Total item area: 106 -Total item width: 24 -Total item height: 18 +Mean item width: 6 +Mean item height: 4.5 Smallest item width: 4 Smallest item height: 3 Total item profit: 106 @@ -31,29 +31,35 @@ Largest bin cost: 108 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 50.93 TS g 1 d Y q 1 - 0.001 1 1.85 SVC it 0 + 0.010 1 1.85 Final statistics ---------------- -Time (s): 0.00139759 +Time (s): 0.0123242 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 4 / 4 (100%) -Item area: 106 / 106 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 106 / 106 (100%) -Number of bins: 1 / 2 (50%) -Bin area: 108 / 216 (50%) -Bin weight: inf / inf (-nan%) -Bin cost: 108 -Waste: 2 -Waste (%): 1.85185 -Full waste: 2 -Full waste (%): 1.85185 -Area load: 0.490741 -Weight load: 0 -X max: 12 -Y max: 9 -Leftover value: 0 +Number of items: 4 / 4 (100%) +Item area: 106 / 106 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 106 / 106 (100%) +Number of bins: 1 / 2 (50%) +Bin area: 108 / 216 (50%) +Bin weight: inf / inf (-nan%) +Bin cost: 108 +Waste: 2 +Waste (%): 1.85185 +Full waste: 2 +Full waste (%): 1.85185 +Area load: 0.490741 +Weight load: 0 +X max: 12 +Y max: 9 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 11664 +Total staircase leftover value: 108 diff --git a/doc/examples/rectangle/maximum_weight_no/output.txt b/doc/examples/rectangle/maximum_weight_no/output.txt index e3128dd85..afa24ccef 100644 --- a/doc/examples/rectangle/maximum_weight_no/output.txt +++ b/doc/examples/rectangle/maximum_weight_no/output.txt @@ -17,8 +17,8 @@ Number of groups: 1 Number of defects: 0 Unloading constraint: None Total item area: 240000 -Total item width: 1200 -Total item height: 800 +Mean item width: 300 +Mean item height: 200 Smallest item width: 200 Smallest item height: 200 Total item profit: 240000 @@ -31,28 +31,35 @@ Largest bin cost: 240000 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 1 0.00 TS g 0 d X q 1 + 0.001 1 0.00 TS g 0 d X q 1 Final statistics ---------------- -Time (s): 0.000729104 +Time (s): 0.00313916 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- -Number of items: 4 / 4 (100%) -Item area: 240000 / 240000 (100%) -Item weight: 400 / 400 (100%) -Item profit: 240000 / 240000 (100%) -Number of bins: 1 / 10 (10%) -Bin area: 240000 / 2400000 (10%) -Bin weight: inf / inf (-nan%) -Bin cost: 240000 -Waste: 0 -Waste (%): 0 -Full waste: 0 -Full waste (%): 0 -Area load: 0.1 -Weight load: 0 -X max: 600 -Y max: 400 -Leftover value: 0 +Number of items: 4 / 4 (100%) +Item area: 240000 / 240000 (100%) +Item weight: 400 / 400 (100%) +Item profit: 240000 / 240000 (100%) +Number of bins: 1 / 10 (10%) +Bin area: 240000 / 2400000 (10%) +Bin weight: inf / inf (-nan%) +Bin cost: 240000 +Waste: 0 +Waste (%): 0 +Full waste: 0 +Full waste (%): 0 +Area load: 0.1 +Weight load: 0 +X max: 600 +Y max: 400 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 5.184e+11 +Total staircase leftover value: 2160000 diff --git a/doc/examples/rectangle/maximum_weight_yes/output.txt b/doc/examples/rectangle/maximum_weight_yes/output.txt index d455ca1b2..f4da7e9b5 100644 --- a/doc/examples/rectangle/maximum_weight_yes/output.txt +++ b/doc/examples/rectangle/maximum_weight_yes/output.txt @@ -17,8 +17,8 @@ Number of groups: 1 Number of defects: 0 Unloading constraint: None Total item area: 240000 -Total item width: 1200 -Total item height: 800 +Mean item width: 300 +Mean item height: 200 Smallest item width: 200 Smallest item height: 200 Total item profit: 240000 @@ -31,28 +31,35 @@ Largest bin cost: 240000 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 50.00 TS g 1 d Y q 1 + 0.001 2 50.00 TS g 0 d X q 1 Final statistics ---------------- -Time (s): 0.00078615 +Time (s): 0.00717125 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- -Number of items: 4 / 4 (100%) -Item area: 240000 / 240000 (100%) -Item weight: 400 / 400 (100%) -Item profit: 240000 / 240000 (100%) -Number of bins: 2 / 10 (20%) -Bin area: 480000 / 2400000 (20%) -Bin weight: 400 / 2000 (20%) -Bin cost: 480000 -Waste: 120000 -Waste (%): 33.3333 -Full waste: 240000 -Full waste (%): 50 -Area load: 0.1 -Weight load: 0.2 -X max: 300 -Y max: 400 -Leftover value: 120000 +Number of items: 4 / 4 (100%) +Item area: 240000 / 240000 (100%) +Item weight: 400 / 400 (100%) +Item profit: 240000 / 240000 (100%) +Number of bins: 2 / 10 (20%) +Bin area: 480000 / 2400000 (20%) +Bin weight: 400 / 2000 (20%) +Bin cost: 480000 +Waste: 120000 +Waste (%): 33.3333 +Full waste: 240000 +Full waste (%): 50 +Area load: 0.1 +Weight load: 0.2 +X max: 600 +Y max: 200 +Leftover value: 1.44e+10 +Staircase leftover value: 120000 +Total leftover value: 4.896e+11 +Total staircase leftover value: 2160000 diff --git a/doc/examples/rectangle/maximum_weight_yes/solution.csv b/doc/examples/rectangle/maximum_weight_yes/solution.csv index f02ca2d70..9093d18bd 100644 --- a/doc/examples/rectangle/maximum_weight_yes/solution.csv +++ b/doc/examples/rectangle/maximum_weight_yes/solution.csv @@ -1,7 +1,7 @@ TYPE,ID,COPIES,BIN,X,Y,LX,LY,GROUP_ID BIN,0,1,0,0,0,600,400, ITEM,0,1,0,0,0,300,200,0 -ITEM,0,1,0,300,0,300,200,0 +ITEM,0,1,0,0,200,300,200,0 BIN,0,1,1,0,0,600,400, ITEM,0,1,1,0,0,300,200,0 -ITEM,0,1,1,0,200,300,200,0 +ITEM,0,1,1,300,0,300,200,0 diff --git a/doc/examples/rectangle/objective_bin_packing_with_leftovers/output.txt b/doc/examples/rectangle/objective_bin_packing_with_leftovers/output.txt index aee60d0a0..01a653ca4 100644 --- a/doc/examples/rectangle/objective_bin_packing_with_leftovers/output.txt +++ b/doc/examples/rectangle/objective_bin_packing_with_leftovers/output.txt @@ -9,6 +9,9 @@ Rectangle Instance -------- Objective: BinPackingWithLeftovers +Leftover mode: Area +Leftover value type: SquaredArea +Leftover all bins: 1 Number of item types: 3 Number of items: 34 Number of bin types: 2 @@ -17,8 +20,8 @@ Number of groups: 1 Number of defects: 0 Unloading constraint: None Total item area: 772500 -Total item width: 7000 -Total item height: 3600 +Mean item width: 205.882 +Mean item height: 105.882 Smallest item width: 75 Smallest item height: 75 Total item profit: 772500 @@ -31,36 +34,44 @@ Largest bin cost: 500000 Time # bins Leftover Comment ---- ------ -------- ------- - 0.001 2 37500 TS g 1 d Any q 1 - 0.001 2 87500 TS g 1 d Any q 1 - 0.001 2 125000 TS g 1 d Any q 1 - 0.002 2 137500 TS g 1 d Any q 2 - 0.002 2 162500 TS g 0 d Any q 2 - 0.002 2 175000 SSK it 0 - 0.002 2 200000 TS g 0 d Any q 2 - 0.003 2 212500 TS g 1 d Any q 4 - 2.235 2 225000 TS g 1 d Any q 1066 + 0.001 2 1.40625e+09 TS g 0 d Any q 1 + 0.002 2 7.65625e+09 TS g 0 d Any q 1 + 0.007 2 1.5625e+10 TS g 0 d Any q 1 + 0.012 2 2.64062e+10 TS g 0 d Any q 2 + 0.015 2 4e+10 SSK it 0 + 0.020 2 4.51562e+10 TS g 1 d Any q 4 + 0.031 2 4.51562e+10 SSK it 3 + 0.034 2 4.51562e+10 TS g 0 d Any q 19 + 0.042 2 4.51562e+10 SSK it 4 + 0.045 2 4.51562e+10 TS g 0 d Any q 28 + 0.263 2 4.51562e+10 TS g 0 d Any q 156 + 0.788 2 5.0625e+10 SSK it 8 + 1.910 2 5.0625e+10 TS g 1 d Any q 1066 Final statistics ---------------- -Time (s): 5.00676 +Time (s): 5.00936 +Is proven infeasible: 0 Solution -------- -Number of items: 34 / 34 (100%) -Item area: 772500 / 772500 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 772500 / 772500 (100%) -Number of bins: 2 / 20 (10%) -Bin area: 1000000 / 7800000 (12.8205%) -Bin weight: inf / inf (-nan%) -Bin cost: 1e+06 -Waste: 2500 -Waste (%): 0.322581 -Full waste: 227500 -Full waste (%): 22.75 -Area load: 0.0990385 -Weight load: 0 -X max: 550 -Y max: 500 -Leftover value: 225000 +Number of items: 34 / 34 (100%) +Item area: 772500 / 772500 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 772500 / 772500 (100%) +Number of bins: 2 / 20 (10%) +Bin area: 1000000 / 7800000 (12.8205%) +Bin weight: inf / inf (-nan%) +Bin cost: 1e+06 +Waste: 2500 +Waste (%): 0.322581 +Full waste: 227500 +Full waste (%): 22.75 +Area load: 0.0990385 +Weight load: 0 +X max: 550 +Y max: 500 +Leftover value: 5.0625e+10 +Staircase leftover value: 226875 +Total leftover value: 2.83462e+12 +Total staircase leftover value: 7026875 diff --git a/doc/examples/rectangle/objective_knapsack/output.txt b/doc/examples/rectangle/objective_knapsack/output.txt index 48a8c745c..683078ee5 100644 --- a/doc/examples/rectangle/objective_knapsack/output.txt +++ b/doc/examples/rectangle/objective_knapsack/output.txt @@ -17,8 +17,8 @@ Number of groups: 1 Number of defects: 0 Unloading constraint: None Total item area: 772500 -Total item width: 7000 -Total item height: 3600 +Mean item width: 205.882 +Mean item height: 105.882 Smallest item width: 75 Smallest item height: 75 Total item profit: 772500 @@ -31,55 +31,56 @@ Largest bin cost: 280000 Time Profit # items Comment ---- ------ ------- ------- - 0.000 37500 1 TS g 5 d Y q 1 - 0.001 75000 2 TS g 5 d Y q 1 - 0.001 112500 3 TS g 5 d Y q 1 - 0.001 150000 4 TS g 5 d Y q 1 - 0.001 187500 5 TS g 5 d Y q 1 - 0.001 207500 6 TS g 5 d Y q 1 - 0.001 227500 7 TS g 5 d Y q 1 - 0.001 247500 8 TS g 5 d Y q 1 - 0.001 285000 9 TS g 5 d Y q 1 - 0.001 322500 10 TS g 5 d Y q 1 - 0.002 360000 11 TS g 5 d Y q 1 - 0.002 397500 12 TS g 5 d Y q 1 - 0.002 435000 13 TS g 5 d Y q 1 - 0.002 455000 14 TS g 5 d Y q 1 - 0.002 475000 15 TS g 5 d Y q 1 - 0.002 495000 16 TS g 5 d Y q 1 - 0.002 501250 17 TS g 5 d Y q 3 - 0.002 515000 17 TS g 4 d X q 2 - 0.003 517500 18 TS g 4 d Y q 2 - 0.003 535000 18 TS g 4 d X q 2 - 0.003 541250 19 TS g 4 d X q 2 - 0.010 543750 20 TS g 4 d X q 19 - 0.013 545625 22 TS g 4 d X q 28 - 0.018 550000 21 TS g 4 d Y q 42 - 0.027 551250 24 TS g 4 d X q 63 - 0.028 551875 23 TS g 4 d Y q 63 - 0.054 558125 24 TS g 4 d Y q 94 - 0.058 560000 26 TS g 4 d X q 94 + 0.002 37500 1 TS g 4 d Y q 1 + 0.003 75000 2 TS g 4 d Y q 1 + 0.005 112500 3 TS g 5 d X q 1 + 0.008 132500 4 TS g 5 d X q 1 + 0.012 150000 4 TS g 4 d Y q 1 + 0.014 170000 5 TS g 5 d X q 1 + 0.017 207500 6 TS g 5 d X q 1 + 0.020 227500 7 TS g 5 d X q 1 + 0.022 247500 8 TS g 5 d X q 1 + 0.026 285000 9 TS g 5 d X q 1 + 0.029 322500 10 TS g 5 d X q 1 + 0.032 360000 11 TS g 5 d X q 1 + 0.035 380000 12 TS g 5 d X q 1 + 0.038 417500 13 TS g 5 d X q 1 + 0.040 455000 14 TS g 5 d X q 1 + 0.044 475000 15 TS g 5 d X q 1 + 0.049 495000 16 TS g 5 d X q 1 + 0.053 515000 17 TS g 5 d X q 2 + 0.056 535000 18 TS g 5 d X q 2 + 0.061 541250 19 TS g 4 d X q 2 + 0.071 543750 20 TS g 4 d X q 19 + 0.074 560000 22 CG n 1 Final statistics ---------------- -Time (s): 5.00804 +Time (s): 0.0762371 +Is proven infeasible: 0 +Primal bound: 560000 +Dual bound: 560000 +Gap: 0% Solution -------- -Number of items: 26 / 34 (76.4706%) -Item area: 560000 / 772500 (72.4919%) -Item weight: 0 / 0 (-nan%) -Item profit: 560000 / 772500 (72.4919%) -Number of bins: 2 / 2 (100%) -Bin area: 560000 / 560000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 560000 -Waste: 0 -Waste (%): 0 -Full waste: 0 -Full waste (%): 0 -Area load: 1 -Weight load: 0 -X max: 700 -Y max: 400 -Leftover value: 0 +Number of items: 22 / 34 (64.7059%) +Item area: 560000 / 772500 (72.4919%) +Item weight: 0 / 0 (-nan%) +Item profit: 560000 / 772500 (72.4919%) +Number of bins: 2 / 2 (100%) +Bin area: 560000 / 560000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 560000 +Waste: 0 +Waste (%): 0 +Full waste: 0 +Full waste (%): 0 +Area load: 1 +Weight load: 0 +X max: 700 +Y max: 400 +Leftover value: 0 +Staircase leftover value: 0 +Total leftover value: 0 +Total staircase leftover value: 0 diff --git a/doc/examples/rectangle/objective_knapsack/solution.csv b/doc/examples/rectangle/objective_knapsack/solution.csv index 07ce94468..c55f69a30 100644 --- a/doc/examples/rectangle/objective_knapsack/solution.csv +++ b/doc/examples/rectangle/objective_knapsack/solution.csv @@ -1,18 +1,14 @@ TYPE,ID,COPIES,BIN,X,Y,LX,LY,GROUP_ID BIN,0,1,0,0,0,700,400, ITEM,0,1,0,0,0,250,150,0 -ITEM,0,1,0,0,150,250,150,0 -ITEM,1,1,0,0,300,200,100,0 -ITEM,1,1,0,200,300,200,100,0 +ITEM,0,1,0,0,150,150,250,0 +ITEM,0,1,0,150,150,150,250,0 ITEM,2,1,0,250,0,175,75,0 ITEM,2,1,0,250,75,175,75,0 -ITEM,2,1,0,250,150,175,75,0 -ITEM,2,1,0,250,225,175,75,0 -ITEM,1,1,0,400,300,200,100,0 +ITEM,0,1,0,300,150,150,250,0 ITEM,2,1,0,425,0,175,75,0 ITEM,2,1,0,425,75,175,75,0 -ITEM,2,1,0,425,150,175,75,0 -ITEM,2,1,0,425,225,175,75,0 +ITEM,0,1,0,450,150,150,250,0 ITEM,1,1,0,600,0,100,200,0 ITEM,1,1,0,600,200,100,200,0 BIN,0,1,1,0,0,700,400, diff --git a/doc/examples/rectangle/objective_open_dimension_x/output.txt b/doc/examples/rectangle/objective_open_dimension_x/output.txt index fa1e0ca59..4a29a5f79 100644 --- a/doc/examples/rectangle/objective_open_dimension_x/output.txt +++ b/doc/examples/rectangle/objective_open_dimension_x/output.txt @@ -17,8 +17,8 @@ Number of groups: 1 Number of defects: 0 Unloading constraint: None Total item area: 772500 -Total item width: 7000 -Total item height: 3600 +Mean item width: 205.882 +Mean item height: 105.882 Smallest item width: 75 Smallest item height: 75 Total item profit: 772500 @@ -31,32 +31,39 @@ Largest bin cost: 1e+06 Time X Comment ---- - ------- - 0.000 1750 TS g 1 d X q 1 - 0.001 1675 TS g 0 d X q 2 - 0.001 1600 TS g 0 d X q 2 - 0.009 1575 TS g 1 d X q 13 - 0.080 1550 TS g 1 d X q 94 + 0.001 1750 TS g 0 d X q 1 + 0.005 1675 TS g 0 d X q 2 + 0.009 1600 TS g 0 d X q 2 + 0.021 1575 TS g 1 d X q 13 + 0.076 1550 TS g 1 d X q 94 Final statistics ---------------- -Time (s): 5.00327 +Time (s): 5.00652 +Is proven infeasible: 0 +Primal bound: 1550 +Dual bound: 1545 +Gap: 0.322581% Solution -------- -Number of items: 34 / 34 (100%) -Item area: 772500 / 772500 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 772500 / 772500 (100%) -Number of bins: 1 / 1 (100%) -Bin area: 1000000 / 1000000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 1e+06 -Waste: 2500 -Waste (%): 0.322581 -Full waste: 227500 -Full waste (%): 22.75 -Area load: 0.7725 -Weight load: 0 -X max: 1550 -Y max: 500 -Leftover value: 225000 +Number of items: 34 / 34 (100%) +Item area: 772500 / 772500 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 772500 / 772500 (100%) +Number of bins: 1 / 1 (100%) +Bin area: 1000000 / 1000000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 1e+06 +Waste: 2500 +Waste (%): 0.322581 +Full waste: 227500 +Full waste (%): 22.75 +Area load: 0.7725 +Weight load: 0 +X max: 1550 +Y max: 500 +Leftover value: 5.0625e+10 +Staircase leftover value: 225000 +Total leftover value: 5.0625e+10 +Total staircase leftover value: 225000 diff --git a/doc/examples/rectangle/objective_variable_sized_bin_packing/output.txt b/doc/examples/rectangle/objective_variable_sized_bin_packing/output.txt index 82a229c45..8e1ec75ed 100644 --- a/doc/examples/rectangle/objective_variable_sized_bin_packing/output.txt +++ b/doc/examples/rectangle/objective_variable_sized_bin_packing/output.txt @@ -17,8 +17,8 @@ Number of groups: 1 Number of defects: 0 Unloading constraint: None Total item area: 772500 -Total item width: 7000 -Total item height: 3600 +Mean item width: 205.882 +Mean item height: 105.882 Smallest item width: 75 Smallest item height: 75 Total item profit: 772500 @@ -31,30 +31,37 @@ Largest bin cost: 500000 Time Cost # bins Full waste (%) Comment ---- ---- ------ -------------- ------- - 0.001 1e+06 2 22.75 DS q 1 w 0.1 - 0.004 840000 3 8.04 DS q 4 w 0.0436893 - 0.050 780000 2 0.96 SSK it 6 + 0.002 1e+06 2 22.75 DS q 1 w 0.1 + 0.008 840000 3 8.04 DS q 4 w 0.043692 + 0.076 780000 2 0.96 DS q 128 w 0.00485615 Final statistics ---------------- -Time (s): 5.00366 +Time (s): 0.0795398 +Is proven infeasible: 0 +Primal bound: 780000 +Dual bound: 780000 +Gap: 0% Solution -------- -Number of items: 34 / 34 (100%) -Item area: 772500 / 772500 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 772500 / 772500 (100%) -Number of bins: 2 / 20 (10%) -Bin area: 780000 / 7800000 (10%) -Bin weight: inf / inf (-nan%) -Bin cost: 780000 -Waste: 7500 -Waste (%): 0.961538 -Full waste: 7500 -Full waste (%): 0.961538 -Area load: 0.0990385 -Weight load: 0 -X max: 700 -Y max: 400 -Leftover value: 0 +Number of items: 34 / 34 (100%) +Item area: 772500 / 772500 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 772500 / 772500 (100%) +Number of bins: 2 / 20 (10%) +Bin area: 780000 / 7800000 (10%) +Bin weight: inf / inf (-nan%) +Bin cost: 780000 +Waste: 7500 +Waste (%): 0.961538 +Full waste: 7500 +Full waste (%): 0.961538 +Area load: 0.0990385 +Weight load: 0 +X max: 1000 +Y max: 500 +Leftover value: 0 +Staircase leftover value: 1875 +Total leftover value: 2.9556e+12 +Total staircase leftover value: 7021875 diff --git a/doc/examples/rectangle/objective_variable_sized_bin_packing/solution.csv b/doc/examples/rectangle/objective_variable_sized_bin_packing/solution.csv index 81d63dd7c..b2cbb4f5e 100644 --- a/doc/examples/rectangle/objective_variable_sized_bin_packing/solution.csv +++ b/doc/examples/rectangle/objective_variable_sized_bin_packing/solution.csv @@ -1,37 +1,37 @@ TYPE,ID,COPIES,BIN,X,Y,LX,LY,GROUP_ID -BIN,0,1,0,0,0,1000,500, -ITEM,0,1,0,0,0,250,150,0 -ITEM,0,1,0,250,0,250,150,0 -ITEM,0,1,0,500,0,250,150,0 -ITEM,0,1,0,750,0,250,150,0 -ITEM,0,1,0,0,150,150,250,0 -ITEM,0,1,0,150,150,150,250,0 -ITEM,0,1,0,300,150,150,250,0 -ITEM,0,1,0,450,150,150,250,0 -ITEM,0,1,0,600,150,250,150,0 -ITEM,0,1,0,850,150,150,250,0 -ITEM,1,1,0,600,300,100,200,0 -ITEM,1,1,0,700,300,100,200,0 -ITEM,1,1,0,0,400,200,100,0 -ITEM,1,1,0,200,400,200,100,0 -ITEM,1,1,0,400,400,200,100,0 -ITEM,1,1,0,800,400,200,100,0 -BIN,1,1,1,0,0,700,400, -ITEM,1,1,1,0,0,200,100,0 -ITEM,1,1,1,0,100,200,100,0 -ITEM,1,1,1,0,200,200,100,0 -ITEM,1,1,1,0,300,200,100,0 -ITEM,1,1,1,200,0,100,200,0 -ITEM,1,1,1,200,200,100,200,0 -ITEM,2,1,1,300,0,175,75,0 -ITEM,2,1,1,300,75,175,75,0 -ITEM,2,1,1,300,150,175,75,0 -ITEM,2,1,1,300,225,75,175,0 -ITEM,2,1,1,375,225,75,175,0 -ITEM,2,1,1,450,225,75,175,0 -ITEM,2,1,1,475,0,75,175,0 -ITEM,2,1,1,525,175,175,75,0 -ITEM,2,1,1,525,250,175,75,0 -ITEM,2,1,1,525,325,175,75,0 -ITEM,2,1,1,550,0,75,175,0 -ITEM,2,1,1,625,0,75,175,0 +BIN,1,1,0,0,0,700,400, +ITEM,0,1,0,0,0,150,250,0 +ITEM,0,1,0,150,0,150,250,0 +ITEM,0,1,0,300,0,150,250,0 +ITEM,0,1,0,450,0,150,250,0 +ITEM,1,1,0,600,0,100,200,0 +ITEM,1,1,0,600,200,100,200,0 +ITEM,0,1,0,0,250,250,150,0 +ITEM,2,1,0,250,250,175,75,0 +ITEM,2,1,0,425,250,175,75,0 +ITEM,2,1,0,250,325,175,75,0 +ITEM,2,1,0,425,325,175,75,0 +BIN,0,1,1,0,0,1000,500, +ITEM,0,1,1,0,0,150,250,0 +ITEM,0,1,1,0,250,150,250,0 +ITEM,0,1,1,150,0,250,150,0 +ITEM,0,1,1,150,150,250,150,0 +ITEM,1,1,1,150,300,200,100,0 +ITEM,1,1,1,150,400,200,100,0 +ITEM,1,1,1,350,300,200,100,0 +ITEM,1,1,1,350,400,200,100,0 +ITEM,1,1,1,400,0,200,100,0 +ITEM,1,1,1,400,100,200,100,0 +ITEM,1,1,1,400,200,200,100,0 +ITEM,1,1,1,550,300,100,200,0 +ITEM,0,1,1,600,100,250,150,0 +ITEM,1,1,1,600,0,200,100,0 +ITEM,2,1,1,650,250,175,75,0 +ITEM,2,1,1,650,325,75,175,0 +ITEM,2,1,1,725,325,75,175,0 +ITEM,1,1,1,800,325,200,100,0 +ITEM,2,1,1,800,0,175,75,0 +ITEM,2,1,1,800,425,175,75,0 +ITEM,2,1,1,825,250,175,75,0 +ITEM,2,1,1,850,75,75,175,0 +ITEM,2,1,1,925,75,75,175,0 diff --git a/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/instance.cpp b/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/instance.cpp new file mode 100644 index 000000000..8fc121f32 --- /dev/null +++ b/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/instance.cpp @@ -0,0 +1,16 @@ +#include "packingsolver/rectangle/instance_builder.hpp" + +using namespace packingsolver; +using namespace packingsolver::rectangle; + +InstanceBuilder instance_builder; +instance_builder.set_objective(Objective::VariableSizedBinPackingWithLeftovers); +BinTypeId bin_type_id = instance_builder.add_bin_type(1000, 500); +instance_builder.set_bin_type_copies(bin_type_id, 10); +bin_type_id = instance_builder.add_bin_type(700, 400); +instance_builder.set_bin_type_copies(bin_type_id, 10); +ItemTypeId item_type_id = instance_builder.add_item_type(250, 150); +instance_builder.set_item_type_copies(item_type_id, 10); +item_type_id = instance_builder.add_item_type(200, 100); +instance_builder.set_item_type_copies(item_type_id, 12); +Instance instance = instance_builder.build(); diff --git a/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/instance.json b/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/instance.json new file mode 100644 index 000000000..759c72af0 --- /dev/null +++ b/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/instance.json @@ -0,0 +1,11 @@ +{ + "objective": "variable-sized-bin-packing-with-leftovers", + "bin_types": [ + {"x": 1000, "y": 500, "copies": 10}, + {"x": 700, "y": 400, "copies": 10} + ], + "item_types": [ + {"x": 250, "y": 150, "copies": 10}, + {"x": 200, "y": 100, "copies": 12} + ] +} diff --git a/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/instance.py b/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/instance.py new file mode 100644 index 000000000..2b36e89e5 --- /dev/null +++ b/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/instance.py @@ -0,0 +1,9 @@ +import packingsolver.rectangle as psr + +instance_builder = psr.InstanceBuilder() +instance_builder.set_objective(psr.Objective.VariableSizedBinPackingWithLeftovers) +instance_builder.add_bin_type(1000, 500, copies=10) +instance_builder.add_bin_type(700, 400, copies=10) +instance_builder.add_item_type(250, 150, copies=10) +instance_builder.add_item_type(200, 100, copies=12) +instance = instance_builder.build() diff --git a/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/output.txt b/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/output.txt new file mode 100644 index 000000000..35bbbf3be --- /dev/null +++ b/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/output.txt @@ -0,0 +1,67 @@ +================================= + PackingSolver +================================= + +Problem type +------------ +Rectangle + +Instance +-------- +Objective: VariableSizedBinPackingWithLeftovers +Number of item types: 2 +Number of items: 22 +Number of bin types: 2 +Number of bins: 20 +Number of groups: 1 +Number of defects: 0 +Unloading constraint: None +Total item area: 615000 +Mean item width: 222.727 +Mean item height: 122.727 +Smallest item width: 100 +Smallest item height: 100 +Total item profit: 615000 +Largest item profit: 37500 +Total item weight: 0 +Largest item copies: 12 +Total bin area: 7800000 +Total bin weight: inf +Largest bin cost: 500000 + + Time Cost # bins Full waste (%) Comment + ---- ---- ------ -------------- ------- + 0.003 780000 2 21.15 DS q 1 w 0.1 + 0.006 780000 2 21.15 SSK it 0 + +Final statistics +---------------- +Time (s): 5.01225 +Is proven infeasible: 0 +Primal bound: 780000 +Dual bound: 780000 +Gap: 0% + +Solution +-------- +Number of items: 22 / 22 (100%) +Item area: 615000 / 615000 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 615000 / 615000 (100%) +Number of bins: 2 / 20 (10%) +Bin area: 780000 / 7800000 (10%) +Bin weight: inf / inf (-nan%) +Bin cost: 780000 +Waste: 65000 +Waste (%): 9.55882 +Full waste: 165000 +Full waste (%): 21.1538 +Area load: 0.0788462 +Weight load: 0 +X max: 450 +Y max: 400 +Leftover value: 1e+10 +Staircase leftover value: 165000 +Total leftover value: 2.9656e+12 +Net cost: 760000 +Total staircase leftover value: 7185000 diff --git a/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/solution.csv b/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/solution.csv new file mode 100644 index 000000000..9cb2170a3 --- /dev/null +++ b/doc/examples/rectangle/objective_variable_sized_bin_packing_with_leftovers/solution.csv @@ -0,0 +1,25 @@ +TYPE,ID,COPIES,BIN,X,Y,LX,LY,GROUP_ID +BIN,0,1,0,0,0,1000,500, +ITEM,1,1,0,0,0,200,100,0 +ITEM,1,1,0,0,100,200,100,0 +ITEM,1,1,0,200,0,200,100,0 +ITEM,1,1,0,200,100,200,100,0 +ITEM,1,1,0,400,0,200,100,0 +ITEM,1,1,0,400,100,200,100,0 +ITEM,1,1,0,600,0,200,100,0 +ITEM,1,1,0,600,100,200,100,0 +ITEM,1,1,0,800,0,200,100,0 +ITEM,1,1,0,800,100,200,100,0 +ITEM,0,1,0,0,200,250,150,0 +ITEM,0,1,0,0,350,250,150,0 +ITEM,0,1,0,250,200,250,150,0 +ITEM,0,1,0,250,350,250,150,0 +ITEM,0,1,0,500,200,250,150,0 +ITEM,0,1,0,500,350,250,150,0 +ITEM,0,1,0,750,200,250,150,0 +ITEM,0,1,0,750,350,250,150,0 +BIN,1,1,1,0,0,700,400, +ITEM,0,1,1,0,0,250,150,0 +ITEM,0,1,1,0,150,250,150,0 +ITEM,1,1,1,0,300,200,100,0 +ITEM,1,1,1,250,0,200,100,0 diff --git a/doc/examples/rectangle/rotation_no/output.txt b/doc/examples/rectangle/rotation_no/output.txt index 4f9df974b..e59aef52f 100644 --- a/doc/examples/rectangle/rotation_no/output.txt +++ b/doc/examples/rectangle/rotation_no/output.txt @@ -9,6 +9,9 @@ Rectangle Instance -------- Objective: BinPackingWithLeftovers +Leftover mode: Area +Leftover value type: SquaredArea +Leftover all bins: 1 Number of item types: 1 Number of items: 3 Number of bin types: 1 @@ -17,8 +20,8 @@ Number of groups: 1 Number of defects: 0 Unloading constraint: None Total item area: 240000 -Total item width: 1200 -Total item height: 600 +Mean item width: 400 +Mean item height: 200 Smallest item width: 400 Smallest item height: 200 Total item profit: 240000 @@ -31,28 +34,32 @@ Largest bin cost: 350000 Time # bins Leftover Comment ---- ------ -------- ------- - 0.000 2 270000 TS g 1 d Y q 1 + 0.004 2 7.29e+10 TS g 0 d X q 1 Final statistics ---------------- -Time (s): 5.0036 +Time (s): 5.0017 +Is proven infeasible: 0 Solution -------- -Number of items: 3 / 3 (100%) -Item area: 240000 / 240000 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 240000 / 240000 (100%) -Number of bins: 2 / 2 (100%) -Bin area: 700000 / 700000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 700000 -Waste: 190000 -Waste (%): 44.186 -Full waste: 460000 -Full waste (%): 65.7143 -Area load: 0.342857 -Weight load: 0 -X max: 400 -Y max: 200 -Leftover value: 270000 +Number of items: 3 / 3 (100%) +Item area: 240000 / 240000 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 240000 / 240000 (100%) +Number of bins: 2 / 2 (100%) +Bin area: 700000 / 700000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 700000 +Waste: 190000 +Waste (%): 44.186 +Full waste: 460000 +Full waste (%): 65.7143 +Area load: 0.342857 +Weight load: 0 +X max: 400 +Y max: 200 +Leftover value: 7.29e+10 +Staircase leftover value: 270000 +Total leftover value: 1.09e+11 +Total staircase leftover value: 460000 diff --git a/doc/examples/rectangle/rotation_yes/output.txt b/doc/examples/rectangle/rotation_yes/output.txt index 86f862905..29c18bae7 100644 --- a/doc/examples/rectangle/rotation_yes/output.txt +++ b/doc/examples/rectangle/rotation_yes/output.txt @@ -9,6 +9,9 @@ Rectangle Instance -------- Objective: BinPackingWithLeftovers +Leftover mode: Area +Leftover value type: SquaredArea +Leftover all bins: 1 Number of item types: 1 Number of items: 3 Number of bin types: 1 @@ -17,8 +20,8 @@ Number of groups: 1 Number of defects: 0 Unloading constraint: None Total item area: 240000 -Total item width: 1200 -Total item height: 600 +Mean item width: 400 +Mean item height: 200 Smallest item width: 200 Smallest item height: 200 Total item profit: 240000 @@ -31,28 +34,32 @@ Largest bin cost: 350000 Time # bins Leftover Comment ---- ------ -------- ------- - 0.000 1 110000 TS g 0 d X q 1 + 0.004 1 1.21e+10 TS g 0 d X q 1 Final statistics ---------------- -Time (s): 5.00179 +Time (s): 5.0022 +Is proven infeasible: 0 Solution -------- -Number of items: 3 / 3 (100%) -Item area: 240000 / 240000 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 240000 / 240000 (100%) -Number of bins: 1 / 2 (50%) -Bin area: 350000 / 700000 (50%) -Bin weight: inf / inf (-nan%) -Bin cost: 350000 -Waste: 0 -Waste (%): 0 -Full waste: 110000 -Full waste (%): 31.4286 -Area load: 0.342857 -Weight load: 0 -X max: 600 -Y max: 400 -Leftover value: 110000 +Number of items: 3 / 3 (100%) +Item area: 240000 / 240000 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 240000 / 240000 (100%) +Number of bins: 1 / 2 (50%) +Bin area: 350000 / 700000 (50%) +Bin weight: inf / inf (-nan%) +Bin cost: 350000 +Waste: 0 +Waste (%): 0 +Full waste: 110000 +Full waste (%): 31.4286 +Area load: 0.342857 +Weight load: 0 +X max: 600 +Y max: 400 +Leftover value: 1.21e+10 +Staircase leftover value: 110000 +Total leftover value: 1.346e+11 +Total staircase leftover value: 460000 diff --git a/doc/examples/rectangle/unloading_increasing_x/output.txt b/doc/examples/rectangle/unloading_increasing_x/output.txt index c496333e5..74ac09c86 100644 --- a/doc/examples/rectangle/unloading_increasing_x/output.txt +++ b/doc/examples/rectangle/unloading_increasing_x/output.txt @@ -17,8 +17,8 @@ Number of groups: 2 Number of defects: 0 Unloading constraint: IncreasingX Total item area: 162500 -Total item width: 850 -Total item height: 550 +Mean item width: 283.333 +Mean item height: 183.333 Smallest item width: 150 Smallest item height: 150 Total item profit: 162500 @@ -32,28 +32,35 @@ Largest bin cost: 320000 Time X Comment ---- - ------- 0.000 700 TS g 1 d X q 1 - 0.000 650 TS g 1 d X q 1 + 0.004 650 TS g 1 d X q 1 Final statistics ---------------- -Time (s): 0.000719904 +Time (s): 0.00823291 +Is proven infeasible: 0 +Primal bound: 650 +Dual bound: 500 +Gap: 23.0769% Solution -------- -Number of items: 3 / 3 (100%) -Item area: 162500 / 162500 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 162500 / 162500 (100%) -Number of bins: 1 / 1 (100%) -Bin area: 320000 / 320000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 320000 -Waste: 97500 -Waste (%): 37.5 -Full waste: 157500 -Full waste (%): 49.2188 -Area load: 0.507812 -Weight load: 0 -X max: 650 -Y max: 400 -Leftover value: 60000 +Number of items: 3 / 3 (100%) +Item area: 162500 / 162500 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 162500 / 162500 (100%) +Number of bins: 1 / 1 (100%) +Bin area: 320000 / 320000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 320000 +Waste: 97500 +Waste (%): 37.5 +Full waste: 157500 +Full waste (%): 49.2188 +Area load: 0.507812 +Weight load: 0 +X max: 650 +Y max: 400 +Leftover value: 3.6e+09 +Staircase leftover value: 60000 +Total leftover value: 3.6e+09 +Total staircase leftover value: 60000 diff --git a/doc/examples/rectangle/unloading_no/output.txt b/doc/examples/rectangle/unloading_no/output.txt index df4d1a8f4..eaae6b4aa 100644 --- a/doc/examples/rectangle/unloading_no/output.txt +++ b/doc/examples/rectangle/unloading_no/output.txt @@ -9,6 +9,9 @@ Rectangle Instance -------- Objective: BinPackingWithLeftovers +Leftover mode: Area +Leftover value type: SquaredArea +Leftover all bins: 1 Number of item types: 3 Number of items: 3 Number of bin types: 1 @@ -17,8 +20,8 @@ Number of groups: 3 Number of defects: 0 Unloading constraint: None Total item area: 222500 -Total item width: 750 -Total item height: 750 +Mean item width: 250 +Mean item height: 250 Smallest item width: 150 Smallest item height: 150 Total item profit: 222500 @@ -31,29 +34,34 @@ Largest bin cost: 280000 Time # bins Leftover Comment ---- ------ -------- ------- - 0.000 2 240000 TS g 1 d Y q 1 - 0.000 1 40000 TS g 0 d X q 2 + 0.003 2 5.76e+10 TS g 0 d X q 1 + 0.004 1 1.6e+09 TS g 0 d X q 2 + 0.006 1 1.6e+09 TS g 0 d X q 6 Final statistics ---------------- -Time (s): 5.00148 +Time (s): 5.00089 +Is proven infeasible: 0 Solution -------- -Number of items: 3 / 3 (100%) -Item area: 222500 / 222500 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 222500 / 222500 (100%) -Number of bins: 1 / 2 (50%) -Bin area: 280000 / 560000 (50%) -Bin weight: inf / inf (-nan%) -Bin cost: 280000 -Waste: 17500 -Waste (%): 7.29167 -Full waste: 57500 -Full waste (%): 20.5357 -Area load: 0.397321 -Weight load: 0 -X max: 600 -Y max: 400 -Leftover value: 40000 +Number of items: 3 / 3 (100%) +Item area: 222500 / 222500 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 222500 / 222500 (100%) +Number of bins: 1 / 2 (50%) +Bin area: 280000 / 560000 (50%) +Bin weight: inf / inf (-nan%) +Bin cost: 280000 +Waste: 17500 +Waste (%): 7.29167 +Full waste: 57500 +Full waste (%): 20.5357 +Area load: 0.397321 +Weight load: 0 +X max: 600 +Y max: 400 +Leftover value: 1.6e+09 +Staircase leftover value: 57500 +Total leftover value: 8e+10 +Total staircase leftover value: 337500 diff --git a/doc/examples/rectangle/unloading_no/solution.csv b/doc/examples/rectangle/unloading_no/solution.csv index da3809a81..7626ce1f5 100644 --- a/doc/examples/rectangle/unloading_no/solution.csv +++ b/doc/examples/rectangle/unloading_no/solution.csv @@ -1,5 +1,5 @@ TYPE,ID,COPIES,BIN,X,Y,LX,LY,GROUP_ID BIN,0,1,0,0,0,700,400, ITEM,1,1,0,0,0,400,400,1 -ITEM,2,1,0,400,0,150,150,2 -ITEM,0,1,0,400,150,200,200,0 +ITEM,0,1,0,400,0,200,200,0 +ITEM,2,1,0,400,200,150,150,2 diff --git a/doc/examples/rectangle/unloading_x_movements/output.txt b/doc/examples/rectangle/unloading_x_movements/output.txt index 82b6140f7..32d078678 100644 --- a/doc/examples/rectangle/unloading_x_movements/output.txt +++ b/doc/examples/rectangle/unloading_x_movements/output.txt @@ -17,8 +17,8 @@ Number of groups: 2 Number of defects: 0 Unloading constraint: OnlyXMovements Total item area: 162500 -Total item width: 850 -Total item height: 550 +Mean item width: 283.333 +Mean item height: 183.333 Smallest item width: 150 Smallest item height: 150 Total item profit: 162500 @@ -31,30 +31,37 @@ Largest bin cost: 320000 Time X Comment ---- - ------- - 0.000 700 TS g 1 d X q 1 - 0.000 650 TS g 1 d X q 1 - 0.001 500 TS g 1 d X q 3 + 0.001 700 TS g 1 d X q 1 + 0.004 650 TS g 1 d X q 1 + 0.007 500 TS g 1 d X q 3 Final statistics ---------------- -Time (s): 0.000694229 +Time (s): 0.0110585 +Is proven infeasible: 0 +Primal bound: 500 +Dual bound: 500 +Gap: 0% Solution -------- -Number of items: 3 / 3 (100%) -Item area: 162500 / 162500 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 162500 / 162500 (100%) -Number of bins: 1 / 1 (100%) -Bin area: 320000 / 320000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 320000 -Waste: 37500 -Waste (%): 18.75 -Full waste: 157500 -Full waste (%): 49.2188 -Area load: 0.507812 -Weight load: 0 -X max: 500 -Y max: 400 -Leftover value: 120000 +Number of items: 3 / 3 (100%) +Item area: 162500 / 162500 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 162500 / 162500 (100%) +Number of bins: 1 / 1 (100%) +Bin area: 320000 / 320000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 320000 +Waste: 37500 +Waste (%): 18.75 +Full waste: 157500 +Full waste (%): 49.2188 +Area load: 0.507812 +Weight load: 0 +X max: 500 +Y max: 400 +Leftover value: 1.44e+10 +Staircase leftover value: 120000 +Total leftover value: 1.44e+10 +Total staircase leftover value: 120000 diff --git a/doc/examples/rectangle/unloading_yes/output.txt b/doc/examples/rectangle/unloading_yes/output.txt index 680a90f03..0ac9e5c4e 100644 --- a/doc/examples/rectangle/unloading_yes/output.txt +++ b/doc/examples/rectangle/unloading_yes/output.txt @@ -9,6 +9,9 @@ Rectangle Instance -------- Objective: BinPackingWithLeftovers +Leftover mode: Area +Leftover value type: SquaredArea +Leftover all bins: 1 Number of item types: 3 Number of items: 3 Number of bin types: 1 @@ -17,8 +20,8 @@ Number of groups: 3 Number of defects: 0 Unloading constraint: OnlyXMovements Total item area: 222500 -Total item width: 750 -Total item height: 750 +Mean item width: 250 +Mean item height: 250 Smallest item width: 150 Smallest item height: 150 Total item profit: 222500 @@ -31,29 +34,33 @@ Largest bin cost: 280000 Time # bins Leftover Comment ---- ------ -------- ------- - 0.000 2 240000 TS g 0 d X q 1 - 0.001 2 257500 SVC it 0 + 0.005 2 5.76e+10 TS g 0 d X q 1 + 0.005 2 6.63062e+10 SVC it 0 Final statistics ---------------- -Time (s): 5.00393 +Time (s): 5.00233 +Is proven infeasible: 0 Solution -------- -Number of items: 3 / 3 (100%) -Item area: 222500 / 222500 (100%) -Item weight: 0 / 0 (-nan%) -Item profit: 222500 / 222500 (100%) -Number of bins: 2 / 2 (100%) -Bin area: 560000 / 560000 (100%) -Bin weight: inf / inf (-nan%) -Bin cost: 560000 -Waste: 80000 -Waste (%): 26.4463 -Full waste: 337500 -Full waste (%): 60.2679 -Area load: 0.397321 -Weight load: 0 -X max: 150 -Y max: 150 -Leftover value: 257500 +Number of items: 3 / 3 (100%) +Item area: 222500 / 222500 (100%) +Item weight: 0 / 0 (-nan%) +Item profit: 222500 / 222500 (100%) +Number of bins: 2 / 2 (100%) +Bin area: 560000 / 560000 (100%) +Bin weight: inf / inf (-nan%) +Bin cost: 560000 +Waste: 80000 +Waste (%): 26.4463 +Full waste: 337500 +Full waste (%): 60.2679 +Area load: 0.397321 +Weight load: 0 +X max: 150 +Y max: 150 +Leftover value: 6.63062e+10 +Staircase leftover value: 257500 +Total leftover value: 6.79062e+10 +Total staircase leftover value: 337500 diff --git a/doc/examples/rectangleguillotine/basic/output.txt b/doc/examples/rectangleguillotine/basic/output.txt index ad6115ada..23347c825 100644 --- a/doc/examples/rectangleguillotine/basic/output.txt +++ b/doc/examples/rectangleguillotine/basic/output.txt @@ -36,15 +36,16 @@ Largest bin cost: 700000 Time # bins Waste Waste (%) Comment ---- ------ ----- --------- ------- - 0.000 1 210000 42.86 TS g 1 d Vertical q 1 - 0.000 1 175000 38.46 TS g 1 d Vertical q 1 - 0.001 1 70000 20.00 TS g 1 d Vertical q 1 - 0.002 1 35000 11.11 TS g 1 d Vertical q 19 - 0.010 1 35000 11.11 TS g 0 d Vertical q 211 + 0.003 1 385000 57.89 TS g 0 d Vertical q 1 + 0.004 1 210000 42.86 TS g 1 d Vertical q 1 + 0.008 1 70000 20.00 SSK it 0 + 0.013 1 35000 11.11 TS g 1 d Vertical q 19 + 0.024 1 35000 11.11 TS g 0 d Vertical q 211 Final statistics ---------------- -Time (s): 5.00008 +Time (s): 5.00012 +Is proven infeasible: 0 Solution -------- @@ -73,5 +74,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/cutdefects_no/output.txt b/doc/examples/rectangleguillotine/cutdefects_no/output.txt index aa2b8c2fd..1b437ddad 100644 --- a/doc/examples/rectangleguillotine/cutdefects_no/output.txt +++ b/doc/examples/rectangleguillotine/cutdefects_no/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 100 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 72.50 TS g 1 d Vertical q 1 + 0.001 2 72.50 TS g 0 d Vertical q 1 Final statistics ---------------- -Time (s): 0.0226661 +Time (s): 0.00750028 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- @@ -56,7 +60,7 @@ Waste: 95 (63.3333%) Full waste: 145 (72.5%) Width: 5 Height: 10 -Second leftover value: 25 +Second leftover value: 20 Number of stages: 2 Feasible: 1 Number of stages: 1 @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/cutdefects_no/solution.csv b/doc/examples/rectangleguillotine/cutdefects_no/solution.csv index 28c8e071c..7892aa327 100644 --- a/doc/examples/rectangleguillotine/cutdefects_no/solution.csv +++ b/doc/examples/rectangleguillotine/cutdefects_no/solution.csv @@ -1,14 +1,14 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 0,1,0,0,0,10,10,0,0, 0,1,1,0,0,6,10,-2,1,0 -0,1,2,0,0,6,6,-2,2,1 -0,1,3,0,0,5,6,1,3,2 -0,1,4,5,0,1,6,-1,3,2 -0,1,5,0,6,6,4,-1,2,1 +0,1,2,0,0,6,5,-2,2,1 +0,1,3,0,0,5,5,0,3,2 +0,1,4,5,0,1,5,-1,3,2 +0,1,5,0,5,6,5,-1,2,1 0,1,6,6,0,4,10,-1,1,0 0,1,-1,4,7,2,2,-4,-1, 1,1,7,0,0,10,10,1,0, 1,1,8,0,0,5,10,-2,1,7 -1,1,9,0,0,5,5,0,2,8 -1,1,10,0,5,5,5,-1,2,8 +1,1,9,0,0,5,6,1,2,8 +1,1,10,0,6,5,4,-1,2,8 1,1,11,5,0,5,10,-3,1,7 diff --git a/doc/examples/rectangleguillotine/cutdefects_yes/output.txt b/doc/examples/rectangleguillotine/cutdefects_yes/output.txt index aa833cac5..1d20d1595 100644 --- a/doc/examples/rectangleguillotine/cutdefects_yes/output.txt +++ b/doc/examples/rectangleguillotine/cutdefects_yes/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 100 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 1 45.00 TS g 1 d Vertical q 1 + 0.001 1 45.00 TS g 0 d Vertical q 1 Final statistics ---------------- -Time (s): 0.00294625 +Time (s): 0.0041923 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- @@ -56,7 +60,7 @@ Waste: 45 (45%) Full waste: 45 (45%) Width: 10 Height: 10 -Second leftover value: 25 +Second leftover value: 20 Number of stages: 1 Feasible: 1 Number of stages: 1 @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/cutdefects_yes/solution.csv b/doc/examples/rectangleguillotine/cutdefects_yes/solution.csv index 7d9a6f8d3..f6486a01f 100644 --- a/doc/examples/rectangleguillotine/cutdefects_yes/solution.csv +++ b/doc/examples/rectangleguillotine/cutdefects_yes/solution.csv @@ -1,9 +1,9 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 0,1,0,0,0,10,10,0,0, 0,1,1,0,0,5,10,-2,1,0 -0,1,2,0,0,5,6,1,2,1 -0,1,3,0,6,5,4,-1,2,1 +0,1,2,0,0,5,5,0,2,1 +0,1,3,0,5,5,5,-1,2,1 0,1,4,5,0,5,10,-2,1,0 -0,1,5,5,0,5,5,0,2,4 -0,1,6,5,5,5,5,-1,2,4 +0,1,5,5,0,5,6,1,2,4 +0,1,6,5,6,5,4,-1,2,4 0,1,-1,4,7,2,2,-4,-1, diff --git a/doc/examples/rectangleguillotine/cutthickness_no/output.txt b/doc/examples/rectangleguillotine/cutthickness_no/output.txt index cb301ff85..476591970 100644 --- a/doc/examples/rectangleguillotine/cutthickness_no/output.txt +++ b/doc/examples/rectangleguillotine/cutthickness_no/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 100 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 1 0.00 TS g 1 d Vertical q 1 + 0.001 1 0.00 TS g 0 d Vertical q 1 Final statistics ---------------- -Time (s): 0.00274874 +Time (s): 0.00450839 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/cutthickness_no/solution.csv b/doc/examples/rectangleguillotine/cutthickness_no/solution.csv index 4c89c402f..ff488fc27 100644 --- a/doc/examples/rectangleguillotine/cutthickness_no/solution.csv +++ b/doc/examples/rectangleguillotine/cutthickness_no/solution.csv @@ -4,6 +4,6 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 0,1,2,0,0,10,4,-2,2,1 0,1,3,0,0,10,4,0,3,2 0,1,4,0,4,10,3,-2,2,1 -0,1,5,0,4,10,3,1,3,4 +0,1,5,0,4,10,3,2,3,4 0,1,6,0,7,10,3,-2,2,1 -0,1,7,0,7,10,3,2,3,6 +0,1,7,0,7,10,3,1,3,6 diff --git a/doc/examples/rectangleguillotine/cutthickness_yes/output.txt b/doc/examples/rectangleguillotine/cutthickness_yes/output.txt index 1715fbb2f..aba813b6b 100644 --- a/doc/examples/rectangleguillotine/cutthickness_yes/output.txt +++ b/doc/examples/rectangleguillotine/cutthickness_yes/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 100 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 50.00 TS g 1 d Vertical q 1 + 0.000 2 50.00 Final statistics ---------------- -Time (s): 0.000831258 +Time (s): 0.00475449 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- @@ -56,7 +60,7 @@ Waste: 100 (50%) Full waste: 100 (50%) Width: 10 Height: 10 -Second leftover value: 60 +Second leftover value: 10 Number of stages: 2 Feasible: 1 Number of stages: 1 @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/cutthickness_yes/solution.csv b/doc/examples/rectangleguillotine/cutthickness_yes/solution.csv index ed130b82d..9e7e5e9e7 100644 --- a/doc/examples/rectangleguillotine/cutthickness_yes/solution.csv +++ b/doc/examples/rectangleguillotine/cutthickness_yes/solution.csv @@ -1,13 +1,10 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 0,1,0,0,0,10,10,0,0, 0,1,1,0,0,10,10,-2,1,0 -0,1,2,0,0,10,4,-2,2,1 -0,1,3,0,0,10,4,0,3,2 -0,1,4,0,5,10,3,-2,2,1 -0,1,5,0,5,10,3,1,3,4 -0,1,6,0,9,10,1,-1,2,1 -1,1,7,0,0,10,10,0,0, -1,1,8,0,0,10,10,-2,1,7 -1,1,9,0,0,10,3,-2,2,8 -1,1,10,0,0,10,3,2,3,9 -1,1,11,0,4,10,6,-1,2,8 +0,1,2,0,0,10,3,2,2,1 +0,1,3,0,4,10,6,-1,2,1 +1,1,4,0,0,10,10,0,0, +1,1,5,0,0,10,10,-2,1,4 +1,1,6,0,0,10,4,0,2,5 +1,1,7,0,5,10,3,1,2,5 +1,1,8,0,9,10,1,-1,2,5 diff --git a/doc/examples/rectangleguillotine/cuttype_exact/output.txt b/doc/examples/rectangleguillotine/cuttype_exact/output.txt index 1ae9a5aab..39faf650d 100644 --- a/doc/examples/rectangleguillotine/cuttype_exact/output.txt +++ b/doc/examples/rectangleguillotine/cuttype_exact/output.txt @@ -36,17 +36,15 @@ Largest bin cost: 3200 Time # bins Waste Waste (%) Comment ---- ------ ----- --------- ------- - 0.001 3 1869 27.01 TS g 0 d Vertical q 1 - 0.001 3 1869 27.01 TS g 0 d Vertical q 2 - 0.001 3 1829 26.58 TS g 0 d Vertical q 3 - 0.002 2 909 15.25 TS g 1 d Vertical q 6 - 0.004 2 789 13.51 TS g 1 d Vertical q 6 - 0.004 2 669 11.70 TS g 0 d Vertical q 11 - 0.009 2 589 10.44 TS g 1 d Vertical q 28 + 0.006 3 1869 27.01 TS g 0 d Vertical q 1 + 0.007 3 1869 27.01 TS g 1 d Vertical q 2 + 0.015 2 669 11.70 SVC it 0 + 0.022 2 589 10.44 TS g 1 d Vertical q 28 Final statistics ---------------- -Time (s): 10.1059 +Time (s): 10.0839 +Is proven infeasible: 0 Solution -------- @@ -75,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/cuttype_homogenous/output.txt b/doc/examples/rectangleguillotine/cuttype_homogenous/output.txt index 9f61af873..6a8b064a2 100644 --- a/doc/examples/rectangleguillotine/cuttype_homogenous/output.txt +++ b/doc/examples/rectangleguillotine/cuttype_homogenous/output.txt @@ -36,23 +36,27 @@ Largest bin cost: 3200 Time # bins Waste Waste (%) Comment ---- ------ ----- --------- ------- - 0.000 3 1869 27.01 TS g 0 d Vertical q 1 - 0.001 3 1869 27.01 TS g 0 d Vertical q 2 - 0.001 3 1829 26.58 TS g 0 d Vertical q 3 - 0.002 2 909 15.25 TS g 1 d Vertical q 5 - 0.003 2 789 13.51 TS g 1 d Vertical q 5 - 0.041 2 749 12.91 TS g 0 d Vertical q 141 - 0.042 2 749 12.91 TS g 0 d Vertical q 141 - 0.080 2 749 12.91 TS g 1 d Vertical q 316 - 0.194 2 749 12.91 TS g 0 d Vertical q 711 - 0.705 2 709 12.31 TS g 1 d Vertical q 2398 - 1.772 2 669 11.70 TS g 1 d Vertical q 5395 - 1.772 2 669 11.70 TS g 1 d Vertical q 5395 - 4.020 2 669 11.70 TS g 0 d Vertical q 12138 + 0.007 3 1869 27.01 TS g 0 d Vertical q 1 + 0.008 3 1869 27.01 TS g 0 d Vertical q 2 + 0.013 3 1829 26.58 TS g 0 d Vertical q 3 + 0.018 2 909 15.25 TS g 1 d Vertical q 5 + 0.023 2 789 13.51 TS g 1 d Vertical q 5 + 0.045 2 749 12.91 TS g 0 d Vertical q 141 + 0.049 2 749 12.91 TS g 0 d Vertical q 156 + 0.072 2 749 12.91 TS g 1 d Vertical q 316 + 0.124 2 749 12.91 TS g 0 d Vertical q 645 + 0.405 2 709 12.31 TS g 0 d Vertical q 2398 + 0.410 2 709 12.31 TS g 0 d Vertical q 2398 + 0.430 2 709 12.31 TS g 1 d Vertical q 2398 + 1.211 2 669 11.70 TS g 1 d Vertical q 4734 + 1.215 2 669 11.70 TS g 1 d Vertical q 4734 + 2.276 2 669 11.70 TS g 0 d Vertical q 12138 + 7.346 2 629 11.07 TS g 1 d Vertical q 27310 Final statistics ---------------- -Time (s): 10.0928 +Time (s): 10.0922 +Is proven infeasible: 0 Solution -------- @@ -64,11 +68,11 @@ Number of different bins: 2 Bin area: 6400 / 22400 (28.5714%) Bin cost: 6400 Cutting cost: 0 -Waste: 669 (11.6958%) +Waste: 629 (11.0739%) Full waste: 1349 (21.0781%) -Width: 63 +Width: 62 Height: 40 -Second leftover value: 48 +Second leftover value: 11 Number of stages: 3 Feasible: 1 Number of stages: 1 @@ -81,5 +85,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/cuttype_homogenous/solution.csv b/doc/examples/rectangleguillotine/cuttype_homogenous/solution.csv index 0df6ad9d8..54fa57127 100644 --- a/doc/examples/rectangleguillotine/cuttype_homogenous/solution.csv +++ b/doc/examples/rectangleguillotine/cuttype_homogenous/solution.csv @@ -1,64 +1,66 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 0,1,0,0,0,80,40,0,0, -0,1,1,0,0,13,40,-2,1,0 -0,1,2,0,0,13,10,-2,2,1 -0,1,3,0,0,13,10,5,3,2 -0,1,4,0,10,13,11,-2,2,1 -0,1,5,0,10,13,11,9,3,4 -0,1,6,0,21,13,13,-2,2,1 -0,1,7,0,21,13,13,3,3,6 -0,1,8,0,34,13,5,-2,2,1 -0,1,9,0,34,5,5,11,3,8 -0,1,10,5,34,5,5,11,3,8 -0,1,11,10,34,3,5,-1,3,8 -0,1,12,0,39,13,1,-1,2,1 -0,1,13,13,0,19,40,-2,1,0 -0,1,14,13,0,19,19,-2,2,13 -0,1,15,13,0,19,19,1,3,14 -0,1,16,13,19,19,19,-2,2,13 -0,1,17,13,19,19,19,1,3,16 -0,1,18,13,38,19,2,-1,2,13 -0,1,19,32,0,26,40,-2,1,0 -0,1,20,32,0,26,13,-2,2,19 -0,1,21,32,0,13,13,3,3,20 -0,1,22,45,0,13,13,3,3,20 -0,1,23,32,13,26,4,-2,2,19 -0,1,24,32,13,13,4,4,3,23 -0,1,25,45,13,13,4,-1,3,23 -0,1,26,32,17,26,23,-2,2,19 -0,1,27,32,17,23,23,0,3,26 -0,1,28,55,17,3,23,-1,3,26 -0,1,29,58,0,21,40,-2,1,0 -0,1,30,58,0,21,19,-2,2,29 -0,1,31,58,0,19,19,1,3,30 -0,1,32,77,0,2,19,-1,3,30 -0,1,33,58,19,21,7,-2,2,29 -0,1,34,58,19,7,7,10,3,33 -0,1,35,65,19,7,7,10,3,33 -0,1,36,72,19,7,7,10,3,33 -0,1,37,58,26,21,11,-2,2,29 -0,1,38,58,26,11,11,8,3,37 -0,1,39,69,26,10,11,-1,3,37 -0,1,40,58,37,21,3,-1,2,29 -0,1,41,79,0,1,40,-1,1,0 -1,1,42,0,0,80,40,0,0, -1,1,43,0,0,51,40,-2,1,42 -1,1,44,0,0,51,17,-2,2,43 -1,1,45,0,0,17,17,2,3,44 -1,1,46,17,0,17,17,2,3,44 -1,1,47,34,0,17,17,2,3,44 -1,1,48,0,17,51,23,-2,2,43 -1,1,49,0,17,23,23,0,3,48 -1,1,50,23,17,23,23,0,3,48 -1,1,51,46,17,5,23,-1,3,48 -1,1,52,51,0,12,40,-2,1,42 -1,1,53,51,0,12,20,-2,2,52 -1,1,54,51,0,12,20,6,3,53 -1,1,55,51,20,12,11,-2,2,52 -1,1,56,51,20,9,11,7,3,55 -1,1,57,60,20,3,11,-1,3,55 -1,1,58,51,31,12,5,-2,2,52 -1,1,59,51,31,5,5,11,3,58 -1,1,60,56,31,7,5,-1,3,58 -1,1,61,51,36,12,4,-1,2,52 -1,1,62,63,0,17,40,-3,1,42 +0,1,1,0,0,19,40,-2,1,0 +0,1,2,0,0,19,19,-2,2,1 +0,1,3,0,0,19,19,1,3,2 +0,1,4,0,19,19,19,-2,2,1 +0,1,5,0,19,19,19,1,3,4 +0,1,6,0,38,19,2,-1,2,1 +0,1,7,19,0,14,40,-2,1,0 +0,1,8,19,0,14,7,-2,2,7 +0,1,9,19,0,7,7,10,3,8 +0,1,10,26,0,7,7,10,3,8 +0,1,11,19,7,14,13,-2,2,7 +0,1,12,19,7,13,13,3,3,11 +0,1,13,32,7,1,13,-1,3,11 +0,1,14,19,20,14,20,-2,2,7 +0,1,15,19,20,12,20,6,3,14 +0,1,16,31,20,2,20,-1,3,14 +0,1,17,33,0,26,40,-2,1,0 +0,1,18,33,0,26,13,-2,2,17 +0,1,19,33,0,13,13,3,3,18 +0,1,20,46,0,13,13,3,3,18 +0,1,21,33,13,26,4,-2,2,17 +0,1,22,33,13,13,4,4,3,21 +0,1,23,46,13,13,4,-1,3,21 +0,1,24,33,17,26,23,-2,2,17 +0,1,25,33,17,23,23,0,3,24 +0,1,26,56,17,3,23,-1,3,24 +0,1,27,59,0,19,40,-2,1,0 +0,1,28,59,0,19,19,-2,2,27 +0,1,29,59,0,19,19,1,3,28 +0,1,30,59,19,19,10,-2,2,27 +0,1,31,59,19,13,10,5,3,30 +0,1,32,72,19,6,10,-1,3,30 +0,1,33,59,29,19,11,-2,2,27 +0,1,34,59,29,13,11,9,3,33 +0,1,35,72,29,6,11,-1,3,33 +0,1,36,78,0,2,40,-1,1,0 +1,1,37,0,0,80,40,0,0, +1,1,38,0,0,51,40,-2,1,37 +1,1,39,0,0,51,23,-2,2,38 +1,1,40,0,0,23,23,0,3,39 +1,1,41,23,0,23,23,0,3,39 +1,1,42,46,0,5,23,-1,3,39 +1,1,43,0,23,51,17,-2,2,38 +1,1,44,0,23,17,17,2,3,43 +1,1,45,17,23,17,17,2,3,43 +1,1,46,34,23,17,17,2,3,43 +1,1,47,51,0,11,40,-2,1,37 +1,1,48,51,0,11,11,-2,2,47 +1,1,49,51,0,11,11,8,3,48 +1,1,50,51,11,11,5,-2,2,47 +1,1,51,51,11,5,5,11,3,50 +1,1,52,56,11,5,5,11,3,50 +1,1,53,61,11,1,5,-1,3,50 +1,1,54,51,16,11,11,-2,2,47 +1,1,55,51,16,9,11,7,3,54 +1,1,56,60,16,2,11,-1,3,54 +1,1,57,51,27,11,7,-2,2,47 +1,1,58,51,27,7,7,10,3,57 +1,1,59,58,27,4,7,-1,3,57 +1,1,60,51,34,11,5,-2,2,47 +1,1,61,51,34,5,5,11,3,60 +1,1,62,56,34,6,5,-1,3,60 +1,1,63,51,39,11,1,-1,2,47 +1,1,64,62,0,18,40,-3,1,37 diff --git a/doc/examples/rectangleguillotine/cuttype_nonexact/output.txt b/doc/examples/rectangleguillotine/cuttype_nonexact/output.txt index 1b7904919..2ffb29278 100644 --- a/doc/examples/rectangleguillotine/cuttype_nonexact/output.txt +++ b/doc/examples/rectangleguillotine/cuttype_nonexact/output.txt @@ -36,17 +36,18 @@ Largest bin cost: 3200 Time # bins Waste Waste (%) Comment ---- ------ ----- --------- ------- - 0.000 2 949 15.82 TS g 0 d Vertical q 1 - 0.003 2 869 14.68 TS g 0 d Vertical q 13 - 0.003 2 869 14.68 TS g 0 d Vertical q 13 - 0.003 2 589 10.44 TS g 0 d Vertical q 13 - 0.016 2 389 7.15 SVC it 0 - 0.031 2 349 6.46 SVC it 1 - 0.473 2 349 6.46 TS g 1 d Vertical q 1599 + 0.009 2 949 15.82 TS g 0 d Vertical q 1 + 0.012 2 869 14.68 TS g 0 d Vertical q 13 + 0.019 2 869 14.68 TS g 1 d Vertical q 19 + 0.024 2 789 13.51 TS g 0 d Vertical q 14 + 0.028 2 389 7.15 SVC it 0 + 0.041 2 349 6.46 SVC it 1 + 0.403 2 349 6.46 TS g 1 d Vertical q 1599 Final statistics ---------------- -Time (s): 10.0808 +Time (s): 10.0599 +Is proven infeasible: 0 Solution -------- @@ -75,5 +76,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/cuttype_roadef2018/output.txt b/doc/examples/rectangleguillotine/cuttype_roadef2018/output.txt index d100ca5f6..3300c830a 100644 --- a/doc/examples/rectangleguillotine/cuttype_roadef2018/output.txt +++ b/doc/examples/rectangleguillotine/cuttype_roadef2018/output.txt @@ -36,21 +36,23 @@ Largest bin cost: 3200 Time # bins Waste Waste (%) Comment ---- ------ ----- --------- ------- - 0.000 2 869 14.68 TS g 1 d Vertical q 1 - 0.002 2 749 12.91 TS g 1 d Vertical q 4 - 0.002 2 589 10.44 TS g 0 d Vertical q 3 - 0.010 2 589 10.44 TS g 0 d Vertical q 5 - 0.012 2 549 9.80 TS g 1 d Vertical q 13 - 0.016 2 349 6.46 TS g 1 d Vertical q 28 - 0.027 2 349 6.46 TS g 1 d Vertical q 63 - 0.027 2 349 6.46 TS g 1 d Vertical q 63 - 0.027 2 309 5.76 TS g 1 d Vertical q 63 - 0.037 2 309 5.76 TS g 1 d Vertical q 94 - 0.073 2 309 5.76 TS g 1 d Vertical q 211 + 0.007 2 1349 21.08 TS g 0 d Vertical q 1 + 0.008 2 869 14.68 TS g 1 d Vertical q 1 + 0.013 2 589 10.44 TS g 0 d Vertical q 3 + 0.017 2 589 10.44 TS g 0 d Vertical q 5 + 0.020 2 549 9.80 TS g 1 d Vertical q 13 + 0.024 2 349 6.46 SVC it 0 + 0.028 2 349 6.46 TS g 1 d Vertical q 28 + 0.036 2 349 6.46 TS g 0 d Vertical q 94 + 0.042 2 349 6.46 TS g 1 d Vertical q 63 + 0.045 2 309 5.76 TS g 1 d Vertical q 63 + 0.051 2 309 5.76 TS g 0 d Vertical q 141 + 0.085 2 309 5.76 TS g 1 d Vertical q 156 Final statistics ---------------- -Time (s): 10.0722 +Time (s): 10.0699 +Is proven infeasible: 0 Solution -------- @@ -79,5 +81,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/cuttype_roadef2018/solution.csv b/doc/examples/rectangleguillotine/cuttype_roadef2018/solution.csv index 4beb85244..4d3de27db 100644 --- a/doc/examples/rectangleguillotine/cuttype_roadef2018/solution.csv +++ b/doc/examples/rectangleguillotine/cuttype_roadef2018/solution.csv @@ -11,42 +11,42 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 0,1,9,0,17,23,23,0,3,8 0,1,10,23,17,23,23,0,3,8 0,1,11,46,17,1,23,-1,3,8 -0,1,12,47,0,20,40,-2,1,0 -0,1,13,47,0,20,11,-2,2,12 -0,1,14,47,0,11,11,8,3,13 -0,1,15,58,0,9,11,7,3,13 -0,1,16,47,11,20,19,-2,2,12 -0,1,17,47,11,19,19,1,3,16 -0,1,18,66,11,1,19,-1,3,16 -0,1,19,47,30,20,10,-2,2,12 -0,1,20,47,30,13,10,5,3,19 -0,1,21,60,30,7,10,-2,3,19 -0,1,22,60,30,7,7,10,4,21 -0,1,23,60,37,7,3,-1,4,21 -0,1,24,67,0,13,40,-2,1,0 -0,1,25,67,0,13,13,-2,2,24 -0,1,26,67,0,13,13,3,3,25 -0,1,27,67,13,13,24,-2,2,24 -0,1,28,67,13,13,24,-2,3,27 -0,1,29,67,13,13,13,3,4,28 -0,1,30,67,26,13,11,9,4,28 -0,1,31,67,37,13,3,-1,2,24 +0,1,12,47,0,13,40,-2,1,0 +0,1,13,47,0,13,13,-2,2,12 +0,1,14,47,0,13,13,3,3,13 +0,1,15,47,13,13,24,-2,2,12 +0,1,16,47,13,13,24,-2,3,15 +0,1,17,47,13,13,13,3,4,16 +0,1,18,47,26,13,11,9,4,16 +0,1,19,47,37,13,3,-1,2,12 +0,1,20,60,0,20,40,-2,1,0 +0,1,21,60,0,20,19,-2,2,20 +0,1,22,60,0,19,19,1,3,21 +0,1,23,79,0,1,19,-1,3,21 +0,1,24,60,19,20,11,-2,2,20 +0,1,25,60,19,11,11,8,3,24 +0,1,26,71,19,9,11,7,3,24 +0,1,27,60,30,20,10,-2,2,20 +0,1,28,60,30,13,10,5,3,27 +0,1,29,73,30,7,10,-2,3,27 +0,1,30,73,30,7,7,10,4,29 +0,1,31,73,37,7,3,-1,4,29 1,1,32,0,0,80,40,0,0, -1,1,33,0,0,19,40,-2,1,32 -1,1,34,0,0,19,19,-2,2,33 -1,1,35,0,0,19,19,1,3,34 -1,1,36,0,19,19,19,-2,2,33 -1,1,37,0,19,19,19,1,3,36 -1,1,38,0,38,19,2,-1,2,33 -1,1,39,19,0,23,40,-2,1,32 -1,1,40,19,0,23,23,-2,2,39 -1,1,41,19,0,23,23,0,3,40 -1,1,42,19,23,23,17,-2,2,39 -1,1,43,19,23,17,17,2,3,42 -1,1,44,36,23,5,17,-2,3,42 -1,1,45,36,23,5,5,11,4,44 -1,1,46,36,28,5,12,-1,4,44 -1,1,47,41,23,1,17,-1,3,42 +1,1,33,0,0,23,40,-2,1,32 +1,1,34,0,0,23,23,-2,2,33 +1,1,35,0,0,23,23,0,3,34 +1,1,36,0,23,23,17,-2,2,33 +1,1,37,0,23,17,17,2,3,36 +1,1,38,17,23,5,17,-2,3,36 +1,1,39,17,23,5,5,11,4,38 +1,1,40,17,28,5,12,-1,4,38 +1,1,41,22,23,1,17,-1,3,36 +1,1,42,23,0,19,40,-2,1,32 +1,1,43,23,0,19,19,-2,2,42 +1,1,44,23,0,19,19,1,3,43 +1,1,45,23,19,19,19,-2,2,42 +1,1,46,23,19,19,19,1,3,45 +1,1,47,23,38,19,2,-1,2,42 1,1,48,42,0,12,40,-2,1,32 1,1,49,42,0,12,7,-2,2,48 1,1,50,42,0,7,7,10,3,49 diff --git a/doc/examples/rectangleguillotine/defects_no/output.txt b/doc/examples/rectangleguillotine/defects_no/output.txt index 568a064b3..aec04d9e2 100644 --- a/doc/examples/rectangleguillotine/defects_no/output.txt +++ b/doc/examples/rectangleguillotine/defects_no/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 120 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 1 0.00 TS g 1 d Vertical q 1 + 0.000 1 0.00 Final statistics ---------------- -Time (s): 0.00411838 +Time (s): 0.00458382 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/defects_no/solution.csv b/doc/examples/rectangleguillotine/defects_no/solution.csv index e4303db79..23abd26f3 100644 --- a/doc/examples/rectangleguillotine/defects_no/solution.csv +++ b/doc/examples/rectangleguillotine/defects_no/solution.csv @@ -1,7 +1,5 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 0,1,0,0,0,10,12,0,0, 0,1,1,0,0,10,12,-2,1,0 -0,1,2,0,0,10,6,-2,2,1 -0,1,3,0,0,10,6,0,3,2 -0,1,4,0,6,10,6,-2,2,1 -0,1,5,0,6,10,6,0,3,4 +0,1,2,0,0,10,6,0,2,1 +0,1,3,0,6,10,6,0,2,1 diff --git a/doc/examples/rectangleguillotine/defects_yes/output.txt b/doc/examples/rectangleguillotine/defects_yes/output.txt index 6d72742af..1738db734 100644 --- a/doc/examples/rectangleguillotine/defects_yes/output.txt +++ b/doc/examples/rectangleguillotine/defects_yes/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 120 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 50.00 TS g 1 d Vertical q 1 + 0.001 2 50.00 TS g 0 d Vertical q 1 Final statistics ---------------- -Time (s): 0.00422216 +Time (s): 0.00749962 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/guillotine_vs_non_guillotine/output.txt b/doc/examples/rectangleguillotine/guillotine_vs_non_guillotine/output.txt index 6f36cd3bf..0f40ce8be 100644 --- a/doc/examples/rectangleguillotine/guillotine_vs_non_guillotine/output.txt +++ b/doc/examples/rectangleguillotine/guillotine_vs_non_guillotine/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 108 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 50.93 TS g 1 d Vertical q 1 + 0.001 2 50.93 TS g 1 d Vertical q 1 Final statistics ---------------- -Time (s): 0.000996325 +Time (s): 0.00910654 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/maxcuts2_no/output.txt b/doc/examples/rectangleguillotine/maxcuts2_no/output.txt index 60c93045c..b3de3ff79 100644 --- a/doc/examples/rectangleguillotine/maxcuts2_no/output.txt +++ b/doc/examples/rectangleguillotine/maxcuts2_no/output.txt @@ -36,12 +36,15 @@ Largest bin cost: 200 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 50.00 TS g 0 d Vertical q 1 - 0.001 1 0.00 SVC it 0 + 0.001 1 0.00 TS g 1 d Vertical q 1 Final statistics ---------------- -Time (s): 0.000963691 +Time (s): 0.00446908 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- @@ -70,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/maxcuts2_no/solution.csv b/doc/examples/rectangleguillotine/maxcuts2_no/solution.csv index db58b28e3..21dc9d02e 100644 --- a/doc/examples/rectangleguillotine/maxcuts2_no/solution.csv +++ b/doc/examples/rectangleguillotine/maxcuts2_no/solution.csv @@ -7,6 +7,6 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 0,1,5,10,0,10,4,-2,2,4 0,1,6,10,0,10,4,2,3,5 0,1,7,10,4,10,3,-2,2,4 -0,1,8,10,4,10,3,0,3,7 +0,1,8,10,4,10,3,1,3,7 0,1,9,10,7,10,3,-2,2,4 -0,1,10,10,7,10,3,1,3,9 +0,1,10,10,7,10,3,0,3,9 diff --git a/doc/examples/rectangleguillotine/maxcuts2_yes/output.txt b/doc/examples/rectangleguillotine/maxcuts2_yes/output.txt index 35335a669..a9f8cf780 100644 --- a/doc/examples/rectangleguillotine/maxcuts2_yes/output.txt +++ b/doc/examples/rectangleguillotine/maxcuts2_yes/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 200 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 50.00 TS g 0 d Vertical q 1 + 0.001 2 50.00 TS g 0 d Vertical q 1 Final statistics ---------------- -Time (s): 0.00076164 +Time (s): 0.00556115 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 1 +Gap: 50% Solution -------- @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/maxcuts2_yes/solution.csv b/doc/examples/rectangleguillotine/maxcuts2_yes/solution.csv index 357f69fb0..0b34bc460 100644 --- a/doc/examples/rectangleguillotine/maxcuts2_yes/solution.csv +++ b/doc/examples/rectangleguillotine/maxcuts2_yes/solution.csv @@ -2,8 +2,8 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 0,1,0,0,0,20,10,0,0, 0,1,1,0,0,20,10,-2,1,0 0,1,2,0,0,20,3,-2,2,1 -0,1,3,0,0,10,3,0,3,2 -0,1,4,10,0,10,3,1,3,2 +0,1,3,0,0,10,3,1,3,2 +0,1,4,10,0,10,3,0,3,2 0,1,5,0,3,20,7,-2,2,1 0,1,6,0,3,10,7,-2,3,5 0,1,7,0,3,10,4,2,4,6 diff --git a/doc/examples/rectangleguillotine/maxcuts_no/output.txt b/doc/examples/rectangleguillotine/maxcuts_no/output.txt index b23834941..bc0a43197 100644 --- a/doc/examples/rectangleguillotine/maxcuts_no/output.txt +++ b/doc/examples/rectangleguillotine/maxcuts_no/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 100 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 1 10.00 TS g 1 d Vertical q 1 + 0.001 1 10.00 TS g 0 d Vertical q 1 Final statistics ---------------- -Time (s): 0.00294092 +Time (s): 0.00420577 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/maxcuts_yes/output.txt b/doc/examples/rectangleguillotine/maxcuts_yes/output.txt index b21023796..114631f56 100644 --- a/doc/examples/rectangleguillotine/maxcuts_yes/output.txt +++ b/doc/examples/rectangleguillotine/maxcuts_yes/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 100 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 55.00 TS g 0 d Vertical q 1 + 0.001 2 55.00 TS g 0 d Vertical q 1 Final statistics ---------------- -Time (s): 0.000810487 +Time (s): 0.00346998 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 1 +Gap: 50% Solution -------- @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/orientation_no/output.txt b/doc/examples/rectangleguillotine/orientation_no/output.txt index b6626bd05..be94edf76 100644 --- a/doc/examples/rectangleguillotine/orientation_no/output.txt +++ b/doc/examples/rectangleguillotine/orientation_no/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 100 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 53.00 TS g 1 d Horizontal q 1 + 0.001 2 53.00 TS g 0 d Horizontal q 1 Final statistics ---------------- -Time (s): 0.0075128 +Time (s): 0.00814125 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- @@ -52,11 +56,11 @@ Number of different bins: 2 Bin area: 200 / 300 (66.6667%) Bin cost: 200 Cutting cost: 0 -Waste: 46 (32.8571%) +Waste: 76 (44.7059%) Full waste: 106 (53%) Width: 10 -Height: 4 -Second leftover value: 16 +Height: 7 +Second leftover value: 42 Number of stages: 2 Feasible: 1 Number of stages: 1 @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/orientation_no/solution.csv b/doc/examples/rectangleguillotine/orientation_no/solution.csv index 2ccabad1f..766888c38 100644 --- a/doc/examples/rectangleguillotine/orientation_no/solution.csv +++ b/doc/examples/rectangleguillotine/orientation_no/solution.csv @@ -1,15 +1,17 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 0,1,0,0,0,10,10,0,0, -0,1,1,0,0,10,7,-2,1,0 -0,1,2,0,0,6,7,-2,2,1 -0,1,3,0,0,6,5,2,3,2 -0,1,4,0,5,6,2,-1,3,2 -0,1,5,6,0,4,7,1,2,1 -0,1,6,0,7,10,3,-2,1,0 -0,1,7,0,7,4,3,0,2,6 -0,1,8,4,7,6,3,-1,2,6 -1,1,9,0,0,10,10,0,0, -1,1,10,0,0,10,4,-2,1,9 -1,1,11,0,0,6,4,3,2,10 -1,1,12,6,0,4,4,-1,2,10 -1,1,13,0,4,10,6,-3,1,9 +0,1,1,0,0,10,4,-2,1,0 +0,1,2,0,0,4,4,-2,2,1 +0,1,3,0,0,4,3,0,3,2 +0,1,4,0,3,4,1,-1,3,2 +0,1,5,4,0,6,4,3,2,1 +0,1,6,0,4,10,6,-2,1,0 +0,1,7,0,4,6,6,-2,2,6 +0,1,8,0,4,6,5,2,3,7 +0,1,9,0,9,6,1,-1,3,7 +0,1,10,6,4,4,6,-1,2,6 +1,1,11,0,0,10,10,0,0, +1,1,12,0,0,10,7,-2,1,11 +1,1,13,0,0,4,7,1,2,12 +1,1,14,4,0,6,7,-1,2,12 +1,1,15,0,7,10,3,-3,1,11 diff --git a/doc/examples/rectangleguillotine/orientation_yes/output.txt b/doc/examples/rectangleguillotine/orientation_yes/output.txt index 84a59a9e3..97b2f4ea7 100644 --- a/doc/examples/rectangleguillotine/orientation_yes/output.txt +++ b/doc/examples/rectangleguillotine/orientation_yes/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 100 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.001 1 6.00 TS g 1 d Vertical q 1 + 0.001 1 6.00 TS g 0 d Vertical q 1 Final statistics ---------------- -Time (s): 0.000940947 +Time (s): 0.00455538 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- @@ -56,7 +60,7 @@ Waste: 6 (6%) Full waste: 6 (6%) Width: 10 Height: 10 -Second leftover value: 0 +Second leftover value: 6 Number of stages: 2 Feasible: 1 Number of stages: 1 @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/orientation_yes/solution.csv b/doc/examples/rectangleguillotine/orientation_yes/solution.csv index a5fbb5243..a4faad1bb 100644 --- a/doc/examples/rectangleguillotine/orientation_yes/solution.csv +++ b/doc/examples/rectangleguillotine/orientation_yes/solution.csv @@ -1,9 +1,9 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 0,1,0,0,0,10,10,0,0, -0,1,1,0,0,6,10,-2,1,0 -0,1,2,0,0,6,5,2,2,1 -0,1,3,0,5,6,4,3,2,1 -0,1,4,0,9,6,1,-1,2,1 -0,1,5,6,0,4,10,-2,1,0 -0,1,6,6,0,4,7,1,2,5 -0,1,7,6,7,4,3,0,2,5 +0,1,1,0,0,4,10,-2,1,0 +0,1,2,0,0,4,3,0,2,1 +0,1,3,0,3,4,7,1,2,1 +0,1,4,4,0,6,10,-2,1,0 +0,1,5,4,0,6,5,2,2,4 +0,1,6,4,5,6,4,3,2,4 +0,1,7,4,9,6,1,-1,2,4 diff --git a/doc/examples/rectangleguillotine/rotation_no/output.txt b/doc/examples/rectangleguillotine/rotation_no/output.txt index 9b1d689e6..bc463cfa5 100644 --- a/doc/examples/rectangleguillotine/rotation_no/output.txt +++ b/doc/examples/rectangleguillotine/rotation_no/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 120 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 2 50.00 TS g 1 d Vertical q 1 + 0.000 2 50.00 Final statistics ---------------- -Time (s): 0.00761241 +Time (s): 0.00254587 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- @@ -48,7 +52,7 @@ Number of items: 2 / 2 (100%) Item area: 120 / 120 (100%) Item profit: 120 / 120 (100%) Number of bins: 2 / 2 (100%) -Number of different bins: 2 +Number of different bins: 1 Bin area: 240 / 240 (100%) Bin cost: 240 Cutting cost: 0 @@ -57,7 +61,7 @@ Full waste: 120 (50%) Width: 6 Height: 12 Second leftover value: 12 -Number of stages: 2 +Number of stages: 1 Feasible: 1 Number of stages: 1 Min. waste length: 1 @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/rotation_no/solution.csv b/doc/examples/rectangleguillotine/rotation_no/solution.csv index 707aaa676..f11c292f0 100644 --- a/doc/examples/rectangleguillotine/rotation_no/solution.csv +++ b/doc/examples/rectangleguillotine/rotation_no/solution.csv @@ -1,13 +1,6 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT -0,1,0,0,0,10,12,0,0, -0,1,1,0,0,6,12,-2,1,0 -0,1,2,0,0,6,10,-2,2,1 -0,1,3,0,0,6,10,0,3,2 -0,1,4,0,10,6,2,-1,2,1 -0,1,5,6,0,4,12,-1,1,0 -1,1,6,0,0,10,12,0,0, -1,1,7,0,0,6,12,-2,1,6 -1,1,8,0,0,6,10,-2,2,7 -1,1,9,0,0,6,10,0,3,8 -1,1,10,0,10,6,2,-1,2,7 -1,1,11,6,0,4,12,-3,1,6 +0,2,0,0,0,10,12,0,0, +0,2,1,0,0,6,12,-2,1,0 +0,2,2,0,0,6,10,0,2,1 +0,2,3,0,10,6,2,-1,2,1 +0,2,4,6,0,4,12,-3,1,0 diff --git a/doc/examples/rectangleguillotine/rotation_yes/output.txt b/doc/examples/rectangleguillotine/rotation_yes/output.txt index f4f09eb52..b69f2f0c6 100644 --- a/doc/examples/rectangleguillotine/rotation_yes/output.txt +++ b/doc/examples/rectangleguillotine/rotation_yes/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 120 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.000 1 0.00 TS g 0 d Vertical q 1 + 0.001 1 0.00 TS g 0 d Vertical q 1 Final statistics ---------------- -Time (s): 0.000810747 +Time (s): 0.00409746 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/stacks_no/output.txt b/doc/examples/rectangleguillotine/stacks_no/output.txt index 0b416d5db..35a3dc1f7 100644 --- a/doc/examples/rectangleguillotine/stacks_no/output.txt +++ b/doc/examples/rectangleguillotine/stacks_no/output.txt @@ -37,11 +37,15 @@ Largest bin cost: 100 Time Bins Full waste (%) Comment ---- ---- -------------- ------- 0.001 2 50.00 TS g 0 d Vertical q 1 - 0.022 1 0.00 SVC it 0 + 0.004 1 0.00 SVC it 0 Final statistics ---------------- -Time (s): 0.028119 +Time (s): 0.00778047 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- @@ -70,5 +74,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/stacks_yes/output.txt b/doc/examples/rectangleguillotine/stacks_yes/output.txt index 8ec66bd42..c0ac5dc45 100644 --- a/doc/examples/rectangleguillotine/stacks_yes/output.txt +++ b/doc/examples/rectangleguillotine/stacks_yes/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 100 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.001 2 50.00 TS g 1 d Vertical q 1 + 0.001 2 50.00 TS g 0 d Vertical q 1 Final statistics ---------------- -Time (s): 0.00998285 +Time (s): 0.00584676 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/stages_2/output.txt b/doc/examples/rectangleguillotine/stages_2/output.txt index 3ef587b6b..96e598bbf 100644 --- a/doc/examples/rectangleguillotine/stages_2/output.txt +++ b/doc/examples/rectangleguillotine/stages_2/output.txt @@ -36,15 +36,16 @@ Largest bin cost: 3200 Time # bins Waste Waste (%) Comment ---- ------ ----- --------- ------- - 0.000 3 3429 40.44 TS g 1 d Vertical q 1 - 0.001 3 3429 40.44 TS g 0 d Vertical q 4 - 0.008 3 3389 40.15 TS g 0 d Vertical q 9 - 0.014 3 3389 40.15 TS g 0 d Vertical q 9 - 0.024 3 3389 40.15 TS g 0 d Vertical q 23 + 0.006 3 3429 40.44 TS g 0 d Vertical q 1 + 0.007 3 3429 40.44 TS g 0 d Vertical q 4 + 0.012 3 3389 40.15 TS g 0 d Vertical q 9 + 0.016 3 3389 40.15 TS g 0 d Vertical q 9 + 0.023 3 3389 40.15 TS g 0 d Vertical q 23 Final statistics ---------------- -Time (s): 10.0024 +Time (s): 10.0008 +Is proven infeasible: 0 Solution -------- @@ -73,5 +74,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/stages_3/output.txt b/doc/examples/rectangleguillotine/stages_3/output.txt index 06db234f6..38f1a00be 100644 --- a/doc/examples/rectangleguillotine/stages_3/output.txt +++ b/doc/examples/rectangleguillotine/stages_3/output.txt @@ -36,15 +36,16 @@ Largest bin cost: 3200 Time # bins Waste Waste (%) Comment ---- ------ ----- --------- ------- - 0.000 3 1869 27.01 TS g 0 d Vertical q 1 - 0.001 3 1869 27.01 TS g 1 d Vertical q 2 - 0.006 3 1829 26.58 TS g 0 d Vertical q 3 - 0.010 2 669 11.70 SVC it 0 - 0.018 2 589 10.44 TS g 1 d Vertical q 28 + 0.008 3 1869 27.01 TS g 0 d Vertical q 1 + 0.009 3 1869 27.01 TS g 0 d Vertical q 2 + 0.014 3 1829 26.58 TS g 0 d Vertical q 3 + 0.017 2 669 11.70 SVC it 0 + 0.025 2 589 10.44 TS g 1 d Vertical q 28 Final statistics ---------------- -Time (s): 10.133 +Time (s): 10.0855 +Is proven infeasible: 0 Solution -------- @@ -73,5 +74,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/stages_unlimited/output.txt b/doc/examples/rectangleguillotine/stages_unlimited/output.txt index 478e3cba6..2883f9579 100644 --- a/doc/examples/rectangleguillotine/stages_unlimited/output.txt +++ b/doc/examples/rectangleguillotine/stages_unlimited/output.txt @@ -17,7 +17,7 @@ Number of stacks: 12 Number of defects: 0 Number of stages: 120 Cut type: Exact -First stage orientation: Vertical +First stage orientation: Any Minimum distance between 1-cuts: 0 Maximum distance between 1-cuts: -1 Minimum distance between 2-cuts: 0 @@ -36,19 +36,18 @@ Largest bin cost: 3200 Time # bins Waste Waste (%) Comment ---- ------ ----- --------- ------- - 0.000 3 1869 27.01 TS g 1 d Vertical q 1 - 0.001 3 1869 27.01 TS g 1 d Vertical q 2 - 0.008 3 1829 26.58 TS g 0 d Vertical q 3 - 0.014 2 909 15.25 TS g 1 d Vertical q 5 - 0.020 2 789 13.51 TS g 1 d Vertical q 5 - 0.026 2 669 11.70 TS g 0 d Vertical q 11 - 0.030 2 589 10.44 TS g 1 d Vertical q 28 - 0.411 2 469 8.50 SVC it 0 - 0.911 2 349 6.46 SVC it 1 + 0.005 3 1869 27.01 TS g 0 d Vertical q 1 + 0.006 3 1869 27.01 TS g 0 d Vertical q 2 + 0.011 2 1349 21.08 TS g 1 d Horizontal q 2 + 0.016 2 909 15.25 TS g 1 d Vertical q 6 + 0.020 2 789 13.51 TS g 1 d Horizontal q 6 + 0.027 2 669 11.70 TS g 1 d Vertical q 13 + 0.033 2 589 10.44 TS g 1 d Vertical q 28 Final statistics ---------------- -Time (s): 10.1385 +Time (s): 10.0969 +Is proven infeasible: 0 Solution -------- @@ -60,12 +59,12 @@ Number of different bins: 2 Bin area: 6400 / 22400 (28.5714%) Bin cost: 6400 Cutting cost: 0 -Waste: 349 (6.46296%) +Waste: 589 (10.4433%) Full waste: 1349 (21.0781%) -Width: 55 +Width: 61 Height: 40 -Second leftover value: 38 -Number of stages: 10 +Second leftover value: 57 +Number of stages: 3 Feasible: 1 Number of stages: 1 Min. waste length: 1 @@ -77,5 +76,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/stages_unlimited/solution.csv b/doc/examples/rectangleguillotine/stages_unlimited/solution.csv index 4b2568917..d7845375b 100644 --- a/doc/examples/rectangleguillotine/stages_unlimited/solution.csv +++ b/doc/examples/rectangleguillotine/stages_unlimited/solution.csv @@ -1,74 +1,62 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 0,1,0,0,0,80,40,0,0, -0,1,1,0,0,79,40,-2,1,0 -0,1,2,0,0,79,40,-2,2,1 -0,1,3,0,0,47,40,-2,3,2 -0,1,4,0,0,47,17,-2,4,3 -0,1,5,0,0,30,17,-2,5,4 -0,1,6,0,0,30,17,-2,6,5 -0,1,7,0,0,13,17,-2,7,6 -0,1,8,0,0,13,4,4,8,7 -0,1,9,0,4,13,13,3,8,7 -0,1,10,13,0,17,17,2,7,6 -0,1,11,30,0,17,17,2,5,4 -0,1,12,0,17,47,23,-2,4,3 -0,1,13,0,17,46,23,-2,5,12 -0,1,14,0,17,46,23,-2,6,13 -0,1,15,0,17,23,23,0,7,14 -0,1,16,23,17,23,23,0,7,14 -0,1,17,46,17,1,23,-1,5,12 -0,1,18,47,0,32,40,-2,3,2 -0,1,19,47,0,32,40,-2,4,18 -0,1,20,47,0,13,40,-2,5,19 -0,1,21,47,0,13,5,-2,6,20 -0,1,22,47,0,10,5,-2,7,21 -0,1,23,47,0,10,5,-2,8,22 -0,1,24,47,0,5,5,11,9,23 -0,1,25,52,0,5,5,11,9,23 -0,1,26,57,0,3,5,-1,7,21 -0,1,27,47,5,13,35,-2,6,20 -0,1,28,47,5,13,35,-2,7,27 -0,1,29,47,5,13,24,-2,8,28 -0,1,30,47,5,13,24,-2,9,29 -0,1,31,47,5,13,13,3,10,30 -0,1,32,47,18,13,11,9,10,30 -0,1,33,47,29,13,11,-2,8,28 -0,1,34,47,29,11,11,8,9,33 -0,1,35,58,29,2,11,-1,9,33 -0,1,36,60,0,19,40,-2,5,19 -0,1,37,60,0,19,21,-2,6,36 -0,1,38,60,0,7,21,-2,7,37 -0,1,39,60,0,7,7,10,8,38 -0,1,40,60,7,7,7,10,8,38 -0,1,41,60,14,7,7,10,8,38 -0,1,42,67,0,12,21,-2,7,37 -0,1,43,67,0,12,20,6,8,42 -0,1,44,67,20,12,1,-1,8,42 -0,1,45,60,21,19,19,1,6,36 -0,1,46,79,0,1,40,-1,1,0 -1,1,47,0,0,80,40,0,0, -1,1,48,0,0,13,40,-2,1,47 -1,1,49,0,0,13,10,-2,2,48 -1,1,50,0,0,13,10,5,3,49 -1,1,51,0,10,13,13,-2,2,48 -1,1,52,0,10,13,13,3,3,51 -1,1,53,0,23,13,5,-2,2,48 -1,1,54,0,23,5,5,11,3,53 -1,1,55,5,23,8,5,-1,3,53 -1,1,56,0,28,13,11,-2,2,48 -1,1,57,0,28,9,11,7,3,56 -1,1,58,9,28,4,11,-1,3,56 -1,1,59,0,39,13,1,-1,2,48 -1,1,60,13,0,23,40,-2,1,47 -1,1,61,13,0,23,23,-2,2,60 -1,1,62,13,0,23,23,0,3,61 -1,1,63,13,23,23,17,-2,2,60 -1,1,64,13,23,17,17,2,3,63 -1,1,65,30,23,6,17,-1,3,63 -1,1,66,36,0,19,40,-2,1,47 -1,1,67,36,0,19,19,-2,2,66 -1,1,68,36,0,19,19,1,3,67 -1,1,69,36,19,19,19,-2,2,66 -1,1,70,36,19,19,19,1,3,69 -1,1,71,36,38,19,2,-1,2,66 -1,1,72,55,0,25,40,-3,1,47 +0,1,1,0,0,51,40,-2,1,0 +0,1,2,0,0,51,17,-2,2,1 +0,1,3,0,0,17,17,2,3,2 +0,1,4,17,0,17,17,2,3,2 +0,1,5,34,0,17,17,2,3,2 +0,1,6,0,17,51,23,-2,2,1 +0,1,7,0,17,23,23,0,3,6 +0,1,8,23,17,23,23,0,3,6 +0,1,9,46,17,5,23,-1,3,6 +0,1,10,51,0,13,40,-2,1,0 +0,1,11,51,0,13,10,-2,2,10 +0,1,12,51,0,13,10,5,3,11 +0,1,13,51,10,13,13,-2,2,10 +0,1,14,51,10,13,13,3,3,13 +0,1,15,51,23,13,13,-2,2,10 +0,1,16,51,23,13,13,3,3,15 +0,1,17,51,36,13,4,-2,2,10 +0,1,18,51,36,13,4,4,3,17 +0,1,19,64,0,14,40,-2,1,0 +0,1,20,64,0,14,13,-2,2,19 +0,1,21,64,0,13,13,3,3,20 +0,1,22,77,0,1,13,-1,3,20 +0,1,23,64,13,14,7,-2,2,19 +0,1,24,64,13,7,7,10,3,23 +0,1,25,71,13,7,7,10,3,23 +0,1,26,64,20,14,20,-2,2,19 +0,1,27,64,20,12,20,6,3,26 +0,1,28,76,20,2,20,-1,3,26 +0,1,29,78,0,2,40,-1,1,0 +1,1,30,0,0,80,40,0,0, +1,1,31,0,0,23,40,-2,1,30 +1,1,32,0,0,23,23,-2,2,31 +1,1,33,0,0,23,23,0,3,32 +1,1,34,0,23,23,11,-2,2,31 +1,1,35,0,23,13,11,9,3,34 +1,1,36,13,23,9,11,7,3,34 +1,1,37,22,23,1,11,-1,3,34 +1,1,38,0,34,23,5,-2,2,31 +1,1,39,0,34,5,5,11,3,38 +1,1,40,5,34,5,5,11,3,38 +1,1,41,10,34,5,5,11,3,38 +1,1,42,15,34,8,5,-1,3,38 +1,1,43,0,39,23,1,-1,2,31 +1,1,44,23,0,19,40,-2,1,30 +1,1,45,23,0,19,19,-2,2,44 +1,1,46,23,0,19,19,1,3,45 +1,1,47,23,19,19,19,-2,2,44 +1,1,48,23,19,19,19,1,3,47 +1,1,49,23,38,19,2,-1,2,44 +1,1,50,42,0,19,40,-2,1,30 +1,1,51,42,0,19,19,-2,2,50 +1,1,52,42,0,19,19,1,3,51 +1,1,53,42,19,19,11,-2,2,50 +1,1,54,42,19,11,11,8,3,53 +1,1,55,53,19,8,11,-1,3,53 +1,1,56,42,30,19,7,-2,2,50 +1,1,57,42,30,7,7,10,3,56 +1,1,58,49,30,12,7,-1,3,56 +1,1,59,42,37,19,3,-1,2,50 +1,1,60,61,0,19,40,-3,1,30 diff --git a/doc/examples/rectangleguillotine/trims_no/output.txt b/doc/examples/rectangleguillotine/trims_no/output.txt index 56b4f542a..8a2e152ee 100644 --- a/doc/examples/rectangleguillotine/trims_no/output.txt +++ b/doc/examples/rectangleguillotine/trims_no/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 100 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.001 1 20.00 TS g 1 d Vertical q 1 + 0.001 1 20.00 TS g 0 d Vertical q 1 Final statistics ---------------- -Time (s): 0.00433793 +Time (s): 0.00461061 +Is proven infeasible: 0 +Primal bound: 1 +Dual bound: 1 +Gap: 0% Solution -------- @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/trims_no/solution.csv b/doc/examples/rectangleguillotine/trims_no/solution.csv index aa5e14135..d5a0224a1 100644 --- a/doc/examples/rectangleguillotine/trims_no/solution.csv +++ b/doc/examples/rectangleguillotine/trims_no/solution.csv @@ -3,6 +3,6 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 0,1,1,0,0,10,10,-2,1,0 0,1,2,0,0,10,8,-2,2,1 0,1,3,0,0,4,8,0,3,2 -0,1,4,4,0,3,8,1,3,2 -0,1,5,7,0,3,8,2,3,2 +0,1,4,4,0,3,8,2,3,2 +0,1,5,7,0,3,8,1,3,2 0,1,6,0,8,10,2,-1,2,1 diff --git a/doc/examples/rectangleguillotine/trims_yes/output.txt b/doc/examples/rectangleguillotine/trims_yes/output.txt index ac1ac2ade..5f2ff976a 100644 --- a/doc/examples/rectangleguillotine/trims_yes/output.txt +++ b/doc/examples/rectangleguillotine/trims_yes/output.txt @@ -36,11 +36,15 @@ Largest bin cost: 100 Time Bins Full waste (%) Comment ---- ---- -------------- ------- - 0.004 2 37.50 TS g 1 d Vertical q 1 + 0.001 2 37.50 TS g 0 d Vertical q 1 Final statistics ---------------- -Time (s): 0.00672196 +Time (s): 0.0062093 +Is proven infeasible: 0 +Primal bound: 2 +Dual bound: 2 +Gap: 0% Solution -------- @@ -52,7 +56,7 @@ Number of different bins: 2 Bin area: 128 / 192 (66.6667%) Bin cost: 200 Cutting cost: 0 -Waste: -6 (-8.10811%) +Waste: 8 (9.09091%) Full waste: 48 (37.5%) Width: 4 Height: 10 @@ -69,5 +73,6 @@ Feasible: 1 Max. no. 2-cuts: 1 Stacks: 1 Defects: 1 + Trims: 1 Cut through defects: 1 Item copies: 1 diff --git a/doc/examples/rectangleguillotine/trims_yes/solution.csv b/doc/examples/rectangleguillotine/trims_yes/solution.csv index d6aa6a459..57ac45abf 100644 --- a/doc/examples/rectangleguillotine/trims_yes/solution.csv +++ b/doc/examples/rectangleguillotine/trims_yes/solution.csv @@ -7,7 +7,7 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 0,1,5,1,1,7,9,-2,1,4 0,1,6,1,1,7,8,-2,2,5 0,1,7,1,1,4,8,0,3,6 -0,1,8,5,1,3,8,1,3,6 +0,1,8,5,1,3,8,2,3,6 0,1,9,1,9,7,1,-1,2,5 0,1,10,8,1,2,9,-1,1,4 1,1,11,0,0,10,10,0,0, @@ -17,6 +17,6 @@ PLATE_ID,COPIES,NODE_ID,X,Y,WIDTH,HEIGHT,TYPE,CUT,PARENT 1,1,15,1,1,9,9,-2,0,11 1,1,16,1,1,3,9,-2,1,15 1,1,17,1,1,3,8,-2,2,16 -1,1,18,1,1,3,8,2,3,17 +1,1,18,1,1,3,8,1,3,17 1,1,19,1,9,3,1,-1,2,16 1,1,20,4,1,6,9,-3,1,15 diff --git a/doc/img/box_example_solution.png b/doc/img/box_example_solution.png index 29bb2ea73..a2932cf62 100644 Binary files a/doc/img/box_example_solution.png and b/doc/img/box_example_solution.png differ diff --git a/doc/img/boxstacks_axle_weight_no.png b/doc/img/boxstacks_axle_weight_no.png index 80713e7bd..d2950ab5e 100644 Binary files a/doc/img/boxstacks_axle_weight_no.png and b/doc/img/boxstacks_axle_weight_no.png differ diff --git a/doc/img/boxstacks_axle_weight_yes.png b/doc/img/boxstacks_axle_weight_yes.png index c7a1c1895..66b52d054 100644 Binary files a/doc/img/boxstacks_axle_weight_yes.png and b/doc/img/boxstacks_axle_weight_yes.png differ diff --git a/doc/img/boxstacks_box_vs_boxstacks_box.png b/doc/img/boxstacks_box_vs_boxstacks_box.png index 67ebb645a..118b1455c 100644 Binary files a/doc/img/boxstacks_box_vs_boxstacks_box.png and b/doc/img/boxstacks_box_vs_boxstacks_box.png differ diff --git a/doc/img/boxstacks_box_vs_boxstacks_boxstacks.png b/doc/img/boxstacks_box_vs_boxstacks_boxstacks.png index eee142d1b..9e331d6b1 100644 Binary files a/doc/img/boxstacks_box_vs_boxstacks_boxstacks.png and b/doc/img/boxstacks_box_vs_boxstacks_boxstacks.png differ diff --git a/doc/img/boxstacks_example_solution.png b/doc/img/boxstacks_example_solution.png index bfbcdb62b..7e7ac2f91 100644 Binary files a/doc/img/boxstacks_example_solution.png and b/doc/img/boxstacks_example_solution.png differ diff --git a/doc/img/boxstacks_maximum_stack_density_no.png b/doc/img/boxstacks_maximum_stack_density_no.png index 111622747..ab5985781 100644 Binary files a/doc/img/boxstacks_maximum_stack_density_no.png and b/doc/img/boxstacks_maximum_stack_density_no.png differ diff --git a/doc/img/boxstacks_maximum_stack_density_yes.png b/doc/img/boxstacks_maximum_stack_density_yes.png index 273e43638..1755cc5be 100644 Binary files a/doc/img/boxstacks_maximum_stack_density_yes.png and b/doc/img/boxstacks_maximum_stack_density_yes.png differ diff --git a/doc/img/boxstacks_maximum_stackability_no.png b/doc/img/boxstacks_maximum_stackability_no.png index 095c2afb7..e3f4414a8 100644 Binary files a/doc/img/boxstacks_maximum_stackability_no.png and b/doc/img/boxstacks_maximum_stackability_no.png differ diff --git a/doc/img/boxstacks_maximum_stackability_yes.png b/doc/img/boxstacks_maximum_stackability_yes.png index 359495dc9..51c610f66 100644 Binary files a/doc/img/boxstacks_maximum_stackability_yes.png and b/doc/img/boxstacks_maximum_stackability_yes.png differ diff --git a/doc/img/boxstacks_maximum_weight_above_no.png b/doc/img/boxstacks_maximum_weight_above_no.png index 24c2a4a07..f2b3aef7c 100644 Binary files a/doc/img/boxstacks_maximum_weight_above_no.png and b/doc/img/boxstacks_maximum_weight_above_no.png differ diff --git a/doc/img/boxstacks_maximum_weight_above_yes.png b/doc/img/boxstacks_maximum_weight_above_yes.png index c1b38621e..b491e347d 100644 Binary files a/doc/img/boxstacks_maximum_weight_above_yes.png and b/doc/img/boxstacks_maximum_weight_above_yes.png differ diff --git a/doc/img/boxstacks_nesting_height_no.png b/doc/img/boxstacks_nesting_height_no.png index e6b121c9d..c675fb6e7 100644 Binary files a/doc/img/boxstacks_nesting_height_no.png and b/doc/img/boxstacks_nesting_height_no.png differ diff --git a/doc/img/boxstacks_nesting_height_yes.png b/doc/img/boxstacks_nesting_height_yes.png index 269b6bd4f..af77739fc 100644 Binary files a/doc/img/boxstacks_nesting_height_yes.png and b/doc/img/boxstacks_nesting_height_yes.png differ diff --git a/doc/img/boxstacks_rotation_no.png b/doc/img/boxstacks_rotation_no.png index 719867d24..5f577a30f 100644 Binary files a/doc/img/boxstacks_rotation_no.png and b/doc/img/boxstacks_rotation_no.png differ diff --git a/doc/img/boxstacks_rotation_yes.png b/doc/img/boxstacks_rotation_yes.png index 1198f18ea..c8fb93588 100644 Binary files a/doc/img/boxstacks_rotation_yes.png and b/doc/img/boxstacks_rotation_yes.png differ diff --git a/doc/img/boxstacks_unloading_no.png b/doc/img/boxstacks_unloading_no.png index fe8360f73..17c2d87b3 100644 Binary files a/doc/img/boxstacks_unloading_no.png and b/doc/img/boxstacks_unloading_no.png differ diff --git a/doc/img/boxstacks_unloading_yes.png b/doc/img/boxstacks_unloading_yes.png index 22543ef4d..f4012f67a 100644 Binary files a/doc/img/boxstacks_unloading_yes.png and b/doc/img/boxstacks_unloading_yes.png differ diff --git a/doc/img/irregular_irregular_bin.png b/doc/img/irregular_irregular_bin.png index ca6a93353..a15dfaba0 100644 Binary files a/doc/img/irregular_irregular_bin.png and b/doc/img/irregular_irregular_bin.png differ diff --git a/doc/img/irregular_item_defect_spacing_no.png b/doc/img/irregular_item_defect_spacing_no.png index 4e9af173d..bb85a3db8 100644 Binary files a/doc/img/irregular_item_defect_spacing_no.png and b/doc/img/irregular_item_defect_spacing_no.png differ diff --git a/doc/img/irregular_item_defect_spacing_yes.png b/doc/img/irregular_item_defect_spacing_yes.png index 4fcff7d64..3700d4385 100644 Binary files a/doc/img/irregular_item_defect_spacing_yes.png and b/doc/img/irregular_item_defect_spacing_yes.png differ diff --git a/doc/img/irregular_mirroring_no.png b/doc/img/irregular_mirroring_no.png index 326902adf..3a5c1e939 100644 Binary files a/doc/img/irregular_mirroring_no.png and b/doc/img/irregular_mirroring_no.png differ diff --git a/doc/img/irregular_rotation_continuous.png b/doc/img/irregular_rotation_continuous.png index b0eca3c78..8dda07a74 100644 Binary files a/doc/img/irregular_rotation_continuous.png and b/doc/img/irregular_rotation_continuous.png differ diff --git a/doc/img/leftovers_value.png b/doc/img/leftovers_value.png new file mode 100644 index 000000000..0577495c3 Binary files /dev/null and b/doc/img/leftovers_value.png differ diff --git a/doc/img/objective_knapsack_solution.png b/doc/img/objective_knapsack_solution.png index 5ff4bf9eb..95efd9726 100644 Binary files a/doc/img/objective_knapsack_solution.png and b/doc/img/objective_knapsack_solution.png differ diff --git a/doc/img/objective_variable_sized_bin_packing_solution.png b/doc/img/objective_variable_sized_bin_packing_solution.png index edf59e60e..146f75530 100644 Binary files a/doc/img/objective_variable_sized_bin_packing_solution.png and b/doc/img/objective_variable_sized_bin_packing_solution.png differ diff --git a/doc/img/objective_variable_sized_bin_packing_with_leftovers_solution.png b/doc/img/objective_variable_sized_bin_packing_with_leftovers_solution.png new file mode 100644 index 000000000..e152de7ac Binary files /dev/null and b/doc/img/objective_variable_sized_bin_packing_with_leftovers_solution.png differ diff --git a/doc/img/onedimensional_solution.png b/doc/img/onedimensional_solution.png index 6bb047e61..c179c1e26 100644 Binary files a/doc/img/onedimensional_solution.png and b/doc/img/onedimensional_solution.png differ diff --git a/doc/img/rectangle_example_solution.png b/doc/img/rectangle_example_solution.png index e37b1f6a1..2e2bb4ec3 100644 Binary files a/doc/img/rectangle_example_solution.png and b/doc/img/rectangle_example_solution.png differ diff --git a/doc/img/rectangle_maximum_weight_yes.png b/doc/img/rectangle_maximum_weight_yes.png index e0282dd26..a070eabbe 100644 Binary files a/doc/img/rectangle_maximum_weight_yes.png and b/doc/img/rectangle_maximum_weight_yes.png differ diff --git a/doc/img/rectangle_unloading_no.png b/doc/img/rectangle_unloading_no.png index 66338feca..f7a5373e9 100644 Binary files a/doc/img/rectangle_unloading_no.png and b/doc/img/rectangle_unloading_no.png differ diff --git a/doc/img/rectangleguillotine_cutdefects_no.png b/doc/img/rectangleguillotine_cutdefects_no.png index 21c66b0b3..4480c5a76 100644 Binary files a/doc/img/rectangleguillotine_cutdefects_no.png and b/doc/img/rectangleguillotine_cutdefects_no.png differ diff --git a/doc/img/rectangleguillotine_cutdefects_yes.png b/doc/img/rectangleguillotine_cutdefects_yes.png index dd739834d..b4537e9af 100644 Binary files a/doc/img/rectangleguillotine_cutdefects_yes.png and b/doc/img/rectangleguillotine_cutdefects_yes.png differ diff --git a/doc/img/rectangleguillotine_cutthickness_no.png b/doc/img/rectangleguillotine_cutthickness_no.png index bf0c174a9..1893ea756 100644 Binary files a/doc/img/rectangleguillotine_cutthickness_no.png and b/doc/img/rectangleguillotine_cutthickness_no.png differ diff --git a/doc/img/rectangleguillotine_cutthickness_yes.png b/doc/img/rectangleguillotine_cutthickness_yes.png index 2ef09f02a..67777077b 100644 Binary files a/doc/img/rectangleguillotine_cutthickness_yes.png and b/doc/img/rectangleguillotine_cutthickness_yes.png differ diff --git a/doc/img/rectangleguillotine_cuttype_homogenous.png b/doc/img/rectangleguillotine_cuttype_homogenous.png index 7ffa42752..c2e30b293 100644 Binary files a/doc/img/rectangleguillotine_cuttype_homogenous.png and b/doc/img/rectangleguillotine_cuttype_homogenous.png differ diff --git a/doc/img/rectangleguillotine_cuttype_roadef2018.png b/doc/img/rectangleguillotine_cuttype_roadef2018.png index cc528673d..69bbdd002 100644 Binary files a/doc/img/rectangleguillotine_cuttype_roadef2018.png and b/doc/img/rectangleguillotine_cuttype_roadef2018.png differ diff --git a/doc/img/rectangleguillotine_defects_no.png b/doc/img/rectangleguillotine_defects_no.png index 2cbf0bddd..0b752aa0f 100644 Binary files a/doc/img/rectangleguillotine_defects_no.png and b/doc/img/rectangleguillotine_defects_no.png differ diff --git a/doc/img/rectangleguillotine_maxcuts2_no.png b/doc/img/rectangleguillotine_maxcuts2_no.png index 91fc8cc2e..a6324ddc2 100644 Binary files a/doc/img/rectangleguillotine_maxcuts2_no.png and b/doc/img/rectangleguillotine_maxcuts2_no.png differ diff --git a/doc/img/rectangleguillotine_maxcuts2_yes.png b/doc/img/rectangleguillotine_maxcuts2_yes.png index 292abaa4a..d06a2afb0 100644 Binary files a/doc/img/rectangleguillotine_maxcuts2_yes.png and b/doc/img/rectangleguillotine_maxcuts2_yes.png differ diff --git a/doc/img/rectangleguillotine_orientation_no.png b/doc/img/rectangleguillotine_orientation_no.png index ed58fc770..0cae5bb44 100644 Binary files a/doc/img/rectangleguillotine_orientation_no.png and b/doc/img/rectangleguillotine_orientation_no.png differ diff --git a/doc/img/rectangleguillotine_orientation_yes.png b/doc/img/rectangleguillotine_orientation_yes.png index b872f1a13..e0d1bce39 100644 Binary files a/doc/img/rectangleguillotine_orientation_yes.png and b/doc/img/rectangleguillotine_orientation_yes.png differ diff --git a/doc/img/rectangleguillotine_rotation_no.png b/doc/img/rectangleguillotine_rotation_no.png index 22acf8a43..6d6e98335 100644 Binary files a/doc/img/rectangleguillotine_rotation_no.png and b/doc/img/rectangleguillotine_rotation_no.png differ diff --git a/doc/img/rectangleguillotine_stages_unlimited.png b/doc/img/rectangleguillotine_stages_unlimited.png index 2ffd6fd41..34b1566b8 100644 Binary files a/doc/img/rectangleguillotine_stages_unlimited.png and b/doc/img/rectangleguillotine_stages_unlimited.png differ diff --git a/doc/img/rectangleguillotine_trims_no.png b/doc/img/rectangleguillotine_trims_no.png index 4a0eb3981..342dd18af 100644 Binary files a/doc/img/rectangleguillotine_trims_no.png and b/doc/img/rectangleguillotine_trims_no.png differ diff --git a/doc/img/rectangleguillotine_trims_yes.png b/doc/img/rectangleguillotine_trims_yes.png index 31d83b89f..09874dba6 100644 Binary files a/doc/img/rectangleguillotine_trims_yes.png and b/doc/img/rectangleguillotine_trims_yes.png differ diff --git a/doc/index.rst b/doc/index.rst index f779df276..fd72bd967 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -7,6 +7,7 @@ PackingSolver's documentation self objectives + leftovers optimization_modes onedimensional rectangle diff --git a/doc/irregular.rst b/doc/irregular.rst index 43f226189..9fd9d00c9 100644 --- a/doc/irregular.rst +++ b/doc/irregular.rst @@ -22,6 +22,7 @@ Features: * Open dimension Y * Open dimension XY * Variable-sized bin packing + * Variable-sized bin packing with leftovers * Feasibility * Item types @@ -73,13 +74,13 @@ An instance is a JSON object with the following fields: * - Field - Description * - ``objective`` - - **Mandatory**. One of ``knapsack``, ``bin-packing``, ``bin-packing-with-leftovers``, ``open-dimension-x``, ``open-dimension-y``, ``open-dimension-xy``, ``variable-sized-bin-packing``, ``feasibility``; see :ref:`objectives` + - **Mandatory**. One of ``knapsack``, ``bin-packing``, ``bin-packing-with-leftovers``, ``open-dimension-x``, ``open-dimension-y``, ``open-dimension-xy``, ``variable-sized-bin-packing``, ``variable-sized-bin-packing-with-leftovers``, ``feasibility``; see :ref:`objectives` * - ``knapsack_goal`` - For the ``knapsack`` objective, the search stops as soon as a solution reaches this profit. Default: none * - ``knapsack_cutoff`` - For the ``knapsack`` objective, the solutions whose profit is below this value are not useful: the search stops as soon as the bound proves that no solution reaches it. Default: none * - ``parameters`` - - An object with the optional fields ``item_item_minimum_spacing`` (see :ref:`irregular-item-item-spacing`), ``open_dimension_xy_aspect_ratio`` (the ratio height / width of the bin for the ``open-dimension-xy`` objective), and ``leftover_mode`` (the corner or side from which the leftover is measured, for the ``bin-packing-with-leftovers`` objective: ``bottom-left`` (default), ``bottom-right``, ``top-left``, ``top-right``, ``left``, ``right``, ``bottom``, ``top``) + - An object with the optional fields ``item_item_minimum_spacing`` (see :ref:`irregular-item-item-spacing`), ``open_dimension_xy_aspect_ratio`` (the ratio height / width of the bin for the ``open-dimension-xy`` objective), ``leftover_mode`` (the corner or side towards which the items are packed, which defines the shape of the leftover, for the ``bin-packing-with-leftovers`` objective (see :ref:`leftovers`): ``bottom-left`` (default), ``bottom-right``, ``top-left``, ``top-right``, ``left``, ``right``, ``bottom``, ``top``, and ``bottom-left-cut``, ``bottom-right-cut``, ``top-left-cut``, ``top-right-cut`` (the L-shape of the corner, cut into two rectangles), and ``bottom-left-staircase``, ``bottom-right-staircase``, ``top-left-staircase``, ``top-right-staircase`` (the bounding box of the bin minus the rectangles between the corner and the opposite corner of the bounding box of each item)), and ``leftover_value_type`` (how the value of the leftover is computed, for the ``bin-packing-with-leftovers`` objective: ``squared-area`` (default) or ``depth``; see :ref:`leftovers`) * - ``bin_types`` - **Mandatory**. The bin types (array) * - ``item_types`` diff --git a/doc/leftovers.rst b/doc/leftovers.rst new file mode 100644 index 000000000..3b059b779 --- /dev/null +++ b/doc/leftovers.rst @@ -0,0 +1,116 @@ +.. _leftovers: + +Leftovers +========= + +With the :code:`bin-packing-with-leftovers` objective, the solver first minimizes the number of bins, and then maximizes the value of what remains in stock: the **leftover** of the last bin, and, as tie-breaks, the leftovers of the other bins. With the :code:`variable-sized-bin-packing-with-leftovers` objective, it minimizes the cost of the bins minus a refund for the value of their leftovers (see :ref:`objectives`). + +This page describes how a leftover is defined from a packing (its shape) and how its value is computed. It applies to the :ref:`rectangle`, :ref:`box`, :ref:`box-stacks` and :ref:`irregular` problem types, and to the :ref:`rectangle-guillotine` problem type with the :code:`variable-sized-bin-packing-with-leftovers` objective (see :ref:`leftovers-rectangleguillotine`). The :ref:`one-dimensional` problem type measures its leftovers directly by the length left in the bin. + +Shape of a leftover +------------------- + +The leftover of a bin is the bin minus the space used by its items. The space used is a box in a corner of the bin: it goes from this corner to the items, along the dimensions given by the **leftover mode**, and covers the whole bin along the other dimensions. Depending on the leftover mode, the leftover is: + +* a **rectangle** (or a box), when the used space covers the whole bin along all but one dimension; for example, with the mode ``x`` of the :ref:`rectangle` problem type, the leftover is the part of the bin on the right of the items; +* an **L-shape**, when the used space stops at the items along two dimensions; for example, with the default mode ``area`` of the :ref:`rectangle` problem type, the leftover is the bin minus the rectangle between its bottom-left corner and the top-right corner of the items; in three dimensions, the leftover is a box minus a corner box; +* the same L-shape **cut** into rectangles (or boxes), with the modes ending with ``cut``; when the leftover is kept as separate pieces, the cut is made along the faces of the used space, in the order which gives the largest value; +* a **staircase**, with the modes ``staircase``: instead of a single box covering all the items, each item uses the box between the corner of the bin and its opposite corner, and the leftover is the bin minus the union of these boxes. It follows the outline of the items more closely, so it is larger than the L-shape, and it is suited to the case where the next items are packed into what remains of the bin. + +The leftover modes of each problem type: + +.. list-table:: + :header-rows: 1 + :widths: 1 2 2 2 2 + + * - Problem type + - Rectangle (or box) + - L-shape + - Cut L-shape + - Staircase + * - :ref:`rectangle` + - ``x``, ``y`` + - ``area`` (default) + - ``area-cut`` + - ``staircase`` + * - :ref:`box` + - ``x``, ``y``, ``z`` + - ``xy``, ``xz``, ``yz``, ``xyz`` (default) + - ``xy-cut``, ``xz-cut``, ``yz-cut``, ``xyz-cut`` + - ``staircase`` + * - :ref:`box-stacks` + - ``x``, ``y`` + - ``xy`` (default) + - ``xy-cut`` + - ``staircase`` + * - :ref:`irregular` + - ``left``, ``right``, ``bottom``, ``top`` + - ``bottom-left`` (default), ``bottom-right``, ``top-left``, ``top-right`` + - ``bottom-left-cut``, ``bottom-right-cut``, ``top-left-cut``, ``top-right-cut`` + - ``bottom-left-staircase``, ``bottom-right-staircase``, ``top-left-staircase``, ``top-right-staircase`` + +For the :ref:`irregular` problem type, the bin and the items are replaced by their bounding boxes. With the modes of the last three columns, the items are packed the same way, towards the same corner: only the shape of the leftover differs. + +With a staircase leftover, the staircase value used as a tie-break (see below) measures the same region as the leftover itself. + +Value of a leftover +------------------- + +The **leftover value type** (``leftover_value_type``) defines how the value of a leftover is computed from its shape. It is one of: + +* ``squared-area`` (default): the value of a leftover is the square of its area (or of its volume, in three dimensions); when the leftover is cut, it is the sum of the squares of the areas of its pieces; +* ``depth``: the value of a leftover also accounts for how compact it is, as described below. + +Which one to choose depends on how the leftovers are reused: + +* when the bin stays whole, and the items of the next jobs are packed into what remains of it, the free area is what matters: choose ``squared-area``; +* when the leftovers are cut out and stored as stock, a large compact piece is worth more than a long thin one of the same area: choose ``depth``. + +Squared area +^^^^^^^^^^^^ + +Squaring the area doesn't change how two leftovers are ranked: the larger one is worth more. But it changes how the leftovers of several bins add up: a single large leftover is worth more than several smaller leftovers of the same total area. For example, two leftovers of 1.5 m² and 0.5 m² are worth 1.5² + 0.5² = 2.5, and two leftovers of 1 m² are only worth 1² + 1² = 2. In the same way, an L-shape is worth more than the same L-shape cut into two rectangles, and with the modes ending with ``cut``, the cut which is chosen is the one which gives the most unbalanced pieces. + +Depth +^^^^^ + +With the ``depth`` value type, the value of a leftover is its area times the **average depth** of its points, the depth of a point being its distance to the edge of the leftover: the half side of the largest square centered on the point which fits in the leftover. Points close to the edge of a leftover, or in a thin part of it, count for little; points deep inside count for more. + +In other words, the value is the integral, over the points of the leftover, of their depth. It is also the integral, over *t*, of the area of the leftover shrunk by *t* on every side. + +.. image:: img/leftovers_value.png + :align: center + +The figure above shows the depth of the points of a few leftovers. A 1500 × 1000 rectangle is worth 0.29 × 10⁹, but a 3000 × 500 rectangle of the same area is only worth 0.18 × 10⁹. An L-shape is worth a bit more than the same L-shape cut into two rectangles, since cutting it creates a new edge, along which the points lose their depth. + +For a *w* × *h* rectangle, with *h* ≤ *w*, the value is *h*\ :sup:`2` (3 *w* − *h*) / 12; for a square of side *s*, it is *s*\ :sup:`3` / 6. In three dimensions, the value is the volume of the leftover times the average depth of its points. + +As a consequence: + +* among the leftovers of a given area, compact ones are worth more than long and thin ones; for example, the solver prefers to leave a single rectangle on the side of the bin rather than an L-shape of slightly larger area whose arms are thin; +* the value grows faster than the area (like the area to the power 1.5): a single large leftover is worth more than several smaller leftovers of the same total area, as with the ``squared-area`` value type, but less strongly; +* the value has no parameter to tune. + +Comparison of solutions +----------------------- + +For the :code:`bin-packing-with-leftovers` objective, two solutions are compared on: + +#. the number of bins; +#. the value of the leftover of the last bin; +#. the staircase value of the last bin: the area of the bin which is not dominated by an item, an item dominating the points between the corner of the bin and the opposite corner of the item; it measures how compact the packing of the last bin is; +#. if ``leftover_all_bins`` is enabled (default), the total value of the leftovers of all the bins of the instance, the bins which are not used counting for their whole value; +#. if ``leftover_all_bins`` is enabled, the total staircase value of all the bins. + +For the :code:`variable-sized-bin-packing-with-leftovers` objective, two solutions are compared on their net cost, the cost of their bins minus the refunds of their leftovers (see :ref:`objectives`), then on the total staircase value of all the bins. + +The solution also reports these values, in the fields ``LeftoverValue``, ``StaircaseLeftoverValue``, ``TotalLeftoverValue`` and ``TotalStaircaseLeftoverValue`` of the output. With the ``squared-area`` value type, ``LeftoverValue`` and ``TotalLeftoverValue`` are squared areas, while the staircase values are areas. + +.. _leftovers-rectangleguillotine: + +Rectangle guillotine +-------------------- + +For the :ref:`rectangle-guillotine` problem type, the :code:`bin-packing-with-leftovers` objective minimizes the number of bins, then the waste (the area of the bins which is used, minus the area of the items, the plate after the last 1-cut of the last bin being the leftover), and then maximizes the area of the second leftover: the sub-plate after the last 2-cut of the last first-level sub-plate of the last bin. + +With the :code:`variable-sized-bin-packing-with-leftovers` objective, the leftovers of a bin are the pieces that its guillotine cuts already separate from the items: the plate after its last 1-cut, and the sub-plate after the last 2-cut of its last first-level sub-plate, when they are not used. Since they are rectangles, the leftovers of a bin are valued like a cut leftover: with ``squared-area``, their value is the sum of the squares of their areas. Two solutions are compared on their net cost: the cost of their bins minus the refunds of their leftovers (see :ref:`objectives`). diff --git a/doc/objectives.rst b/doc/objectives.rst index 868d73e19..9658b8fdd 100644 --- a/doc/objectives.rst +++ b/doc/objectives.rst @@ -12,7 +12,7 @@ There is a single output maximization objective called **knapsack**. There is also a **feasibility** objective that simply checks whether a valid packing exists. -For input minimization, there are 3 objective types: +For input minimization, there are 3 objective types (each with a variant which values the leftovers, see :ref:`leftovers`): * **Open-dimension**: there is a single bin and the objective is to minimize the space used in this bin * **Bin packing**: there are multiple bins, the objective is to use as few bins as possible; bins must be used in the order they are provided @@ -52,7 +52,7 @@ Bins must be used **in the order they are provided**. PackingSolver supports two variants of this type of objective: * :code:`bin-packing`: minimize the number of bins -* :code:`bin-packing-with-leftovers`: minimize the number of bins; and then maximize the value of the leftover of the last bin of the solution +* :code:`bin-packing-with-leftovers`: minimize the number of bins; and then maximize the value of the leftover of the last bin of the solution (see :ref:`leftovers`) **Example** @@ -80,6 +80,29 @@ The input is the same as the previous one. With the variable-sized bin packing o .. example-tabs:: rectangle/objective_variable_sized_bin_packing +Variable-sized bin packing with leftovers +----------------------------------------- + +The :code:`variable-sized-bin-packing-with-leftovers` objective also accounts for what goes back into stock after packing the items: the leftovers of the bins which are used (see :ref:`leftovers`). It is available for the :ref:`rectangle-guillotine`, :ref:`rectangle`, :ref:`box`, :ref:`box-stacks` and :ref:`irregular` problem types. + +The objective is to minimize the **net cost** of the bins: the cost of the bins which are used, minus a **refund** for each of their leftovers. A leftover is refunded at the price of its bin per unit of space (the cost of the bin divided by its area, or its volume), for the space equivalent to its value: the value of the leftover times a factor which makes the largest bin type worth its own space. With the default ``squared-area`` value type, a leftover of area :math:`a` in a bin of cost :math:`c` and area :math:`A` is refunded :math:`c / A \times a^2 / A_{\max}`, where :math:`A_{\max}` is the area of the largest bin type. + +Therefore: + +* the cost of the bins and the value of their leftovers are traded off in a single quantity, whether costs are set for the bin types or not (if no cost is set, the cost of a bin is its space, and the net cost is the space of the bins which is not refunded); +* a leftover is refunded less than its space, and the smaller it is, the less it is refunded per unit of space: a large leftover as large as the largest bin type is refunded in full, and a single large leftover is worth more than several smaller ones of the same total space. + +The solutions are found by the algorithms of the :code:`variable-sized-bin-packing` objective; only the comparison of the solutions differs. Since there is no bound on the net cost, the solver never proves a solution optimal for this objective. The net cost of a solution is given in the field ``NetCost`` of the output. + +**Example** + +The bin types are the same as in the previous examples, with fewer items, and no cost is set for the bin types. Both the variable-sized bin packing objective and the variable-sized bin packing with leftovers objective use a bin of each type, for a cost of 1000 × 500 + 700 × 400 = 780000. With the variable-sized bin packing objective, the space left is spread over the two bins. With the variable-sized bin packing with leftovers objective, the large bin is filled entirely, and the space left forms a single 250 × 400 leftover on the right of the small bin. It is refunded 100000² / 500000 = 20000, for a net cost of 760000. + +.. image:: img/objective_variable_sized_bin_packing_with_leftovers_solution.png + :align: center + +.. example-tabs:: rectangle/objective_variable_sized_bin_packing_with_leftovers + Open-dimension -------------- diff --git a/doc/rectangle.rst b/doc/rectangle.rst index 6d218c995..47b67217f 100644 --- a/doc/rectangle.rst +++ b/doc/rectangle.rst @@ -21,6 +21,7 @@ Features: * Open dimension X * Open dimension Y * Variable-sized bin packing + * Variable-sized bin packing with leftovers * With or without item rotations @@ -58,13 +59,15 @@ An instance is a JSON object with the following fields: * - Field - Description * - ``objective`` - - **Mandatory**. One of ``knapsack``, ``bin-packing``, ``bin-packing-with-leftovers``, ``open-dimension-x``, ``open-dimension-y``, ``variable-sized-bin-packing``; see :ref:`objectives` + - **Mandatory**. One of ``knapsack``, ``bin-packing``, ``bin-packing-with-leftovers``, ``open-dimension-x``, ``open-dimension-y``, ``variable-sized-bin-packing``, ``variable-sized-bin-packing-with-leftovers``; see :ref:`objectives` * - ``knapsack_goal`` - For the ``knapsack`` objective, the search stops as soon as a solution reaches this profit. Default: none * - ``knapsack_cutoff`` - For the ``knapsack`` objective, the solutions whose profit is below this value are not useful: the search stops as soon as the bound proves that no solution reaches it. Default: none * - ``leftover_mode`` - - How the leftover of the last bin is measured, for the ``bin-packing-with-leftovers`` objective: ``area`` (default; the area of the bin minus the area of the rectangle containing its items), ``x`` (the width of the bin on the right of the items, times the height of the bin), or ``y`` (the height of the bin above the items, times the width of the bin) + - The shape of the leftover of a bin, for the ``bin-packing-with-leftovers`` objective (see :ref:`leftovers`): ``area`` (default; the L-shape between the top-right corner of the bin and the rectangle containing its items), ``area-cut`` (the same L-shape, cut into two rectangles), ``staircase`` (the bin minus the rectangles between its bottom-left corner and the top-right corner of each item), ``x`` (the rectangle on the right of the items), or ``y`` (the rectangle above the items) + * - ``leftover_value_type`` + - How the value of the leftover is computed, for the ``bin-packing-with-leftovers`` objective (see :ref:`leftovers`): ``squared-area`` (default) or ``depth`` * - ``unloading_constraint`` - See :ref:`rectangle-unloading-constraints`. Default: ``none`` * - ``bin_types`` diff --git a/doc/rectangleguillotine.rst b/doc/rectangleguillotine.rst index b677fda17..6934ae5d2 100644 --- a/doc/rectangleguillotine.rst +++ b/doc/rectangleguillotine.rst @@ -21,6 +21,7 @@ Features: * Open dimension X * Open dimension Y * Variable-sized bin packing + * Variable-sized bin packing with leftovers * Item types @@ -102,7 +103,7 @@ An instance is a JSON object with the following fields: * - Field - Description * - ``objective`` - - **Mandatory**. One of ``knapsack``, ``bin-packing``, ``bin-packing-with-leftovers``, ``open-dimension-x``, ``open-dimension-y``, ``variable-sized-bin-packing``; see :ref:`objectives` + - **Mandatory**. One of ``knapsack``, ``bin-packing``, ``bin-packing-with-leftovers``, ``open-dimension-x``, ``open-dimension-y``, ``variable-sized-bin-packing``, ``variable-sized-bin-packing-with-leftovers``; see :ref:`objectives` * - ``knapsack_goal`` - For the ``knapsack`` objective, the search stops as soon as a solution reaches this profit. Default: none * - ``knapsack_cutoff`` @@ -117,6 +118,8 @@ An instance is a JSON object with the following fields: - See :ref:`rectangleguillotine-cut-thickness`. Default: ``0`` * - ``cut_through_defects`` - See :ref:`rectangleguillotine-cut-through-defects`. Default: ``false`` + * - ``leftover_value_type`` + - How the value of the leftovers is computed, for the ``variable-sized-bin-packing-with-leftovers`` objective (see :ref:`leftovers`): ``squared-area`` (default) or ``depth`` * - ``minimum_distance_1_cuts``, ``maximum_distance_1_cuts``, ``minimum_distance_2_cuts``, ``maximum_distance_2_cuts``, ``minimum_waste_length`` - See :ref:`rectangleguillotine-distances` * - ``maximum_number_1_cuts``, ``maximum_number_2_cuts`` diff --git a/include/packingsolver/algorithms/common.hpp b/include/packingsolver/algorithms/common.hpp index 373fa1b1b..9232e93ba 100644 --- a/include/packingsolver/algorithms/common.hpp +++ b/include/packingsolver/algorithms/common.hpp @@ -234,6 +234,40 @@ std::ostream& operator<<( std::ostream& os, OptimizationMode optimization_mode); +/** + * How the value of a leftover is computed, for the 'BinPackingWithLeftovers' + * objective (the shape of the leftover is given by the leftover mode of the + * problem type). + */ +enum class LeftoverValueType +{ + /** + * The value of a leftover is the square of its area (or volume), or the + * sum of the squares of the areas of its pieces if it is cut (default). + * + * For a single leftover, it ranks the leftovers as their areas. Over + * several bins, a large leftover is worth more than several smaller + * leftovers of the same total area. + */ + SquaredArea, + + /** + * The value of a leftover is the integral, over its points, of their + * distance to its edge: its area (or volume) times the average depth of + * its points, so a compact leftover is worth more than a thin one of the + * same area (see 'src/algorithms/leftover.hpp'). + */ + Depth, +}; + +std::istream& operator>>( + std::istream& in, + LeftoverValueType& leftover_value_type); + +std::ostream& operator<<( + std::ostream& os, + LeftoverValueType leftover_value_type); + enum class ProblemType { @@ -285,8 +319,42 @@ enum class Objective SequentialOneDimensionalRectangleSubproblem, Feasibility, BinPackingCuttingCost, + /** + * Variable-sized bin packing in which the leftovers of the bins are + * valued (see 'LeftoverValueType'). + * + * If the cost of a bin type is set, the cost of the solution is minimized + * first; otherwise, the value of the stock left after packing the items + * (the leftovers of the bins of the solution and the bins which are not + * used) is maximized directly. The algorithms optimize it as + * 'VariableSizedBinPacking'. + */ + VariableSizedBinPackingWithLeftovers, }; +/** + * Return 'true' iff an objective is optimized as variable-sized bin packing: + * 'VariableSizedBinPacking' or 'VariableSizedBinPackingWithLeftovers'. + */ +inline bool is_variable_sized_bin_packing(Objective objective) +{ + return objective == Objective::VariableSizedBinPacking + || objective == Objective::VariableSizedBinPackingWithLeftovers; +} + +/** + * Get the objective of a onedimensional sub-instance built from an instance + * of another problem type: the onedimensional problem type doesn't value the + * leftovers in variable-sized bin packing, so + * 'VariableSizedBinPackingWithLeftovers' becomes 'VariableSizedBinPacking'. + */ +inline Objective onedimensional_subproblem_objective(Objective objective) +{ + return (objective == Objective::VariableSizedBinPackingWithLeftovers)? + Objective::VariableSizedBinPacking: + objective; +} + std::istream& operator>>( std::istream& in, Objective& objective); diff --git a/include/packingsolver/box/instance.hpp b/include/packingsolver/box/instance.hpp index c150c9521..be1bf77ab 100644 --- a/include/packingsolver/box/instance.hpp +++ b/include/packingsolver/box/instance.hpp @@ -5,8 +5,10 @@ #include "optimizationtools/utils/timer.hpp" #include "packingsolver/algorithms/resource.hpp" +#include #include #include +#include namespace packingsolver { @@ -45,12 +47,19 @@ enum class Rotation constexpr int NUMBER_OF_ROTATIONS = 6; /** - * How the leftover of the last bin of a solution is measured, for the - * 'BinPackingWithLeftovers' objective: the volume of the bin minus the volume - * used, the volume used being the box from the origin of the bin to the - * items along the dimensions of the mode, and the whole bin along the other - * dimensions. For example, with 'X', the volume used is - * 'x_max * bin.y * bin.z', and with 'XYZ', 'x_max * y_max * z_max'. + * Leftover of a bin, for the 'BinPackingWithLeftovers' objective. + * + * The leftover is the bin minus the box used by the items, the used box being + * the box from the origin of the bin to the items along the dimensions of the + * mode, and the whole bin along the other dimensions. For example, with 'X', + * the used box is 'x_max * bin.y * bin.z', and the leftover is a box; with + * 'XYZ', it is 'x_max * y_max * z_max'. The modes ending with 'Cut' cut the + * leftover into boxes along the faces of the used box, with the best order of + * the cuts. With 'Staircase', the leftover is the bin minus the union of the + * boxes between the origin of the bin and the opposite corner of each item. + * + * The value of the leftover is computed from its shape (see + * 'leftover_value'). */ enum class LeftoverMode { @@ -61,8 +70,61 @@ enum class LeftoverMode XZ, YZ, XYZ, + XYCut, + XZCut, + YZCut, + XYZCut, + Staircase, }; +/** Return 'true' iff the used box of a leftover mode stops at the items along x. */ +inline bool leftover_mode_along_x(LeftoverMode leftover_mode) +{ + return (leftover_mode == LeftoverMode::X + || leftover_mode == LeftoverMode::XY + || leftover_mode == LeftoverMode::XZ + || leftover_mode == LeftoverMode::XYZ + || leftover_mode == LeftoverMode::XYCut + || leftover_mode == LeftoverMode::XZCut + || leftover_mode == LeftoverMode::XYZCut + || leftover_mode == LeftoverMode::Staircase); +} + +/** Return 'true' iff the used box of a leftover mode stops at the items along y. */ +inline bool leftover_mode_along_y(LeftoverMode leftover_mode) +{ + return (leftover_mode == LeftoverMode::Y + || leftover_mode == LeftoverMode::XY + || leftover_mode == LeftoverMode::YZ + || leftover_mode == LeftoverMode::XYZ + || leftover_mode == LeftoverMode::XYCut + || leftover_mode == LeftoverMode::YZCut + || leftover_mode == LeftoverMode::XYZCut + || leftover_mode == LeftoverMode::Staircase); +} + +/** Return 'true' iff the used box of a leftover mode stops at the items along z. */ +inline bool leftover_mode_along_z(LeftoverMode leftover_mode) +{ + return (leftover_mode == LeftoverMode::Z + || leftover_mode == LeftoverMode::XZ + || leftover_mode == LeftoverMode::YZ + || leftover_mode == LeftoverMode::XYZ + || leftover_mode == LeftoverMode::XZCut + || leftover_mode == LeftoverMode::YZCut + || leftover_mode == LeftoverMode::XYZCut + || leftover_mode == LeftoverMode::Staircase); +} + +/** Return 'true' iff the leftover of a leftover mode is cut into boxes. */ +inline bool leftover_mode_cut(LeftoverMode leftover_mode) +{ + return (leftover_mode == LeftoverMode::XYCut + || leftover_mode == LeftoverMode::XZCut + || leftover_mode == LeftoverMode::YZCut + || leftover_mode == LeftoverMode::XYZCut); +} + std::istream& operator>>( std::istream& in, LeftoverMode& leftover_mode); @@ -155,18 +217,9 @@ inline Box leftover_mode_used_box( Length y_max, Length z_max) { - bool along_x = (leftover_mode == LeftoverMode::X - || leftover_mode == LeftoverMode::XY - || leftover_mode == LeftoverMode::XZ - || leftover_mode == LeftoverMode::XYZ); - bool along_y = (leftover_mode == LeftoverMode::Y - || leftover_mode == LeftoverMode::XY - || leftover_mode == LeftoverMode::YZ - || leftover_mode == LeftoverMode::XYZ); - bool along_z = (leftover_mode == LeftoverMode::Z - || leftover_mode == LeftoverMode::XZ - || leftover_mode == LeftoverMode::YZ - || leftover_mode == LeftoverMode::XYZ); + bool along_x = leftover_mode_along_x(leftover_mode); + bool along_y = leftover_mode_along_y(leftover_mode); + bool along_z = leftover_mode_along_z(leftover_mode); return { (along_x? x_max: bin.x), (along_y? y_max: bin.y), @@ -180,6 +233,42 @@ std::ostream& operator<<( std::ostream& os, Box box); +/** + * Get the value of the leftover of a bin of dimensions 'bin' for + * 'LeftoverMode::Staircase': the bin minus the union of the boxes + * [0, x] x [0, y] x [0, z] of the extents given, for a leftover value type. + */ +double staircase_leftover_value( + LeftoverValueType leftover_value_type, + const Box& bin, + const std::vector>& extents); + +/** + * Get the value of the leftover of a bin of dimensions 'bin' whose items end + * at 'x_max', 'y_max', 'z_max', for a leftover value type and a leftover + * mode. + * + * With 'LeftoverValueType::SquaredArea', the value of a leftover is the + * square of its volume (the sum of the squares of the volumes of its pieces + * if it is cut). + * With 'LeftoverValueType::Depth', it is the integral, over its points, of + * their distance to its edge (see 'algorithms/leftover.hpp'): its volume + * times the average distance of its points to its edge, so a compact + * leftover is worth more than a thin one of the same volume. An empty bin is + * worth 'leftover_value(leftover_value_type, leftover_mode, bin, 0, 0, 0)'. + * + * For 'LeftoverMode::Staircase', the value depends on the staircase of the + * items (see 'staircase_leftover_value'); this function returns the value of + * the leftover of 'XYZ', which is the same for an empty bin. + */ +double leftover_value( + LeftoverValueType leftover_value_type, + LeftoverMode leftover_mode, + const Box& bin, + Length x_max, + Length y_max, + Length z_max); + //////////////////////////////////////////////////////////////////////////////// ///////////////////////// Item type, Bin type, Defect ////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -347,6 +436,12 @@ struct Parameters /** Leftover mode (see 'LeftoverMode'). */ LeftoverMode leftover_mode = LeftoverMode::XYZ; + /** + * How the value of the leftover of a bin is computed, for the + * BinPackingWithLeftovers objective (see 'LeftoverValueType'). + */ + LeftoverValueType leftover_value_type = LeftoverValueType::SquaredArea; + /** * For the BinPackingWithLeftovers objective, also compare the solutions * on the sum of the leftover values of the bins and on the sum of their @@ -459,6 +554,32 @@ class Instance /** Get a bin type. */ inline const BinType& bin_type(BinTypeId bin_type_id) const { return bin_types_[bin_type_id]; } + /** + * Get the factor which converts a leftover value into a space, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the minimum, over the + * bin types, of the volume of the bin divided by its leftover + * value when it is empty. + */ + inline double leftover_value_factor() const { return leftover_value_factor_; } + + /** + * Get the refund of a leftover of a bin, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the price of the bin + * per unit of volume, times the space equivalent to the value of + * the leftover. + * + * The refund of an empty bin is at most its cost; it is equal for the + * bin types which define 'leftover_value_factor()'. + */ + inline Profit leftover_refund( + BinTypeId bin_type_id, + double leftover_value) const + { + const BinType& bin_type = this->bin_type(bin_type_id); + double space = (double)bin_type.volume(); + return bin_type.cost / space * leftover_value_factor_ * leftover_value; + } + /** Get the number of bins. */ inline BinPos number_of_bins() const { return bin_type_ids_.size(); } @@ -619,6 +740,9 @@ class Instance /** Bin types. */ std::vector bin_types_; + /** Factor which converts a leftover value into a space. */ + double leftover_value_factor_ = 0; + /** Item types. */ std::vector item_types_; diff --git a/include/packingsolver/box/instance_builder.hpp b/include/packingsolver/box/instance_builder.hpp index 80c94521b..38fbe8bd7 100644 --- a/include/packingsolver/box/instance_builder.hpp +++ b/include/packingsolver/box/instance_builder.hpp @@ -70,6 +70,9 @@ class InstanceBuilder /** Set the leftover mode (see 'LeftoverMode'). */ void set_leftover_mode(LeftoverMode leftover_mode) { instance_.parameters_.leftover_mode = leftover_mode; } + /** Set how the value of the leftover of a bin is computed. */ + void set_leftover_value_type(LeftoverValueType leftover_value_type) { instance_.parameters_.leftover_value_type = leftover_value_type; } + /** Set whether the leftover values of all the bins are compared. */ void set_leftover_all_bins(bool leftover_all_bins) { instance_.parameters_.leftover_all_bins = leftover_all_bins; } diff --git a/include/packingsolver/box/optimize.hpp b/include/packingsolver/box/optimize.hpp index 7854309f6..c461877e6 100644 --- a/include/packingsolver/box/optimize.hpp +++ b/include/packingsolver/box/optimize.hpp @@ -70,6 +70,9 @@ struct Output: packingsolver::Output case Objective::VariableSizedBinPacking: return solution_pool.best().feasible() && equal_cost(variable_sized_bin_packing_bound, solution_pool.best().cost()); + case Objective::VariableSizedBinPackingWithLeftovers: + // There is no bound on the value of the leftovers. + return false; case Objective::OpenDimensionX: return solution_pool.best().feasible() && open_dimension_x_bound == solution_pool.best().x_max(); @@ -108,7 +111,7 @@ struct Output: packingsolver::Output if (output.bin_packing_bound > bin_packing_bound) bin_packing_bound = output.bin_packing_bound; break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: if (output.variable_sized_bin_packing_bound > variable_sized_bin_packing_bound) variable_sized_bin_packing_bound = output.variable_sized_bin_packing_bound; break; @@ -154,7 +157,7 @@ struct Output: packingsolver::Output case Objective::BinPacking: write_bound(os, width, solution_pool.best().number_of_bins(), bin_packing_bound); break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: write_bound(os, width, solution_pool.best().cost(), variable_sized_bin_packing_bound); break; case Objective::OpenDimensionX: diff --git a/include/packingsolver/box/solution.hpp b/include/packingsolver/box/solution.hpp index 1b190051c..d064057bd 100644 --- a/include/packingsolver/box/solution.hpp +++ b/include/packingsolver/box/solution.hpp @@ -56,8 +56,8 @@ struct SolutionBin */ bool maximum_weight_above_feasible = true; - /** Leftover value of the bin (see 'LeftoverMode'). */ - Volume leftover_value = 0; + /** Leftover value of the bin (see 'leftover_value'). */ + double leftover_value = 0; /** * Staircase leftover value of the bin: the volume of the bin which is not @@ -259,20 +259,35 @@ class Solution /** Get the maximum z of the solution. */ inline Length z_max() const { return z_max_; } - /** Get the area of the solution. */ - inline Profit leftover_value() const { return leftover_value_; } + /** + * Get the value of the leftover of the last bin (see 'LeftoverMode' and + * 'leftover_value'). + */ + inline double leftover_value() const { return leftover_value_; } /** Get the staircase leftover value of the last bin of the solution. */ inline Volume staircase_leftover_value() const { return staircase_leftover_value_; } - /** Get the sum of the leftover values of the bins of the solution. */ - inline Volume total_leftover_value() const { return total_leftover_value_; } + /** + * Get the sum of the leftover values of all the bins of the instance: + * the leftover values of the bins of the solution, and the values of the + * bins which are not used. + */ + double total_leftover_value() const; + + /** + * Get the net cost of the solution, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the cost of its bins + * minus the refunds of their leftovers (see 'Instance::leftover_refund'). + */ + inline Profit net_cost() const { return net_cost_; } /** - * Get the sum of the staircase leftover values of the bins of the - * solution. + * Get the sum of the staircase leftover values of all the bins of the + * instance: the staircase leftover values of the bins of the solution, + * and the volumes of the bins which are not used. */ - inline Volume total_staircase_leftover_value() const { return total_staircase_leftover_value_; } + inline Volume total_staircase_leftover_value() const { return instance().bin_volume() - staircase_dominated_volume_; } /** Get the volume of the solution. */ inline Volume volume() const { return volume_; } @@ -380,17 +395,26 @@ class Solution /** Total volume of the solution. */ Volume volume_ = 0; - /** Value of the leftover. */ - Profit leftover_value_ = 0.0; + /** Value of the leftover of the last bin. */ + double leftover_value_ = 0.0; /** Staircase leftover value of the last bin. */ Volume staircase_leftover_value_ = 0; - /** Sum of the leftover values of the bins. */ - Volume total_leftover_value_ = 0; + /** + * Sum, over the bins of the solution, of the value of the bin minus its + * leftover value. + */ + double leftover_value_loss_ = 0; + + /** Net cost of the solution. */ + Profit net_cost_ = 0; - /** Sum of the staircase leftover values of the bins. */ - Volume total_staircase_leftover_value_ = 0; + /** + * Sum, over the bins of the solution, of the volume dominated by the + * staircase of their items. + */ + Volume staircase_dominated_volume_ = 0; /** Total volume of the bins of the solution. */ Volume bin_volume_ = 0; diff --git a/include/packingsolver/boxstacks/instance.hpp b/include/packingsolver/boxstacks/instance.hpp index 7bc0838e3..64a019d22 100644 --- a/include/packingsolver/boxstacks/instance.hpp +++ b/include/packingsolver/boxstacks/instance.hpp @@ -5,7 +5,9 @@ #include "packingsolver/algorithms/truck.hpp" #include "packingsolver/rectangle/instance.hpp" +#include #include +#include namespace packingsolver { @@ -51,19 +53,29 @@ std::string to_string(Rotation rotation); Rotation rotation_from_string(const std::string& str); /** - * How the leftover of the last bin of a solution is measured, for the - * 'BinPackingWithLeftovers' objective: the volume of the bin minus the volume - * used, the volume used being the box from the origin of the bin to the - * stacks along the dimensions of the mode, and the whole bin along the other - * dimensions (the whole height of the bin in all the modes). For example, - * with 'X', the volume used is 'x_max * bin.y * bin.z', and with 'XY', - * 'x_max * y_max * bin.z'. + * Leftover of a bin, for the 'BinPackingWithLeftovers' objective. + * + * The leftover is the bin minus the box used by the stacks, the used box + * being the box from the origin of the bin to the stacks along the + * dimensions of the mode, and the whole bin along the other dimensions (the + * whole height of the bin in all the modes). For example, with 'X', the used + * box is 'x_max * bin.y * bin.z', and the leftover is a box; with 'XY', it is + * 'x_max * y_max * bin.z'. With 'XYCut', the leftover of 'XY' is cut into two + * boxes, along the best of the two cuts at x_max and at y_max. With + * 'Staircase', the leftover is the bin minus the union of the boxes between + * the origin of the bin and the opposite corner of each stack, over the + * whole height of the bin. + * + * The value of the leftover is computed from its shape (see + * 'leftover_value'). */ enum class LeftoverMode { X, Y, XY, + XYCut, + Staircase, }; std::istream& operator>>( @@ -129,6 +141,41 @@ inline Box leftover_mode_used_box( bin.z}; } +/** + * Get the value of the leftover of a bin of dimensions 'bin' whose stacks end + * at 'x_max' and 'y_max', for a leftover value type and a leftover mode. + * + * With 'LeftoverValueType::SquaredArea', the value of a leftover is the + * square of its volume (the sum of the squares of the volumes of its pieces + * if it is cut). + * With 'LeftoverValueType::Depth', it is the integral, over its points, of + * their distance to its edge (see 'algorithms/leftover.hpp'): its volume + * times the average distance of its points to its edge, so a compact + * leftover is worth more than a thin one of the same volume. An empty bin is + * worth 'leftover_value(leftover_value_type, leftover_mode, bin, 0, 0)'. + * + * For 'LeftoverMode::Staircase', the value depends on the staircase of the + * stacks (see 'staircase_leftover_value'); this function returns the value + * of the leftover of 'XY', which is the same for an empty bin. + */ +double leftover_value( + LeftoverValueType leftover_value_type, + LeftoverMode leftover_mode, + const Box& bin, + Length x_max, + Length y_max); + +/** + * Get the value of the leftover of a bin of dimensions 'bin' for + * 'LeftoverMode::Staircase': the bin minus the union of the boxes + * [0, x] x [0, y] x [0, bin.z] of the extents (x, y) given, for a leftover + * value type. + */ +double staircase_leftover_value( + LeftoverValueType leftover_value_type, + const Box& bin, + const std::vector>& extents); + //////////////////////////////////////////////////////////////////////////////// ///////////////////////// Item type, Bin type, Defect ////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -375,6 +422,12 @@ struct Parameters /** Leftover mode (see 'LeftoverMode'). */ LeftoverMode leftover_mode = LeftoverMode::XY; + /** + * How the value of the leftover of a bin is computed, for the + * BinPackingWithLeftovers objective (see 'LeftoverValueType'). + */ + LeftoverValueType leftover_value_type = LeftoverValueType::SquaredArea; + /** * For the BinPackingWithLeftovers objective, also compare the solutions * on the sum of the leftover values of the bins and on the sum of their @@ -478,6 +531,32 @@ class Instance /** Get a bin type. */ inline const BinType& bin_type(BinTypeId bin_type_id) const { return bin_types_[bin_type_id]; } + /** + * Get the factor which converts a leftover value into a space, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the minimum, over the + * bin types, of the volume of the bin divided by its leftover + * value when it is empty. + */ + inline double leftover_value_factor() const { return leftover_value_factor_; } + + /** + * Get the refund of a leftover of a bin, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the price of the bin + * per unit of volume, times the space equivalent to the value of + * the leftover. + * + * The refund of an empty bin is at most its cost; it is equal for the + * bin types which define 'leftover_value_factor()'. + */ + inline Profit leftover_refund( + BinTypeId bin_type_id, + double leftover_value) const + { + const BinType& bin_type = this->bin_type(bin_type_id); + double space = (double)bin_type.volume(); + return bin_type.cost / space * leftover_value_factor_ * leftover_value; + } + /** Get the number of bins. */ inline BinPos number_of_bins() const { return bin_type_ids_.size(); } @@ -623,6 +702,9 @@ class Instance /** Bin types. */ std::vector bin_types_; + /** Factor which converts a leftover value into a space. */ + double leftover_value_factor_ = 0; + /** Item types. */ std::vector item_types_; diff --git a/include/packingsolver/boxstacks/instance_builder.hpp b/include/packingsolver/boxstacks/instance_builder.hpp index 84a26eec9..e7f4e856b 100644 --- a/include/packingsolver/boxstacks/instance_builder.hpp +++ b/include/packingsolver/boxstacks/instance_builder.hpp @@ -84,6 +84,9 @@ class InstanceBuilder /** Set the leftover mode (see 'LeftoverMode'). */ void set_leftover_mode(LeftoverMode leftover_mode) { instance_.parameters_.leftover_mode = leftover_mode; } + /** Set how the value of the leftover of a bin is computed. */ + void set_leftover_value_type(LeftoverValueType leftover_value_type) { instance_.parameters_.leftover_value_type = leftover_value_type; } + /** Set whether the leftover values of all the bins are compared. */ void set_leftover_all_bins(bool leftover_all_bins) { instance_.parameters_.leftover_all_bins = leftover_all_bins; } diff --git a/include/packingsolver/boxstacks/optimize.hpp b/include/packingsolver/boxstacks/optimize.hpp index 9430fa8b5..7fe4aba3d 100644 --- a/include/packingsolver/boxstacks/optimize.hpp +++ b/include/packingsolver/boxstacks/optimize.hpp @@ -61,6 +61,9 @@ struct Output: packingsolver::Output case Objective::VariableSizedBinPacking: return solution_pool.best().feasible() && equal_cost(variable_sized_bin_packing_bound, solution_pool.best().cost()); + case Objective::VariableSizedBinPackingWithLeftovers: + // There is no bound on the value of the leftovers. + return false; case Objective::Feasibility: return solution_pool.best().feasible(); default: @@ -90,7 +93,7 @@ struct Output: packingsolver::Output case Objective::BinPacking: write_bound(os, width, solution_pool.best().number_of_bins(), bin_packing_bound); break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: write_bound(os, width, solution_pool.best().cost(), variable_sized_bin_packing_bound); break; case Objective::Feasibility: diff --git a/include/packingsolver/boxstacks/solution.hpp b/include/packingsolver/boxstacks/solution.hpp index 1334c4e1f..2d51e2242 100644 --- a/include/packingsolver/boxstacks/solution.hpp +++ b/include/packingsolver/boxstacks/solution.hpp @@ -85,8 +85,8 @@ struct SolutionBin /** Profit. */ Profit profit = 0.0; - /** Leftover value of the bin (see 'LeftoverMode'). */ - Volume leftover_value = 0; + /** Leftover value of the bin (see 'leftover_value'). */ + double leftover_value = 0; /** * Staircase leftover value of the bin: the volume of the bin which is not @@ -284,22 +284,34 @@ class Solution inline Area waste() const { return volume_ - item_volume_; } /** - * Get the value of the leftover of the last bin of the solution: a volume - * (see 'LeftoverMode'). + * Get the value of the leftover of the last bin (see 'LeftoverMode' and + * 'leftover_value'). */ - inline Volume leftover_value() const { return bin_volume_ - volume_; } + inline double leftover_value() const { return leftover_value_; } /** Get the staircase leftover value of the last bin of the solution. */ inline Volume staircase_leftover_value() const { return staircase_leftover_value_; } - /** Get the sum of the leftover values of the bins of the solution. */ - inline Volume total_leftover_value() const { return total_leftover_value_; } + /** + * Get the sum of the leftover values of all the bins of the instance: + * the leftover values of the bins of the solution, and the values of the + * bins which are not used. + */ + double total_leftover_value() const; + + /** + * Get the net cost of the solution, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the cost of its bins + * minus the refunds of their leftovers (see 'Instance::leftover_refund'). + */ + inline Profit net_cost() const { return net_cost_; } /** - * Get the sum of the staircase leftover values of the bins of the - * solution. + * Get the sum of the staircase leftover values of all the bins of the + * instance: the staircase leftover values of the bins of the solution, + * and the volumes of the bins which are not used. */ - inline Volume total_staircase_leftover_value() const { return total_staircase_leftover_value_; } + inline Volume total_staircase_leftover_value() const { return instance().bin_volume() - staircase_dominated_volume_; } /** Get the fraction of waste of the solution. */ inline double waste_percentage() const { return (volume() == 0)? 0: (double)waste() / volume(); } @@ -421,14 +433,26 @@ class Solution /** Total volume of the solution. */ Volume volume_ = 0; + /** Value of the leftover of the last bin. */ + double leftover_value_ = 0.0; + /** Staircase leftover value of the last bin. */ Volume staircase_leftover_value_ = 0; - /** Sum of the leftover values of the bins. */ - Volume total_leftover_value_ = 0; + /** + * Sum, over the bins of the solution, of the value of the bin minus its + * leftover value. + */ + double leftover_value_loss_ = 0; + + /** Net cost of the solution. */ + Profit net_cost_ = 0; - /** Sum of the staircase leftover values of the bins. */ - Volume total_staircase_leftover_value_ = 0; + /** + * Sum, over the bins of the solution, of the volume dominated by the + * staircase of their stacks. + */ + Volume staircase_dominated_volume_ = 0; /** Total volume of the bins of the solution. */ Volume bin_volume_ = 0; diff --git a/include/packingsolver/irregular/instance.hpp b/include/packingsolver/irregular/instance.hpp index 0c1803ad0..d55039421 100644 --- a/include/packingsolver/irregular/instance.hpp +++ b/include/packingsolver/irregular/instance.hpp @@ -21,6 +21,28 @@ using namespace shape; ///////////////////////// Item type, Bin type, Defect ////////////////////////// //////////////////////////////////////////////////////////////////////////////// +/** + * Leftover of a bin, for the 'BinPackingWithLeftovers' objective. + * + * The leftover is the bounding box of the bin minus the rectangle used by + * the items: + * - with a corner mode ('BottomLeft', ...), the rectangle between this + * corner and the opposite corner of the bounding box of the items; the + * leftover is an L-shape + * - with a side mode ('Left', ...), the rectangle between this side and the + * opposite side of the bounding box of the items; the leftover is a + * rectangle + * - with a corner mode ending with 'Cut' ('BottomLeftCut', ...), the + * L-shape of the corner mode is cut into two rectangles, along the best of + * the two cuts + * - with a corner mode ending with 'Staircase' ('BottomLeftStaircase', ...), + * the leftover is the bounding box of the bin minus the union of the + * rectangles between the corner and the opposite corner of the bounding + * box of each item: a staircase + * + * The value of the leftover is computed from its shape (see + * 'leftover_value'). + */ enum class LeftoverMode { BottomLeft, @@ -31,8 +53,57 @@ enum class LeftoverMode Right, Bottom, Top, + BottomLeftCut, + BottomRightCut, + TopLeftCut, + TopRightCut, + BottomLeftStaircase, + BottomRightStaircase, + TopLeftStaircase, + TopRightStaircase, }; +/** + * Get the corner or side mode of a leftover mode: for a mode ending with + * 'Cut' or 'Staircase', the corner mode it derives from, otherwise the mode + * itself. + * + * The items are packed the same way for all of them, towards the same corner + * or side; only the shape of the leftover differs. + */ +inline LeftoverMode leftover_mode_base(LeftoverMode leftover_mode) +{ + switch (leftover_mode) { + case LeftoverMode::BottomLeftCut: return LeftoverMode::BottomLeft; + case LeftoverMode::BottomRightCut: return LeftoverMode::BottomRight; + case LeftoverMode::TopLeftCut: return LeftoverMode::TopLeft; + case LeftoverMode::TopRightCut: return LeftoverMode::TopRight; + case LeftoverMode::BottomLeftStaircase: return LeftoverMode::BottomLeft; + case LeftoverMode::BottomRightStaircase: return LeftoverMode::BottomRight; + case LeftoverMode::TopLeftStaircase: return LeftoverMode::TopLeft; + case LeftoverMode::TopRightStaircase: return LeftoverMode::TopRight; + default: return leftover_mode; + } +} + +/** Return 'true' iff the leftover of a leftover mode is cut into rectangles. */ +inline bool leftover_mode_cut(LeftoverMode leftover_mode) +{ + return (leftover_mode == LeftoverMode::BottomLeftCut + || leftover_mode == LeftoverMode::BottomRightCut + || leftover_mode == LeftoverMode::TopLeftCut + || leftover_mode == LeftoverMode::TopRightCut); +} + +/** Return 'true' iff the leftover of a leftover mode is a staircase. */ +inline bool leftover_mode_staircase(LeftoverMode leftover_mode) +{ + return (leftover_mode == LeftoverMode::BottomLeftStaircase + || leftover_mode == LeftoverMode::BottomRightStaircase + || leftover_mode == LeftoverMode::TopLeftStaircase + || leftover_mode == LeftoverMode::TopRightStaircase); +} + std::istream& operator>>( std::istream& in, LeftoverMode& leftover_mode); @@ -57,6 +128,12 @@ struct Parameters /** Reference corner/edge to compute the leftover value. */ LeftoverMode leftover_mode = LeftoverMode::BottomLeft; + /** + * How the value of the leftover of a bin is computed, for the + * BinPackingWithLeftovers objective (see 'LeftoverValueType'). + */ + LeftoverValueType leftover_value_type = LeftoverValueType::SquaredArea; + /** * For the BinPackingWithLeftovers objective, also compare the solutions * on the sum of the leftover values of the bins and on the sum of their @@ -475,6 +552,33 @@ class Instance /** Get bin type i. */ inline const BinType& bin_type(BinTypeId bin_type_id) const { return bin_types_[bin_type_id]; } + /** + * Get the factor which converts a leftover value into a space, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the minimum, over the + * bin types, of the area of the bounding box of the bin divided by its leftover + * value when it is empty. + */ + inline double leftover_value_factor() const { return leftover_value_factor_; } + + /** + * Get the refund of a leftover of a bin, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the price of the bin + * per unit of area of the bounding box, times the space equivalent to the value of + * the leftover. + * + * The refund of an empty bin is at most its cost; it is equal for the + * bin types which define 'leftover_value_factor()'. + */ + inline Profit leftover_refund( + BinTypeId bin_type_id, + double leftover_value) const + { + const BinType& bin_type = this->bin_type(bin_type_id); + double space = (bin_type.aabb_orig.x_max - bin_type.aabb_orig.x_min) + * (bin_type.aabb_orig.y_max - bin_type.aabb_orig.y_min); + return bin_type.cost / space * leftover_value_factor_ * leftover_value; + } + /** Get the scaled item_bin_minimum_spacing of bin type 'bin_type_id'. */ inline LengthDbl bin_spacing_scaled(BinTypeId bin_type_id) const { @@ -689,6 +793,9 @@ class Instance /** Bin types. */ std::vector bin_types_; + /** Factor which converts a leftover value into a space. */ + double leftover_value_factor_ = 0; + /** Item types. */ std::vector item_types_; diff --git a/include/packingsolver/irregular/instance_builder.hpp b/include/packingsolver/irregular/instance_builder.hpp index ffdaf178e..d4842b504 100644 --- a/include/packingsolver/irregular/instance_builder.hpp +++ b/include/packingsolver/irregular/instance_builder.hpp @@ -65,6 +65,9 @@ class InstanceBuilder /** Set the leftover mode. */ void set_leftover_mode(LeftoverMode leftover_mode) { instance_.parameters_.leftover_mode = leftover_mode; } + /** Set how the value of the leftover of a bin is computed. */ + void set_leftover_value_type(LeftoverValueType leftover_value_type) { instance_.parameters_.leftover_value_type = leftover_value_type; } + /** Set whether the leftover values of all the bins are compared. */ void set_leftover_all_bins(bool leftover_all_bins) { instance_.parameters_.leftover_all_bins = leftover_all_bins; } diff --git a/include/packingsolver/irregular/optimize.hpp b/include/packingsolver/irregular/optimize.hpp index 184e7ad05..0b97867e2 100644 --- a/include/packingsolver/irregular/optimize.hpp +++ b/include/packingsolver/irregular/optimize.hpp @@ -118,6 +118,9 @@ struct Output: packingsolver::Output case Objective::VariableSizedBinPacking: return solution_pool.best().feasible() && equal_cost(variable_sized_bin_packing_bound, solution_pool.best().cost()); + case Objective::VariableSizedBinPackingWithLeftovers: + // There is no bound on the value of the leftovers. + return false; case Objective::OpenDimensionX: return solution_pool.best().feasible() && equal(open_dimension_x_bound, solution_pool.best().x_max()); @@ -159,7 +162,7 @@ struct Output: packingsolver::Output if (output.bin_packing_bound > bin_packing_bound) bin_packing_bound = output.bin_packing_bound; break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: if (output.variable_sized_bin_packing_bound > variable_sized_bin_packing_bound) variable_sized_bin_packing_bound = output.variable_sized_bin_packing_bound; break; @@ -207,7 +210,7 @@ struct Output: packingsolver::Output case Objective::BinPacking: write_bound(os, width, solution_pool.best().number_of_bins(), bin_packing_bound); break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: write_bound(os, width, solution_pool.best().cost(), variable_sized_bin_packing_bound); break; case Objective::OpenDimensionX: diff --git a/include/packingsolver/irregular/solution.hpp b/include/packingsolver/irregular/solution.hpp index cb2ba8da7..e8cb34dc5 100644 --- a/include/packingsolver/irregular/solution.hpp +++ b/include/packingsolver/irregular/solution.hpp @@ -33,8 +33,8 @@ struct SolutionBin /** Maximum y of the items in this bin. */ LengthDbl y_max = -std::numeric_limits::infinity(); - /** Leftover value of the bin (see 'LeftoverMode'). */ - AreaDbl leftover_value = 0; + /** Leftover value of the bin (see 'leftover_value'). */ + double leftover_value = 0; /** * Area of the bin which is not dominated by an item, an item dominating @@ -184,19 +184,44 @@ class Solution /** Get the area of the (last bin of the) solution. */ AreaDbl open_dimension_xy_area() const; - /** Get the area of the solution. */ - inline Profit leftover_value_orig() const { return leftover_value_orig_; } + /** + * Get the value of the leftover of the last bin, in original coordinates + * (see 'LeftoverMode' and 'leftover_value'). + */ + inline double leftover_value_orig() const { return leftover_value_orig_; } + + /** + * Get the area of the leftover of the last bin, in original coordinates + * (see 'LeftoverMode'). + */ + inline AreaDbl leftover_area() const { return leftover_area_; } - inline Profit leftover_value_scaled() const { return leftover_value_scaled_; } + /** Get the value of the leftover of the last bin, in scaled coordinates. */ + inline double leftover_value_scaled() const { return leftover_value_scaled_; } /** Get the staircase leftover value of the last bin of the solution. */ inline AreaDbl staircase_leftover_value() const { return staircase_leftover_value_; } - /** Get the sum of the leftover values of the bins. */ - inline AreaDbl total_leftover_value() const { return total_leftover_value_; } + /** + * Get the sum of the leftover values of all the bins of the instance: + * the leftover values of the bins of the solution, and the values of the + * bins which are not used. + */ + double total_leftover_value() const; + + /** + * Get the net cost of the solution, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the cost of its bins + * minus the refunds of their leftovers (see 'Instance::leftover_refund'). + */ + inline Profit net_cost() const { return net_cost_; } - /** Get the sum of the staircase leftover values of the bins. */ - inline AreaDbl total_staircase_leftover_value() const { return total_staircase_leftover_value_; } + /** + * Get the sum of the staircase leftover values of all the bins of the + * instance: the staircase leftover values of the bins of the solution, + * and the areas of the bounding boxes of the bins which are not used. + */ + AreaDbl total_staircase_leftover_value() const; /** Get the waste of the solution including the residual. */ inline AreaDbl full_waste() const { return bin_area() - item_area(); } @@ -306,20 +331,32 @@ class Solution /** Number of items. */ ItemPos number_of_items_ = 0; - /** Value of the leftover in original coordinates. */ - Profit leftover_value_orig_ = 0.0; + /** Value of the leftover of the last bin in original coordinates. */ + double leftover_value_orig_ = 0.0; - /** Value of the leftover in scaled coordinates. */ - Profit leftover_value_scaled_ = 0.0; + /** Area of the leftover of the last bin in original coordinates. */ + AreaDbl leftover_area_ = 0.0; + + /** Value of the leftover of the last bin in scaled coordinates. */ + double leftover_value_scaled_ = 0.0; /** Staircase leftover value of the last bin. */ AreaDbl staircase_leftover_value_ = 0; - /** Sum of the leftover values of the bins. */ - AreaDbl total_leftover_value_ = 0; + /** + * Sum, over the bins of the solution, of the value of the bin minus its + * leftover value. + */ + double leftover_value_loss_ = 0; + + /** Net cost of the solution. */ + Profit net_cost_ = 0; - /** Sum of the staircase leftover values of the bins. */ - AreaDbl total_staircase_leftover_value_ = 0; + /** + * Sum, over the bins of the solution, of the area dominated by the + * staircase of their items. + */ + AreaDbl staircase_dominated_area_ = 0; /** Total area of the bins of the solution. */ AreaDbl bin_area_ = 0; diff --git a/include/packingsolver/onedimensional/optimize.hpp b/include/packingsolver/onedimensional/optimize.hpp index ce58f4089..ed5ebd197 100644 --- a/include/packingsolver/onedimensional/optimize.hpp +++ b/include/packingsolver/onedimensional/optimize.hpp @@ -57,7 +57,7 @@ struct Output: packingsolver::Output && (bin_packing_bound == solution_pool.best().number_of_bins() || solution_pool.best().number_of_bins() <= bin_packing_goal); } - case Objective::VariableSizedBinPacking: { + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { Profit variable_sized_bin_packing_goal = solution_pool.best().instance().variable_sized_bin_packing_goal(); return solution_pool.best().feasible() @@ -94,7 +94,7 @@ struct Output: packingsolver::Output if (output.bin_packing_bound > bin_packing_bound) bin_packing_bound = output.bin_packing_bound; break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: if (output.variable_sized_bin_packing_bound > variable_sized_bin_packing_bound) variable_sized_bin_packing_bound = output.variable_sized_bin_packing_bound; break; @@ -125,7 +125,7 @@ struct Output: packingsolver::Output case Objective::BinPacking: write_bound(os, width, solution_pool.best().number_of_bins(), bin_packing_bound); break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: write_bound(os, width, solution_pool.best().cost(), variable_sized_bin_packing_bound); break; case Objective::Feasibility: diff --git a/include/packingsolver/rectangle/instance.hpp b/include/packingsolver/rectangle/instance.hpp index 8a1d7db9a..eb4794e01 100644 --- a/include/packingsolver/rectangle/instance.hpp +++ b/include/packingsolver/rectangle/instance.hpp @@ -6,6 +6,7 @@ #include "packingsolver/algorithms/resource.hpp" #include "packingsolver/algorithms/truck.hpp" +#include #include #include @@ -24,20 +25,41 @@ std::ostream& operator<<( std::ostream& os, Direction o); +/** + * Leftover of a bin, for the BinPackingWithLeftovers objective. + * + * The leftover mode defines the shape of the leftover: the bin minus the + * rectangle used by the items. The value of the leftover is computed from + * its shape (see 'leftover_value'). + */ enum class LeftoverMode { - /** Leftover value is bin_area - x_max * y_max (default). */ + /** + * The leftover is the L-shape between the top-right corner of the bin + * and the rectangle [0, x_max] x [0, y_max] (default). + */ Area, /** - * Leftover value is (bin_width - x_max) * bin_height; forces - * Direction::X. + * The leftover is the rectangle [x_max, bin_width] x [0, bin_height]; + * forces Direction::X. */ X, /** - * Leftover value is bin_width * (bin_height - y_max); forces - * Direction::Y. + * The leftover is the rectangle [0, bin_width] x [y_max, bin_height]; + * forces Direction::Y. */ Y, + /** + * As 'Area', but the L-shape is cut into two rectangles, along the best + * of the two cuts at x_max and at y_max. + */ + AreaCut, + /** + * The leftover is the bin minus the union of the rectangles between the + * bottom-left corner of the bin and the top-right corner of each item: a + * staircase. + */ + Staircase, }; std::istream& operator>>( @@ -66,6 +88,43 @@ std::ostream& operator<<( std::ostream& os, UnloadingConstraint unloading_constraint); +/** + * Get the value of the leftover of a bin of dimensions 'bin_x' x 'bin_y' + * whose items are in [0, x_max] x [0, y_max], for a leftover value type and + * a leftover mode. + * + * With 'LeftoverValueType::SquaredArea', the value of a leftover is the + * square of its area (the sum of the squares of the areas of its pieces if it + * is cut). With + * 'LeftoverValueType::Depth', it is the integral, over its points, of their + * distance to its edge (see 'algorithms/leftover.hpp'): its area times the + * average distance of its points to its edge, so a compact leftover is worth + * more than a thin one of the same area. An empty bin is worth + * 'leftover_value(leftover_value_type, leftover_mode, bin_x, bin_y, 0, 0)'. + * + * For 'LeftoverMode::Staircase', the value depends on the staircase of the + * items (see 'staircase_leftover_value'); this function returns the value of + * the L-shape of 'Area', which is the same for an empty bin. + */ +double leftover_value( + LeftoverValueType leftover_value_type, + LeftoverMode leftover_mode, + Length bin_x, + Length bin_y, + Length x_max, + Length y_max); + +/** + * Get the value of the leftover of a bin of dimensions 'bin_x' x 'bin_y' for + * 'LeftoverMode::Staircase': the bin minus the union of the rectangles + * [0, x] x [0, y] of the extents given, for a leftover value type. + */ +double staircase_leftover_value( + LeftoverValueType leftover_value_type, + Length bin_x, + Length bin_y, + const std::vector>& extents); + struct Point { /** x-coordinate. */ @@ -318,6 +377,12 @@ struct Parameters /** How the leftover value is defined for BinPackingWithLeftovers. */ LeftoverMode leftover_mode = LeftoverMode::Area; + /** + * How the value of the leftover of a bin is computed, for the + * BinPackingWithLeftovers objective (see 'LeftoverValueType'). + */ + LeftoverValueType leftover_value_type = LeftoverValueType::SquaredArea; + /** * For the BinPackingWithLeftovers objective, also compare the solutions * on the sum of the leftover values of the bins and on the sum of their @@ -445,6 +510,32 @@ class Instance /** Get a bin type. */ inline const BinType& bin_type(BinTypeId bin_type_id) const { return bin_types_[bin_type_id]; } + /** + * Get the factor which converts a leftover value into a space, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the minimum, over the + * bin types, of the area of the bin divided by its leftover + * value when it is empty. + */ + inline double leftover_value_factor() const { return leftover_value_factor_; } + + /** + * Get the refund of a leftover of a bin, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the price of the bin + * per unit of area, times the space equivalent to the value of + * the leftover. + * + * The refund of an empty bin is at most its cost; it is equal for the + * bin types which define 'leftover_value_factor()'. + */ + inline Profit leftover_refund( + BinTypeId bin_type_id, + double leftover_value) const + { + const BinType& bin_type = this->bin_type(bin_type_id); + double space = (double)bin_type.area(); + return bin_type.cost / space * leftover_value_factor_ * leftover_value; + } + /** Get the number of bins. */ inline BinPos number_of_bins() const { return bin_type_ids_.size(); } @@ -624,6 +715,9 @@ class Instance /** Bin types. */ std::vector bin_types_; + /** Factor which converts a leftover value into a space. */ + double leftover_value_factor_ = 0; + /** Item types. */ std::vector item_types_; diff --git a/include/packingsolver/rectangle/instance_builder.hpp b/include/packingsolver/rectangle/instance_builder.hpp index f56ac25e1..a558cca8b 100644 --- a/include/packingsolver/rectangle/instance_builder.hpp +++ b/include/packingsolver/rectangle/instance_builder.hpp @@ -82,6 +82,9 @@ class InstanceBuilder void set_leftover_mode(LeftoverMode leftover_mode) { instance_.parameters_.leftover_mode = leftover_mode; } + /** Set how the value of the leftover of a bin is computed. */ + void set_leftover_value_type(LeftoverValueType leftover_value_type) { instance_.parameters_.leftover_value_type = leftover_value_type; } + /** Set whether the leftover values of all the bins are compared. */ void set_leftover_all_bins(bool leftover_all_bins) { instance_.parameters_.leftover_all_bins = leftover_all_bins; } diff --git a/include/packingsolver/rectangle/optimize.hpp b/include/packingsolver/rectangle/optimize.hpp index dcc6cef8f..2e5523892 100644 --- a/include/packingsolver/rectangle/optimize.hpp +++ b/include/packingsolver/rectangle/optimize.hpp @@ -67,6 +67,9 @@ struct Output: packingsolver::Output case Objective::VariableSizedBinPacking: return solution_pool.best().feasible() && equal_cost(variable_sized_bin_packing_bound, solution_pool.best().cost()); + case Objective::VariableSizedBinPackingWithLeftovers: + // There is no bound on the value of the leftovers. + return false; case Objective::OpenDimensionX: return solution_pool.best().feasible() && open_dimension_x_bound == solution_pool.best().x_max(); @@ -102,7 +105,7 @@ struct Output: packingsolver::Output if (output.bin_packing_bound > bin_packing_bound) bin_packing_bound = output.bin_packing_bound; break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: if (output.variable_sized_bin_packing_bound > variable_sized_bin_packing_bound) variable_sized_bin_packing_bound = output.variable_sized_bin_packing_bound; break; @@ -143,7 +146,7 @@ struct Output: packingsolver::Output case Objective::BinPacking: write_bound(os, width, solution_pool.best().number_of_bins(), bin_packing_bound); break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: write_bound(os, width, solution_pool.best().cost(), variable_sized_bin_packing_bound); break; case Objective::OpenDimensionX: diff --git a/include/packingsolver/rectangle/reduction.hpp b/include/packingsolver/rectangle/reduction.hpp index 04b826779..2d1ba1ac7 100644 --- a/include/packingsolver/rectangle/reduction.hpp +++ b/include/packingsolver/rectangle/reduction.hpp @@ -260,7 +260,8 @@ struct ReductionParameters: optimizationtools::Parameters * measures how far items extend along a given axis * ('Objective::OpenDimensionX'/'OpenDimensionY', or * 'Objective::BinPackingWithLeftovers' with a 'LeftoverMode' that - * depends on that axis - 'X'/'Y' for their own axis, 'Area' for both) + * depends on that axis - 'X'/'Y' for their own axis, 'Area', + * 'AreaCut' and 'Staircase' for both) * must never lift on that axis. Lifting only ever grows an item type's * *declared* dimension in the reduced instance the downstream solve * actually runs on ('reduction_to_instance' carries 'item.rect' over @@ -559,9 +560,11 @@ class Reduction * axis, i.e. 'Objective::OpenDimensionX' (for the 'x' axis) / * 'OpenDimensionY' (for 'y'), or 'Objective::BinPackingWithLeftovers' * with a 'LeftoverMode' that depends on this axis ('LeftoverMode::X' - * for 'x', 'LeftoverMode::Y' for 'y', 'LeftoverMode::Area' for - * either); and 'false' when the compaction along this axis could break - * a constraint: along 'x' with a semi-trailer truck, or with an + * for 'x', 'LeftoverMode::Y' for 'y', 'LeftoverMode::Area', + * 'LeftoverMode::AreaCut' and 'LeftoverMode::Staircase' for either); and + * 'false' when the + * compaction along this axis could break a constraint: along 'x' with + * a semi-trailer truck, or with an * unloading constraint 'OnlyYMovements'/'IncreasingX' (resp. * 'OnlyXMovements'/'IncreasingY' along 'y') - see the class-level doc * comment. Independent of 'lift_item_dimensions_applies()' - both diff --git a/include/packingsolver/rectangle/solution.hpp b/include/packingsolver/rectangle/solution.hpp index 8553fd0d4..7ca93e81b 100644 --- a/include/packingsolver/rectangle/solution.hpp +++ b/include/packingsolver/rectangle/solution.hpp @@ -47,8 +47,8 @@ struct SolutionBin /** Resource consumption, indexed by resource_id. */ std::vector resource_consumption; - /** Leftover value of the bin (see 'LeftoverMode'). */ - Area leftover_value = 0; + /** Leftover value of the bin (see 'leftover_value'). */ + double leftover_value = 0; /** * Staircase leftover value of the bin: the area of the bin which is not @@ -199,22 +199,34 @@ class Solution inline Length y_max() const { return y_max_; } /** - * Get the value of the leftover: the area of the last bin which is not - * used (see 'LeftoverMode'). + * Get the value of the leftover of the last bin (see 'LeftoverMode' and + * 'leftover_value'). */ - inline Profit leftover_value() const { return leftover_value_; } + inline double leftover_value() const { return leftover_value_; } /** Get the staircase leftover value of the last bin of the solution. */ inline Area staircase_leftover_value() const { return staircase_leftover_value_; } - /** Get the sum of the leftover values of the bins of the solution. */ - inline Area total_leftover_value() const { return total_leftover_value_; } + /** + * Get the sum of the leftover values of all the bins of the instance: + * the leftover values of the bins of the solution, and the values of the + * bins which are not used. + */ + double total_leftover_value() const; + + /** + * Get the net cost of the solution, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the cost of its bins + * minus the refunds of their leftovers (see 'Instance::leftover_refund'). + */ + inline Profit net_cost() const { return net_cost_; } /** - * Get the sum of the staircase leftover values of the bins of the - * solution. + * Get the sum of the staircase leftover values of all the bins of the + * instance: the staircase leftover values of the bins of the solution, + * and the areas of the bins which are not used. */ - inline Area total_staircase_leftover_value() const { return total_staircase_leftover_value_; } + inline Area total_staircase_leftover_value() const { return instance().bin_area() - staircase_dominated_area_; } /** * Get the area used by the solution: the area of the bins minus the @@ -314,17 +326,26 @@ class Solution /** Area used by the solution: the area of the bins minus the leftover. */ Area area_ = 0; - /** Value of the leftover: an area (see 'LeftoverMode'). */ - Profit leftover_value_ = 0.0; + /** Value of the leftover of the last bin. */ + double leftover_value_ = 0.0; /** Staircase leftover value of the last bin. */ Area staircase_leftover_value_ = 0; - /** Sum of the leftover values of the bins. */ - Area total_leftover_value_ = 0; + /** + * Sum, over the bins of the solution, of the value of the bin minus its + * leftover value. + */ + double leftover_value_loss_ = 0; + + /** Net cost of the solution. */ + Profit net_cost_ = 0; - /** Sum of the staircase leftover values of the bins. */ - Area total_staircase_leftover_value_ = 0; + /** + * Sum, over the bins of the solution, of the area dominated by the + * staircase of their items. + */ + Area staircase_dominated_area_ = 0; /** Total area of the bins of the solution. */ Area bin_area_ = 0; diff --git a/include/packingsolver/rectangleguillotine/instance.hpp b/include/packingsolver/rectangleguillotine/instance.hpp index b467b48a9..e0027f586 100644 --- a/include/packingsolver/rectangleguillotine/instance.hpp +++ b/include/packingsolver/rectangleguillotine/instance.hpp @@ -163,6 +163,16 @@ struct Parameters /** Cut thickness. */ Length cut_thickness = 0; + /** + * Value of the leftovers, for the 'VariableSizedBinPackingWithLeftovers' + * objective. + * + * The leftovers of a bin are the plate after its last 1-cut and the + * sub-plate after the last 2-cut of its last first-level sub-plate, + * when they are not used. + */ + LeftoverValueType leftover_value_type = LeftoverValueType::SquaredArea; + /** * Costs for the 'BinPackingCuttingCost' objective, indexed by stage * number: index 0 is the cost of a bin (fixed cost per bin, variable @@ -471,6 +481,32 @@ class Instance /** Get bin type i. */ inline const BinType& bin_type(BinTypeId bin_type_id) const { return bin_types_[bin_type_id]; } + /** + * Get the factor which converts a leftover value into a space, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the minimum, over the + * bin types, of the area inside the trims of the bin divided by its leftover + * value when it is empty. + */ + inline double leftover_value_factor() const { return leftover_value_factor_; } + + /** + * Get the refund of a leftover of a bin, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the price of the bin + * per unit of area inside the trims, times the space equivalent to the value of + * the leftover. + * + * The refund of an empty bin is at most its cost; it is equal for the + * bin types which define 'leftover_value_factor()'. + */ + inline Profit leftover_refund( + BinTypeId bin_type_id, + double leftover_value) const + { + const BinType& bin_type = this->bin_type(bin_type_id); + double space = (double)bin_type.area(); + return bin_type.cost / space * leftover_value_factor_ * leftover_value; + } + /** Get the number of bins. */ inline BinPos number_of_bins() const { return bin_type_ids_.size(); } @@ -698,6 +734,9 @@ class Instance /** Bin types. */ std::vector bin_types_; + /** Factor which converts a leftover value into a space. */ + double leftover_value_factor_ = 0; + /** Item types. */ std::vector item_types_; diff --git a/include/packingsolver/rectangleguillotine/instance_builder.hpp b/include/packingsolver/rectangleguillotine/instance_builder.hpp index c87ed55e1..bf4a4f709 100644 --- a/include/packingsolver/rectangleguillotine/instance_builder.hpp +++ b/include/packingsolver/rectangleguillotine/instance_builder.hpp @@ -100,6 +100,9 @@ class InstanceBuilder /** Set cut thickness. */ void set_cut_thickness(Length cut_thickness) { instance_.parameters_.cut_thickness = cut_thickness; } + /** Set the value of the leftovers. */ + void set_leftover_value_type(LeftoverValueType leftover_value_type) { instance_.parameters_.leftover_value_type = leftover_value_type; } + /** * Set the fixed cost of stage 'stage_id' (0 for the bin, 1 to * number_of_stages + 1 for cuts), for the 'BinPackingCuttingCost' diff --git a/include/packingsolver/rectangleguillotine/optimize.hpp b/include/packingsolver/rectangleguillotine/optimize.hpp index 794586e3a..e58fb7ca7 100644 --- a/include/packingsolver/rectangleguillotine/optimize.hpp +++ b/include/packingsolver/rectangleguillotine/optimize.hpp @@ -67,6 +67,9 @@ struct Output: packingsolver::Output case Objective::VariableSizedBinPacking: return solution_pool.best().feasible() && equal_cost(variable_sized_bin_packing_bound, solution_pool.best().cost()); + case Objective::VariableSizedBinPackingWithLeftovers: + // There is no bound on the value of the leftovers. + return false; case Objective::OpenDimensionX: return solution_pool.best().feasible() && open_dimension_x_bound == solution_pool.best().width(); @@ -102,7 +105,7 @@ struct Output: packingsolver::Output if (output.bin_packing_bound > bin_packing_bound) bin_packing_bound = output.bin_packing_bound; break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: if (output.variable_sized_bin_packing_bound > variable_sized_bin_packing_bound) variable_sized_bin_packing_bound = output.variable_sized_bin_packing_bound; break; @@ -143,7 +146,7 @@ struct Output: packingsolver::Output case Objective::BinPacking: write_bound(os, width, solution_pool.best().number_of_bins(), bin_packing_bound); break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: write_bound(os, width, solution_pool.best().cost(), variable_sized_bin_packing_bound); break; case Objective::OpenDimensionX: diff --git a/include/packingsolver/rectangleguillotine/solution.hpp b/include/packingsolver/rectangleguillotine/solution.hpp index 112d72975..e7b82f738 100644 --- a/include/packingsolver/rectangleguillotine/solution.hpp +++ b/include/packingsolver/rectangleguillotine/solution.hpp @@ -70,6 +70,13 @@ struct SolutionBin /** Resource consumption, indexed by resource_id. */ std::vector resource_consumption; + + /** + * Value of the leftovers of the bin: the plate after its last 1-cut and + * the sub-plate after the last 2-cut of its last first-level sub-plate, + * when they are not used (see 'Parameters::leftover_value_type'). + */ + double leftover_value = 0; }; bool operator==(const SolutionBin& solution_bin_1, const SolutionBin& solution_bin_2); @@ -260,6 +267,21 @@ class Solution /** Get the second leftover value. */ inline Area second_leftover_value() const { return second_leftover_value_; } + /** + * Get the sum of the leftover values of all the bins of the instance: + * the leftover values of the bins of the solution (see + * 'SolutionBin::leftover_value'), and the values of the bins which are + * not used. + */ + double total_leftover_value() const; + + /** + * Get the net cost of the solution, for the + * 'VariableSizedBinPackingWithLeftovers' objective: the cost of its bins + * minus the refunds of their leftovers (see 'Instance::leftover_refund'). + */ + inline Profit net_cost() const { return net_cost_; } + /* * Others */ @@ -418,6 +440,15 @@ class Solution /** Value (area) of the second leftover. */ Area second_leftover_value_ = 0; + /** + * Sum, over the bins of the solution, of the value of the bin minus its + * leftover value. + */ + double leftover_value_loss_ = 0; + + /** Net cost of the solution. */ + Profit net_cost_ = 0; + friend class SolutionBuilder; }; diff --git a/python/packingsolver/__init__.py b/python/packingsolver/__init__.py index af51412de..763ebee31 100644 --- a/python/packingsolver/__init__.py +++ b/python/packingsolver/__init__.py @@ -19,6 +19,7 @@ from ._version import __version__ from ._packingsolver import ( InstanceFormat, + LeftoverValueType, LinearProgrammingSolver, Objective, OptimizationMode, @@ -27,6 +28,7 @@ __all__ = [ "__version__", "InstanceFormat", + "LeftoverValueType", "LinearProgrammingSolver", "Objective", "OptimizationMode", diff --git a/python/packingsolver/box.py b/python/packingsolver/box.py index 98c317db6..4f8198ef5 100644 --- a/python/packingsolver/box.py +++ b/python/packingsolver/box.py @@ -2,6 +2,7 @@ from ._packingsolver import ( InstanceFormat, + LeftoverValueType, LinearProgrammingSolver, Objective, OptimizationMode, diff --git a/python/packingsolver/boxstacks.py b/python/packingsolver/boxstacks.py index 48cc59f61..54565cba7 100644 --- a/python/packingsolver/boxstacks.py +++ b/python/packingsolver/boxstacks.py @@ -2,6 +2,7 @@ from ._packingsolver import ( InstanceFormat, + LeftoverValueType, LinearProgrammingSolver, Objective, OptimizationMode, diff --git a/python/packingsolver/irregular.py b/python/packingsolver/irregular.py index fbac76b3a..632ced89c 100644 --- a/python/packingsolver/irregular.py +++ b/python/packingsolver/irregular.py @@ -2,6 +2,7 @@ from ._packingsolver import ( InstanceFormat, + LeftoverValueType, LinearProgrammingSolver, Objective, OptimizationMode, diff --git a/python/packingsolver/rectangle.py b/python/packingsolver/rectangle.py index ecebe6928..541551d7d 100644 --- a/python/packingsolver/rectangle.py +++ b/python/packingsolver/rectangle.py @@ -2,6 +2,7 @@ from ._packingsolver import ( InstanceFormat, + LeftoverValueType, LinearProgrammingSolver, Objective, OptimizationMode, diff --git a/python/packingsolver/rectangleguillotine.py b/python/packingsolver/rectangleguillotine.py index 2ce6ab733..1f66fd7e1 100644 --- a/python/packingsolver/rectangleguillotine.py +++ b/python/packingsolver/rectangleguillotine.py @@ -2,6 +2,7 @@ from ._packingsolver import ( InstanceFormat, + LeftoverValueType, LinearProgrammingSolver, Objective, OptimizationMode, diff --git a/python/src/box.cpp b/python/src/box.cpp index 492a0cd22..a5def271c 100644 --- a/python/src/box.cpp +++ b/python/src/box.cpp @@ -38,7 +38,12 @@ void bind_box(nb::module_& m) .value("XY", LeftoverMode::XY) .value("XZ", LeftoverMode::XZ) .value("YZ", LeftoverMode::YZ) - .value("XYZ", LeftoverMode::XYZ); + .value("XYZ", LeftoverMode::XYZ) + .value("XYCut", LeftoverMode::XYCut) + .value("XZCut", LeftoverMode::XZCut) + .value("YZCut", LeftoverMode::YZCut) + .value("XYZCut", LeftoverMode::XYZCut) + .value("Staircase", LeftoverMode::Staircase); /* * Instance @@ -146,6 +151,7 @@ void bind_box(nb::module_& m) .def("read_item_types", &InstanceBuilder::read_item_types, nb::arg("items_path")) .def("set_weight_tolerance", &InstanceBuilder::set_weight_tolerance, nb::arg("weight_tolerance")) .def("set_leftover_mode", &InstanceBuilder::set_leftover_mode, nb::arg("leftover_mode")) + .def("set_leftover_value_type", &InstanceBuilder::set_leftover_value_type, nb::arg("leftover_value_type")) .def("set_leftover_all_bins", &InstanceBuilder::set_leftover_all_bins, nb::arg("leftover_all_bins")) .def("set_static_stability", &InstanceBuilder::set_static_stability, nb::arg("static_stability")) // Bin types. diff --git a/python/src/boxstacks.cpp b/python/src/boxstacks.cpp index 73716fbed..6de461680 100644 --- a/python/src/boxstacks.cpp +++ b/python/src/boxstacks.cpp @@ -71,7 +71,9 @@ void bind_boxstacks(nb::module_& m) nb::enum_(m, "LeftoverMode") .value("X", LeftoverMode::X) .value("Y", LeftoverMode::Y) - .value("XY", LeftoverMode::XY); + .value("XY", LeftoverMode::XY) + .value("XYCut", LeftoverMode::XYCut) + .value("Staircase", LeftoverMode::Staircase); /* * Instance @@ -214,6 +216,7 @@ void bind_boxstacks(nb::module_& m) nb::arg("group_id"), nb::arg("check_weight_constraints")) .def("set_unloading_constraint", &InstanceBuilder::set_unloading_constraint, nb::arg("unloading_constraint")) .def("set_leftover_mode", &InstanceBuilder::set_leftover_mode, nb::arg("leftover_mode")) + .def("set_leftover_value_type", &InstanceBuilder::set_leftover_value_type, nb::arg("leftover_value_type")) .def("set_leftover_all_bins", &InstanceBuilder::set_leftover_all_bins, nb::arg("leftover_all_bins")) // Bin types. .def("add_bin_type", diff --git a/python/src/common.cpp b/python/src/common.cpp index 581c11499..3520c5dab 100644 --- a/python/src/common.cpp +++ b/python/src/common.cpp @@ -47,6 +47,7 @@ void packingsolver::python::bind_common(nb::module_& m) .value("OpenDimensionXY", Objective::OpenDimensionXY) .value("Knapsack", Objective::Knapsack) .value("VariableSizedBinPacking", Objective::VariableSizedBinPacking) + .value("VariableSizedBinPackingWithLeftovers", Objective::VariableSizedBinPackingWithLeftovers) .value("SequentialOneDimensionalRectangleSubproblem", Objective::SequentialOneDimensionalRectangleSubproblem) .value("Feasibility", Objective::Feasibility) .value("BinPackingCuttingCost", Objective::BinPackingCuttingCost); @@ -58,6 +59,10 @@ void packingsolver::python::bind_common(nb::module_& m) .value("NotAnytimeSequential", OptimizationMode::NotAnytimeSequential) .value("Exact", OptimizationMode::Exact); + nb::enum_(m, "LeftoverValueType") + .value("SquaredArea", LeftoverValueType::SquaredArea) + .value("Depth", LeftoverValueType::Depth); + nb::enum_(m, "InstanceFormat") .value("Csv", InstanceFormat::Csv) .value("Json", InstanceFormat::Json); diff --git a/python/src/irregular.cpp b/python/src/irregular.cpp index 743320314..f5f217664 100644 --- a/python/src/irregular.cpp +++ b/python/src/irregular.cpp @@ -276,7 +276,15 @@ void bind_irregular(nb::module_& m) .value("Left", LeftoverMode::Left) .value("Right", LeftoverMode::Right) .value("Bottom", LeftoverMode::Bottom) - .value("Top", LeftoverMode::Top); + .value("Top", LeftoverMode::Top) + .value("BottomLeftCut", LeftoverMode::BottomLeftCut) + .value("BottomRightCut", LeftoverMode::BottomRightCut) + .value("TopLeftCut", LeftoverMode::TopLeftCut) + .value("TopRightCut", LeftoverMode::TopRightCut) + .value("BottomLeftStaircase", LeftoverMode::BottomLeftStaircase) + .value("BottomRightStaircase", LeftoverMode::BottomRightStaircase) + .value("TopLeftStaircase", LeftoverMode::TopLeftStaircase) + .value("TopRightStaircase", LeftoverMode::TopRightStaircase); /* * Instance @@ -286,6 +294,7 @@ void bind_irregular(nb::module_& m) .def_ro("quality_rules", &irregular::Parameters::quality_rules) .def_ro("item_item_minimum_spacing", &irregular::Parameters::item_item_minimum_spacing) .def_ro("leftover_mode", &irregular::Parameters::leftover_mode) + .def_ro("leftover_value_type", &irregular::Parameters::leftover_value_type) .def_ro("leftover_all_bins", &irregular::Parameters::leftover_all_bins) .def_ro("scale_value", &irregular::Parameters::scale_value) .def_ro("open_dimension_xy_aspect_ratio", &irregular::Parameters::open_dimension_xy_aspect_ratio); @@ -450,6 +459,7 @@ void bind_irregular(nb::module_& m) .def("set_open_dimension_xy_aspect_ratio", &InstanceBuilder::set_open_dimension_xy_aspect_ratio, nb::arg("open_dimension_xy_aspect_ratio")) .def("set_leftover_mode", &InstanceBuilder::set_leftover_mode, nb::arg("leftover_mode")) + .def("set_leftover_value_type", &InstanceBuilder::set_leftover_value_type, nb::arg("leftover_value_type")) .def("set_leftover_all_bins", &InstanceBuilder::set_leftover_all_bins, nb::arg("leftover_all_bins")) // Bin types. .def("add_bin_type", diff --git a/python/src/rectangle.cpp b/python/src/rectangle.cpp index bdd1641f0..26e601178 100644 --- a/python/src/rectangle.cpp +++ b/python/src/rectangle.cpp @@ -23,7 +23,9 @@ void bind_rectangle(nb::module_& m) nb::enum_(m, "LeftoverMode") .value("Area", LeftoverMode::Area) .value("X", LeftoverMode::X) - .value("Y", LeftoverMode::Y); + .value("Y", LeftoverMode::Y) + .value("AreaCut", LeftoverMode::AreaCut) + .value("Staircase", LeftoverMode::Staircase); // 'None' is a Python keyword. nb::enum_(m, "UnloadingConstraint") @@ -115,6 +117,7 @@ void bind_rectangle(nb::module_& m) nb::arg("group_id"), nb::arg("check_weight_constraints")) .def("set_unloading_constraint", &InstanceBuilder::set_unloading_constraint, nb::arg("unloading_constraint")) .def("set_leftover_mode", &InstanceBuilder::set_leftover_mode, nb::arg("leftover_mode")) + .def("set_leftover_value_type", &InstanceBuilder::set_leftover_value_type, nb::arg("leftover_value_type")) .def("set_leftover_all_bins", &InstanceBuilder::set_leftover_all_bins, nb::arg("leftover_all_bins")) // Bin types. .def("add_bin_type", diff --git a/python/src/rectangleguillotine.cpp b/python/src/rectangleguillotine.cpp index 56c468463..cfa0e0665 100644 --- a/python/src/rectangleguillotine.cpp +++ b/python/src/rectangleguillotine.cpp @@ -109,6 +109,7 @@ void bind_rectangleguillotine(nb::module_& m) .def_ro("maximum_number_2_cuts", &rectangleguillotine::Parameters::maximum_number_2_cuts) .def_ro("cut_through_defects", &rectangleguillotine::Parameters::cut_through_defects) .def_ro("cut_thickness", &rectangleguillotine::Parameters::cut_thickness) + .def_ro("leftover_value_type", &rectangleguillotine::Parameters::leftover_value_type) .def_ro("cutting_costs", &rectangleguillotine::Parameters::cutting_costs) .def_ro("waste_cost", &rectangleguillotine::Parameters::waste_cost); @@ -257,6 +258,7 @@ void bind_rectangleguillotine(nb::module_& m) .def("set_cut_through_defects", &InstanceBuilder::set_cut_through_defects, nb::arg("cut_through_defects")) .def("set_cut_thickness", &InstanceBuilder::set_cut_thickness, nb::arg("cut_thickness")) + .def("set_leftover_value_type", &InstanceBuilder::set_leftover_value_type, nb::arg("leftover_value_type")) .def("set_fixed_cutting_cost", &InstanceBuilder::set_fixed_cutting_cost, nb::arg("stage_id"), nb::arg("fixed_cost")) .def("set_variable_cutting_cost", &InstanceBuilder::set_variable_cutting_cost, diff --git a/python/tests/test_leftover_modes.py b/python/tests/test_leftover_modes.py index 5f4dc346d..cec4b8bb4 100644 --- a/python/tests/test_leftover_modes.py +++ b/python/tests/test_leftover_modes.py @@ -1,9 +1,11 @@ -"""The leftover modes of the 'box' and 'boxstacks' problem types, and the -nested length of the items of the 'onedimensional' problem type.""" +"""The leftover modes of the 'box' and 'boxstacks' problem types, the +leftover value types, and the nested length of the items of the +'onedimensional' problem type.""" import packingsolver.box as psb import packingsolver.boxstacks as psbs import packingsolver.onedimensional as pso +import packingsolver.rectangle as psr def solve(module, instance): @@ -13,8 +15,8 @@ def solve(module, instance): def test_box_leftover_modes(): - # 12 items of 30 x 20 x 10 in a 100 x 50 x 40 bin: the best leftover of - # each mode. + # 12 items of 30 x 20 x 10 in a 100 x 50 x 40 bin: the volume of the best + # leftover of each mode (its value is its squared volume). expected = { psb.LeftoverMode.X: 40 * 50 * 40, psb.LeftoverMode.Y: 100 * 30 * 40, @@ -29,7 +31,7 @@ def test_box_leftover_modes(): instance_builder.add_item_type(30, 20, 10, copies=12) solution = solve(psb, instance_builder.build()) assert solution.number_of_bins() == 1 - assert solution.leftover_value() == leftover_value, leftover_mode + assert solution.leftover_value() == leftover_value ** 2, leftover_mode def test_boxstacks_leftover_modes(): @@ -44,7 +46,27 @@ def test_boxstacks_leftover_modes(): instance_builder.add_item_type(30, 20, 10, copies=12) solution = solve(psbs, instance_builder.build()) assert solution.number_of_bins() == 1 - assert solution.leftover_value() >= leftover_value, leftover_mode + assert solution.leftover_value() >= leftover_value ** 2, leftover_mode + + +def test_rectangle_leftover_value_type(): + # Nine 3 x 2 items in a 12 x 10 bin. Valued by its squared area, the best + # leftover is the L-shape around a 9 x 6 block (area 66). Valued by depth, + # it is the 6 x 10 rectangle on the right of two columns of items (area + # 60, value 6^2 (3 * 10 - 6) / 12 = 72). + expected = { + psr.LeftoverValueType.SquaredArea: 66 ** 2, + psr.LeftoverValueType.Depth: 72, + } + for leftover_value_type, leftover_value in expected.items(): + instance_builder = psr.InstanceBuilder() + instance_builder.set_objective(psr.Objective.BinPackingWithLeftovers) + instance_builder.set_leftover_value_type(leftover_value_type) + instance_builder.add_bin_type(12, 10, copies=1) + instance_builder.add_item_type(3, 2, oriented=True, copies=9) + solution = solve(psr, instance_builder.build()) + assert solution.number_of_bins() == 1 + assert abs(solution.leftover_value() - leftover_value) <= 1e-6, leftover_value_type def test_onedimensional_item_nested_length(): diff --git a/scripts/generate_doc_examples.py b/scripts/generate_doc_examples.py index d7554af81..519093fb2 100644 --- a/scripts/generate_doc_examples.py +++ b/scripts/generate_doc_examples.py @@ -56,6 +56,21 @@ "--scale", "0.5", ]) +print("objective_variable_sized_bin_packing_with_leftovers") +subprocess.run([ + os.path.join(bin_dir, "packingsolver_rectangle"), + "--input", os.path.join(ex, "rectangle", "objective_variable_sized_bin_packing_with_leftovers", "instance.json"), + "--certificate", os.path.join(ex, "rectangle", "objective_variable_sized_bin_packing_with_leftovers", "solution.csv"), + "--time-limit", "5", +], stdout=open(os.path.join(ex, "rectangle", "objective_variable_sized_bin_packing_with_leftovers", "output.txt"), "w"), stderr=subprocess.STDOUT) +subprocess.run([ + sys.executable, os.path.join("scripts", "visualize_rectangle.py"), + os.path.join(ex, "rectangle", "objective_variable_sized_bin_packing_with_leftovers", "solution.csv"), + "--output", os.path.join(img, "objective_variable_sized_bin_packing_with_leftovers_solution.png"), + "--columns", "1", + "--scale", "0.5", +]) + print("objective_open_dimension_x") subprocess.run([ os.path.join(bin_dir, "packingsolver_rectangle"), diff --git a/src/algorithms/column_generation.hpp b/src/algorithms/column_generation.hpp index 08230cf96..319afff2b 100644 --- a/src/algorithms/column_generation.hpp +++ b/src/algorithms/column_generation.hpp @@ -259,7 +259,7 @@ columngenerationsolver::Model get_model( { columngenerationsolver::Model model; - if (instance.objective() == Objective::VariableSizedBinPacking + if (is_variable_sized_bin_packing(instance.objective()) || instance.objective() == Objective::BinPacking || instance.objective() == Objective::Feasibility) { model.objective_sense = optimizationtools::ObjectiveDirection::Minimize; @@ -278,7 +278,7 @@ columngenerationsolver::Model get_model( row.coefficient_upper_bound = 1; model.rows.push_back(row); } - if (instance.objective() == Objective::VariableSizedBinPacking + if (is_variable_sized_bin_packing(instance.objective()) || instance.objective() == Objective::BinPacking || instance.objective() == Objective::Feasibility || instance.objective() == Objective::Knapsack) { @@ -317,7 +317,7 @@ std::vector> solution_to_columns( Solution extra_solution(instance); extra_solution.append_bin(solution, bin_pos, 1); Column column; - if (instance.objective() == Objective::VariableSizedBinPacking + if (is_variable_sized_bin_packing(instance.objective()) || instance.objective() == Objective::BinPacking) { column.objective_coefficient = extra_solution.cost() / multiplier_cost; } else if (instance.objective() == Objective::Feasibility) { @@ -413,7 +413,7 @@ PricingOutput ColumnGenerationPricingSolver::infinity(); - if (instance_.objective() == Objective::VariableSizedBinPacking + if (is_variable_sized_bin_packing(instance_.objective()) || instance_.objective() == Objective::BinPacking) { threshold = (solve_feasibility? 0: bin_type.cost / multiplier_cost) - duals[bin_type_id]; @@ -706,7 +706,7 @@ PricingOutput ColumnGenerationPricingSolver::infinity(); if (std::isfinite(overcost_goal) && maximum_number_of_bins > 0) { Profit overcost_target = -std::numeric_limits::infinity(); - if (instance_.objective() == Objective::VariableSizedBinPacking + if (is_variable_sized_bin_packing(instance_.objective()) || instance_.objective() == Objective::BinPacking || instance_.objective() == Objective::Feasibility) { // The reduced cost bound is at most 0. @@ -749,7 +749,7 @@ PricingOutput ColumnGenerationPricingSolver(new Solution(extra_solution)); - if (instance_.objective() == Objective::VariableSizedBinPacking + if (is_variable_sized_bin_packing(instance_.objective()) || instance_.objective() == Objective::BinPacking) { column.objective_coefficient = extra_solution.cost() / multiplier_cost; } else if (instance_.objective() == Objective::Feasibility) { @@ -1820,7 +1820,7 @@ Output column_generation( (cgslds_output.bound == std::numeric_limits::infinity()); if (bound_proves_infeasible) { algorithm_formatter.update_is_proven_infeasible(); - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { double multiplier_cost = largest_power_of_two_lesser_or_equal(instance.largest_bin_cost()); algorithm_formatter.update_variable_sized_bin_packing_bound( cgslds_output.bound * multiplier_cost); diff --git a/src/algorithms/common.cpp b/src/algorithms/common.cpp index e02a5fa04..9274c40af 100644 --- a/src/algorithms/common.cpp +++ b/src/algorithms/common.cpp @@ -54,6 +54,40 @@ std::ostream& packingsolver::operator<<( return os; } +std::istream& packingsolver::operator>>( + std::istream& in, + LeftoverValueType& leftover_value_type) +{ + std::string token; + in >> token; + if (token == "squared-area" + || token == "SquaredArea") { + leftover_value_type = LeftoverValueType::SquaredArea; + } else if (token == "depth" + || token == "Depth") { + leftover_value_type = LeftoverValueType::Depth; + } else { + in.setstate(std::ios_base::failbit); + } + return in; +} + +std::ostream& packingsolver::operator<<( + std::ostream& os, + LeftoverValueType leftover_value_type) +{ + switch (leftover_value_type) { + case LeftoverValueType::SquaredArea: { + os << "SquaredArea"; + break; + } case LeftoverValueType::Depth: { + os << "Depth"; + break; + } + } + return os; +} + std::istream& packingsolver::operator>>( std::istream& in, ProblemType& problem_type) @@ -160,6 +194,10 @@ std::istream& packingsolver::operator>>( || token == "VariableSizedBinPacking" || token == "VBPP") { objective = Objective::VariableSizedBinPacking; + } else if (token == "variable-sized-bin-packing-with-leftovers" + || token == "VariableSizedBinPackingWithLeftovers" + || token == "VBPPL") { + objective = Objective::VariableSizedBinPackingWithLeftovers; } else if (token == "sequential-onedimensional-rectangle-subproblem" || token == "SequentialOneDimensionalRectangleSubproblem" || token == "BDRS") { @@ -206,6 +244,9 @@ std::ostream& packingsolver::operator<<( } case Objective::VariableSizedBinPacking: { os << "VariableSizedBinPacking"; break; + } case Objective::VariableSizedBinPackingWithLeftovers: { + os << "VariableSizedBinPackingWithLeftovers"; + break; } case Objective::SequentialOneDimensionalRectangleSubproblem: { os << "SequentialOneDimensionalRectangleSubproblem"; break; diff --git a/src/algorithms/leftover.hpp b/src/algorithms/leftover.hpp new file mode 100644 index 000000000..8ecacd68c --- /dev/null +++ b/src/algorithms/leftover.hpp @@ -0,0 +1,378 @@ +#pragma once + +#include "packingsolver/algorithms/common.hpp" + +#include +#include +#include +#include +#include + +namespace packingsolver +{ + +/** + * Value of a leftover. + * + * The leftover of a bin is the bin minus the box used by its items, the used + * box being in a corner of the bin. On an axis, the used box may span the + * whole bin, in which case the leftover is a box; otherwise it is an L-shape + * (in two dimensions) or a box minus a corner box (in three dimensions). + * + * The value of a leftover is the integral, over the points of the leftover, + * of their distance to the edge of the leftover, the distance being the + * infinity norm (the half side of the largest square, or cube, centered on + * the point and included in the leftover). Equivalently, it is the integral, + * over t, of the area (or volume) of the leftover shrunk by t on every side. + * + * It is the area of the leftover times the average distance of its points to + * its edge: a leftover which is thin, or split into small pieces, is worth + * less than a compact leftover of the same area. The value of a w x h + * rectangle, h <= w, is h^2 (3w - h) / 12, and the value of a square of side + * s is s^3 / 6. + * + * The leftover shrunk by t is the bin shrunk by t minus the used box grown by + * t, so its area (or volume) is: + * prod_i (D_i - 2t) - prod_i min(u_i, D_i - 2t) + * where 'D' are the dimensions of the bin and 'u' the dimensions of the used + * box. It is a polynomial of degree at most 3 between two consecutive values + * of t where an arm of the leftover vanishes, (D_i - u_i) / 2, so Simpson's + * rule computes the integral exactly on each of these intervals. + */ +template +double leftover_value( + const std::array& bin_dimensions, + const std::array& used_dimensions) +{ + static_assert(N >= 1 && N <= 3, "leftover_value: 1 to 3 dimensions"); + + // Area (or volume) of the leftover shrunk by t. + auto shrunk_leftover = [&bin_dimensions, &used_dimensions](double t) + { + double bin = 1.0; + double used = 1.0; + for (std::size_t i = 0; i < N; ++i) { + double d = (std::max)(0.0, bin_dimensions[i] - 2 * t); + double u = (std::max)(0.0, used_dimensions[i]); + bin *= d; + used *= (std::min)(u, d); + } + return (std::max)(0.0, bin - used); + }; + + double t_max = bin_dimensions[0] / 2; + for (std::size_t i = 1; i < N; ++i) + t_max = (std::min)(t_max, bin_dimensions[i] / 2); + if (t_max <= 0) + return 0.0; + + // Breakpoints. This function is called for each node of the tree + // searches, so they are stored in a fixed-size array. + std::array breakpoints; + std::size_t number_of_breakpoints = 0; + breakpoints[number_of_breakpoints++] = 0.0; + breakpoints[number_of_breakpoints++] = t_max; + for (std::size_t i = 0; i < N; ++i) { + double t = (bin_dimensions[i] - used_dimensions[i]) / 2; + if (t > 0 && t < t_max) + breakpoints[number_of_breakpoints++] = t; + } + std::sort(breakpoints.begin(), breakpoints.begin() + number_of_breakpoints); + + // Simpson's rule on each interval. + double value = 0.0; + for (std::size_t pos = 0; pos + 1 < number_of_breakpoints; ++pos) { + double t1 = breakpoints[pos]; + double t2 = breakpoints[pos + 1]; + if (t2 <= t1) + continue; + value += (t2 - t1) / 6 * ( + shrunk_leftover(t1) + + 4 * shrunk_leftover((t1 + t2) / 2) + + shrunk_leftover(t2)); + } + return value; +} + +/** + * Value of a box: the value of the leftover of a bin of these dimensions with + * no used box (see 'leftover_value'). + */ +template +double box_leftover_value( + const std::array& dimensions) +{ + std::array used_dimensions; + used_dimensions.fill(0.0); + return leftover_value(dimensions, used_dimensions); +} + +/** + * Value of a leftover which is cut into boxes, given the value of a box. + * + * The leftover, a bin minus a used box in a corner, is cut into boxes with + * guillotine cuts along the faces of the used box: a cut along axis i at u_i + * splits the leftover into the box beyond the cut and the leftover of the + * bin of dimension u_i along axis i, which is cut in turn along the other + * axes ('axes' is the bit mask of the axes which are not cut yet). The value + * is the largest, over the orders of the cuts, of the sum of the values of + * the boxes. + */ +template +double cut_leftover_value( + const std::array& bin_dimensions, + const std::array& used_dimensions, + const BoxValue& box_value, + unsigned axes = (1u << N) - 1) +{ + double best = -1; + for (std::size_t i = 0; i < N; ++i) { + if (!(axes & (1u << i))) + continue; + if (used_dimensions[i] >= bin_dimensions[i]) + continue; + // Box beyond the cut. + std::array box = bin_dimensions; + box[i] = bin_dimensions[i] - (std::max)(0.0, used_dimensions[i]); + double v = box_value(box); + // Rest of the leftover. + std::array rest = bin_dimensions; + rest[i] = (std::max)(0.0, used_dimensions[i]); + v += cut_leftover_value(rest, used_dimensions, box_value, axes & ~(1u << i)); + best = (std::max)(best, v); + } + // If no cut is possible, the rest is entirely used. + return (best < 0)? 0.0: best; +} + +/** + * Value of a leftover which is cut into boxes, the value of a box being + * given by 'box_leftover_value'. + */ +template +double cut_leftover_value( + const std::array& bin_dimensions, + const std::array& used_dimensions) +{ + return cut_leftover_value( + bin_dimensions, + used_dimensions, + [](const std::array& box) { return box_leftover_value(box); }); +} + +/** + * Area (or volume) of the leftover of a bin minus a used box in a corner. + */ +template +double leftover_area( + const std::array& bin_dimensions, + const std::array& used_dimensions) +{ + double bin = 1.0; + double used = 1.0; + for (std::size_t i = 0; i < N; ++i) { + bin *= bin_dimensions[i]; + used *= (std::min)( + bin_dimensions[i], + (std::max)(0.0, used_dimensions[i])); + } + return bin - used; +} + +/** + * Value of the leftover of a bin minus a used box in a corner, kept whole + * ('cut' false) or cut into boxes ('cut' true), for a leftover value type. + * + * With 'LeftoverValueType::SquaredArea', the value is the square of the area + * (or volume) of the leftover, or the sum of the squares of the areas of its + * pieces if it is cut. + */ +template +double leftover_value( + LeftoverValueType leftover_value_type, + const std::array& bin_dimensions, + const std::array& used_dimensions, + bool cut) +{ + switch (leftover_value_type) { + case LeftoverValueType::SquaredArea: { + if (cut) { + return cut_leftover_value( + bin_dimensions, + used_dimensions, + [](const std::array& box) + { + double area = 1.0; + for (std::size_t i = 0; i < N; ++i) + area *= box[i]; + return area * area; + }); + } + double area = leftover_area(bin_dimensions, used_dimensions); + return area * area; + } case LeftoverValueType::Depth: { + return (cut)? + cut_leftover_value(bin_dimensions, used_dimensions): + leftover_value(bin_dimensions, used_dimensions); + } + } + return 0.0; +} + +/** + * Volume of the union of the boxes [0, e[0]] x ... x [0, e[N - 1]], for the + * extents 'e' given. + */ +template +struct CornerBoxesUnionVolume +{ + static double compute(std::vector> extents) + { + // By decreasing last coordinate: between two consecutive values of + // the last coordinate, the section of the union is the union of the + // sections of the boxes whose last coordinate is greater. + std::sort( + extents.begin(), + extents.end(), + []( + const std::array& extent_1, + const std::array& extent_2) + { + return extent_1[N - 1] > extent_2[N - 1]; + }); + double volume = 0; + std::vector> sections; + for (std::size_t pos = 0; pos < extents.size(); ++pos) { + std::array section; + for (std::size_t i = 0; i < N - 1; ++i) + section[i] = extents[pos][i]; + sections.push_back(section); + double next = (pos + 1 < extents.size())? extents[pos + 1][N - 1]: 0.0; + double height = extents[pos][N - 1] - next; + if (height > 0) + volume += CornerBoxesUnionVolume::compute(sections) * height; + } + return volume; + } +}; + +template <> +struct CornerBoxesUnionVolume<1> +{ + static double compute(const std::vector>& extents) + { + double length = 0; + for (const auto& extent: extents) + length = (std::max)(length, extent[0]); + return length; + } +}; + +/** + * Value of a staircase leftover: a bin minus the union of the boxes between + * its corner and the extents given (the staircase of its items), for a + * leftover value type. + * + * With 'LeftoverValueType::Depth', the value is computed as for an L-shape + * (see 'leftover_value'): the leftover shrunk by t is the bin shrunk by t + * minus the union of the boxes of dimensions min(e_i, D_i - 2t), whose + * volume is a polynomial of degree at most N between two consecutive values + * of t where a step of the staircase vanishes, (D_i - e_i) / 2. + */ +template +double staircase_leftover_value( + LeftoverValueType leftover_value_type, + const std::array& bin_dimensions, + const std::vector>& extents) +{ + // Volume of the leftover shrunk by t. + auto shrunk_leftover = [&bin_dimensions, &extents](double t) + { + double bin = 1.0; + std::array shrunk_bin; + for (std::size_t i = 0; i < N; ++i) { + shrunk_bin[i] = (std::max)(0.0, bin_dimensions[i] - 2 * t); + bin *= shrunk_bin[i]; + } + std::vector> clipped_extents = extents; + for (auto& extent: clipped_extents) + for (std::size_t i = 0; i < N; ++i) + extent[i] = (std::min)(shrunk_bin[i], (std::max)(0.0, extent[i])); + return (std::max)(0.0, bin - CornerBoxesUnionVolume::compute(clipped_extents)); + }; + + if (leftover_value_type == LeftoverValueType::SquaredArea) { + double area = shrunk_leftover(0.0); + return area * area; + } + + double t_max = bin_dimensions[0] / 2; + for (std::size_t i = 1; i < N; ++i) + t_max = (std::min)(t_max, bin_dimensions[i] / 2); + if (t_max <= 0) + return 0.0; + + // Breakpoints. + std::vector breakpoints = {0.0, t_max}; + for (const auto& extent: extents) { + for (std::size_t i = 0; i < N; ++i) { + double t = (bin_dimensions[i] - extent[i]) / 2; + if (t > 0 && t < t_max) + breakpoints.push_back(t); + } + } + std::sort(breakpoints.begin(), breakpoints.end()); + breakpoints.erase( + std::unique(breakpoints.begin(), breakpoints.end()), + breakpoints.end()); + + // Simpson's rule on each interval. + double value = 0.0; + double previous = shrunk_leftover(breakpoints[0]); + for (std::size_t pos = 0; pos + 1 < breakpoints.size(); ++pos) { + double t1 = breakpoints[pos]; + double t2 = breakpoints[pos + 1]; + double next = shrunk_leftover(t2); + value += (t2 - t1) / 6 * ( + previous + + 4 * shrunk_leftover((t1 + t2) / 2) + + next); + previous = next; + } + return value; +} + +/** + * Return 'true' iff a leftover value 'value_1' is strictly greater than a + * leftover value 'value_2'. + * + * With 'LeftoverValueType::SquaredArea', the values only depend on integer + * lengths, through products and sums, so they are compared without + * tolerance; with 'LeftoverValueType::Depth', they are compared with a + * relative tolerance. + */ +inline bool strictly_greater_leftover_value( + LeftoverValueType leftover_value_type, + double value_1, + double value_2) +{ + return (leftover_value_type == LeftoverValueType::SquaredArea)? + value_1 > value_2: + strictly_greater_profit(value_1, value_2); +} + +/** + * Get a length from a leftover value in two dimensions, for the comparisons + * with an absolute tolerance on lengths: the fourth root of a squared area, + * the cube root of a value of type 'LeftoverValueType::Depth'. + */ +inline double leftover_value_length_2d( + LeftoverValueType leftover_value_type, + double value) +{ + return (leftover_value_type == LeftoverValueType::SquaredArea)? + std::sqrt(std::sqrt(value)): + std::cbrt(value); +} + +} diff --git a/src/algorithms/sequential_value_correction.hpp b/src/algorithms/sequential_value_correction.hpp index d4c4e8f01..258cf33d5 100644 --- a/src/algorithms/sequential_value_correction.hpp +++ b/src/algorithms/sequential_value_correction.hpp @@ -190,7 +190,7 @@ SequentialValueCorrectionOutput sequential_value_cor // boost the initial profits of the item types competing for scarce bins. std::vector item_type_ids_by_decreasing_space; std::vector> item_type_fits_bin_type; - if (instance.objective() == Objective::VariableSizedBinPacking + if (is_variable_sized_bin_packing(instance.objective()) && (parameters.restrict_bin_types || parameters.scarce_item_types_profit_factor_exponent != 0.0)) { item_type_ids_by_decreasing_space.resize(instance.number_of_item_types()); @@ -334,7 +334,7 @@ SequentialValueCorrectionOutput sequential_value_cor // Find bin types to try. std::vector bin_type_ids; - if (instance.objective() == Objective::VariableSizedBinPacking) { + if (is_variable_sized_bin_packing(instance.objective())) { // Start with mandatory bins (bin types with copies_min > 0). BinTypeId smallest_mandatory_bin_type_id = -1; for (BinTypeId bin_type_id = 0; @@ -418,7 +418,7 @@ SequentialValueCorrectionOutput sequential_value_cor for (const auto& fixed_item: bin_type.fixed_items) bin_fixed_copies[fixed_item.item_type_id]++; - if (instance.objective() == Objective::VariableSizedBinPacking + if (is_variable_sized_bin_packing(instance.objective()) && solutions_cur[bin_type_id].first.number_of_items() > 0) { // Check if previous solution is still valid. bool valid = true; @@ -558,7 +558,7 @@ SequentialValueCorrectionOutput sequential_value_cor // If the objective is VariableSizedBinPacking and the // current solution is full, check if it is the new best // solution. - if (instance.objective() == Objective::VariableSizedBinPacking + if (is_variable_sized_bin_packing(instance.objective()) && solution.number_of_items() + number_of_copies * kp_solution.number_of_items() == instance.number_of_items()) { @@ -623,7 +623,7 @@ SequentialValueCorrectionOutput sequential_value_cor // above already tries every not-yet-exhausted bin type as a // candidate every iteration, so none of them being useful // here genuinely does mean none ever will be. - if (instance.objective() == Objective::VariableSizedBinPacking) + if (is_variable_sized_bin_packing(instance.objective())) break; solution.append_empty_bin(bin_type_ids[0], 1); continue; diff --git a/src/algorithms/staircase.hpp b/src/algorithms/staircase.hpp index 369c41bfc..71a73cca1 100644 --- a/src/algorithms/staircase.hpp +++ b/src/algorithms/staircase.hpp @@ -61,6 +61,12 @@ class Staircase2D /** Get the area of the union of the rectangles. */ inline Area area() const { return area_; } + /** + * Get the non-dominated extents (x, y) of the rectangles, by decreasing + * x. + */ + inline const std::vector>& extents() const { return extents_; } + private: /** @@ -129,6 +135,9 @@ class Staircase3D /** Get the volume of the union of the boxes. */ inline Volume volume() const { return volume_; } + /** Get the non-dominated extents (x, y, z) of the boxes. */ + inline const std::vector>& extents() const { return extents_; } + private: /** Non-dominated extents. */ diff --git a/src/box/algorithm_formatter.cpp b/src/box/algorithm_formatter.cpp index db8268d98..0998723f5 100644 --- a/src/box/algorithm_formatter.cpp +++ b/src/box/algorithm_formatter.cpp @@ -118,7 +118,7 @@ void AlgorithmFormatter::print_header() << std::setw(32) << "-------" << std::endl; break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { *os_ << std::setw(12) << "Time" << std::setw(14) << "Cost" @@ -204,7 +204,7 @@ void AlgorithmFormatter::print( << std::setw(32) << s << std::endl; break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { *os_ << std::setw(12) << std::fixed << std::setprecision(3) << output_.time << std::defaultfloat << std::setprecision(precision) << std::setw(14) << output_.solution_pool.best().cost() @@ -369,7 +369,7 @@ void AlgorithmFormatter::update_bounds( case Objective::BinPacking: update_bin_packing_bound(output.bin_packing_bound); break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: update_variable_sized_bin_packing_bound(output.variable_sized_bin_packing_bound); break; case Objective::OpenDimensionX: diff --git a/src/box/instance.cpp b/src/box/instance.cpp index e936f1265..9bbce12b2 100644 --- a/src/box/instance.cpp +++ b/src/box/instance.cpp @@ -1,5 +1,7 @@ #include "packingsolver/box/instance.hpp" +#include "algorithms/leftover.hpp" + #include #include #include @@ -109,6 +111,16 @@ std::istream& box::operator>>( leftover_mode = LeftoverMode::YZ; } else if (token == "xyz" || token == "XYZ") { leftover_mode = LeftoverMode::XYZ; + } else if (token == "xy-cut" || token == "XYCut") { + leftover_mode = LeftoverMode::XYCut; + } else if (token == "xz-cut" || token == "XZCut") { + leftover_mode = LeftoverMode::XZCut; + } else if (token == "yz-cut" || token == "YZCut") { + leftover_mode = LeftoverMode::YZCut; + } else if (token == "xyz-cut" || token == "XYZCut") { + leftover_mode = LeftoverMode::XYZCut; + } else if (token == "staircase" || token == "Staircase") { + leftover_mode = LeftoverMode::Staircase; } else { in.setstate(std::ios_base::failbit); } @@ -141,11 +153,57 @@ std::ostream& box::operator<<( } case LeftoverMode::XYZ: { os << "XYZ"; break; + } case LeftoverMode::XYCut: { + os << "XYCut"; + break; + } case LeftoverMode::XZCut: { + os << "XZCut"; + break; + } case LeftoverMode::YZCut: { + os << "YZCut"; + break; + } case LeftoverMode::XYZCut: { + os << "XYZCut"; + break; + } case LeftoverMode::Staircase: { + os << "Staircase"; + break; } } return os; } +double box::leftover_value( + LeftoverValueType leftover_value_type, + LeftoverMode leftover_mode, + const Box& bin, + Length x_max, + Length y_max, + Length z_max) +{ + Box used_box = leftover_mode_used_box(leftover_mode, bin, x_max, y_max, z_max); + return packingsolver::leftover_value<3>( + leftover_value_type, + {(double)bin.x, (double)bin.y, (double)bin.z}, + {(double)used_box.x, (double)used_box.y, (double)used_box.z}, + leftover_mode_cut(leftover_mode)); +} + +double box::staircase_leftover_value( + LeftoverValueType leftover_value_type, + const Box& bin, + const std::vector>& extents) +{ + std::vector> extents_dbl; + extents_dbl.reserve(extents.size()); + for (const auto& extent: extents) + extents_dbl.push_back({(double)extent[0], (double)extent[1], (double)extent[2]}); + return packingsolver::staircase_leftover_value<3>( + leftover_value_type, + {(double)bin.x, (double)bin.y, (double)bin.z}, + extents_dbl); +} + std::ostream& box::operator<<( std::ostream& os, Point xyz) @@ -237,6 +295,7 @@ std::ostream& Instance::format( if (this->objective() == Objective::BinPackingWithLeftovers) { os << "Leftover mode: " << this->parameters().leftover_mode << std::endl + << "Leftover value type: " << this->parameters().leftover_value_type << std::endl << "Leftover all bins: " << this->parameters().leftover_all_bins << std::endl ; } @@ -402,6 +461,11 @@ void Instance::write_json( ss << parameters().leftover_mode; j["leftover_mode"] = ss.str(); } + { + std::stringstream ss; + ss << parameters().leftover_value_type; + j["leftover_value_type"] = ss.str(); + } j["leftover_all_bins"] = parameters().leftover_all_bins; j["static_stability"] = parameters().static_stability; diff --git a/src/box/instance_builder.cpp b/src/box/instance_builder.cpp index 40d3a2687..91184115f 100644 --- a/src/box/instance_builder.cpp +++ b/src/box/instance_builder.cpp @@ -712,6 +712,8 @@ void InstanceBuilder::read_parameters( } else if (name == "leftover_mode") { LeftoverMode leftover_mode = read_enum(value, name); set_leftover_mode(leftover_mode); + } else if (name == "leftover_value_type") { + set_leftover_value_type(read_enum(value, name)); } else if (name == "leftover_all_bins") { set_leftover_all_bins(value == "1" || value == "true"); } else if (name == "static_stability") { @@ -940,6 +942,11 @@ void InstanceBuilder::read( "leftover_mode"); set_leftover_mode(leftover_mode); } + if (j.contains("leftover_value_type")) { + set_leftover_value_type(read_enum( + j["leftover_value_type"].get(), + "leftover_value_type")); + } if (j.contains("leftover_all_bins")) set_leftover_all_bins(j["leftover_all_bins"]); if (j.contains("static_stability")) @@ -1298,6 +1305,25 @@ Instance InstanceBuilder::build() if (original_instance_ != nullptr) copy_cache_from_original_instance(); + // Compute the factor which converts a leftover value into a space. + instance_.leftover_value_factor_ = 0; + for (const BinType& bin_type: instance_.bin_types_) { + double space = (double)bin_type.volume(); + double value = box::leftover_value( + instance_.parameters_.leftover_value_type, + instance_.parameters_.leftover_mode, + bin_type.box, + 0, + 0, + 0); + if (value <= 0) + continue; + if (instance_.leftover_value_factor_ == 0 + || space / value < instance_.leftover_value_factor_) { + instance_.leftover_value_factor_ = space / value; + } + } + return std::move(instance_); } diff --git a/src/box/main.cpp b/src/box/main.cpp index 2e8e10375..7a89a81e8 100644 --- a/src/box/main.cpp +++ b/src/box/main.cpp @@ -76,7 +76,8 @@ int main(int argc, char *argv[]) ("no-item-rotation", "") ("objective,f", po::value(), "Objective") - ("leftover-mode,", po::value(), "Leftover mode (bin-packing-with-leftovers): X, Y, Z, XY, XZ, YZ, XYZ") + ("leftover-mode,", po::value(), "Leftover mode (bin-packing-with-leftovers): X, Y, Z, XY, XZ, YZ, XYZ, XYCut, XZCut, YZCut, XYZCut, Staircase") + ("leftover-value-type,", po::value(), "Leftover value type (bin-packing-with-leftovers): area, depth") ("leftover-all-bins", po::value(), "also compare the leftover values of all the bins") ("static-stability", po::value(), "require the solutions to be in static mechanical equilibrium") @@ -196,6 +197,8 @@ int main(int argc, char *argv[]) instance_builder.set_objective(vm["objective"].as()); if (vm.count("leftover-mode")) instance_builder.set_leftover_mode(vm["leftover-mode"].as()); + if (vm.count("leftover-value-type")) + instance_builder.set_leftover_value_type(vm["leftover-value-type"].as()); if (vm.count("leftover-all-bins")) instance_builder.set_leftover_all_bins(vm["leftover-all-bins"].as()); if (vm.count("static-stability")) diff --git a/src/box/optimize.cpp b/src/box/optimize.cpp index f4d26f70b..099377b00 100644 --- a/src/box/optimize.cpp +++ b/src/box/optimize.cpp @@ -42,7 +42,7 @@ void optimize_onedimensional_bound( // the same cost), so the bound the onedimensional solver finds for it // (which runs the same dichotomic search) is a valid lower bound here. onedimensional::InstanceBuilder onedim_instance_builder; - onedim_instance_builder.set_objective(instance.objective()); + onedim_instance_builder.set_objective(onedimensional_subproblem_objective(instance.objective())); for (BinTypeId bin_type_id = 0; bin_type_id < instance.number_of_bin_types(); ++bin_type_id) { @@ -105,7 +105,7 @@ void optimize_onedimensional_bound( algorithm_formatter.update_knapsack_bound( onedim_output.knapsack_bound + negative_penalty_sum(instance)); break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { algorithm_formatter.update_variable_sized_bin_packing_bound( onedim_output.variable_sized_bin_packing_bound); break; @@ -661,7 +661,7 @@ packingsolver::box::Output packingsolver::box::optimize( if (instance.objective() == Objective::BinPacking || instance.objective() == Objective::BinPackingWithLeftovers || instance.objective() == Objective::Knapsack - || instance.objective() == Objective::VariableSizedBinPacking + || is_variable_sized_bin_packing(instance.objective()) || instance.objective() == Objective::Feasibility) { optimize_onedimensional_bound( instance, @@ -726,7 +726,7 @@ packingsolver::box::Output packingsolver::box::optimize( // single bin but 'VariableSizedBinPacking' (through the sequential // feasibility algorithm for the objectives other than 'Knapsack' and // 'Feasibility'). - if (instance.objective() == Objective::VariableSizedBinPacking) + if (is_variable_sized_bin_packing(instance.objective())) use_tree_search_maximal_spaces = false; // Automatic selection. if (!use_tree_search @@ -858,7 +858,7 @@ packingsolver::box::Output packingsolver::box::optimize( } } } - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { // Disable algorithms which are not available for this objective. use_tree_search_maximal_spaces = false; if (instance.number_of_bin_types() == 1) { diff --git a/src/box/reduction.cpp b/src/box/reduction.cpp index ab689eacf..d7342eb03 100644 --- a/src/box/reduction.cpp +++ b/src/box/reduction.cpp @@ -318,7 +318,7 @@ bool Reduction::remove_dominated_bin_types_applies(const Instance& instance) // available earlier than the original instance allows. if (instance.objective() != Objective::Knapsack && instance.objective() != Objective::Feasibility - && instance.objective() != Objective::VariableSizedBinPacking) { + && !is_variable_sized_bin_packing(instance.objective())) { return false; } return instance.number_of_bin_types() > 1; @@ -801,18 +801,9 @@ bool Reduction::lift_item_dimensions_applies_axis( return false; if (instance.objective() == Objective::BinPackingWithLeftovers) { LeftoverMode leftover_mode = instance.parameters().leftover_mode; - bool x = (leftover_mode == LeftoverMode::X - || leftover_mode == LeftoverMode::XY - || leftover_mode == LeftoverMode::XZ - || leftover_mode == LeftoverMode::XYZ); - bool y = (leftover_mode == LeftoverMode::Y - || leftover_mode == LeftoverMode::XY - || leftover_mode == LeftoverMode::YZ - || leftover_mode == LeftoverMode::XYZ); - bool z = (leftover_mode == LeftoverMode::Z - || leftover_mode == LeftoverMode::XZ - || leftover_mode == LeftoverMode::YZ - || leftover_mode == LeftoverMode::XYZ); + bool x = leftover_mode_along_x(leftover_mode); + bool y = leftover_mode_along_y(leftover_mode); + bool z = leftover_mode_along_z(leftover_mode); if ((axis == 0 && x) || (axis == 1 && y) || (axis == 2 && z)) return false; } diff --git a/src/box/sequential_feasibility.cpp b/src/box/sequential_feasibility.cpp index ab9605fb7..9aa18b24a 100644 --- a/src/box/sequential_feasibility.cpp +++ b/src/box/sequential_feasibility.cpp @@ -29,7 +29,7 @@ int shrunk_dimension( return 2; } default: { switch (instance.parameters().leftover_mode) { - case LeftoverMode::Y: case LeftoverMode::YZ: { + case LeftoverMode::Y: case LeftoverMode::YZ: case LeftoverMode::YZCut: { return 1; } case LeftoverMode::Z: { return 2; diff --git a/src/box/solution.cpp b/src/box/solution.cpp index 49e7de31f..e9ae00ca4 100644 --- a/src/box/solution.cpp +++ b/src/box/solution.cpp @@ -2,6 +2,7 @@ #include "box/static_stability.hpp" +#include "algorithms/leftover.hpp" #include "algorithms/staircase.hpp" #include "optimizationtools/utils/utils.hpp" @@ -115,23 +116,47 @@ void Solution::update_indicators( } // Update the leftover values. The volume used in a bin is the box from - // its origin to its items, the rest of the bin being the leftover (see - // 'LeftoverMode'). + // its origin to its items (see 'LeftoverMode'). Box used_box = leftover_mode_used_box( instance().parameters().leftover_mode, bin_type.box, bin_x_max, bin_y_max, bin_z_max); - bin.leftover_value = bin_type.volume() - used_box.volume(); + bin.leftover_value = (instance().parameters().leftover_mode == LeftoverMode::Staircase)? + box::staircase_leftover_value( + instance().parameters().leftover_value_type, + bin_type.box, + staircase.extents()): + box::leftover_value( + instance().parameters().leftover_value_type, + instance().parameters().leftover_mode, + bin_type.box, + bin_x_max, + bin_y_max, + bin_z_max); bin.staircase_leftover_value = bin_type.volume() - staircase.volume(); - total_leftover_value_ += bin.copies * bin.leftover_value; - total_staircase_leftover_value_ += bin.copies * bin.staircase_leftover_value; + leftover_value_loss_ += bin.copies * ( + box::leftover_value( + instance().parameters().leftover_value_type, + instance().parameters().leftover_mode, + bin_type.box, + 0, + 0, + 0) + - bin.leftover_value); + net_cost_ += bin.copies * ( + bin_type.cost + - instance().leftover_refund(bin.bin_type_id, bin.leftover_value)); + staircase_dominated_volume_ += bin.copies * staircase.volume(); if (bin_pos == (BinPos)bins_.size() - 1) { x_max_ = bin_x_max; y_max_ = bin_y_max; z_max_ = bin_z_max; - volume_ = bin_volume_ - bin.leftover_value; + Volume used_volume = (instance().parameters().leftover_mode == LeftoverMode::Staircase)? + staircase.volume(): + used_box.volume(); + volume_ = bin_volume_ - (bin_type.volume() - used_volume); leftover_value_ = bin.leftover_value; staircase_leftover_value_ = bin.staircase_leftover_value; } @@ -206,6 +231,24 @@ void Solution::append_empty_bin( update_indicators(bins_.size() - 1); } +double Solution::total_leftover_value() const +{ + double value = 0; + for (BinTypeId bin_type_id = 0; + bin_type_id < instance().number_of_bin_types(); + ++bin_type_id) { + const BinType& bin_type = instance().bin_type(bin_type_id); + value += bin_type.copies * box::leftover_value( + instance().parameters().leftover_value_type, + instance().parameters().leftover_mode, + bin_type.box, + 0, + 0, + 0); + } + return value - leftover_value_loss_; +} + bool Solution::operator<(const Solution& solution) const { // Check feasibility. @@ -220,8 +263,11 @@ bool Solution::operator<(const Solution& solution) const } case Objective::BinPackingWithLeftovers: { if (solution.number_of_bins() != number_of_bins()) return solution.number_of_bins() < number_of_bins(); - if (solution.leftover_value() != leftover_value()) - return solution.leftover_value() > leftover_value(); + LeftoverValueType leftover_value_type = instance().parameters().leftover_value_type; + if (strictly_greater_leftover_value(leftover_value_type, solution.leftover_value(), leftover_value())) + return true; + if (strictly_greater_leftover_value(leftover_value_type, leftover_value(), solution.leftover_value())) + return false; // Tie-breaks: the staircase leftover value of the last bin, then, if // 'leftover_all_bins', the leftover value and the staircase leftover // value of all the bins. @@ -229,9 +275,14 @@ bool Solution::operator<(const Solution& solution) const return solution.staircase_leftover_value() > staircase_leftover_value(); if (!instance().parameters().leftover_all_bins) return false; - if (solution.total_leftover_value() != total_leftover_value()) - return solution.total_leftover_value() > total_leftover_value(); - return solution.total_staircase_leftover_value() > total_staircase_leftover_value(); + // The leftover values of all the bins, used or not, are compared + // through the value lost in the used bins, the values of the bins + // being the same for both solutions. + if (strictly_greater_leftover_value(leftover_value_type, leftover_value_loss_, solution.leftover_value_loss_)) + return true; + if (strictly_greater_leftover_value(leftover_value_type, solution.leftover_value_loss_, leftover_value_loss_)) + return false; + return solution.staircase_dominated_volume_ < staircase_dominated_volume_; } case Objective::OpenDimensionX: { return solution.x_max() < x_max(); } case Objective::OpenDimensionY: { @@ -244,6 +295,15 @@ bool Solution::operator<(const Solution& solution) const return strictly_greater_profit(solution.profit(), profit()); } case Objective::VariableSizedBinPacking: { return strictly_lesser_cost(solution.cost(), cost()); + } case Objective::VariableSizedBinPackingWithLeftovers: { + // The net cost: the cost of the bins minus the refunds of their + // leftovers (see 'Instance::leftover_refund'), and then the staircase + // leftover values. + if (strictly_lesser_cost(solution.net_cost(), net_cost())) + return true; + if (strictly_lesser_cost(net_cost(), solution.net_cost())) + return false; + return solution.staircase_dominated_volume_ < staircase_dominated_volume_; } default: { std::stringstream ss; ss << FUNC_SIGNATURE << ": " @@ -328,6 +388,7 @@ nlohmann::json Solution::to_json() const {"LeftoverValue", leftover_value()}, {"StaircaseLeftoverValue", staircase_leftover_value()}, {"TotalLeftoverValue", total_leftover_value()}, + {"NetCost", net_cost()}, {"TotalStaircaseLeftoverValue", total_staircase_leftover_value()}, {"Waste", waste()}, {"WastePercentage", waste_percentage()}, @@ -372,6 +433,7 @@ void Solution::format( << "Leftover value: " << leftover_value() << std::endl << "Staircase leftover value: " << staircase_leftover_value() << std::endl << "Total leftover value: " << total_leftover_value() << std::endl + << "Net cost: " << net_cost() << std::endl << "Total staircase leftover value: " << total_staircase_leftover_value() << std::endl ; } diff --git a/src/box/tree_search.cpp b/src/box/tree_search.cpp index 3bf214903..71d85984f 100644 --- a/src/box/tree_search.cpp +++ b/src/box/tree_search.cpp @@ -433,12 +433,13 @@ BranchingScheme::Node BranchingScheme::child_tmp( } const BinType& bin_type_orig = this->instance().bin_type(bin_type_id); LeftoverMode leftover_mode = this->instance().parameters().leftover_mode; - node.leftover_value = bin_type_orig.volume() - leftover_mode_used_box( + node.leftover_value = leftover_value( + this->instance().parameters().leftover_value_type, leftover_mode, bin_type_orig.box, x_max, y_max, - z_max).volume(); + z_max); // Update the staircase of the last bin. if (insertion.new_bin > 0) { // New bin. @@ -467,6 +468,12 @@ BranchingScheme::Node BranchingScheme::child_tmp( item_used_box.z); node.last_bin_staircase_leftover_value = bin_type_orig.volume() - node.last_bin_staircase.volume(); + if (leftover_mode == LeftoverMode::Staircase) { + node.leftover_value = staircase_leftover_value( + this->instance().parameters().leftover_value_type, + bin_type_orig.box, + node.last_bin_staircase.extents()); + } } node.id = node_id_++; @@ -780,7 +787,7 @@ bool BranchingScheme::better( const std::shared_ptr& node_2) const { switch (instance().objective()) { - case Objective::BinPacking: case Objective::VariableSizedBinPacking: { + case Objective::BinPacking: case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { if (!leaf(node_1)) return false; if (!leaf(node_2)) @@ -840,7 +847,7 @@ bool BranchingScheme::bound( const std::shared_ptr& node_2) const { switch (instance().objective()) { - case Objective::BinPacking: case Objective::VariableSizedBinPacking: { + case Objective::BinPacking: case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { if (!leaf(node_2)) return false; BinPos bin_pos = -1; diff --git a/src/box/tree_search.hpp b/src/box/tree_search.hpp index f80df63c4..b9b7535be 100644 --- a/src/box/tree_search.hpp +++ b/src/box/tree_search.hpp @@ -182,7 +182,7 @@ class BranchingScheme * 'BinPackingWithLeftovers' objective (see 'LeftoverMode'). It can * only decrease when items are added to the last bin. */ - Volume leftover_value = 0; + double leftover_value = 0; /** * Staircase of the items of the last bin, in the frame of the @@ -196,8 +196,14 @@ class BranchingScheme */ Volume last_bin_staircase_leftover_value = 0; - /** Sum of the leftover values of the bins but the last one. */ - Volume previous_bins_leftover_value = 0; + /** + * Sum of the leftover values of the bins but the last one. + * + * Two nodes with the same number of bins have the same bin types, so + * comparing these sums is the same as comparing the leftover values + * of all the bins of the instance. + */ + double previous_bins_leftover_value = 0; /** Sum of the staircase leftover values of the bins but the last one. */ Volume previous_bins_staircase_leftover_value = 0; diff --git a/src/boxstacks/algorithm_formatter.cpp b/src/boxstacks/algorithm_formatter.cpp index f57c57cf4..543c1ac70 100644 --- a/src/boxstacks/algorithm_formatter.cpp +++ b/src/boxstacks/algorithm_formatter.cpp @@ -107,7 +107,7 @@ void AlgorithmFormatter::print_header() << std::setw(32) << "-------" << std::endl; break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { *os_ << std::setw(12) << "Time" << std::setw(14) << "Cost" @@ -186,7 +186,7 @@ void AlgorithmFormatter::print( << std::setw(32) << s << std::endl; break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { *os_ << std::setw(12) << std::fixed << std::setprecision(3) << output_.time << std::defaultfloat << std::setprecision(precision) << std::setw(14) << output_.solution_pool.best().cost() @@ -303,7 +303,7 @@ void AlgorithmFormatter::update_bounds( case Objective::BinPacking: update_bin_packing_bound(output.bin_packing_bound); break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: update_variable_sized_bin_packing_bound(output.variable_sized_bin_packing_bound); break; default: diff --git a/src/boxstacks/instance.cpp b/src/boxstacks/instance.cpp index 94a658d1e..a0b73b49d 100644 --- a/src/boxstacks/instance.cpp +++ b/src/boxstacks/instance.cpp @@ -1,5 +1,7 @@ #include "packingsolver/boxstacks/instance.hpp" +#include "algorithms/leftover.hpp" + #include #include #include @@ -121,6 +123,10 @@ std::istream& boxstacks::operator>>( leftover_mode = LeftoverMode::Y; } else if (token == "xy" || token == "XY") { leftover_mode = LeftoverMode::XY; + } else if (token == "xy-cut" || token == "XYCut") { + leftover_mode = LeftoverMode::XYCut; + } else if (token == "staircase" || token == "Staircase") { + leftover_mode = LeftoverMode::Staircase; } else { in.setstate(std::ios_base::failbit); } @@ -141,11 +147,47 @@ std::ostream& boxstacks::operator<<( } case LeftoverMode::XY: { os << "XY"; break; + } case LeftoverMode::XYCut: { + os << "XYCut"; + break; + } case LeftoverMode::Staircase: { + os << "Staircase"; + break; } } return os; } +double boxstacks::leftover_value( + LeftoverValueType leftover_value_type, + LeftoverMode leftover_mode, + const Box& bin, + Length x_max, + Length y_max) +{ + Box used_box = leftover_mode_used_box(leftover_mode, bin, x_max, y_max); + return packingsolver::leftover_value<3>( + leftover_value_type, + {(double)bin.x, (double)bin.y, (double)bin.z}, + {(double)used_box.x, (double)used_box.y, (double)used_box.z}, + leftover_mode == LeftoverMode::XYCut); +} + +double boxstacks::staircase_leftover_value( + LeftoverValueType leftover_value_type, + const Box& bin, + const std::vector>& extents) +{ + std::vector> extents_dbl; + extents_dbl.reserve(extents.size()); + for (const auto& extent: extents) + extents_dbl.push_back({(double)extent[0], (double)extent[1], (double)bin.z}); + return packingsolver::staircase_leftover_value<3>( + leftover_value_type, + {(double)bin.x, (double)bin.y, (double)bin.z}, + extents_dbl); +} + std::ostream& Instance::format( std::ostream& os, int verbosity_level) const @@ -157,6 +199,7 @@ std::ostream& Instance::format( if (objective() == Objective::BinPackingWithLeftovers) { os << "Leftover mode: " << parameters_.leftover_mode << std::endl + << "Leftover value type: " << parameters_.leftover_value_type << std::endl << "Leftover all bins: " << parameters_.leftover_all_bins << std::endl ; } @@ -384,6 +427,11 @@ void Instance::write_json( ss << parameters_.leftover_mode; j["leftover_mode"] = ss.str(); } + { + std::stringstream ss; + ss << parameters_.leftover_value_type; + j["leftover_value_type"] = ss.str(); + } j["leftover_all_bins"] = parameters_.leftover_all_bins; j["no_check_weight_constraints"] = nlohmann::json::array(); for (GroupId group_id = 0; @@ -595,6 +643,7 @@ void Instance::write_parameters( << "objective," << objective() << std::endl << "unloading-constraint," << parameters_.unloading_constraint << std::endl << "leftover-mode," << parameters_.leftover_mode << std::endl + << "leftover-value-type," << parameters_.leftover_value_type << std::endl << "leftover-all-bins," << parameters_.leftover_all_bins << std::endl ; for (GroupId group_id = 0; diff --git a/src/boxstacks/instance_builder.cpp b/src/boxstacks/instance_builder.cpp index 7c33e7a88..4edb71430 100644 --- a/src/boxstacks/instance_builder.cpp +++ b/src/boxstacks/instance_builder.cpp @@ -770,6 +770,8 @@ void InstanceBuilder::read_parameters( } if (name == "leftover-mode" || name == "leftover_mode") { LeftoverMode leftover_mode = read_enum(value, name); set_leftover_mode(leftover_mode); + } if (name == "leftover-value-type" || name == "leftover_value_type") { + set_leftover_value_type(read_enum(value, name)); } if (name == "leftover-all-bins" || name == "leftover_all_bins") { set_leftover_all_bins(value == "1" || value == "true"); } if (name == "no-check-weight-constraints") { @@ -1109,6 +1111,11 @@ void InstanceBuilder::read( "leftover_mode"); set_leftover_mode(leftover_mode); } + if (j.contains("leftover_value_type")) { + set_leftover_value_type(read_enum( + j["leftover_value_type"].get(), + "leftover_value_type")); + } if (j.contains("leftover_all_bins")) set_leftover_all_bins(j["leftover_all_bins"]); if (j.contains("unloading_constraint")) { @@ -1457,5 +1464,23 @@ Instance InstanceBuilder::build() instance_.item_types_[fixed_item.item_type_id].copies_fixed += bin_type.copies; } + // Compute the factor which converts a leftover value into a space. + instance_.leftover_value_factor_ = 0; + for (const BinType& bin_type: instance_.bin_types_) { + double space = (double)bin_type.volume(); + double value = boxstacks::leftover_value( + instance_.parameters_.leftover_value_type, + instance_.parameters_.leftover_mode, + bin_type.box, + 0, + 0); + if (value <= 0) + continue; + if (instance_.leftover_value_factor_ == 0 + || space / value < instance_.leftover_value_factor_) { + instance_.leftover_value_factor_ = space / value; + } + } + return std::move(instance_); } diff --git a/src/boxstacks/main.cpp b/src/boxstacks/main.cpp index 09cb55213..61c4ef297 100644 --- a/src/boxstacks/main.cpp +++ b/src/boxstacks/main.cpp @@ -75,7 +75,8 @@ int main(int argc, char *argv[]) ("no-item-rotation", "") ("objective,f", po::value(), "Objective") - ("leftover-mode,", po::value(), "Leftover mode (bin-packing-with-leftovers): X, Y, XY") + ("leftover-mode,", po::value(), "Leftover mode (bin-packing-with-leftovers): X, Y, XY, XYCut, Staircase") + ("leftover-value-type,", po::value(), "Leftover value type (bin-packing-with-leftovers): area, depth") ("leftover-all-bins", po::value(), "also compare the leftover values of all the bins") ("unloading-constraint,", po::value(), "") @@ -197,6 +198,8 @@ int main(int argc, char *argv[]) instance_builder.set_objective(vm["objective"].as()); if (vm.count("leftover-mode")) instance_builder.set_leftover_mode(vm["leftover-mode"].as()); + if (vm.count("leftover-value-type")) + instance_builder.set_leftover_value_type(vm["leftover-value-type"].as()); if (vm.count("leftover-all-bins")) instance_builder.set_leftover_all_bins(vm["leftover-all-bins"].as()); if (vm.count("unloading-constraint")) diff --git a/src/boxstacks/optimize.cpp b/src/boxstacks/optimize.cpp index aabc27bf6..127f4b7ec 100644 --- a/src/boxstacks/optimize.cpp +++ b/src/boxstacks/optimize.cpp @@ -34,7 +34,7 @@ void optimize_onedimensional_bound( // cheaply (dichotomic search), so this stays fast regardless of how // hard the geometric relaxation would be to search. onedimensional::InstanceBuilder onedim_instance_builder; - onedim_instance_builder.set_objective(box_instance.objective()); + onedim_instance_builder.set_objective(onedimensional_subproblem_objective(box_instance.objective())); for (BinTypeId bin_type_id = 0; bin_type_id < box_instance.number_of_bin_types(); ++bin_type_id) { @@ -90,7 +90,7 @@ void optimize_onedimensional_bound( case Objective::BinPacking: algorithm_formatter.update_bin_packing_bound(onedim_output.bin_packing_bound); break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: algorithm_formatter.update_variable_sized_bin_packing_bound(onedim_output.variable_sized_bin_packing_bound); break; default: @@ -618,7 +618,7 @@ packingsolver::boxstacks::Output packingsolver::boxstacks::optimize( && (instance.objective() == Objective::Knapsack || instance.objective() == Objective::BinPacking || instance.objective() == Objective::BinPackingWithLeftovers - || instance.objective() == Objective::VariableSizedBinPacking + || is_variable_sized_bin_packing(instance.objective()) || instance.objective() == Objective::Feasibility)) { optimize_box_bound(instance, parameters, algorithm_formatter); } diff --git a/src/boxstacks/reduction.cpp b/src/boxstacks/reduction.cpp index b03fdb59f..9c711e040 100644 --- a/src/boxstacks/reduction.cpp +++ b/src/boxstacks/reduction.cpp @@ -173,7 +173,7 @@ bool Reduction::remove_dominated_bin_types_applies(const Instance& instance) // available earlier than the original instance allows. if (instance.objective() != Objective::Knapsack && instance.objective() != Objective::Feasibility - && instance.objective() != Objective::VariableSizedBinPacking) { + && !is_variable_sized_bin_packing(instance.objective())) { return false; } return instance.number_of_bin_types() > 1; @@ -432,7 +432,9 @@ bool Reduction::lift_item_dimensions_applies_axis( return false; if (instance.objective() == Objective::BinPackingWithLeftovers && (leftover_mode == LeftoverMode::X - || leftover_mode == LeftoverMode::XY)) { + || leftover_mode == LeftoverMode::XY + || leftover_mode == LeftoverMode::XYCut + || leftover_mode == LeftoverMode::Staircase)) { return false; } if (instance.bin_type(0).semi_trailer_truck_data.is) @@ -446,7 +448,9 @@ bool Reduction::lift_item_dimensions_applies_axis( return false; if (instance.objective() == Objective::BinPackingWithLeftovers && (leftover_mode == LeftoverMode::Y - || leftover_mode == LeftoverMode::XY)) { + || leftover_mode == LeftoverMode::XY + || leftover_mode == LeftoverMode::XYCut + || leftover_mode == LeftoverMode::Staircase)) { return false; } if (unloading_constraint == rectangle::UnloadingConstraint::OnlyXMovements diff --git a/src/boxstacks/sequential_onedimensional_rectangle.cpp b/src/boxstacks/sequential_onedimensional_rectangle.cpp index fbc9cc76c..56721861d 100644 --- a/src/boxstacks/sequential_onedimensional_rectangle.cpp +++ b/src/boxstacks/sequential_onedimensional_rectangle.cpp @@ -1439,7 +1439,7 @@ SequentialOneDimensionalRectangleOutput sequential_onedimensional_rectangle_x( if (instance.number_of_items() > 0) x_algorithm_formatter.update_bin_packing_bound(1); break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { if (instance.number_of_items() > 0) { Profit cost = std::numeric_limits::infinity(); for (BinTypeId bin_type_id = 0; diff --git a/src/boxstacks/solution.cpp b/src/boxstacks/solution.cpp index 661d1fd25..7f7d28863 100644 --- a/src/boxstacks/solution.cpp +++ b/src/boxstacks/solution.cpp @@ -2,6 +2,7 @@ #include "packingsolver/rectangle/instance.hpp" +#include "algorithms/leftover.hpp" #include "algorithms/staircase.hpp" #include "optimizationtools/utils/utils.hpp" @@ -96,21 +97,44 @@ void Solution::update_indicators( } // Update the leftover values. The volume used in a bin is the box from - // its origin to its stacks, the rest of the bin being the leftover (see - // 'LeftoverMode'). + // its origin to its stacks (see 'LeftoverMode'). Box used_box = leftover_mode_used_box( instance().parameters().leftover_mode, bin_type.box, bin_x_max, bin_y_max); - bin.leftover_value = bin_type.volume() - used_box.volume(); + bin.leftover_value = (instance().parameters().leftover_mode == LeftoverMode::Staircase)? + boxstacks::staircase_leftover_value( + instance().parameters().leftover_value_type, + bin_type.box, + staircase.extents()): + boxstacks::leftover_value( + instance().parameters().leftover_value_type, + instance().parameters().leftover_mode, + bin_type.box, + bin_x_max, + bin_y_max); bin.staircase_leftover_value = bin_type.volume() - staircase.area() * bin_type.box.z; - total_leftover_value_ += bin.copies * bin.leftover_value; - total_staircase_leftover_value_ += bin.copies * bin.staircase_leftover_value; + leftover_value_loss_ += bin.copies * ( + boxstacks::leftover_value( + instance().parameters().leftover_value_type, + instance().parameters().leftover_mode, + bin_type.box, + 0, + 0) + - bin.leftover_value); + net_cost_ += bin.copies * ( + bin_type.cost + - instance().leftover_refund(bin.bin_type_id, bin.leftover_value)); + staircase_dominated_volume_ += bin.copies * staircase.area() * bin_type.box.z; if (bin_pos == (BinPos)bins_.size() - 1) { x_max_ = bin_x_max; y_max_ = bin_y_max; - volume_ = bin_volume_ - bin.leftover_value; + Volume used_volume = (instance().parameters().leftover_mode == LeftoverMode::Staircase)? + staircase.area() * bin_type.box.z: + used_box.volume(); + volume_ = bin_volume_ - (bin_type.volume() - used_volume); + leftover_value_ = bin.leftover_value; staircase_leftover_value_ = bin.staircase_leftover_value; } @@ -308,6 +332,23 @@ void Solution::append_empty_bin( update_indicators(bins_.size() - 1); } +double Solution::total_leftover_value() const +{ + double value = 0; + for (BinTypeId bin_type_id = 0; + bin_type_id < instance().number_of_bin_types(); + ++bin_type_id) { + const BinType& bin_type = instance().bin_type(bin_type_id); + value += bin_type.copies * boxstacks::leftover_value( + instance().parameters().leftover_value_type, + instance().parameters().leftover_mode, + bin_type.box, + 0, + 0); + } + return value - leftover_value_loss_; +} + bool Solution::operator<(const Solution& solution) const { // Check feasibility. @@ -322,8 +363,11 @@ bool Solution::operator<(const Solution& solution) const } case Objective::BinPackingWithLeftovers: { if (solution.number_of_bins() != number_of_bins()) return solution.number_of_bins() < number_of_bins(); - if (solution.leftover_value() != leftover_value()) - return solution.leftover_value() > leftover_value(); + LeftoverValueType leftover_value_type = instance().parameters().leftover_value_type; + if (strictly_greater_leftover_value(leftover_value_type, solution.leftover_value(), leftover_value())) + return true; + if (strictly_greater_leftover_value(leftover_value_type, leftover_value(), solution.leftover_value())) + return false; // Tie-breaks: the staircase leftover value of the last bin, then, if // 'leftover_all_bins', the leftover value and the staircase leftover // value of all the bins. @@ -331,9 +375,14 @@ bool Solution::operator<(const Solution& solution) const return solution.staircase_leftover_value() > staircase_leftover_value(); if (!instance().parameters().leftover_all_bins) return false; - if (solution.total_leftover_value() != total_leftover_value()) - return solution.total_leftover_value() > total_leftover_value(); - return solution.total_staircase_leftover_value() > total_staircase_leftover_value(); + // The leftover values of all the bins, used or not, are compared + // through the value lost in the used bins, the values of the bins + // being the same for both solutions. + if (strictly_greater_leftover_value(leftover_value_type, leftover_value_loss_, solution.leftover_value_loss_)) + return true; + if (strictly_greater_leftover_value(leftover_value_type, solution.leftover_value_loss_, leftover_value_loss_)) + return false; + return solution.staircase_dominated_volume_ < staircase_dominated_volume_; } case Objective::OpenDimensionX: { return solution.x_max() < x_max(); } case Objective::OpenDimensionY: { @@ -344,6 +393,15 @@ bool Solution::operator<(const Solution& solution) const return strictly_greater_profit(solution.profit(), profit()); } case Objective::VariableSizedBinPacking: { return strictly_lesser_cost(solution.cost(), cost()); + } case Objective::VariableSizedBinPackingWithLeftovers: { + // The net cost: the cost of the bins minus the refunds of their + // leftovers (see 'Instance::leftover_refund'), and then the staircase + // leftover values. + if (strictly_lesser_cost(solution.net_cost(), net_cost())) + return true; + if (strictly_lesser_cost(net_cost(), solution.net_cost())) + return false; + return solution.staircase_dominated_volume_ < staircase_dominated_volume_; } default: { std::stringstream ss; ss << FUNC_SIGNATURE << ": " @@ -519,6 +577,7 @@ nlohmann::json Solution::to_json() const {"LeftoverValue", leftover_value()}, {"StaircaseLeftoverValue", staircase_leftover_value()}, {"TotalLeftoverValue", total_leftover_value()}, + {"NetCost", net_cost()}, {"TotalStaircaseLeftoverValue", total_staircase_leftover_value()}, {"Waste", waste()}, {"WastePercentage", waste_percentage()}, @@ -561,6 +620,7 @@ void Solution::format( << "Leftover value: " << leftover_value() << std::endl << "Staircase leftover value: " << staircase_leftover_value() << std::endl << "Total leftover value: " << total_leftover_value() << std::endl + << "Net cost: " << net_cost() << std::endl << "Total staircase leftover value: " << total_staircase_leftover_value() << std::endl ; } diff --git a/src/boxstacks/tree_search.cpp b/src/boxstacks/tree_search.cpp index 5b2e6b7d6..750441907 100644 --- a/src/boxstacks/tree_search.cpp +++ b/src/boxstacks/tree_search.cpp @@ -793,11 +793,12 @@ BranchingScheme::Node BranchingScheme::child_tmp( } const BinType& bin_type_orig = this->instance().bin_type(bin_type_id); LeftoverMode leftover_mode = this->instance().parameters().leftover_mode; - node.leftover_value = bin_type_orig.volume() - leftover_mode_used_box( + node.leftover_value = leftover_value( + this->instance().parameters().leftover_value_type, leftover_mode, bin_type_orig.box, x_max, - y_max).volume(); + y_max); // Update the staircase of the last bin. if (insertion.new_bin > 0) { // New bin. @@ -823,6 +824,12 @@ BranchingScheme::Node BranchingScheme::child_tmp( node.last_bin_staircase_leftover_value = bin_type_orig.volume() - node.last_bin_staircase.area() * bin_type_orig.box.z; + if (leftover_mode == LeftoverMode::Staircase) { + node.leftover_value = staircase_leftover_value( + this->instance().parameters().leftover_value_type, + bin_type_orig.box, + node.last_bin_staircase.extents()); + } } if (instance.unloading_constraint() == rectangle::UnloadingConstraint::IncreasingX) { @@ -1520,7 +1527,7 @@ bool BranchingScheme::better( || node_2->rear_axle_overweight > 0) return true; switch (instance().objective()) { - case Objective::BinPacking: case Objective::VariableSizedBinPacking: { + case Objective::BinPacking: case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { if (!leaf(node_1)) return false; if (!leaf(node_2)) @@ -1584,7 +1591,7 @@ bool BranchingScheme::bound( const std::shared_ptr& node_2) const { switch (instance().objective()) { - case Objective::BinPacking: case Objective::VariableSizedBinPacking: { + case Objective::BinPacking: case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { if (!leaf(node_2)) return false; BinPos bin_pos = -1; diff --git a/src/boxstacks/tree_search.hpp b/src/boxstacks/tree_search.hpp index 57e53464a..cf3146667 100644 --- a/src/boxstacks/tree_search.hpp +++ b/src/boxstacks/tree_search.hpp @@ -242,7 +242,7 @@ class BranchingScheme * 'BinPackingWithLeftovers' objective (see 'LeftoverMode'). It can * only decrease when items are added to the last bin. */ - Volume leftover_value = 0; + double leftover_value = 0; /** * Staircase of the stacks of the last bin, in the frame of the @@ -256,8 +256,14 @@ class BranchingScheme */ Volume last_bin_staircase_leftover_value = 0; - /** Sum of the leftover values of the bins but the last one. */ - Volume previous_bins_leftover_value = 0; + /** + * Sum of the leftover values of the bins but the last one. + * + * Two nodes with the same number of bins have the same bin types, so + * comparing these sums is the same as comparing the leftover values + * of all the bins of the instance. + */ + double previous_bins_leftover_value = 0; /** Sum of the staircase leftover values of the bins but the last one. */ Volume previous_bins_staircase_leftover_value = 0; diff --git a/src/irregular/algorithm_formatter.cpp b/src/irregular/algorithm_formatter.cpp index cbc618fdb..d84df8f14 100644 --- a/src/irregular/algorithm_formatter.cpp +++ b/src/irregular/algorithm_formatter.cpp @@ -122,7 +122,7 @@ void AlgorithmFormatter::print_header() << std::setw(32) << "-------" << std::endl; break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { *os_ << std::setw(12) << "Time" << std::setw(14) << "Cost" @@ -210,7 +210,7 @@ void AlgorithmFormatter::print( << std::setw(32) << s << std::endl; break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { *os_ << std::setw(12) << std::fixed << std::setprecision(3) << output_.time << std::defaultfloat << std::setprecision(precision) << std::setw(14) << output_.solution_pool.best().cost() @@ -383,7 +383,7 @@ void AlgorithmFormatter::update_bounds( case Objective::BinPacking: update_bin_packing_bound(output.bin_packing_bound); break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: update_variable_sized_bin_packing_bound(output.variable_sized_bin_packing_bound); break; case Objective::OpenDimensionX: diff --git a/src/irregular/benders_decomposition.cpp b/src/irregular/benders_decomposition.cpp index 411118606..530a379b9 100644 --- a/src/irregular/benders_decomposition.cpp +++ b/src/irregular/benders_decomposition.cpp @@ -739,7 +739,7 @@ onedimensional::Instance build_master_instance( Profit variable_sized_bin_packing_goal) { onedimensional::InstanceBuilder master_instance_builder; - master_instance_builder.set_objective(instance.objective()); + master_instance_builder.set_objective(onedimensional_subproblem_objective(instance.objective())); master_instance_builder.set_bin_packing_goal(bin_packing_goal); master_instance_builder.set_knapsack_goal(knapsack_goal); master_instance_builder.set_variable_sized_bin_packing_goal(variable_sized_bin_packing_goal); @@ -874,7 +874,7 @@ BendersDecompositionOutput packingsolver::irregular::benders_decomposition( if (instance.objective() != Objective::Knapsack && instance.objective() != Objective::BinPacking - && instance.objective() != Objective::VariableSizedBinPacking) { + && !is_variable_sized_bin_packing(instance.objective())) { std::stringstream ss; ss << FUNC_SIGNATURE << ": " << "objective \"" @@ -1056,7 +1056,7 @@ BendersDecompositionOutput packingsolver::irregular::benders_decomposition( algorithm_formatter.update_knapsack_bound(master_output.knapsack_bound); } else if (instance.objective() == Objective::BinPacking) { algorithm_formatter.update_bin_packing_bound(master_output.bin_packing_bound); - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { algorithm_formatter.update_variable_sized_bin_packing_bound( master_output.variable_sized_bin_packing_bound); } @@ -1073,7 +1073,7 @@ BendersDecompositionOutput packingsolver::irregular::benders_decomposition( master_knapsack_goal = (std::min)( master_knapsack_goal, master_output.knapsack_bound); - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { master_variable_sized_bin_packing_goal = (std::max)( master_variable_sized_bin_packing_goal, master_output.variable_sized_bin_packing_bound); @@ -1095,7 +1095,7 @@ BendersDecompositionOutput packingsolver::irregular::benders_decomposition( } else if (instance.objective() == Objective::BinPacking) { if (master_solution.number_of_bins() >= output.solution_pool.best().number_of_bins()) break; - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { if (master_solution.cost() >= output.solution_pool.best().cost()) break; } diff --git a/src/irregular/instance.cpp b/src/irregular/instance.cpp index 346841a83..8137b08cc 100644 --- a/src/irregular/instance.cpp +++ b/src/irregular/instance.cpp @@ -44,6 +44,38 @@ std::istream& packingsolver::irregular::operator>>( || token == "Top" || token == "t") { leftover_mode = LeftoverMode::Top; + } else if (token == "bottom-left-cut" + || token == "BottomLeftCut" + || token == "blc") { + leftover_mode = LeftoverMode::BottomLeftCut; + } else if (token == "bottom-right-cut" + || token == "BottomRightCut" + || token == "brc") { + leftover_mode = LeftoverMode::BottomRightCut; + } else if (token == "top-left-cut" + || token == "TopLeftCut" + || token == "tlc") { + leftover_mode = LeftoverMode::TopLeftCut; + } else if (token == "top-right-cut" + || token == "TopRightCut" + || token == "trc") { + leftover_mode = LeftoverMode::TopRightCut; + } else if (token == "bottom-left-staircase" + || token == "BottomLeftStaircase" + || token == "bls") { + leftover_mode = LeftoverMode::BottomLeftStaircase; + } else if (token == "bottom-right-staircase" + || token == "BottomRightStaircase" + || token == "brs") { + leftover_mode = LeftoverMode::BottomRightStaircase; + } else if (token == "top-left-staircase" + || token == "TopLeftStaircase" + || token == "tls") { + leftover_mode = LeftoverMode::TopLeftStaircase; + } else if (token == "top-right-staircase" + || token == "TopRightStaircase" + || token == "trs") { + leftover_mode = LeftoverMode::TopRightStaircase; } else { in.setstate(std::ios_base::failbit); } @@ -79,6 +111,30 @@ std::ostream& packingsolver::irregular::operator<<( } case LeftoverMode::Top: { os << "Top"; break; + } case LeftoverMode::BottomLeftCut: { + os << "BottomLeftCut"; + break; + } case LeftoverMode::BottomRightCut: { + os << "BottomRightCut"; + break; + } case LeftoverMode::TopLeftCut: { + os << "TopLeftCut"; + break; + } case LeftoverMode::TopRightCut: { + os << "TopRightCut"; + break; + } case LeftoverMode::BottomLeftStaircase: { + os << "BottomLeftStaircase"; + break; + } case LeftoverMode::BottomRightStaircase: { + os << "BottomRightStaircase"; + break; + } case LeftoverMode::TopLeftStaircase: { + os << "TopLeftStaircase"; + break; + } case LeftoverMode::TopRightStaircase: { + os << "TopRightStaircase"; + break; } } return os; @@ -435,6 +491,7 @@ std::ostream& Instance::format( if (objective() == Objective::BinPackingWithLeftovers) { os << "Leftover mode: " << parameters().leftover_mode << std::endl + << "Leftover value type: " << parameters().leftover_value_type << std::endl << "Leftover all bins: " << parameters().leftover_all_bins << std::endl ; } @@ -899,6 +956,9 @@ void Instance::write( std::stringstream leftover_mode_ss; leftover_mode_ss << parameters().leftover_mode; json["parameters"]["leftover_mode"] = leftover_mode_ss.str(); + std::stringstream leftover_value_type_ss; + leftover_value_type_ss << parameters().leftover_value_type; + json["parameters"]["leftover_value_type"] = leftover_value_type_ss.str(); json["parameters"]["leftover_all_bins"] = parameters().leftover_all_bins; file << std::setw(4) << json << std::endl; diff --git a/src/irregular/instance_builder.cpp b/src/irregular/instance_builder.cpp index 329b0e6c2..53664eab0 100644 --- a/src/irregular/instance_builder.cpp +++ b/src/irregular/instance_builder.cpp @@ -1,4 +1,6 @@ #include "packingsolver/irregular/instance_builder.hpp" + +#include "irregular/leftover.hpp" #include "irregular/instance_cache.hpp" #include @@ -644,6 +646,11 @@ void InstanceBuilder::read( "leftover_mode"); set_leftover_mode(leftover_mode); } + if (json_parameters.contains("leftover_value_type")) { + set_leftover_value_type(read_enum( + json_parameters["leftover_value_type"].get(), + "leftover_value_type")); + } if (json_parameters.contains("leftover_all_bins")) set_leftover_all_bins(json_parameters["leftover_all_bins"]); } @@ -1347,6 +1354,22 @@ Instance InstanceBuilder::build() copy_periodic_packings_from_original_instance(); } + // Compute the factor which converts a leftover value into a space. + instance_.leftover_value_factor_ = 0; + for (const BinType& bin_type: instance_.bin_types_) { + double space = (bin_type.aabb_orig.x_max - bin_type.aabb_orig.x_min) + * (bin_type.aabb_orig.y_max - bin_type.aabb_orig.y_min); + double value = irregular::leftover_value( + instance_.parameters_.leftover_value_type, + bin_type.aabb_orig); + if (value <= 0) + continue; + if (instance_.leftover_value_factor_ == 0 + || space / value < instance_.leftover_value_factor_) { + instance_.leftover_value_factor_ = space / value; + } + } + return std::move(instance_); } diff --git a/src/irregular/leftover.cpp b/src/irregular/leftover.cpp index f4ef8415e..a6414af8e 100644 --- a/src/irregular/leftover.cpp +++ b/src/irregular/leftover.cpp @@ -1,43 +1,90 @@ #include "irregular/leftover.hpp" +#include "algorithms/leftover.hpp" + using namespace packingsolver; using namespace packingsolver::irregular; -AreaDbl packingsolver::irregular::leftover_value( +namespace +{ + +/** + * Get the dimensions of the rectangle used by the items of a bin, from the + * corner (or the side) of the leftover mode to the opposite corner (or side) + * of the bounding box of the items. + */ +std::array used_dimensions( LeftoverMode leftover_mode, const AxisAlignedBoundingBox& bin_aabb, const AxisAlignedBoundingBox& items_aabb) { LengthDbl width = bin_aabb.x_max - bin_aabb.x_min; LengthDbl height = bin_aabb.y_max - bin_aabb.y_min; - switch (leftover_mode) { + LengthDbl from_left = (std::max)(0.0, (std::min)(width, items_aabb.x_max - bin_aabb.x_min)); + LengthDbl from_right = (std::max)(0.0, (std::min)(width, bin_aabb.x_max - items_aabb.x_min)); + LengthDbl from_bottom = (std::max)(0.0, (std::min)(height, items_aabb.y_max - bin_aabb.y_min)); + LengthDbl from_top = (std::max)(0.0, (std::min)(height, bin_aabb.y_max - items_aabb.y_min)); + switch (leftover_mode_base(leftover_mode)) { case LeftoverMode::BottomLeft: { - return width * height - - (items_aabb.x_max - bin_aabb.x_min) * (items_aabb.y_max - bin_aabb.y_min); + return {from_left, from_bottom}; } case LeftoverMode::BottomRight: { - return width * height - - (bin_aabb.x_max - items_aabb.x_min) * (items_aabb.y_max - bin_aabb.y_min); + return {from_right, from_bottom}; } case LeftoverMode::TopLeft: { - return width * height - - (items_aabb.x_max - bin_aabb.x_min) * (bin_aabb.y_max - items_aabb.y_min); + return {from_left, from_top}; } case LeftoverMode::TopRight: { - return width * height - - (bin_aabb.x_max - items_aabb.x_min) * (bin_aabb.y_max - items_aabb.y_min); + return {from_right, from_top}; } case LeftoverMode::Left: { - return width * height - - (items_aabb.x_max - bin_aabb.x_min) * height; + return {from_left, height}; } case LeftoverMode::Right: { - return width * height - - (bin_aabb.x_max - items_aabb.x_min) * height; + return {from_right, height}; } case LeftoverMode::Bottom: { - return width * height - - width * (items_aabb.y_max - bin_aabb.y_min); + return {width, from_bottom}; } case LeftoverMode::Top: { - return width * height - - width * (bin_aabb.y_max - items_aabb.y_min); + return {width, from_top}; + } default: { + return {0, 0}; } } - return 0; +} + +} + +double packingsolver::irregular::leftover_value( + LeftoverValueType leftover_value_type, + LeftoverMode leftover_mode, + const AxisAlignedBoundingBox& bin_aabb, + const AxisAlignedBoundingBox& items_aabb) +{ + std::array bin = { + bin_aabb.x_max - bin_aabb.x_min, + bin_aabb.y_max - bin_aabb.y_min}; + std::array used = used_dimensions(leftover_mode, bin_aabb, items_aabb); + return packingsolver::leftover_value( + leftover_value_type, + bin, + used, + leftover_mode_cut(leftover_mode)); +} + +AreaDbl packingsolver::irregular::leftover_area( + LeftoverMode leftover_mode, + const AxisAlignedBoundingBox& bin_aabb, + const AxisAlignedBoundingBox& items_aabb) +{ + std::array used = used_dimensions(leftover_mode, bin_aabb, items_aabb); + return (bin_aabb.x_max - bin_aabb.x_min) * (bin_aabb.y_max - bin_aabb.y_min) + - used[0] * used[1]; +} + +double packingsolver::irregular::leftover_value( + LeftoverValueType leftover_value_type, + const AxisAlignedBoundingBox& bin_aabb) +{ + return packingsolver::leftover_value<2>( + leftover_value_type, + {bin_aabb.x_max - bin_aabb.x_min, bin_aabb.y_max - bin_aabb.y_min}, + {0, 0}, + false); } void Staircase::add_item( @@ -52,7 +99,7 @@ void Staircase::add_item( LengthDbl width = bin_aabb.x_max - bin_aabb.x_min; LengthDbl height = bin_aabb.y_max - bin_aabb.y_min; std::pair extent; - switch (leftover_mode) { + switch (leftover_mode_base(leftover_mode)) { case LeftoverMode::BottomLeft: { extent = {from_left, from_bottom}; break; @@ -121,3 +168,17 @@ AreaDbl Staircase::leftover_value( * (bin_aabb.y_max - bin_aabb.y_min) - dominated_area(); } + +double Staircase::value( + LeftoverValueType leftover_value_type, + const AxisAlignedBoundingBox& bin_aabb) const +{ + std::vector> extents; + extents.reserve(extents_.size()); + for (const auto& extent: extents_) + extents.push_back({extent.first, extent.second}); + return packingsolver::staircase_leftover_value<2>( + leftover_value_type, + {bin_aabb.x_max - bin_aabb.x_min, bin_aabb.y_max - bin_aabb.y_min}, + extents); +} diff --git a/src/irregular/leftover.hpp b/src/irregular/leftover.hpp index 42a34e7b6..2bd9fb3e6 100644 --- a/src/irregular/leftover.hpp +++ b/src/irregular/leftover.hpp @@ -2,6 +2,8 @@ #include "packingsolver/irregular/instance.hpp" +#include "algorithms/leftover.hpp" + namespace packingsolver { namespace irregular @@ -9,15 +11,40 @@ namespace irregular /** * Get the leftover value of a bin, given the bounding box of the bin and the - * bounding box of its items: the area of the bin minus the area of the - * rectangle between the corner (or the side) of the leftover mode and the - * opposite corner (or side) of the bounding box of the items. + * bounding box of its items (see 'LeftoverMode'), for a leftover value type. + * + * With 'LeftoverValueType::SquaredArea', the value of a leftover is the + * square of its area (the sum of the squares of the areas of its pieces if it + * is cut). With + * 'LeftoverValueType::Depth', it is the integral, over its points, of their + * distance to its edge (see 'algorithms/leftover.hpp'): its area times the + * average distance of its points to its edge, so a compact leftover is worth + * more than a thin one of the same area. + */ +double leftover_value( + LeftoverValueType leftover_value_type, + LeftoverMode leftover_mode, + const AxisAlignedBoundingBox& bin_aabb, + const AxisAlignedBoundingBox& items_aabb); + +/** + * Get the area of the leftover of a bin, given the bounding box of the bin + * and the bounding box of its items (see 'LeftoverMode'): the area of the + * bounding box of the bin minus the area of the rectangle used by the items. */ -AreaDbl leftover_value( +AreaDbl leftover_area( LeftoverMode leftover_mode, const AxisAlignedBoundingBox& bin_aabb, const AxisAlignedBoundingBox& items_aabb); +/** + * Get the leftover value of an empty bin, given its bounding box, for a + * leftover value type. + */ +double leftover_value( + LeftoverValueType leftover_value_type, + const AxisAlignedBoundingBox& bin_aabb); + /** * Staircase of the items of a bin. * @@ -43,6 +70,14 @@ class Staircase /** Get the staircase leftover value of a bin. */ AreaDbl leftover_value(const AxisAlignedBoundingBox& bin_aabb) const; + /** + * Get the value of the staircase leftover of a bin, for a leftover value + * type (for the leftover modes ending with 'Staircase'). + */ + double value( + LeftoverValueType leftover_value_type, + const AxisAlignedBoundingBox& bin_aabb) const; + private: /** diff --git a/src/irregular/main.cpp b/src/irregular/main.cpp index c4f31cd17..51560cb20 100644 --- a/src/irregular/main.cpp +++ b/src/irregular/main.cpp @@ -64,6 +64,7 @@ int main(int argc, char *argv[]) ("item-bin-minimum-spacing", po::value(), "Item-bin minimum spacing") ("item-item-minimum-spacing", po::value(), "Item-item minimum spacing") ("leftover-mode", po::value(), "set leftover mode") + ("leftover-value-type,", po::value(), "Leftover value type (bin-packing-with-leftovers): area, depth") ("leftover-all-bins", po::value(), "also compare the leftover values of all the bins") ("bin-unweighted", "") ("unweighted", "") @@ -160,6 +161,8 @@ int main(int argc, char *argv[]) instance_builder.set_item_item_minimum_spacing(vm["item-item-minimum-spacing"].as()); if (vm.count("leftover-mode")) instance_builder.set_leftover_mode(vm["leftover-mode"].as()); + if (vm.count("leftover-value-type")) + instance_builder.set_leftover_value_type(vm["leftover-value-type"].as()); if (vm.count("leftover-all-bins")) instance_builder.set_leftover_all_bins(vm["leftover-all-bins"].as()); if (vm.count("unweighted")) diff --git a/src/irregular/optimize.cpp b/src/irregular/optimize.cpp index ed240b686..43072df2c 100644 --- a/src/irregular/optimize.cpp +++ b/src/irregular/optimize.cpp @@ -184,7 +184,7 @@ void optimize_onedimensional_bound( AlgorithmFormatter& algorithm_formatter) { onedimensional::InstanceBuilder onedim_instance_builder; - onedim_instance_builder.set_objective(instance.objective()); + onedim_instance_builder.set_objective(onedimensional_subproblem_objective(instance.objective())); for (BinTypeId bin_type_id = 0; bin_type_id < instance.number_of_bin_types(); ++bin_type_id) { @@ -292,7 +292,7 @@ void optimize_onedimensional_bound( algorithm_formatter.update_knapsack_bound( onedim_output.knapsack_bound + negative_penalty_sum(instance)); break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { algorithm_formatter.update_variable_sized_bin_packing_bound( onedim_output.variable_sized_bin_packing_bound); break; @@ -1233,7 +1233,7 @@ packingsolver::irregular::Output packingsolver::irregular::optimize( if (instance.objective() == Objective::BinPacking || instance.objective() == Objective::BinPackingWithLeftovers || instance.objective() == Objective::Knapsack - || instance.objective() == Objective::VariableSizedBinPacking + || is_variable_sized_bin_packing(instance.objective()) || instance.objective() == Objective::Feasibility) { optimize_onedimensional_bound( instance, @@ -1286,7 +1286,7 @@ packingsolver::irregular::Output packingsolver::irregular::optimize( // Benders decomposition only supports these objectives. if (instance.objective() != Objective::Knapsack && instance.objective() != Objective::BinPacking - && instance.objective() != Objective::VariableSizedBinPacking) { + && !is_variable_sized_bin_packing(instance.objective())) { use_benders_decomposition = false; } if (instance.number_of_bins() <= 1) { @@ -1514,7 +1514,7 @@ packingsolver::irregular::Output packingsolver::irregular::optimize( } } } - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { // Disable algorithms which are not available for this objective. use_milp_raster = false; use_local_search_linear_programming = false; diff --git a/src/irregular/reduction.cpp b/src/irregular/reduction.cpp index 529eaeda0..606a53cd6 100644 --- a/src/irregular/reduction.cpp +++ b/src/irregular/reduction.cpp @@ -110,7 +110,7 @@ bool Reduction::remove_dominated_bin_types_applies(const Instance& instance) // available earlier than the original instance allows. if (instance.objective() != Objective::Knapsack && instance.objective() != Objective::Feasibility - && instance.objective() != Objective::VariableSizedBinPacking) { + && !is_variable_sized_bin_packing(instance.objective())) { return false; } return instance.number_of_bin_types() > 1; diff --git a/src/irregular/solution.cpp b/src/irregular/solution.cpp index b66a8b2ef..4fc454131 100644 --- a/src/irregular/solution.cpp +++ b/src/irregular/solution.cpp @@ -99,22 +99,36 @@ void Solution::update_indicators( } if (bin.items.empty()) { - bin.leftover_value = (bin_type.aabb_orig.x_max - bin_type.aabb_orig.x_min) - * (bin_type.aabb_orig.y_max - bin_type.aabb_orig.y_min); + bin.leftover_value = leftover_value( + instance().parameters().leftover_value_type, + bin_type.aabb_orig); } else { AxisAlignedBoundingBox items_aabb; items_aabb.x_min = bin.x_min; items_aabb.y_min = bin.y_min; items_aabb.x_max = bin.x_max; items_aabb.y_max = bin.y_max; - bin.leftover_value = leftover_value( - instance().parameters().leftover_mode, - bin_type.aabb_orig, - items_aabb); + bin.leftover_value = (leftover_mode_staircase(instance().parameters().leftover_mode))? + staircase.value( + instance().parameters().leftover_value_type, + bin_type.aabb_orig): + leftover_value( + instance().parameters().leftover_value_type, + instance().parameters().leftover_mode, + bin_type.aabb_orig, + items_aabb); } bin.staircase_leftover_value = staircase.leftover_value(bin_type.aabb_orig); - total_leftover_value_ += bin.copies * bin.leftover_value; - total_staircase_leftover_value_ += bin.copies * bin.staircase_leftover_value; + leftover_value_loss_ += bin.copies + * (leftover_value(instance().parameters().leftover_value_type, bin_type.aabb_orig) + - bin.leftover_value); + net_cost_ += bin.copies * ( + bin_type.cost + - instance().leftover_refund(bin.bin_type_id, bin.leftover_value)); + staircase_dominated_area_ += bin.copies + * ((bin_type.aabb_orig.x_max - bin_type.aabb_orig.x_min) + * (bin_type.aabb_orig.y_max - bin_type.aabb_orig.y_min) + - bin.staircase_leftover_value); // x_min_/y_min_/x_max_/y_max_ and the leftover value track the last bin only. if (bin_pos == (BinPos)bins_.size() - 1) { @@ -130,7 +144,24 @@ void Solution::update_indicators( x_max_ = bin.x_max; y_max_ = bin.y_max; leftover_value_orig_ = bin.leftover_value; - leftover_value_scaled_ = leftover_value_orig_ * instance().parameters().scale_value; + AxisAlignedBoundingBox items_aabb; + items_aabb.x_min = bin.x_min; + items_aabb.y_min = bin.y_min; + items_aabb.x_max = bin.x_max; + items_aabb.y_max = bin.y_max; + leftover_area_ = (leftover_mode_staircase(instance().parameters().leftover_mode))? + bin.staircase_leftover_value: + irregular::leftover_area( + instance().parameters().leftover_mode, + bin_type.aabb_orig, + items_aabb); + // A value of type 'LeftoverValueType::Depth' scales as a length + // to the power 3, a squared area as a length to the power 4. + double scale_value = instance().parameters().scale_value; + leftover_value_scaled_ = leftover_value_orig_ + * scale_value * scale_value * scale_value; + if (instance().parameters().leftover_value_type == LeftoverValueType::SquaredArea) + leftover_value_scaled_ *= scale_value; } } @@ -400,6 +431,34 @@ Solution::OverlappingItems Solution::compute_overlapping_items( return output; } +double Solution::total_leftover_value() const +{ + double value = 0; + for (BinTypeId bin_type_id = 0; + bin_type_id < instance().number_of_bin_types(); + ++bin_type_id) { + const BinType& bin_type = instance().bin_type(bin_type_id); + value += bin_type.copies * leftover_value( + instance().parameters().leftover_value_type, + bin_type.aabb_orig); + } + return value - leftover_value_loss_; +} + +AreaDbl Solution::total_staircase_leftover_value() const +{ + AreaDbl area = 0; + for (BinTypeId bin_type_id = 0; + bin_type_id < instance().number_of_bin_types(); + ++bin_type_id) { + const BinType& bin_type = instance().bin_type(bin_type_id); + area += bin_type.copies + * (bin_type.aabb_orig.x_max - bin_type.aabb_orig.x_min) + * (bin_type.aabb_orig.y_max - bin_type.aabb_orig.y_min); + } + return area - staircase_dominated_area_; +} + bool Solution::operator<(const Solution& solution) const { // Check feasibility. @@ -414,19 +473,26 @@ bool Solution::operator<(const Solution& solution) const } case Objective::BinPackingWithLeftovers: { if (solution.number_of_bins() != number_of_bins()) return solution.number_of_bins() < number_of_bins(); + // The leftover values are compared through their fourth roots (for + // 'LeftoverValueType::SquaredArea') or their cube roots (for + // 'LeftoverValueType::Depth'), and the areas through their square + // roots, so that the tolerance applies to lengths. + LeftoverValueType leftover_value_type = instance().parameters().leftover_value_type; if (shape::strictly_greater( - std::sqrt(solution.leftover_value_scaled()), - std::sqrt(leftover_value_scaled()))) { + leftover_value_length_2d(leftover_value_type, solution.leftover_value_scaled()), + leftover_value_length_2d(leftover_value_type, leftover_value_scaled()))) { return true; } if (shape::strictly_greater( - std::sqrt(leftover_value_scaled()), - std::sqrt(solution.leftover_value_scaled()))) { + leftover_value_length_2d(leftover_value_type, leftover_value_scaled()), + leftover_value_length_2d(leftover_value_type, solution.leftover_value_scaled()))) { return false; } // Tie-breaks: the staircase leftover value of the last bin, then, if // 'leftover_all_bins', the leftover value and the staircase leftover - // value of all the bins. + // value of all the bins, used or not, compared through the value lost + // and the area dominated in the used bins, the values and the areas + // of the bins being the same for both solutions. if (shape::strictly_greater( std::sqrt(solution.staircase_leftover_value()), std::sqrt(staircase_leftover_value()))) { @@ -439,19 +505,19 @@ bool Solution::operator<(const Solution& solution) const } if (!instance().parameters().leftover_all_bins) return false; - if (shape::strictly_greater( - std::sqrt(solution.total_leftover_value()), - std::sqrt(total_leftover_value()))) { + if (shape::strictly_lesser( + leftover_value_length_2d(leftover_value_type, solution.leftover_value_loss_), + leftover_value_length_2d(leftover_value_type, leftover_value_loss_))) { return true; } - if (shape::strictly_greater( - std::sqrt(total_leftover_value()), - std::sqrt(solution.total_leftover_value()))) { + if (shape::strictly_lesser( + leftover_value_length_2d(leftover_value_type, leftover_value_loss_), + leftover_value_length_2d(leftover_value_type, solution.leftover_value_loss_))) { return false; } - return shape::strictly_greater( - std::sqrt(solution.total_staircase_leftover_value()), - std::sqrt(total_staircase_leftover_value())); + return shape::strictly_lesser( + std::sqrt(solution.staircase_dominated_area_), + std::sqrt(staircase_dominated_area_)); } case Objective::OpenDimensionX: { return solution.x_max() < x_max(); } case Objective::OpenDimensionY: { @@ -464,6 +530,17 @@ bool Solution::operator<(const Solution& solution) const return strictly_greater_profit(solution.profit(), profit()); } case Objective::VariableSizedBinPacking: { return strictly_lesser_cost(solution.cost(), cost()); + } case Objective::VariableSizedBinPackingWithLeftovers: { + // The net cost: the cost of the bins minus the refunds of their + // leftovers (see 'Instance::leftover_refund'), and then the staircase + // leftover values. + if (strictly_lesser_cost(solution.net_cost(), net_cost())) + return true; + if (strictly_lesser_cost(net_cost(), solution.net_cost())) + return false; + return shape::strictly_lesser( + std::sqrt(solution.staircase_dominated_area_), + std::sqrt(staircase_dominated_area_)); } default: { std::stringstream ss; ss << FUNC_SIGNATURE << ": " @@ -738,8 +815,10 @@ nlohmann::json Solution::to_json() const {"DensityY", density_y()}, {"OpenDimensionXYArea", open_dimension_xy_area()}, {"LeftoverValue", leftover_value_orig()}, + {"LeftoverArea", leftover_area()}, {"StaircaseLeftoverValue", staircase_leftover_value()}, {"TotalLeftoverValue", total_leftover_value()}, + {"NetCost", net_cost()}, {"TotalStaircaseLeftoverValue", total_staircase_leftover_value()}, }; } @@ -768,6 +847,7 @@ void Solution::format( << "Leftover value: " << leftover_value_orig() << std::endl << "Staircase leftover value: " << staircase_leftover_value() << std::endl << "Total leftover value: " << total_leftover_value() << std::endl + << "Net cost: " << net_cost() << std::endl << "Total staircase leftover value: " << total_staircase_leftover_value() << std::endl ; } diff --git a/src/irregular/tree_search.cpp b/src/irregular/tree_search.cpp index 6d78dbc7e..af7b8d952 100644 --- a/src/irregular/tree_search.cpp +++ b/src/irregular/tree_search.cpp @@ -54,7 +54,7 @@ Direction default_direction( { const BinType& bin_type = instance.bin_type(bin_type_id); bool lengthwise = (bin_type.aabb_scaled.x_max - bin_type.aabb_scaled.x_min) >= (bin_type.aabb_scaled.y_max - bin_type.aabb_scaled.y_min); - switch (instance.parameters().leftover_mode) { + switch (leftover_mode_base(instance.parameters().leftover_mode)) { case LeftoverMode::BottomLeft: { return (lengthwise)? Direction::LeftToRightThenBottomToTop: @@ -818,6 +818,7 @@ BranchingScheme::Node BranchingScheme::child_tmp( items_aabb.x_max = node.x_max; items_aabb.y_max = node.y_max; node.leftover_value = leftover_value( + instance().parameters().leftover_value_type, instance().parameters().leftover_mode, bin_type.aabb_orig, items_aabb); @@ -848,6 +849,11 @@ BranchingScheme::Node BranchingScheme::child_tmp( item_aabb); node.last_bin_staircase_leftover_value = node.last_bin_staircase.leftover_value(bin_type.aabb_orig); + if (leftover_mode_staircase(instance().parameters().leftover_mode)) { + node.leftover_value = node.last_bin_staircase.value( + instance().parameters().leftover_value_type, + bin_type.aabb_orig); + } node.id = node_id_++; //std::cout << "node.id " << node.id << std::endl; @@ -1384,7 +1390,7 @@ bool BranchingScheme::better( const std::shared_ptr& node_2) const { switch (instance().objective()) { - case Objective::BinPacking: case Objective::VariableSizedBinPacking: { + case Objective::BinPacking: case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { if (!leaf(node_1)) return false; if (!leaf(node_2)) @@ -1399,13 +1405,13 @@ bool BranchingScheme::better( return node_2->number_of_bins > node_1->number_of_bins; // Same comparison as 'Solution::operator<'. if (shape::strictly_greater( - std::sqrt(node_1->leftover_value), - std::sqrt(node_2->leftover_value))) { + leftover_value_length_2d(instance().parameters().leftover_value_type, node_1->leftover_value), + leftover_value_length_2d(instance().parameters().leftover_value_type, node_2->leftover_value))) { return true; } if (shape::strictly_greater( - std::sqrt(node_2->leftover_value), - std::sqrt(node_1->leftover_value))) { + leftover_value_length_2d(instance().parameters().leftover_value_type, node_2->leftover_value), + leftover_value_length_2d(instance().parameters().leftover_value_type, node_1->leftover_value))) { return false; } if (shape::strictly_greater( @@ -1421,13 +1427,13 @@ bool BranchingScheme::better( if (!instance().parameters().leftover_all_bins) return false; if (shape::strictly_greater( - std::sqrt(node_1->previous_bins_leftover_value + node_1->leftover_value), - std::sqrt(node_2->previous_bins_leftover_value + node_2->leftover_value))) { + leftover_value_length_2d(instance().parameters().leftover_value_type, node_1->previous_bins_leftover_value + node_1->leftover_value), + leftover_value_length_2d(instance().parameters().leftover_value_type, node_2->previous_bins_leftover_value + node_2->leftover_value))) { return true; } if (shape::strictly_greater( - std::sqrt(node_2->previous_bins_leftover_value + node_2->leftover_value), - std::sqrt(node_1->previous_bins_leftover_value + node_1->leftover_value))) { + leftover_value_length_2d(instance().parameters().leftover_value_type, node_2->previous_bins_leftover_value + node_2->leftover_value), + leftover_value_length_2d(instance().parameters().leftover_value_type, node_1->previous_bins_leftover_value + node_1->leftover_value))) { return false; } return shape::strictly_greater( @@ -1465,7 +1471,7 @@ bool BranchingScheme::bound( const std::shared_ptr& node_2) const { switch (instance().objective()) { - case Objective::BinPacking: case Objective::VariableSizedBinPacking: { + case Objective::BinPacking: case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { if (!leaf(node_2)) return false; return (node_1->number_of_bins >= node_2->number_of_bins); @@ -1480,13 +1486,13 @@ bool BranchingScheme::bound( // The leftover values and the staircase leftover values of a node // are upper bounds of the ones of its descendants in the same bin. if (shape::strictly_greater( - std::sqrt(node_1->leftover_value), - std::sqrt(node_2->leftover_value))) { + leftover_value_length_2d(instance().parameters().leftover_value_type, node_1->leftover_value), + leftover_value_length_2d(instance().parameters().leftover_value_type, node_2->leftover_value))) { return false; } if (shape::strictly_greater( - std::sqrt(node_2->leftover_value), - std::sqrt(node_1->leftover_value))) { + leftover_value_length_2d(instance().parameters().leftover_value_type, node_2->leftover_value), + leftover_value_length_2d(instance().parameters().leftover_value_type, node_1->leftover_value))) { return true; } if (shape::strictly_greater( @@ -1502,13 +1508,13 @@ bool BranchingScheme::bound( if (!instance().parameters().leftover_all_bins) return true; if (shape::strictly_greater( - std::sqrt(node_1->previous_bins_leftover_value + node_1->leftover_value), - std::sqrt(node_2->previous_bins_leftover_value + node_2->leftover_value))) { + leftover_value_length_2d(instance().parameters().leftover_value_type, node_1->previous_bins_leftover_value + node_1->leftover_value), + leftover_value_length_2d(instance().parameters().leftover_value_type, node_2->previous_bins_leftover_value + node_2->leftover_value))) { return false; } if (shape::strictly_greater( - std::sqrt(node_2->previous_bins_leftover_value + node_2->leftover_value), - std::sqrt(node_1->previous_bins_leftover_value + node_1->leftover_value))) { + leftover_value_length_2d(instance().parameters().leftover_value_type, node_2->previous_bins_leftover_value + node_2->leftover_value), + leftover_value_length_2d(instance().parameters().leftover_value_type, node_1->previous_bins_leftover_value + node_1->leftover_value))) { return true; } return !shape::strictly_greater( @@ -2105,7 +2111,7 @@ const packingsolver::irregular::TreeSearchOutput packingsolver::irregular::tree_ }; } else if (instance.number_of_bins() == 1) { if (instance.objective() == Objective::BinPackingWithLeftovers) { - switch (instance.parameters().leftover_mode) { + switch (leftover_mode_base(instance.parameters().leftover_mode)) { case LeftoverMode::BottomLeft: { directions = { Direction::LeftToRightThenBottomToTop, @@ -2173,7 +2179,7 @@ const packingsolver::irregular::TreeSearchOutput packingsolver::irregular::tree_ }; } } else { - switch (instance.parameters().leftover_mode) { + switch (leftover_mode_base(instance.parameters().leftover_mode)) { case LeftoverMode::BottomLeft: { directions = {Direction::LeftToRightThenBottomToTop}; break; diff --git a/src/irregular/tree_search.hpp b/src/irregular/tree_search.hpp index f9aed98d2..44044bee2 100644 --- a/src/irregular/tree_search.hpp +++ b/src/irregular/tree_search.hpp @@ -197,7 +197,7 @@ class BranchingScheme AreaDbl last_bin_staircase_leftover_value = 0; /** Sum of the leftover values of the bins but the last one. */ - AreaDbl previous_bins_leftover_value = 0; + double previous_bins_leftover_value = 0; /** Sum of the staircase leftover values of the bins but the last one. */ AreaDbl previous_bins_staircase_leftover_value = 0; @@ -393,8 +393,8 @@ class BranchingScheme // Check leftover values. if (instance().objective() == Objective::BinPackingWithLeftovers) { if (shape::strictly_greater( - std::sqrt(node_2->leftover_value), - std::sqrt(node_1->leftover_value))) { + leftover_value_length_2d(instance().parameters().leftover_value_type, node_2->leftover_value), + leftover_value_length_2d(instance().parameters().leftover_value_type, node_1->leftover_value))) { return false; } if (shape::strictly_greater( @@ -404,8 +404,8 @@ class BranchingScheme } if (instance().parameters().leftover_all_bins) { if (shape::strictly_greater( - std::sqrt(node_2->previous_bins_leftover_value), - std::sqrt(node_1->previous_bins_leftover_value))) { + leftover_value_length_2d(instance().parameters().leftover_value_type, node_2->previous_bins_leftover_value), + leftover_value_length_2d(instance().parameters().leftover_value_type, node_1->previous_bins_leftover_value))) { return false; } if (shape::strictly_greater( diff --git a/src/irregular/tree_search_maximal_spaces.cpp b/src/irregular/tree_search_maximal_spaces.cpp index 4fbc6189e..88bf1c5d9 100644 --- a/src/irregular/tree_search_maximal_spaces.cpp +++ b/src/irregular/tree_search_maximal_spaces.cpp @@ -158,7 +158,7 @@ BranchingSchemeMaximalSpaces::BranchingSchemeMaximalSpaces( // Corners. corner_ids_ = {0}; if (parameters_.use_multiple_corners) { - LeftoverMode leftover_mode = instance.parameters().leftover_mode; + LeftoverMode leftover_mode = leftover_mode_base(instance.parameters().leftover_mode); if (instance.objective() == Objective::Knapsack || instance.objective() == Objective::Feasibility) { corner_ids_ = {0, 1, 2, 3}; @@ -663,6 +663,7 @@ double BranchingSchemeMaximalSpaces::extent(const Node& node) const } default: { const BinType& bin_type = instance().bin_type(instance().bin_type_id(0)); return -leftover_value( + instance().parameters().leftover_value_type, instance().parameters().leftover_mode, bin_type.aabb_scaled, items_aabb); @@ -1330,7 +1331,7 @@ const packingsolver::irregular::TreeSearchMaximalSpacesOutput packingsolver::irr << "does not support instances with more than one bin."; throw std::logic_error(ss.str()); } - if (instance.objective() == Objective::VariableSizedBinPacking) { + if (is_variable_sized_bin_packing(instance.objective())) { std::stringstream ss; ss << FUNC_SIGNATURE << ": " << "algorithm 'irregular::tree_search_maximal_spaces' " @@ -1401,7 +1402,7 @@ const packingsolver::irregular::TreeSearchMaximalSpacesOutput packingsolver::irr Direction::BottomToTopThenRightToLeft, }; } else if (instance.objective() == Objective::BinPackingWithLeftovers) { - switch (instance.parameters().leftover_mode) { + switch (leftover_mode_base(instance.parameters().leftover_mode)) { case LeftoverMode::BottomLeft: { directions = { Direction::LeftToRightThenBottomToTop, @@ -1462,10 +1463,10 @@ const packingsolver::irregular::TreeSearchMaximalSpacesOutput packingsolver::irr && (instance.objective() == Objective::OpenDimensionX || instance.objective() == Objective::OpenDimensionY || (instance.objective() == Objective::BinPackingWithLeftovers - && (instance.parameters().leftover_mode == LeftoverMode::Left - || instance.parameters().leftover_mode == LeftoverMode::Right - || instance.parameters().leftover_mode == LeftoverMode::Bottom - || instance.parameters().leftover_mode == LeftoverMode::Top)))) { + && (leftover_mode_base(instance.parameters().leftover_mode) == LeftoverMode::Left + || leftover_mode_base(instance.parameters().leftover_mode) == LeftoverMode::Right + || leftover_mode_base(instance.parameters().leftover_mode) == LeftoverMode::Bottom + || leftover_mode_base(instance.parameters().leftover_mode) == LeftoverMode::Top)))) { directions.resize(1); } diff --git a/src/irregular/tree_search_periodic_packing.cpp b/src/irregular/tree_search_periodic_packing.cpp index 3515f3bbe..7b4397319 100644 --- a/src/irregular/tree_search_periodic_packing.cpp +++ b/src/irregular/tree_search_periodic_packing.cpp @@ -2187,7 +2187,7 @@ void validate_tree_search_periodic_packing_instance(const Instance& instance) << "does not support instances with more than one bin."; throw std::logic_error(ss.str()); } - if (instance.objective() == Objective::VariableSizedBinPacking) { + if (is_variable_sized_bin_packing(instance.objective())) { std::stringstream ss; ss << FUNC_SIGNATURE << ": " << "algorithm 'irregular::tree_search_periodic_packing' " diff --git a/src/onedimensional/algorithm_formatter.cpp b/src/onedimensional/algorithm_formatter.cpp index 4a599f30f..583d93e95 100644 --- a/src/onedimensional/algorithm_formatter.cpp +++ b/src/onedimensional/algorithm_formatter.cpp @@ -85,7 +85,7 @@ void AlgorithmFormatter::print_header() << std::setw(32) << "-------" << std::endl; break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { *os_ << std::setw(12) << "Time" << std::setw(14) << "Cost" @@ -150,7 +150,7 @@ void AlgorithmFormatter::print( << std::setw(32) << s << std::endl; break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { *os_ << std::setw(12) << std::fixed << std::setprecision(3) << output_.time << std::defaultfloat << std::setprecision(precision) << std::setw(14) << output_.solution_pool.best().cost() @@ -267,7 +267,7 @@ void AlgorithmFormatter::update_bounds( case Objective::BinPacking: update_bin_packing_bound(output.bin_packing_bound); break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: update_variable_sized_bin_packing_bound(output.variable_sized_bin_packing_bound); break; default: diff --git a/src/onedimensional/instance_builder.cpp b/src/onedimensional/instance_builder.cpp index 839523f18..cda8fb507 100644 --- a/src/onedimensional/instance_builder.cpp +++ b/src/onedimensional/instance_builder.cpp @@ -980,6 +980,13 @@ void InstanceBuilder::resolve_item_types_unlimited_copies() Instance InstanceBuilder::build() { + if (instance_.objective() == Objective::VariableSizedBinPackingWithLeftovers) { + throw std::invalid_argument( + FUNC_SIGNATURE + ": " + "the objective 'VariableSizedBinPackingWithLeftovers' is not " + "available for the problem type 'onedimensional'."); + } + // Compute the tolerances of the resources which haven't been set (see // 'Resource::tolerance'). for (BinType& bin_type: instance_.bin_types_) diff --git a/src/onedimensional/milp_assignment.cpp b/src/onedimensional/milp_assignment.cpp index afae4a65a..0eb861a71 100644 --- a/src/onedimensional/milp_assignment.cpp +++ b/src/onedimensional/milp_assignment.cpp @@ -109,7 +109,7 @@ BinPos compute_bin_instance_upper_bound( algorithm_formatter.update_solution(solution, "single bin type"); if (instance.objective() == Objective::BinPacking) { algorithm_formatter.update_bin_packing_bound(sub_output.bin_packing_bound); - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { // A single bin type: cost is exactly bins used * that type's // cost, so a lower bound on bins used gives one on cost too. algorithm_formatter.update_variable_sized_bin_packing_bound( @@ -557,7 +557,7 @@ MilpModel build_milp_model( // many bins to use via a 'y' variable (the former to minimize cost, the // latter to minimize count, additionally constrained to use bin types in // the order they are provided). - bool needs_y = (instance.objective() == Objective::VariableSizedBinPacking + bool needs_y = (is_variable_sized_bin_packing(instance.objective()) || is_bin_packing); MilpModel milp_model; @@ -1382,7 +1382,7 @@ std::vector compute_bin_type_upper_bounds( const MilpAssignmentParameters& parameters, AlgorithmFormatter& algorithm_formatter) { - if (instance.objective() == Objective::VariableSizedBinPacking) { + if (is_variable_sized_bin_packing(instance.objective())) { return compute_bin_type_upper_bounds_variable_sized_bin_packing( instance, parameters, algorithm_formatter); } @@ -1456,7 +1456,7 @@ MilpAssignmentOutput packingsolver::onedimensional::milp_assignment( algorithm_formatter.start(); algorithm_formatter.print_header(); - if (instance.objective() != Objective::VariableSizedBinPacking + if (!is_variable_sized_bin_packing(instance.objective()) && instance.objective() != Objective::Knapsack && instance.objective() != Objective::Feasibility && instance.objective() != Objective::BinPacking) { @@ -1659,7 +1659,7 @@ MilpAssignmentOutput packingsolver::onedimensional::milp_assignment( // the most up-to-date reporting - including from // 'kCallbackMipImprovingSolution', not just // 'kCallbackMipInterrupt'. - if (instance.objective() == Objective::VariableSizedBinPacking) { + if (is_variable_sized_bin_packing(instance.objective())) { algorithm_formatter.update_variable_sized_bin_packing_bound( highs_output->mip_dual_bound); } else if (instance.objective() == Objective::Knapsack) { @@ -1719,7 +1719,7 @@ MilpAssignmentOutput packingsolver::onedimensional::milp_assignment( number_of_nodes = mathoptsolverscmake::get_number_of_nodes(highs); if (!milp_solution.empty()) { double bound = mathoptsolverscmake::get_bound(highs); - if (instance.objective() == Objective::VariableSizedBinPacking) { + if (is_variable_sized_bin_packing(instance.objective())) { algorithm_formatter.update_variable_sized_bin_packing_bound(bound); } else if (instance.objective() == Objective::Knapsack) { algorithm_formatter.update_knapsack_bound(bound * milp_model.multiplier_profit); diff --git a/src/onedimensional/optimize.cpp b/src/onedimensional/optimize.cpp index e9ab994d0..706b2fd9e 100644 --- a/src/onedimensional/optimize.cpp +++ b/src/onedimensional/optimize.cpp @@ -732,7 +732,7 @@ packingsolver::onedimensional::Output packingsolver::onedimensional::optimize( } } } - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { // Disable algorithms which are not available for this objective. if (instance.number_of_bin_types() == 1) { if (use_dichotomic_search) { diff --git a/src/onedimensional/reduction.cpp b/src/onedimensional/reduction.cpp index d512713e6..ce7909e7e 100644 --- a/src/onedimensional/reduction.cpp +++ b/src/onedimensional/reduction.cpp @@ -327,7 +327,7 @@ bool Reduction::remove_dominated_bin_types_applies(const Instance& instance) // available earlier than the original instance allows. if (instance.objective() != Objective::Knapsack && instance.objective() != Objective::Feasibility - && instance.objective() != Objective::VariableSizedBinPacking) { + && !is_variable_sized_bin_packing(instance.objective())) { return false; } return instance.number_of_bin_types() > 1; diff --git a/src/onedimensional/solution.cpp b/src/onedimensional/solution.cpp index 7f0bbf5e2..77e5343f4 100644 --- a/src/onedimensional/solution.cpp +++ b/src/onedimensional/solution.cpp @@ -257,7 +257,7 @@ bool Solution::operator<(const Solution& solution) const return strictly_greater_profit(solution.profit(), profit()); } case Objective::Feasibility: { return strictly_greater_profit(solution.profit(), profit()); - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { return strictly_lesser_cost(solution.cost(), cost()); } default: { std::stringstream ss; diff --git a/src/onedimensional/tree_search.cpp b/src/onedimensional/tree_search.cpp index 8ba8e1283..5fe7f5e15 100644 --- a/src/onedimensional/tree_search.cpp +++ b/src/onedimensional/tree_search.cpp @@ -426,7 +426,7 @@ bool BranchingScheme::better( const std::shared_ptr& node_2) const { switch (instance_.objective()) { - case Objective::BinPacking: case Objective::VariableSizedBinPacking: { + case Objective::BinPacking: case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { if (!leaf(node_1)) return false; if (!leaf(node_2)) @@ -458,7 +458,7 @@ bool BranchingScheme::bound( const std::shared_ptr& node_2) const { switch (instance_.objective()) { - case Objective::BinPacking: case Objective::VariableSizedBinPacking: { + case Objective::BinPacking: case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { if (!leaf(node_2)) return false; BinPos bin_pos = -1; diff --git a/src/onedimensional/trivial_bound.cpp b/src/onedimensional/trivial_bound.cpp index 2669f4182..47df8fa77 100644 --- a/src/onedimensional/trivial_bound.cpp +++ b/src/onedimensional/trivial_bound.cpp @@ -118,7 +118,7 @@ void trivial_bound_impl( return; } - if (instance.objective() == Objective::VariableSizedBinPacking) { + if (is_variable_sized_bin_packing(instance.objective())) { // Same bin-selection knapsack as the one solved by the dichotomic // search (see 'algorithms/dichotomic_search.hpp'), but solved once // at zero waste instead of iteratively: a real solution can never diff --git a/src/rectangle/algorithm_formatter.cpp b/src/rectangle/algorithm_formatter.cpp index c22c77ece..0b1e6c797 100644 --- a/src/rectangle/algorithm_formatter.cpp +++ b/src/rectangle/algorithm_formatter.cpp @@ -107,7 +107,7 @@ void AlgorithmFormatter::print_header() << std::setw(32) << "-------" << std::endl; break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { *os_ << std::setw(12) << "Time" << std::setw(14) << "Cost" @@ -186,7 +186,7 @@ void AlgorithmFormatter::print( << std::setw(32) << s << std::endl; break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { *os_ << std::setw(12) << std::fixed << std::setprecision(3) << output_.time << std::defaultfloat << std::setprecision(precision) << std::setw(14) << output_.solution_pool.best().cost() @@ -335,7 +335,7 @@ void AlgorithmFormatter::update_bounds( case Objective::BinPacking: update_bin_packing_bound(output.bin_packing_bound); break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: update_variable_sized_bin_packing_bound(output.variable_sized_bin_packing_bound); break; case Objective::OpenDimensionX: diff --git a/src/rectangle/bar_relaxation.cpp b/src/rectangle/bar_relaxation.cpp index 483f11094..309c01464 100644 --- a/src/rectangle/bar_relaxation.cpp +++ b/src/rectangle/bar_relaxation.cpp @@ -137,7 +137,7 @@ double BarRelaxationPricingSolver::price_bars( break; } case Objective::Feasibility: case Objective::BinPacking: - case Objective::VariableSizedBinPacking: { + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { profit = duals[link_row[variant_id]]; break; } default: { @@ -187,7 +187,7 @@ double BarRelaxationPricingSolver::price_bars( break; } case Objective::Feasibility: case Objective::BinPacking: - case Objective::VariableSizedBinPacking: { + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { profit = duals[link_row[variant_id]]; break; } default: { @@ -205,7 +205,7 @@ double BarRelaxationPricingSolver::price_bars( break; } case Objective::Feasibility: case Objective::BinPacking: - case Objective::VariableSizedBinPacking: { + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { reduced_cost = -achieved - duals[cap_row]; break; } default: { @@ -278,7 +278,7 @@ columngenerationsolver::PricingSolver::PricingOutput BarRelaxationPricingSolver: break; } case Objective::Feasibility: case Objective::BinPacking: - case Objective::VariableSizedBinPacking: { + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { overcost += (std::min)(0.0, reduced_cost_row) * (double)bin_type.rect.y * (double)bin_type.copies; break; @@ -303,7 +303,7 @@ columngenerationsolver::PricingSolver::PricingOutput BarRelaxationPricingSolver: break; } case Objective::Feasibility: case Objective::BinPacking: - case Objective::VariableSizedBinPacking: { + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { overcost += (std::min)(0.0, reduced_cost_col) * (double)bin_type.rect.x * (double)bin_type.copies; break; @@ -326,7 +326,7 @@ BarRelaxationOutput packingsolver::rectangle::bar_relaxation( if (instance.objective() != Objective::Knapsack && instance.objective() != Objective::Feasibility && instance.objective() != Objective::BinPacking - && instance.objective() != Objective::VariableSizedBinPacking) + && !is_variable_sized_bin_packing(instance.objective())) throw std::invalid_argument(FUNC_SIGNATURE); // For 'BinPacking' with several bin types, the objective value (a total // cost) would no longer convert to a bin *count* by a single division: @@ -383,7 +383,7 @@ BarRelaxationOutput packingsolver::rectangle::bar_relaxation( break; } case Objective::Feasibility: case Objective::BinPacking: - case Objective::VariableSizedBinPacking: { + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { model.objective_sense = optimizationtools::ObjectiveDirection::Minimize; break; } default: { @@ -486,7 +486,7 @@ BarRelaxationOutput packingsolver::rectangle::bar_relaxation( k_column.objective_coefficient = 0.0; break; } case Objective::BinPacking: - case Objective::VariableSizedBinPacking: { + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { k_column.objective_coefficient = bin_type.cost; break; } default: { @@ -533,7 +533,7 @@ BarRelaxationOutput packingsolver::rectangle::bar_relaxation( break; } case Objective::Feasibility: case Objective::BinPacking: - case Objective::VariableSizedBinPacking: { + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { n_column.objective_coefficient = 0.0; break; } default: { @@ -618,7 +618,7 @@ BarRelaxationOutput packingsolver::rectangle::bar_relaxation( break; } case Objective::Feasibility: { break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { algorithm_formatter.update_variable_sized_bin_packing_bound(cgs_output.bound); break; } case Objective::BinPacking: { diff --git a/src/rectangle/benders_decomposition.cpp b/src/rectangle/benders_decomposition.cpp index cf5dfe273..c99163e0d 100644 --- a/src/rectangle/benders_decomposition.cpp +++ b/src/rectangle/benders_decomposition.cpp @@ -489,7 +489,7 @@ onedimensional::Instance build_master_instance( Profit variable_sized_bin_packing_goal) { onedimensional::InstanceBuilder master_instance_builder; - master_instance_builder.set_objective(instance.objective()); + master_instance_builder.set_objective(onedimensional_subproblem_objective(instance.objective())); master_instance_builder.set_bin_packing_goal(bin_packing_goal); master_instance_builder.set_knapsack_goal(knapsack_goal); master_instance_builder.set_variable_sized_bin_packing_goal(variable_sized_bin_packing_goal); @@ -925,7 +925,7 @@ BendersDecompositionOutput packingsolver::rectangle::benders_decomposition( algorithm_formatter.update_knapsack_bound(master_output.knapsack_bound); } else if (instance.objective() == Objective::BinPacking) { algorithm_formatter.update_bin_packing_bound(master_output.bin_packing_bound); - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { algorithm_formatter.update_variable_sized_bin_packing_bound( master_output.variable_sized_bin_packing_bound); } @@ -943,7 +943,7 @@ BendersDecompositionOutput packingsolver::rectangle::benders_decomposition( master_knapsack_goal = (std::min)( master_knapsack_goal, master_output.knapsack_bound); - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { master_variable_sized_bin_packing_goal = (std::max)( master_variable_sized_bin_packing_goal, master_output.variable_sized_bin_packing_bound); @@ -994,7 +994,7 @@ BendersDecompositionOutput packingsolver::rectangle::benders_decomposition( } else if (instance.objective() == Objective::BinPacking) { if (master_solution.number_of_bins() >= output.solution_pool.best().number_of_bins()) break; - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { if (master_solution.cost() >= output.solution_pool.best().cost()) break; } diff --git a/src/rectangle/instance.cpp b/src/rectangle/instance.cpp index cdc6c621a..a1fc891f1 100644 --- a/src/rectangle/instance.cpp +++ b/src/rectangle/instance.cpp @@ -1,5 +1,7 @@ #include "packingsolver/rectangle/instance.hpp" +#include "algorithms/leftover.hpp" + #include #include #include @@ -65,6 +67,12 @@ std::istream& rectangle::operator>>( } else if (token == "y" || token == "Y") { leftover_mode = LeftoverMode::Y; + } else if (token == "area-cut" + || token == "AreaCut") { + leftover_mode = LeftoverMode::AreaCut; + } else if (token == "staircase" + || token == "Staircase") { + leftover_mode = LeftoverMode::Staircase; } else { in.setstate(std::ios_base::failbit); } @@ -85,11 +93,61 @@ std::ostream& rectangle::operator<<( } case LeftoverMode::Y: { os << "Y"; break; + } case LeftoverMode::AreaCut: { + os << "AreaCut"; + break; + } case LeftoverMode::Staircase: { + os << "Staircase"; + break; } } return os; } +double rectangle::leftover_value( + LeftoverValueType leftover_value_type, + LeftoverMode leftover_mode, + Length bin_x, + Length bin_y, + Length x_max, + Length y_max) +{ + std::array bin = {(double)bin_x, (double)bin_y}; + std::array used = {(double)x_max, (double)y_max}; + switch (leftover_mode) { + case LeftoverMode::Area: case LeftoverMode::AreaCut: case LeftoverMode::Staircase: { + break; + } case LeftoverMode::X: { + used[1] = (double)bin_y; + break; + } case LeftoverMode::Y: { + used[0] = (double)bin_x; + break; + } + } + return packingsolver::leftover_value( + leftover_value_type, + bin, + used, + leftover_mode == LeftoverMode::AreaCut); +} + +double rectangle::staircase_leftover_value( + LeftoverValueType leftover_value_type, + Length bin_x, + Length bin_y, + const std::vector>& extents) +{ + std::vector> extents_dbl; + extents_dbl.reserve(extents.size()); + for (const auto& extent: extents) + extents_dbl.push_back({(double)extent[0], (double)extent[1]}); + return packingsolver::staircase_leftover_value<2>( + leftover_value_type, + {(double)bin_x, (double)bin_y}, + extents_dbl); +} + std::istream& rectangle::operator>>( std::istream& in, UnloadingConstraint& unloading_constraint) @@ -306,6 +364,7 @@ std::ostream& Instance::format( if (objective() == Objective::BinPackingWithLeftovers) { os << "Leftover mode: " << parameters().leftover_mode << std::endl + << "Leftover value type: " << parameters().leftover_value_type << std::endl << "Leftover all bins: " << parameters().leftover_all_bins << std::endl ; } @@ -628,6 +687,7 @@ void Instance::write_csv( << "objective," << objective() << std::endl << "unloading_constraint," << unloading_constraint() << std::endl << "leftover_mode," << parameters().leftover_mode << std::endl + << "leftover_value_type," << parameters().leftover_value_type << std::endl << "leftover_all_bins," << parameters().leftover_all_bins << std::endl; if (std::isfinite(knapsack_goal())) { f_parameters << "knapsack_goal," @@ -665,6 +725,11 @@ void Instance::write_json( ss << parameters().leftover_mode; j["leftover_mode"] = ss.str(); } + { + std::stringstream ss; + ss << parameters().leftover_value_type; + j["leftover_value_type"] = ss.str(); + } j["leftover_all_bins"] = parameters().leftover_all_bins; j["bin_types"] = nlohmann::json::array(); diff --git a/src/rectangle/instance_builder.cpp b/src/rectangle/instance_builder.cpp index 32b57bf65..a80e2bf45 100644 --- a/src/rectangle/instance_builder.cpp +++ b/src/rectangle/instance_builder.cpp @@ -771,6 +771,8 @@ void InstanceBuilder::read_parameters( value, name); set_leftover_mode(leftover_mode); + } else if (name == "leftover_value_type") { + set_leftover_value_type(read_enum(value, name)); } else if (name == "leftover_all_bins") { set_leftover_all_bins(value == "1" || value == "true"); } @@ -1053,6 +1055,11 @@ void InstanceBuilder::read( "leftover_mode"); set_leftover_mode(leftover_mode); } + if (j.contains("leftover_value_type")) { + set_leftover_value_type(read_enum( + j["leftover_value_type"].get(), + "leftover_value_type")); + } if (j.contains("leftover_all_bins")) set_leftover_all_bins(j["leftover_all_bins"]); @@ -1450,6 +1457,25 @@ Instance InstanceBuilder::build() if (original_instance_ != nullptr) copy_cache_from_original_instance(); + // Compute the factor which converts a leftover value into a space. + instance_.leftover_value_factor_ = 0; + for (const BinType& bin_type: instance_.bin_types_) { + double space = (double)bin_type.area(); + double value = rectangle::leftover_value( + instance_.parameters_.leftover_value_type, + instance_.parameters_.leftover_mode, + bin_type.rect.x, + bin_type.rect.y, + 0, + 0); + if (value <= 0) + continue; + if (instance_.leftover_value_factor_ == 0 + || space / value < instance_.leftover_value_factor_) { + instance_.leftover_value_factor_ = space / value; + } + } + return std::move(instance_); } diff --git a/src/rectangle/main.cpp b/src/rectangle/main.cpp index f7a622bbc..a4dddf2b2 100644 --- a/src/rectangle/main.cpp +++ b/src/rectangle/main.cpp @@ -79,6 +79,7 @@ int main(int argc, char *argv[]) ("unloading-constraint,", po::value(), "") ("leftover-mode,", po::value(), "") + ("leftover-value-type,", po::value(), "Leftover value type (bin-packing-with-leftovers): area, depth") ("leftover-all-bins", po::value(), "also compare the leftover values of all the bins") ("output,o", po::value(), "Output path") @@ -210,6 +211,8 @@ int main(int argc, char *argv[]) instance_builder.set_unloading_constraint(vm["unloading-constraint"].as()); if (vm.count("leftover-mode")) instance_builder.set_leftover_mode(vm["leftover-mode"].as()); + if (vm.count("leftover-value-type")) + instance_builder.set_leftover_value_type(vm["leftover-value-type"].as()); if (vm.count("leftover-all-bins")) instance_builder.set_leftover_all_bins(vm["leftover-all-bins"].as()); diff --git a/src/rectangle/optimize.cpp b/src/rectangle/optimize.cpp index 22f118bda..143c685b3 100644 --- a/src/rectangle/optimize.cpp +++ b/src/rectangle/optimize.cpp @@ -174,7 +174,7 @@ void optimize_onedimensional_bound( // same cost), so the bound the onedimensional solver finds for it // (which runs the same dichotomic search) is a valid lower bound here. onedimensional::InstanceBuilder onedim_instance_builder; - onedim_instance_builder.set_objective(instance.objective()); + onedim_instance_builder.set_objective(onedimensional_subproblem_objective(instance.objective())); for (BinTypeId bin_type_id = 0; bin_type_id < instance.number_of_bin_types(); ++bin_type_id) { @@ -237,7 +237,7 @@ void optimize_onedimensional_bound( algorithm_formatter.update_knapsack_bound( onedim_output.knapsack_bound + negative_penalty_sum(instance)); break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { algorithm_formatter.update_variable_sized_bin_packing_bound( onedim_output.variable_sized_bin_packing_bound); break; @@ -947,7 +947,7 @@ packingsolver::rectangle::Output packingsolver::rectangle::optimize( if (instance.objective() == Objective::BinPacking || instance.objective() == Objective::BinPackingWithLeftovers || instance.objective() == Objective::Knapsack - || instance.objective() == Objective::VariableSizedBinPacking + || is_variable_sized_bin_packing(instance.objective()) || instance.objective() == Objective::Feasibility) { optimize_onedimensional_bound( instance, @@ -1012,7 +1012,7 @@ packingsolver::rectangle::Output packingsolver::rectangle::optimize( // single bin but 'VariableSizedBinPacking' (through the sequential // feasibility algorithm for the objectives other than 'Knapsack' and // 'Feasibility'). - if (instance.objective() == Objective::VariableSizedBinPacking) + if (is_variable_sized_bin_packing(instance.objective())) use_tree_search_maximal_spaces = false; // 'tree_search_maximal_spaces' doesn't implement unloading // constraints at all (unlike 'tree_search'): force it off even if @@ -1217,7 +1217,7 @@ packingsolver::rectangle::Output packingsolver::rectangle::optimize( } } } - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { // Disable algorithms which are not available for this objective. use_tree_search_maximal_spaces = false; // 'benders_decomposition_contiguity' only supports 'Knapsack'/ diff --git a/src/rectangle/reduction.cpp b/src/rectangle/reduction.cpp index daee0f611..2507e3deb 100644 --- a/src/rectangle/reduction.cpp +++ b/src/rectangle/reduction.cpp @@ -2097,7 +2097,7 @@ bool Reduction::companion_absorption_applies(const Instance& instance) // Only sound for these three objectives - see the class-level doc // comment's "Companion absorption" paragraph. if (instance.objective() != Objective::BinPacking - && instance.objective() != Objective::VariableSizedBinPacking + && !is_variable_sized_bin_packing(instance.objective()) && instance.objective() != Objective::Feasibility) return false; @@ -2202,7 +2202,9 @@ bool Reduction::lift_item_dimensions_applies_axis( return false; if (instance.objective() == Objective::BinPackingWithLeftovers && (instance.parameters().leftover_mode == LeftoverMode::X - || instance.parameters().leftover_mode == LeftoverMode::Area)) + || instance.parameters().leftover_mode == LeftoverMode::Area + || instance.parameters().leftover_mode == LeftoverMode::AreaCut + || instance.parameters().leftover_mode == LeftoverMode::Staircase)) return false; if (instance.bin_type(0).semi_trailer_truck_data.is) return false; @@ -2214,7 +2216,9 @@ bool Reduction::lift_item_dimensions_applies_axis( return false; if (instance.objective() == Objective::BinPackingWithLeftovers && (instance.parameters().leftover_mode == LeftoverMode::Y - || instance.parameters().leftover_mode == LeftoverMode::Area)) + || instance.parameters().leftover_mode == LeftoverMode::Area + || instance.parameters().leftover_mode == LeftoverMode::AreaCut + || instance.parameters().leftover_mode == LeftoverMode::Staircase)) return false; if (unloading_constraint == UnloadingConstraint::OnlyXMovements || unloading_constraint == UnloadingConstraint::IncreasingY) @@ -2264,7 +2268,7 @@ bool Reduction::remove_dominated_bin_types_applies(const Instance& instance) // earlier than the original instance allows. if (instance.objective() != Objective::Knapsack && instance.objective() != Objective::Feasibility - && instance.objective() != Objective::VariableSizedBinPacking) { + && !is_variable_sized_bin_packing(instance.objective())) { return false; } return instance.number_of_bin_types() > 1; diff --git a/src/rectangle/solution.cpp b/src/rectangle/solution.cpp index 8c67aa517..3ef947262 100644 --- a/src/rectangle/solution.cpp +++ b/src/rectangle/solution.cpp @@ -1,5 +1,6 @@ #include "packingsolver/rectangle/solution.hpp" +#include "algorithms/leftover.hpp" #include "algorithms/staircase.hpp" #include "optimizationtools/utils/utils.hpp" @@ -105,7 +106,7 @@ void Solution::update_indicators( bin_x_max = std::max(bin_x_max, xe); bin_y_max = std::max(bin_y_max, ye); switch (instance().parameters().leftover_mode) { - case LeftoverMode::Area: { + case LeftoverMode::Area: case LeftoverMode::AreaCut: case LeftoverMode::Staircase: { staircase.add(xe, ye); break; } case LeftoverMode::X: { @@ -118,13 +119,15 @@ void Solution::update_indicators( } } - // Update the leftover values. The area used in a bin is the rest of the - // bin being the leftover. + // Update the leftover values. Area used_area = 0; switch (instance().parameters().leftover_mode) { - case LeftoverMode::Area: { + case LeftoverMode::Area: case LeftoverMode::AreaCut: { used_area = bin_x_max * bin_y_max; break; + } case LeftoverMode::Staircase: { + used_area = staircase.area(); + break; } case LeftoverMode::X: { used_area = bin_x_max * bin_type.rect.y; break; @@ -133,14 +136,37 @@ void Solution::update_indicators( break; } } - bin.leftover_value = bin_type.area() - used_area; + bin.leftover_value = (instance().parameters().leftover_mode == LeftoverMode::Staircase)? + rectangle::staircase_leftover_value( + instance().parameters().leftover_value_type, + bin_type.rect.x, + bin_type.rect.y, + staircase.extents()): + rectangle::leftover_value( + instance().parameters().leftover_value_type, + instance().parameters().leftover_mode, + bin_type.rect.x, + bin_type.rect.y, + bin_x_max, + bin_y_max); bin.staircase_leftover_value = bin_type.area() - staircase.area(); - this->total_leftover_value_ += bin.copies * bin.leftover_value; - this->total_staircase_leftover_value_ += bin.copies * bin.staircase_leftover_value; + this->leftover_value_loss_ += bin.copies * ( + rectangle::leftover_value( + instance().parameters().leftover_value_type, + instance().parameters().leftover_mode, + bin_type.rect.x, + bin_type.rect.y, + 0, + 0) + - bin.leftover_value); + net_cost_ += bin.copies * ( + bin_type.cost + - instance().leftover_refund(bin.bin_type_id, bin.leftover_value)); + this->staircase_dominated_area_ += bin.copies * staircase.area(); if (bin_pos == (BinPos)this->bins_.size() - 1) { this->x_max_ = bin_x_max; this->y_max_ = bin_y_max; - this->area_ = this->bin_area_ - bin.leftover_value; + this->area_ = this->bin_area_ - (bin_type.area() - used_area); this->leftover_value_ = bin.leftover_value; this->staircase_leftover_value_ = bin.staircase_leftover_value; } @@ -229,6 +255,24 @@ double Solution::least_load() const return least_load; } +double Solution::total_leftover_value() const +{ + double value = 0; + for (BinTypeId bin_type_id = 0; + bin_type_id < instance().number_of_bin_types(); + ++bin_type_id) { + const BinType& bin_type = instance().bin_type(bin_type_id); + value += bin_type.copies * rectangle::leftover_value( + instance().parameters().leftover_value_type, + instance().parameters().leftover_mode, + bin_type.rect.x, + bin_type.rect.y, + 0, + 0); + } + return value - leftover_value_loss_; +} + bool Solution::operator<(const Solution& solution) const { // Check feasibility. @@ -243,8 +287,11 @@ bool Solution::operator<(const Solution& solution) const } case Objective::BinPackingWithLeftovers: { if (solution.number_of_bins() != number_of_bins()) return solution.number_of_bins() < number_of_bins(); - if (solution.leftover_value() != leftover_value()) - return solution.leftover_value() > leftover_value(); + LeftoverValueType leftover_value_type = instance().parameters().leftover_value_type; + if (strictly_greater_leftover_value(leftover_value_type, solution.leftover_value(), leftover_value())) + return true; + if (strictly_greater_leftover_value(leftover_value_type, leftover_value(), solution.leftover_value())) + return false; // Tie-breaks: the staircase leftover value of the last bin, then, if // 'leftover_all_bins', the leftover value and the staircase leftover // value of all the bins. @@ -252,9 +299,14 @@ bool Solution::operator<(const Solution& solution) const return solution.staircase_leftover_value() > staircase_leftover_value(); if (!instance().parameters().leftover_all_bins) return false; - if (solution.total_leftover_value() != total_leftover_value()) - return solution.total_leftover_value() > total_leftover_value(); - return solution.total_staircase_leftover_value() > total_staircase_leftover_value(); + // The leftover values of all the bins, used or not, are compared + // through the value lost in the used bins, the values of the bins + // being the same for both solutions. + if (strictly_greater_leftover_value(leftover_value_type, leftover_value_loss_, solution.leftover_value_loss_)) + return true; + if (strictly_greater_leftover_value(leftover_value_type, solution.leftover_value_loss_, leftover_value_loss_)) + return false; + return solution.staircase_dominated_area_ < staircase_dominated_area_; } case Objective::OpenDimensionX: { return solution.x_max() < x_max(); } case Objective::OpenDimensionY: { @@ -265,6 +317,15 @@ bool Solution::operator<(const Solution& solution) const return strictly_greater_profit(solution.profit(), profit()); } case Objective::VariableSizedBinPacking: { return strictly_lesser_cost(solution.cost(), cost()); + } case Objective::VariableSizedBinPackingWithLeftovers: { + // The net cost: the cost of the bins minus the refunds of their + // leftovers (see 'Instance::leftover_refund'), and then the staircase + // leftover values. + if (strictly_lesser_cost(solution.net_cost(), net_cost())) + return true; + if (strictly_lesser_cost(net_cost(), solution.net_cost())) + return false; + return solution.staircase_dominated_area_ < staircase_dominated_area_; } case Objective::SequentialOneDimensionalRectangleSubproblem: { if (!equal_profit(solution.profit(), profit())) return strictly_greater_profit(solution.profit(), profit()); @@ -370,6 +431,7 @@ nlohmann::json Solution::to_json() const {"LeftoverValue", leftover_value()}, {"StaircaseLeftoverValue", staircase_leftover_value()}, {"TotalLeftoverValue", total_leftover_value()}, + {"NetCost", net_cost()}, {"TotalStaircaseLeftoverValue", total_staircase_leftover_value()}, }; } @@ -399,6 +461,7 @@ void Solution::format( << "Leftover value: " << leftover_value() << std::endl << "Staircase leftover value: " << staircase_leftover_value() << std::endl << "Total leftover value: " << total_leftover_value() << std::endl + << "Net cost: " << net_cost() << std::endl << "Total staircase leftover value: " << total_staircase_leftover_value() << std::endl ; } diff --git a/src/rectangle/tree_search.cpp b/src/rectangle/tree_search.cpp index 151b9321a..b86ef0523 100644 --- a/src/rectangle/tree_search.cpp +++ b/src/rectangle/tree_search.cpp @@ -555,17 +555,17 @@ BranchingScheme::Node BranchingScheme::child_tmp( "node.waste: " + std::to_string(node.waste) + "."); } - switch (instance.parameters().leftover_mode) { - case LeftoverMode::Area: { - node.leftover_value = bin_type.area() - node.xe_max * node.ye_max; - break; - } case LeftoverMode::X: case LeftoverMode::Y: { - // The leftover along the direction of the bin (Y on the flipped - // instance), as an area. - node.leftover_value = (bin_type.rect.x - node.xe_max) * bin_type.rect.y; - break; - } - } + // For 'LeftoverMode::Y', the leftover along the direction of the bin is + // the one along x on the flipped instance. + node.leftover_value = leftover_value( + instance.parameters().leftover_value_type, + (instance.parameters().leftover_mode == LeftoverMode::Y)? + LeftoverMode::X: + instance.parameters().leftover_mode, + bin_type.rect.x, + bin_type.rect.y, + node.xe_max, + node.ye_max); // Update the staircase of the last bin, in the same frame as the // leftover value. @@ -584,7 +584,7 @@ BranchingScheme::Node BranchingScheme::child_tmp( node.previous_bins_staircase_leftover_value = parent.previous_bins_staircase_leftover_value; } switch (instance.parameters().leftover_mode) { - case LeftoverMode::Area: { + case LeftoverMode::Area: case LeftoverMode::AreaCut: case LeftoverMode::Staircase: { node.last_bin_staircase.add(xe, ye); break; } case LeftoverMode::X: case LeftoverMode::Y: { @@ -594,6 +594,13 @@ BranchingScheme::Node BranchingScheme::child_tmp( } node.last_bin_staircase_leftover_value = bin_type.area() - node.last_bin_staircase.area(); + if (instance.parameters().leftover_mode == LeftoverMode::Staircase) { + node.leftover_value = staircase_leftover_value( + instance.parameters().leftover_value_type, + bin_type.rect.x, + bin_type.rect.y, + node.last_bin_staircase.extents()); + } if (instance.unloading_constraint() == rectangle::UnloadingConstraint::IncreasingX) { if (node.groups[item_type.group_id].x_min > insertion.x) @@ -1192,7 +1199,7 @@ bool BranchingScheme::better( const std::shared_ptr& node_2) const { switch (instance().objective()) { - case Objective::BinPacking: case Objective::VariableSizedBinPacking: { + case Objective::BinPacking: case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { if (!leaf(node_1)) return false; if (!leaf(node_2)) @@ -1260,7 +1267,7 @@ bool BranchingScheme::bound( const std::shared_ptr& node_2) const { switch (instance().objective()) { - case Objective::BinPacking: case Objective::VariableSizedBinPacking: { + case Objective::BinPacking: case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { if (!leaf(node_2)) return false; BinPos bin_pos = -1; diff --git a/src/rectangle/tree_search.hpp b/src/rectangle/tree_search.hpp index dd19c0ffa..6acc79b78 100644 --- a/src/rectangle/tree_search.hpp +++ b/src/rectangle/tree_search.hpp @@ -205,8 +205,8 @@ class BranchingScheme /** Waste. */ Area waste = 0; - /** Leftover value. */ - Profit leftover_value = 0; + /** Leftover value of the last bin (see 'leftover_value'). */ + double leftover_value = 0; /** Staircase of the items of the last bin. */ Staircase2D last_bin_staircase; @@ -214,8 +214,14 @@ class BranchingScheme /** Staircase leftover value of the last bin. */ Area last_bin_staircase_leftover_value = 0; - /** Sum of the leftover values of the bins but the last one. */ - Area previous_bins_leftover_value = 0; + /** + * Sum of the leftover values of the bins but the last one. + * + * Two nodes with the same number of bins have the same bin types, so + * comparing these sums is the same as comparing the leftover values + * of all the bins of the instance. + */ + double previous_bins_leftover_value = 0; /** Sum of the staircase leftover values of the bins but the last one. */ Area previous_bins_staircase_leftover_value = 0; diff --git a/src/rectangleguillotine/algorithm_formatter.cpp b/src/rectangleguillotine/algorithm_formatter.cpp index 16bc36b58..0b5ad75d4 100644 --- a/src/rectangleguillotine/algorithm_formatter.cpp +++ b/src/rectangleguillotine/algorithm_formatter.cpp @@ -122,7 +122,7 @@ void AlgorithmFormatter::print_header() << std::setw(32) << "-------" << std::endl; break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { *os_ << std::setw(12) << "Time" << std::setw(14) << "Cost" @@ -210,7 +210,7 @@ void AlgorithmFormatter::print( << std::setw(32) << s << std::endl; break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { *os_ << std::setw(12) << std::fixed << std::setprecision(3) << output_.time << std::defaultfloat << std::setprecision(precision) << std::setw(14) << output_.solution_pool.best().cost() @@ -367,7 +367,7 @@ void AlgorithmFormatter::update_bounds( case Objective::BinPacking: update_bin_packing_bound(output.bin_packing_bound); break; - case Objective::VariableSizedBinPacking: + case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: update_variable_sized_bin_packing_bound(output.variable_sized_bin_packing_bound); break; case Objective::OpenDimensionX: diff --git a/src/rectangleguillotine/benders_decomposition.cpp b/src/rectangleguillotine/benders_decomposition.cpp index 9befc79ce..ba889a25f 100644 --- a/src/rectangleguillotine/benders_decomposition.cpp +++ b/src/rectangleguillotine/benders_decomposition.cpp @@ -541,7 +541,7 @@ onedimensional::Instance build_master_instance( Profit variable_sized_bin_packing_goal) { onedimensional::InstanceBuilder master_instance_builder; - master_instance_builder.set_objective(instance.objective()); + master_instance_builder.set_objective(onedimensional_subproblem_objective(instance.objective())); master_instance_builder.set_bin_packing_goal(bin_packing_goal); master_instance_builder.set_knapsack_goal(knapsack_goal); master_instance_builder.set_variable_sized_bin_packing_goal(variable_sized_bin_packing_goal); @@ -824,7 +824,7 @@ bool packingsolver::rectangleguillotine::benders_decomposition_supported( { if (instance.objective() != Objective::Knapsack && instance.objective() != Objective::BinPacking - && instance.objective() != Objective::VariableSizedBinPacking) { + && !is_variable_sized_bin_packing(instance.objective())) { return false; } if (instance.number_of_non_empty_stacks() != instance.number_of_item_types()) @@ -956,7 +956,7 @@ const BendersDecompositionOutput packingsolver::rectangleguillotine::benders_dec algorithm_formatter.update_knapsack_bound(master_output.knapsack_bound); } else if (instance.objective() == Objective::BinPacking) { algorithm_formatter.update_bin_packing_bound(master_output.bin_packing_bound); - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { algorithm_formatter.update_variable_sized_bin_packing_bound( master_output.variable_sized_bin_packing_bound); } @@ -974,7 +974,7 @@ const BendersDecompositionOutput packingsolver::rectangleguillotine::benders_dec master_knapsack_goal = (std::min)( master_knapsack_goal, master_output.knapsack_bound); - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { master_variable_sized_bin_packing_goal = (std::max)( master_variable_sized_bin_packing_goal, master_output.variable_sized_bin_packing_bound); @@ -1025,7 +1025,7 @@ const BendersDecompositionOutput packingsolver::rectangleguillotine::benders_dec } else if (instance.objective() == Objective::BinPacking) { if (master_solution.number_of_bins() >= output.solution_pool.best().number_of_bins()) break; - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { if (master_solution.cost() >= output.solution_pool.best().cost()) break; } diff --git a/src/rectangleguillotine/instance.cpp b/src/rectangleguillotine/instance.cpp index 695af0bc6..5ee895735 100644 --- a/src/rectangleguillotine/instance.cpp +++ b/src/rectangleguillotine/instance.cpp @@ -377,7 +377,8 @@ void Instance::write_csv( << "minimum_waste_length," << parameters().minimum_waste_length << std::endl << "maximum_number_1_cuts," << parameters().maximum_number_1_cuts << std::endl << "maximum_number_2_cuts," << parameters().maximum_number_2_cuts << std::endl - << "cut_thickness," << parameters().cut_thickness << std::endl; + << "cut_thickness," << parameters().cut_thickness << std::endl + << "leftover_value_type," << parameters().leftover_value_type << std::endl; for (Counter stage_id = 0; stage_id < (Counter)parameters().cutting_costs.size(); ++stage_id) { @@ -435,6 +436,11 @@ void Instance::write_json( j["maximum_number_2_cuts"] = parameters().maximum_number_2_cuts; j["cut_through_defects"] = parameters().cut_through_defects; j["cut_thickness"] = parameters().cut_thickness; + { + std::stringstream ss; + ss << parameters().leftover_value_type; + j["leftover_value_type"] = ss.str(); + } if (!parameters().cutting_costs.empty()) { j["cutting_costs"] = nlohmann::json::array(); for (const CutCost& cutting_cost: parameters().cutting_costs) { @@ -577,6 +583,7 @@ std::ostream& Instance::format( << "Maximum number of consecutive 2-cuts: " << parameters().maximum_number_2_cuts << std::endl << "Cut through defects: " << parameters().cut_through_defects << std::endl << "Cut thickness: " << parameters().cut_thickness << std::endl + << "Leftover value type: " << parameters().leftover_value_type << std::endl << "Total item area: " << item_area() << std::endl << "Total item profit: " << item_profit() << std::endl << "Largest item profit: " << largest_item_profit() << std::endl diff --git a/src/rectangleguillotine/instance_builder.cpp b/src/rectangleguillotine/instance_builder.cpp index ccdb19a81..cb4adf6c4 100644 --- a/src/rectangleguillotine/instance_builder.cpp +++ b/src/rectangleguillotine/instance_builder.cpp @@ -1,5 +1,7 @@ #include "packingsolver/rectangleguillotine/instance_builder.hpp" +#include "algorithms/leftover.hpp" + #include "rectangleguillotine/block.hpp" #include "rectangleguillotine/instance_cache.hpp" @@ -952,6 +954,8 @@ void InstanceBuilder::read_parameters( set_cut_through_defects(std::stol(value)); } else if (name == "cut_thickness") { set_cut_thickness(std::stol(value)); + } else if (name == "leftover_value_type") { + set_leftover_value_type(read_enum(value, name)); } else if (name.rfind("cuts_fixed_cost_", 0) == 0) { Counter stage_id = std::stol(name.substr(16)); set_fixed_cutting_cost(stage_id, std::stoll(value)); @@ -1281,6 +1285,11 @@ void InstanceBuilder::read( set_cut_through_defects(j["cut_through_defects"]); if (j.contains("cut_thickness")) set_cut_thickness(j["cut_thickness"]); + if (j.contains("leftover_value_type")) { + set_leftover_value_type(read_enum( + j["leftover_value_type"].get(), + "leftover_value_type")); + } if (j.contains("cutting_costs")) { Counter stage_id = 0; for (const auto& json_cutting_cost: j["cutting_costs"]) { @@ -1786,6 +1795,24 @@ Instance InstanceBuilder::build() if (original_instance_ != nullptr) copy_cache_from_original_instance(); + // Compute the factor which converts a leftover value into a space. + instance_.leftover_value_factor_ = 0; + for (const BinType& bin_type: instance_.bin_types_) { + double space = (double)bin_type.area(); + double value = packingsolver::leftover_value<2>( + instance_.parameters_.leftover_value_type, + {(double)(bin_type.rect.w - bin_type.left_trim - bin_type.right_trim), + (double)(bin_type.rect.h - bin_type.bottom_trim - bin_type.top_trim)}, + {0.0, 0.0}, + false); + if (value <= 0) + continue; + if (instance_.leftover_value_factor_ == 0 + || space / value < instance_.leftover_value_factor_) { + instance_.leftover_value_factor_ = space / value; + } + } + return std::move(instance_); } diff --git a/src/rectangleguillotine/main.cpp b/src/rectangleguillotine/main.cpp index 0e85e6dd2..e3bdae2ff 100644 --- a/src/rectangleguillotine/main.cpp +++ b/src/rectangleguillotine/main.cpp @@ -95,6 +95,7 @@ int main(int argc, char *argv[]) ("maximum-number-2-cuts,", po::value(), "") ("cut-through-defects", po::value(), "") ("cut-thickness", po::value(), "") + ("leftover-value-type,", po::value(), "Leftover value type (variable-sized-bin-packing-with-leftovers): squared-area, depth") ("fixed-cutting-costs", po::value>()->multitoken(), "") ("variable-cutting-costs", po::value>()->multitoken(), "") ("waste-cost", po::value(), "") @@ -265,6 +266,8 @@ int main(int argc, char *argv[]) instance_builder.set_cut_through_defects(vm["cut-through-defects"].as()); if (vm.count("cut-thickness")) instance_builder.set_cut_thickness(vm["cut-thickness"].as()); + if (vm.count("leftover-value-type")) + instance_builder.set_leftover_value_type(vm["leftover-value-type"].as()); if (vm.count("fixed-cutting-costs")) { const auto& fixed_cutting_costs = vm["fixed-cutting-costs"].as>(); for (Counter stage_id = 0; diff --git a/src/rectangleguillotine/optimize.cpp b/src/rectangleguillotine/optimize.cpp index 6d139816b..42d095461 100644 --- a/src/rectangleguillotine/optimize.cpp +++ b/src/rectangleguillotine/optimize.cpp @@ -163,7 +163,7 @@ void optimize_onedimensional_bound( // same cost), so the bound the onedimensional solver finds for it // (which runs the same dichotomic search) is a valid lower bound here. onedimensional::InstanceBuilder onedim_instance_builder; - onedim_instance_builder.set_objective(instance.objective()); + onedim_instance_builder.set_objective(onedimensional_subproblem_objective(instance.objective())); for (BinTypeId bin_type_id = 0; bin_type_id < instance.number_of_bin_types(); ++bin_type_id) { @@ -226,7 +226,7 @@ void optimize_onedimensional_bound( algorithm_formatter.update_knapsack_bound( onedim_output.knapsack_bound + negative_penalty_sum(instance)); break; - } case Objective::VariableSizedBinPacking: { + } case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { algorithm_formatter.update_variable_sized_bin_packing_bound( onedim_output.variable_sized_bin_packing_bound); break; @@ -912,7 +912,7 @@ packingsolver::rectangleguillotine::Output packingsolver::rectangleguillotine::o if (instance.objective() == Objective::BinPacking || instance.objective() == Objective::BinPackingWithLeftovers || instance.objective() == Objective::Knapsack - || instance.objective() == Objective::VariableSizedBinPacking + || is_variable_sized_bin_packing(instance.objective()) || instance.objective() == Objective::Feasibility) { optimize_onedimensional_bound( instance, @@ -1162,7 +1162,7 @@ packingsolver::rectangleguillotine::Output packingsolver::rectangleguillotine::o } } } - } else if (instance.objective() == Objective::VariableSizedBinPacking) { + } else if (is_variable_sized_bin_packing(instance.objective())) { // Disable algorithms which are not available for this objective. use_column_generation_strips = false; use_sequential_strips_onedimensional = false; diff --git a/src/rectangleguillotine/reduction.cpp b/src/rectangleguillotine/reduction.cpp index aac7cdf75..f2b80e00f 100644 --- a/src/rectangleguillotine/reduction.cpp +++ b/src/rectangleguillotine/reduction.cpp @@ -390,7 +390,7 @@ bool Reduction::lift_item_dimensions_applies(const Instance& instance) // other axis (see 'lift_item_dimensions_applies_axis'). if (instance.objective() != Objective::Knapsack && instance.objective() != Objective::BinPacking - && instance.objective() != Objective::VariableSizedBinPacking + && !is_variable_sized_bin_packing(instance.objective()) && instance.objective() != Objective::Feasibility && instance.objective() != Objective::OpenDimensionX && instance.objective() != Objective::OpenDimensionY) { @@ -516,7 +516,7 @@ bool Reduction::remove_dominated_bin_types_applies(const Instance& instance) // available earlier than the original instance allows. if (instance.objective() != Objective::Knapsack && instance.objective() != Objective::Feasibility - && instance.objective() != Objective::VariableSizedBinPacking) { + && !is_variable_sized_bin_packing(instance.objective())) { return false; } return instance.number_of_bin_types() > 1; diff --git a/src/rectangleguillotine/sequential_strips_onedimensional.cpp b/src/rectangleguillotine/sequential_strips_onedimensional.cpp index aca5a0138..67c724be5 100644 --- a/src/rectangleguillotine/sequential_strips_onedimensional.cpp +++ b/src/rectangleguillotine/sequential_strips_onedimensional.cpp @@ -220,7 +220,7 @@ void run_phase2_and_reconstruct( std::vector strips = split_into_strips(instance, phase1_solution, orientation); onedimensional::InstanceBuilder phase2_instance_builder; - phase2_instance_builder.set_objective(instance.objective()); + phase2_instance_builder.set_objective(onedimensional_subproblem_objective(instance.objective())); BinTypeId phase2_bin_type_id = phase2_instance_builder.add_bin_type( first_stage_length + cut_thickness); phase2_instance_builder.set_bin_type_cost(phase2_bin_type_id, bin_type.cost); diff --git a/src/rectangleguillotine/solution.cpp b/src/rectangleguillotine/solution.cpp index eb49fd7fd..8473f214c 100644 --- a/src/rectangleguillotine/solution.cpp +++ b/src/rectangleguillotine/solution.cpp @@ -2,6 +2,8 @@ #include "rectangleguillotine/solution_builder.hpp" +#include "algorithms/leftover.hpp" + #include "optimizationtools/utils/utils.hpp" #include @@ -44,6 +46,108 @@ std::ostream& packingsolver::rectangleguillotine::operator<<( /////////////////////////////////// Solution /////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// +namespace +{ + +/** + * Value of a rectangular leftover of a bin, restricted to the part of the bin + * inside the trims. + */ +double rectangle_leftover_value( + LeftoverValueType leftover_value_type, + const BinType& bin_type, + Length l, + Length r, + Length b, + Length t) +{ + l = (std::max)(l, bin_type.left_trim); + r = (std::min)(r, bin_type.rect.w - bin_type.right_trim); + b = (std::max)(b, bin_type.bottom_trim); + t = (std::min)(t, bin_type.rect.h - bin_type.top_trim); + if (l >= r || b >= t) + return 0.0; + return packingsolver::leftover_value<2>( + leftover_value_type, + {(double)(r - l), (double)(t - b)}, + {0.0, 0.0}, + false); +} + +/** Value of a bin which is not used. */ +double bin_leftover_value( + LeftoverValueType leftover_value_type, + const BinType& bin_type) +{ + return rectangle_leftover_value( + leftover_value_type, + bin_type, + 0, + bin_type.rect.w, + 0, + bin_type.rect.h); +} + +/** Return 'true' iff a node is a sub-plate which is not used. */ +bool unused_node(const SolutionNode& node) +{ + return node.children.empty() + && (node.item_type_id == -1 || node.item_type_id == -3); +} + +/** + * Value of the leftovers of a bin: the plate after its last 1-cut and the + * sub-plate after the last 2-cut of its last first-level sub-plate, when they + * are not used. + */ +double bin_leftover_value( + LeftoverValueType leftover_value_type, + const BinType& bin_type, + const SolutionBin& bin) +{ + if (bin.nodes.empty()) + return bin_leftover_value(leftover_value_type, bin_type); + const SolutionNode& root = bin.nodes[0]; + if (root.children.empty()) { + return (unused_node(root))? + bin_leftover_value(leftover_value_type, bin_type): + 0.0; + } + double value = 0.0; + SolutionNodeId plate_pos = (SolutionNodeId)root.children.size() - 1; + // Plate after the last 1-cut. + const SolutionNode& last_plate = bin.nodes[root.children[plate_pos]]; + if (unused_node(last_plate)) { + value += rectangle_leftover_value( + leftover_value_type, + bin_type, + last_plate.l, + last_plate.r, + last_plate.b, + last_plate.t); + --plate_pos; + } + // Sub-plate after the last 2-cut of the last first-level sub-plate. + if (plate_pos >= 0) { + const SolutionNode& plate = bin.nodes[root.children[plate_pos]]; + if (plate.children.size() >= 2) { + const SolutionNode& sub_plate = bin.nodes[plate.children.back()]; + if (unused_node(sub_plate)) { + value += rectangle_leftover_value( + leftover_value_type, + bin_type, + sub_plate.l, + sub_plate.r, + sub_plate.b, + sub_plate.t); + } + } + } + return value; +} + +} + void Solution::update_indicators( BinPos bin_pos) { @@ -365,6 +469,16 @@ void Solution::update_indicators( } } } + // Update the leftover values. + LeftoverValueType leftover_value_type = instance().parameters().leftover_value_type; + bin.leftover_value = bin_leftover_value(leftover_value_type, bin_type, bin); + leftover_value_loss_ += bin.copies * ( + bin_leftover_value(leftover_value_type, bin_type) + - bin.leftover_value); + net_cost_ += bin.copies * ( + bin_type.cost + - instance().leftover_refund(bin.bin_type_id, bin.leftover_value)); + // Staging analysis. // // First pass: compute the maximum depth of any CUT node in this bin. @@ -548,6 +662,20 @@ void Solution::append_empty_bin( append_bins(solution_builder.build(), {}, {}); } +double Solution::total_leftover_value() const +{ + double value = 0; + for (BinTypeId bin_type_id = 0; + bin_type_id < instance().number_of_bin_types(); + ++bin_type_id) { + const BinType& bin_type = instance().bin_type(bin_type_id); + value += bin_type.copies * bin_leftover_value( + instance().parameters().leftover_value_type, + bin_type); + } + return value - leftover_value_loss_; +} + bool Solution::operator<(const Solution& solution) const { // Check feasibility. @@ -575,6 +703,10 @@ bool Solution::operator<(const Solution& solution) const return strictly_greater_profit(solution.profit(), profit()); } case Objective::VariableSizedBinPacking: { return strictly_lesser_cost(solution.cost(), cost()); + } case Objective::VariableSizedBinPackingWithLeftovers: { + // The net cost: the cost of the bins minus the refunds of their + // leftovers (see 'Instance::leftover_refund'). + return strictly_lesser_cost(solution.net_cost(), net_cost()); } default: { std::stringstream ss; ss << FUNC_SIGNATURE << ": " @@ -661,6 +793,8 @@ nlohmann::json Solution::to_json() const {"Width", width()}, {"Height", height()}, {"SecondLeftoverValue", second_leftover_value()}, + {"TotalLeftoverValue", total_leftover_value()}, + {"NetCost", net_cost()}, {"NumberOfStages", number_of_stages()}, {"Feasible", { {"Feasible", feasible()}, @@ -700,6 +834,8 @@ void Solution::format( << "Width: " << width() << std::endl << "Height: " << height() << std::endl << "Second leftover value: " << second_leftover_value() << std::endl + << "Total leftover value: " << total_leftover_value() << std::endl + << "Net cost: " << net_cost() << std::endl << "Number of stages: " << number_of_stages() << std::endl << "Feasible: " << feasible() << std::endl << " Number of stages: " << number_of_stages_feasible() << std::endl diff --git a/src/rectangleguillotine/tree_search.cpp b/src/rectangleguillotine/tree_search.cpp index 859b5c938..d3f08b706 100644 --- a/src/rectangleguillotine/tree_search.cpp +++ b/src/rectangleguillotine/tree_search.cpp @@ -193,7 +193,7 @@ bool BranchingScheme::bound( const std::shared_ptr& node_2) const { switch (instance().objective()) { - case Objective::BinPacking: case Objective::VariableSizedBinPacking: { + case Objective::BinPacking: case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { if (!leaf(node_2)) return false; BinPos bin_pos = -1; @@ -252,7 +252,7 @@ bool BranchingScheme::better( const std::shared_ptr& node_2) const { switch (instance().objective()) { - case Objective::BinPacking: case Objective::VariableSizedBinPacking: { + case Objective::BinPacking: case Objective::VariableSizedBinPacking: case Objective::VariableSizedBinPackingWithLeftovers: { if (!leaf(node_1)) return false; if (!leaf(node_2)) diff --git a/src/rectangleguillotine/tree_search_maximal_spaces.cpp b/src/rectangleguillotine/tree_search_maximal_spaces.cpp index 2b5a412d4..621656d3a 100644 --- a/src/rectangleguillotine/tree_search_maximal_spaces.cpp +++ b/src/rectangleguillotine/tree_search_maximal_spaces.cpp @@ -1056,7 +1056,7 @@ const packingsolver::rectangleguillotine::TreeSearchMaximalSpacesOutput packings << "does not support instances with more than one bin."; throw std::logic_error(ss.str()); } - if (instance.objective() == Objective::VariableSizedBinPacking) { + if (is_variable_sized_bin_packing(instance.objective())) { std::stringstream ss; ss << FUNC_SIGNATURE << ": " << "algorithm 'rectangleguillotine::tree_search_maximal_spaces' " diff --git a/test/algorithms/CMakeLists.txt b/test/algorithms/CMakeLists.txt index 14c675fa7..2dfc42b6d 100644 --- a/test/algorithms/CMakeLists.txt +++ b/test/algorithms/CMakeLists.txt @@ -1,6 +1,7 @@ add_executable(PackingSolver_algorithms_test) target_sources(PackingSolver_algorithms_test PRIVATE common_test.cpp + leftover_test.cpp meet_in_the_middle_test.cpp staircase_test.cpp truck_test.cpp) diff --git a/test/algorithms/leftover_test.cpp b/test/algorithms/leftover_test.cpp new file mode 100644 index 000000000..fc50fc62c --- /dev/null +++ b/test/algorithms/leftover_test.cpp @@ -0,0 +1,171 @@ +#include "algorithms/leftover.hpp" + +#include + +using namespace packingsolver; + +TEST(Leftover, Rectangle) +{ + // Value of a w x h rectangle, h <= w: h^2 (3w - h) / 12. + EXPECT_NEAR(box_leftover_value<2>({1500, 1000}), 1000.0 * 1000 * (3 * 1500 - 1000) / 12, 1e-3); + EXPECT_NEAR(box_leftover_value<2>({1000, 1500}), 1000.0 * 1000 * (3 * 1500 - 1000) / 12, 1e-3); + EXPECT_NEAR(box_leftover_value<2>({1200, 1200}), 1200.0 * 1200 * 1200 / 6, 1e-3); + // A used box spanning the bin along y leaves a rectangle. + EXPECT_NEAR( + leftover_value<2>({3000, 1500}, {1000, 1500}), + box_leftover_value<2>({2000, 1500}), + 1e-3); +} + +TEST(Leftover, Segment) +{ + // In one dimension, the value of a segment of length l is l^2 / 4. + EXPECT_NEAR(leftover_value<1>({100}, {40}), 60.0 * 60 / 4, 1e-6); +} + +TEST(Leftover, Cube) +{ + // Value of a cube of side s: integral of (s - 2t)^3 from 0 to s / 2, that + // is s^4 / 8. + EXPECT_NEAR(box_leftover_value<3>({100, 100, 100}), 100.0 * 100 * 100 * 100 / 8, 1e-3); +} + +TEST(Leftover, LShape) +{ + // Bin 3000 x 1500 minus 2000 x 1000: the leftover shrunk by t has area + // (3000 - 2t)(1500 - 2t) - 2000 * 1000 for t <= 250, then + // (3000 - 2t)(1500 - 2t) - 2000 (1500 - 2t) = (1000 - 2t)(1500 - 2t) for + // t <= 500, then 0. + double expected + = (3000.0 * 1500 - 2000.0 * 1000) * 250 + - 2 * (3000 + 1500) * 250.0 * 250 / 2 + + 4 * 250.0 * 250 * 250 / 3; + // Integral of (1000 - 2t)(1500 - 2t) from 250 to 500. + auto f = [](double t) { return 1000.0 * 1500 * t - (1000 + 1500) * t * t + 4 * t * t * t / 3; }; + expected += f(500) - f(250); + EXPECT_NEAR(leftover_value<2>({3000, 1500}, {2000, 1000}), expected, 1e-9 * expected); + // Worth more than any cut into two rectangles. + EXPECT_GT( + leftover_value<2>({3000, 1500}, {2000, 1000}), + cut_leftover_value<2>({3000, 1500}, {2000, 1000})); +} + +TEST(Leftover, Cut) +{ + // Bin 3000 x 1500 minus 2000 x 1000: cut vertically into 1000 x 1500 and + // 2000 x 500, or horizontally into 3000 x 500 and 1000 x 1000. + double vertical = box_leftover_value<2>({1000, 1500}) + box_leftover_value<2>({2000, 500}); + double horizontal = box_leftover_value<2>({3000, 500}) + box_leftover_value<2>({1000, 1000}); + EXPECT_NEAR( + cut_leftover_value<2>({3000, 1500}, {2000, 1000}), + std::max(vertical, horizontal), + 1e-3); + // Without a used box, the leftover is the whole bin. + EXPECT_NEAR( + cut_leftover_value<2>({3000, 1500}, {0, 0}), + box_leftover_value<2>({3000, 1500}), + 1e-3); + // With a used box spanning the bin, there is no leftover. + EXPECT_NEAR(cut_leftover_value<2>({3000, 1500}, {3000, 1500}), 0.0, 1e-9); + EXPECT_NEAR(leftover_value<2>({3000, 1500}, {3000, 1500}), 0.0, 1e-9); +} + +TEST(Leftover, Monotone) +{ + // A larger used box gives a smaller value. + EXPECT_GT( + leftover_value<3>({1000, 800, 600}, {500, 400, 300}), + leftover_value<3>({1000, 800, 600}, {600, 400, 300})); + EXPECT_GT( + leftover_value<2>({1000, 800}, {500, 400}), + leftover_value<2>({1000, 800}, {500, 401})); +} + +TEST(Leftover, Concentrated) +{ + // Two bins 3000 x 1500 with 3 m^2 free in total: one leftover of + // 1500 x 1500 and one of 500 x 1500 is worth more than two leftovers of + // 1000 x 1500. + EXPECT_GT( + leftover_value<2>({3000, 1500}, {1500, 1500}) + + leftover_value<2>({3000, 1500}, {2500, 1500}), + 2 * leftover_value<2>({3000, 1500}, {2000, 1500})); +} + +TEST(Leftover, StaircaseSingleStep) +{ + // A staircase with a single step is an L-shape. + for (LeftoverValueType leftover_value_type: { + LeftoverValueType::SquaredArea, + LeftoverValueType::Depth}) { + double expected = leftover_value<2>(leftover_value_type, {3000, 1500}, {2000, 1000}, false); + EXPECT_NEAR( + staircase_leftover_value<2>(leftover_value_type, {3000, 1500}, {{2000, 1000}}), + expected, + 1e-9 * expected); + expected = leftover_value<3>(leftover_value_type, {100, 50, 40}, {60, 20, 10}, false); + EXPECT_NEAR( + staircase_leftover_value<3>(leftover_value_type, {100, 50, 40}, {{60, 20, 10}}), + expected, + 1e-9 * expected); + } +} + +TEST(Leftover, StaircaseEmpty) +{ + // Without steps, the leftover is the whole bin. + EXPECT_NEAR( + staircase_leftover_value<2>(LeftoverValueType::Depth, {1500, 1000}, {}), + box_leftover_value<2>({1500, 1000}), + 1e-3); +} + +TEST(Leftover, StaircaseSquaredArea) +{ + // Bin 12 x 10 minus the steps 6 x 4 and 3 x 8: area 120 - 24 - 12 = 84. + EXPECT_NEAR( + staircase_leftover_value<2>(LeftoverValueType::SquaredArea, {12, 10}, {{6, 4}, {3, 8}}), + 84.0 * 84.0, + 1e-9); + // Bin 10 x 10 x 10 minus the boxes 5 x 5 x 10 and 10 x 5 x 5: volume + // 1000 - 250 - 250 + 125 = 625. + EXPECT_NEAR( + staircase_leftover_value<3>(LeftoverValueType::SquaredArea, {10, 10, 10}, {{5, 5, 10}, {10, 5, 5}}), + 625.0 * 625.0, + 1e-9); +} + +TEST(Leftover, StaircaseDepth) +{ + // Bin 12 x 10 minus the steps 6 x 4 and 3 x 8, against a numerical + // integration of the distance to the edge on a fine grid. The distance + // of a point to the edge is its distance to the border of the bin or to + // a step, whichever is smaller; the distance to the step [0, ex] x + // [0, ey] of a point outside it is max(x - ex, y - ey). + double w = 12; + double h = 10; + std::vector> steps = {{6, 4}, {3, 8}}; + int n = 1200; + double cell_x = w / n; + double cell_y = h / n; + double expected = 0; + for (int ix = 0; ix < n; ++ix) { + for (int iy = 0; iy < n; ++iy) { + double x = (ix + 0.5) * cell_x; + double y = (iy + 0.5) * cell_y; + double distance = std::min(std::min(x, w - x), std::min(y, h - y)); + bool inside_step = false; + for (const auto& step: steps) { + if (x < step[0] && y < step[1]) + inside_step = true; + distance = std::min(distance, std::max(x - step[0], y - step[1])); + } + if (!inside_step) + expected += distance * cell_x * cell_y; + } + } + double value = staircase_leftover_value<2>(LeftoverValueType::Depth, {w, h}, steps); + EXPECT_NEAR(value, expected, 1e-3 * expected); + // The staircase is worth more than the L-shape of its bounding box. + EXPECT_GT(value, leftover_value<2>({w, h}, {6, 8})); +} diff --git a/test/box/box_test.cpp b/test/box/box_test.cpp index 2ae679fde..e691756a3 100644 --- a/test/box/box_test.cpp +++ b/test/box/box_test.cpp @@ -2,6 +2,7 @@ #include "packingsolver/box/optimize.hpp" #include "packingsolver/box/post_process.hpp" #include "box/solution_builder.hpp" +#include "algorithms/leftover.hpp" #include #include @@ -110,33 +111,106 @@ TEST(Box, UnlimitedItemCopies) TEST(Box, LeftoverModes) { - // A 100 x 50 x 40 bin whose items end at x 60, y 20, z 10: the volume - // used in each leftover mode is the box from the origin to the items - // along the dimensions of the mode, and the whole bin along the others. - struct Case { LeftoverMode leftover_mode; packingsolver::Volume used; }; + // A 100 x 50 x 40 bin whose items end at x 60, y 20, z 10: the box used + // in each leftover mode is the box from the origin to the items along + // the dimensions of the mode, and the whole bin along the others. The + // leftover is the bin minus this box, cut into boxes for the 'Cut' + // modes. Its value is its squared volume, or its depth-weighted value. + struct Case { LeftoverMode leftover_mode; std::array used; bool cut; }; for (Case c: std::vector{ - {LeftoverMode::X, 60 * 50 * 40}, - {LeftoverMode::Y, 100 * 20 * 40}, - {LeftoverMode::Z, 100 * 50 * 10}, - {LeftoverMode::XY, 60 * 20 * 40}, - {LeftoverMode::XZ, 60 * 50 * 10}, - {LeftoverMode::YZ, 100 * 20 * 10}, - {LeftoverMode::XYZ, 60 * 20 * 10}}) { + {LeftoverMode::X, {60, 50, 40}, false}, + {LeftoverMode::Y, {100, 20, 40}, false}, + {LeftoverMode::Z, {100, 50, 10}, false}, + {LeftoverMode::XY, {60, 20, 40}, false}, + {LeftoverMode::XZ, {60, 50, 10}, false}, + {LeftoverMode::YZ, {100, 20, 10}, false}, + {LeftoverMode::XYZ, {60, 20, 10}, false}, + {LeftoverMode::XYCut, {60, 20, 40}, true}, + {LeftoverMode::XZCut, {60, 50, 10}, true}, + {LeftoverMode::YZCut, {100, 20, 10}, true}, + {LeftoverMode::XYZCut, {60, 20, 10}, true}, + // The two items form a single step. + {LeftoverMode::Staircase, {60, 20, 10}, false}}) { + for (packingsolver::LeftoverValueType leftover_value_type: { + packingsolver::LeftoverValueType::SquaredArea, + packingsolver::LeftoverValueType::Depth}) { + InstanceBuilder instance_builder; + instance_builder.set_objective(packingsolver::Objective::BinPackingWithLeftovers); + instance_builder.set_leftover_mode(c.leftover_mode); + instance_builder.set_leftover_value_type(leftover_value_type); + instance_builder.add_bin_type(100, 50, 40); + packingsolver::ItemTypeId item_type_id = instance_builder.add_item_type(30, 20, 10); + instance_builder.set_item_type_copies(item_type_id, 2); + const Instance instance = instance_builder.build(); + SolutionBuilder solution_builder(instance); + solution_builder.add_bin(0, 1); + solution_builder.add_item(0, item_type_id, {0, 0, 0}, Rotation::XYZ); + solution_builder.add_item(0, item_type_id, {30, 0, 0}, Rotation::XYZ); + const Solution solution = solution_builder.build(); + EXPECT_TRUE(solution.feasible()); + packingsolver::Volume used = (packingsolver::Volume)(c.used[0] * c.used[1] * c.used[2]); + double expected_leftover_value = 0; + if (leftover_value_type == packingsolver::LeftoverValueType::SquaredArea) { + if (c.cut) { + // The best cut into boxes for the squared volumes. + expected_leftover_value = packingsolver::cut_leftover_value<3>( + {100, 50, 40}, + c.used, + [](const std::array& box) + { + double volume = box[0] * box[1] * box[2]; + return volume * volume; + }); + } else { + double volume = 100 * 50 * 40 - used; + expected_leftover_value = volume * volume; + } + } else { + expected_leftover_value = (c.cut)? + packingsolver::cut_leftover_value<3>({100, 50, 40}, c.used): + packingsolver::leftover_value<3>({100, 50, 40}, c.used); + } + EXPECT_NEAR(solution.leftover_value(), expected_leftover_value, 1e-6 * expected_leftover_value) + << c.leftover_mode << " " << leftover_value_type; + EXPECT_EQ(solution.waste(), used - 2 * 30 * 20 * 10) << c.leftover_mode; + } + } +} + +TEST(Box, LeftoverModeStaircase) +{ + // A 10 x 10 x 10 bin with a 5 x 5 x 10 item at the origin and a 5 x 5 x 5 + // item next to it along x: the staircase is the union of the boxes + // 5 x 5 x 10 and 10 x 5 x 5, of volume 375, so the leftover is 625; with + // 'XYZ', the used box is the bounding box 10 x 5 x 10 of the items. + for (packingsolver::LeftoverValueType leftover_value_type: { + packingsolver::LeftoverValueType::SquaredArea, + packingsolver::LeftoverValueType::Depth}) { InstanceBuilder instance_builder; instance_builder.set_objective(packingsolver::Objective::BinPackingWithLeftovers); - instance_builder.set_leftover_mode(c.leftover_mode); - instance_builder.add_bin_type(100, 50, 40); - packingsolver::ItemTypeId item_type_id = instance_builder.add_item_type(30, 20, 10); - instance_builder.set_item_type_copies(item_type_id, 2); + instance_builder.set_leftover_mode(LeftoverMode::Staircase); + instance_builder.set_leftover_value_type(leftover_value_type); + instance_builder.add_bin_type(10, 10, 10); + packingsolver::ItemTypeId item_type_id_1 = instance_builder.add_item_type(5, 5, 10); + packingsolver::ItemTypeId item_type_id_2 = instance_builder.add_item_type(5, 5, 5); const Instance instance = instance_builder.build(); SolutionBuilder solution_builder(instance); solution_builder.add_bin(0, 1); - solution_builder.add_item(0, item_type_id, {0, 0, 0}, Rotation::XYZ); - solution_builder.add_item(0, item_type_id, {30, 0, 0}, Rotation::XYZ); + solution_builder.add_item(0, item_type_id_1, {0, 0, 0}, Rotation::XYZ); + solution_builder.add_item(0, item_type_id_2, {5, 0, 0}, Rotation::XYZ); const Solution solution = solution_builder.build(); EXPECT_TRUE(solution.feasible()); - EXPECT_EQ(solution.leftover_value(), 100 * 50 * 40 - c.used) << c.leftover_mode; - EXPECT_EQ(solution.waste(), c.used - 2 * 30 * 20 * 10) << c.leftover_mode; + double expected_leftover_value = (leftover_value_type == packingsolver::LeftoverValueType::SquaredArea)? + 625.0 * 625.0: + packingsolver::staircase_leftover_value<3>( + leftover_value_type, {10, 10, 10}, {{5, 5, 10}, {10, 5, 5}}); + EXPECT_NEAR(solution.leftover_value(), expected_leftover_value, 1e-9 * expected_leftover_value) + << leftover_value_type; + EXPECT_GT( + solution.leftover_value(), + packingsolver::box::leftover_value(leftover_value_type, LeftoverMode::XYZ, {10, 10, 10}, 10, 5, 10)); + // The waste is measured in the staircase. + EXPECT_EQ(solution.waste(), 0); } } @@ -174,7 +248,7 @@ TEST(Box, ReoptimizeNonLastBins) const Solution new_solution = reoptimize_non_last_bins(solution, parameters); ASSERT_TRUE(new_solution.feasible()); EXPECT_EQ(new_solution.number_of_bins(), 2); - EXPECT_EQ(new_solution.bin(0).leftover_value, 1000 - 250) + EXPECT_EQ(new_solution.bin(0).leftover_value, (1000.0 - 250) * (1000.0 - 250)) << "use_tree_search_maximal_spaces " << use_tree_search_maximal_spaces; EXPECT_EQ(new_solution.bin(0).staircase_leftover_value, 1000 - 250) << "use_tree_search_maximal_spaces " << use_tree_search_maximal_spaces; diff --git a/test/boxstacks/leftover_volume_test.cpp b/test/boxstacks/leftover_volume_test.cpp index 69bebb245..83ce2206d 100644 --- a/test/boxstacks/leftover_volume_test.cpp +++ b/test/boxstacks/leftover_volume_test.cpp @@ -2,6 +2,7 @@ #include "packingsolver/boxstacks/solution.hpp" #include "packingsolver/boxstacks/post_process.hpp" #include "boxstacks/solution_builder.hpp" +#include "algorithms/leftover.hpp" #include @@ -84,30 +85,62 @@ TEST(BoxStacks, LeftoverVolumeOnlyLastPhysicalBin) TEST(BoxStacks, LeftoverModes) { - // A 100 x 50 x 40 bin whose stacks end at x 60 and y 20: the volume used - // is the box from the origin to the stacks along the dimensions of the - // mode, the whole bin along the others, and the whole height. - struct Case { LeftoverMode leftover_mode; Volume used; }; + // A 100 x 50 x 40 bin whose stacks end at x 60 and y 20: the box used is + // the box from the origin to the stacks along the dimensions of the + // mode, the whole bin along the others, and the whole height. The + // leftover is the bin minus this box, cut into two boxes for 'XYCut'. + // Its value is its squared volume, or its depth-weighted value. + struct Case { LeftoverMode leftover_mode; std::array used; bool cut; }; for (Case c: std::vector{ - {LeftoverMode::X, 60 * 50 * 40}, - {LeftoverMode::Y, 100 * 20 * 40}, - {LeftoverMode::XY, 60 * 20 * 40}}) { - InstanceBuilder ib; - ib.set_objective(Objective::BinPackingWithLeftovers); - ib.set_leftover_mode(c.leftover_mode); - ib.add_bin_type(100, 50, 40); - auto item = ib.add_item_type(30, 20, 10); - ib.set_item_type_copies(item, 2); - const Instance instance = ib.build(); - SolutionBuilder sb(instance); - sb.add_bin(0, 1); - sb.add_stack(0, 0, 30, 0, 20); - sb.add_item(0, 0, item, Rotation::XYZ); - sb.add_stack(0, 30, 60, 0, 20); - sb.add_item(0, 1, item, Rotation::XYZ); - const Solution solution = sb.build(); - EXPECT_TRUE(solution.feasible()); - EXPECT_EQ(solution.leftover_value(), 100 * 50 * 40 - c.used) << c.leftover_mode; + {LeftoverMode::X, {60, 50, 40}, false}, + {LeftoverMode::Y, {100, 20, 40}, false}, + {LeftoverMode::XY, {60, 20, 40}, false}, + {LeftoverMode::XYCut, {60, 20, 40}, true}, + // The two stacks form a single step. + {LeftoverMode::Staircase, {60, 20, 40}, false}}) { + for (LeftoverValueType leftover_value_type: { + LeftoverValueType::SquaredArea, + LeftoverValueType::Depth}) { + InstanceBuilder ib; + ib.set_objective(Objective::BinPackingWithLeftovers); + ib.set_leftover_mode(c.leftover_mode); + ib.set_leftover_value_type(leftover_value_type); + ib.add_bin_type(100, 50, 40); + auto item = ib.add_item_type(30, 20, 10); + ib.set_item_type_copies(item, 2); + const Instance instance = ib.build(); + SolutionBuilder sb(instance); + sb.add_bin(0, 1); + sb.add_stack(0, 0, 30, 0, 20); + sb.add_item(0, 0, item, Rotation::XYZ); + sb.add_stack(0, 30, 60, 0, 20); + sb.add_item(0, 1, item, Rotation::XYZ); + const Solution solution = sb.build(); + EXPECT_TRUE(solution.feasible()); + double expected_leftover_value = 0; + if (leftover_value_type == LeftoverValueType::SquaredArea) { + if (c.cut) { + // The best cut into two boxes for the squared volumes. + expected_leftover_value = packingsolver::cut_leftover_value<3>( + {100, 50, 40}, + c.used, + [](const std::array& box) + { + double volume = box[0] * box[1] * box[2]; + return volume * volume; + }); + } else { + double volume = 100.0 * 50 * 40 - c.used[0] * c.used[1] * c.used[2]; + expected_leftover_value = volume * volume; + } + } else { + expected_leftover_value = (c.cut)? + packingsolver::cut_leftover_value<3>({100, 50, 40}, c.used): + packingsolver::leftover_value<3>({100, 50, 40}, c.used); + } + EXPECT_NEAR(solution.leftover_value(), expected_leftover_value, 1e-6 * expected_leftover_value) + << c.leftover_mode << " " << leftover_value_type; + } } } @@ -133,8 +166,8 @@ TEST(BoxStacks, LeftoverModeRanksSolutions) }; const Solution along_x = build(10, 0); const Solution along_y = build(0, 10); - EXPECT_EQ(along_x.leftover_value(), 100 * 90 * 100); - EXPECT_EQ(along_y.leftover_value(), 100 * 80 * 100); + EXPECT_EQ(along_x.leftover_value(), (100.0 * 90 * 100) * (100.0 * 90 * 100)); + EXPECT_EQ(along_y.leftover_value(), (100.0 * 80 * 100) * (100.0 * 80 * 100)); EXPECT_TRUE(along_y < along_x); // operator< means the right solution is better. } @@ -170,7 +203,7 @@ TEST(BoxStacks, ReoptimizeNonLastBins) const Solution new_solution = reoptimize_non_last_bins(solution, parameters); ASSERT_TRUE(new_solution.feasible()); EXPECT_EQ(new_solution.number_of_bins(), 2); - EXPECT_EQ(new_solution.bin(0).leftover_value, (100 - 50) * 10); + EXPECT_EQ(new_solution.bin(0).leftover_value, ((100.0 - 50) * 10) * ((100.0 - 50) * 10)); EXPECT_EQ(new_solution.bin(0).staircase_leftover_value, (100 - 50) * 10); EXPECT_EQ(new_solution.leftover_value(), solution.leftover_value()); EXPECT_TRUE(solution < new_solution); diff --git a/test/rectangle/rectangle_test.cpp b/test/rectangle/rectangle_test.cpp index 3ecbfce11..9cdc7e346 100644 --- a/test/rectangle/rectangle_test.cpp +++ b/test/rectangle/rectangle_test.cpp @@ -3,6 +3,8 @@ #include "packingsolver/rectangle/post_process.hpp" #include "rectangle/solution_builder.hpp" +#include "algorithms/leftover.hpp" + #include #include @@ -39,12 +41,106 @@ TEST(Rectangle, ReoptimizeNonLastBins) const Solution new_solution = reoptimize_non_last_bins(solution, parameters); ASSERT_TRUE(new_solution.feasible()); EXPECT_EQ(new_solution.number_of_bins(), 2); - EXPECT_EQ(new_solution.bin(0).leftover_value, 50); + EXPECT_EQ(new_solution.bin(0).leftover_value, 50 * 50); EXPECT_EQ(new_solution.bin(0).staircase_leftover_value, 50); EXPECT_EQ(new_solution.leftover_value(), solution.leftover_value()); EXPECT_TRUE(solution < new_solution); } +TEST(Rectangle, LeftoverModeStaircase) +{ + // A 12 x 10 bin with a 6 x 4 item at the origin and a 3 x 4 item above + // it: the staircase is the union of the rectangles 6 x 4 and 3 x 8, so the + // leftover area is 120 - 24 - 12 = 84, against 120 - 6 x 8 = 72 for the + // L-shape of the bounding box of the items. + for (packingsolver::LeftoverValueType leftover_value_type: { + packingsolver::LeftoverValueType::SquaredArea, + packingsolver::LeftoverValueType::Depth}) { + InstanceBuilder instance_builder; + instance_builder.set_objective(packingsolver::Objective::BinPackingWithLeftovers); + instance_builder.set_leftover_mode(LeftoverMode::Staircase); + instance_builder.set_leftover_value_type(leftover_value_type); + packingsolver::BinTypeId bin_type_id = instance_builder.add_bin_type(12, 10); + packingsolver::ItemTypeId item_type_id_1 = instance_builder.add_item_type(6, 4); + packingsolver::ItemTypeId item_type_id_2 = instance_builder.add_item_type(3, 4); + const Instance instance = instance_builder.build(); + + SolutionBuilder solution_builder(instance); + solution_builder.add_bin(bin_type_id, 1); + solution_builder.add_item(0, item_type_id_1, {0, 0}, false); + solution_builder.add_item(0, item_type_id_2, {0, 4}, false); + const Solution solution = solution_builder.build(); + ASSERT_TRUE(solution.feasible()); + double expected_leftover_value = (leftover_value_type == packingsolver::LeftoverValueType::SquaredArea)? + 84.0 * 84.0: + packingsolver::staircase_leftover_value<2>(leftover_value_type, {12, 10}, {{6, 4}, {3, 8}}); + EXPECT_NEAR(solution.leftover_value(), expected_leftover_value, 1e-9 * expected_leftover_value) + << leftover_value_type; + EXPECT_GT( + solution.leftover_value(), + packingsolver::rectangle::leftover_value(leftover_value_type, LeftoverMode::Area, 12, 10, 6, 8)); + // The waste is measured in the staircase. + EXPECT_EQ(solution.waste(), 0); + } +} + +TEST(Rectangle, VariableSizedBinPackingWithLeftovers) +{ + // A 100 x 100 bin, a 50 x 50 bin and a 50 x 50 item. In the first + // solution, the item is in the small bin, which is used entirely: the + // large bin is kept whole. In the second one, the item is in the large + // bin, which leaves an L-shape of area 7500, and the small bin is kept. + // The leftover value factor is 1 / 10000: the L-shape is refunded + // 7500^2 / 10000 = 5625 units of area, at the price of the large bin. + for (bool costs: {false, true}) { + InstanceBuilder instance_builder; + instance_builder.set_objective(packingsolver::Objective::VariableSizedBinPackingWithLeftovers); + packingsolver::BinTypeId large_bin_type_id = instance_builder.add_bin_type(100, 100); + packingsolver::BinTypeId small_bin_type_id = instance_builder.add_bin_type(50, 50); + if (costs) { + instance_builder.set_bin_type_cost(large_bin_type_id, 1); + instance_builder.set_bin_type_cost(small_bin_type_id, 10); + } + packingsolver::ItemTypeId item_type_id = instance_builder.add_item_type(50, 50); + const Instance instance = instance_builder.build(); + EXPECT_DOUBLE_EQ(instance.leftover_value_factor(), 1.0 / 10000); + + SolutionBuilder small_solution_builder(instance); + small_solution_builder.add_bin(small_bin_type_id, 1); + small_solution_builder.add_item(0, item_type_id, {0, 0}, false); + const Solution small_solution = small_solution_builder.build(); + SolutionBuilder large_solution_builder(instance); + large_solution_builder.add_bin(large_bin_type_id, 1); + large_solution_builder.add_item(0, item_type_id, {0, 0}, false); + const Solution large_solution = large_solution_builder.build(); + + // The stock left: 10000^2 against 7500^2 + 2500^2. + EXPECT_EQ(small_solution.total_leftover_value(), 10000.0 * 10000.0); + EXPECT_EQ(large_solution.total_leftover_value(), 7500.0 * 7500.0 + 2500.0 * 2500.0); + if (costs) { + // The large bin is much cheaper: 1 - 5625 / 10000 against 10. + EXPECT_DOUBLE_EQ(small_solution.net_cost(), 10); + EXPECT_DOUBLE_EQ(large_solution.net_cost(), 1 - 0.5625); + EXPECT_TRUE(small_solution < large_solution); + EXPECT_FALSE(large_solution < small_solution); + } else { + // 10000 - 5625 against 2500: the large bin is kept whole. + EXPECT_DOUBLE_EQ(small_solution.net_cost(), 2500); + EXPECT_DOUBLE_EQ(large_solution.net_cost(), 10000 - 5625); + EXPECT_TRUE(large_solution < small_solution); + EXPECT_FALSE(small_solution < large_solution); + } + + OptimizeParameters parameters; + parameters.optimization_mode = packingsolver::OptimizationMode::NotAnytimeSequential; + const Output output = optimize(instance, parameters); + ASSERT_TRUE(output.solution_pool.best().feasible()); + EXPECT_EQ(output.solution_pool.best().number_of_bins(), 1); + EXPECT_EQ(output.solution_pool.best().bin(0).bin_type_id, + (costs)? large_bin_type_id: small_bin_type_id); + } +} + TEST(Rectangle, BinCopies) { InstanceBuilder instance_builder; diff --git a/test/rectangle/tree_search/tree_search_test.cpp b/test/rectangle/tree_search/tree_search_test.cpp index 3297723f7..321411ca1 100644 --- a/test/rectangle/tree_search/tree_search_test.cpp +++ b/test/rectangle/tree_search/tree_search_test.cpp @@ -79,6 +79,16 @@ INSTANTIATE_TEST_SUITE_P( fs::path(""), fs::path("data") / "rectangle" / "tests" / "bin_packing_with_leftovers_area" / "parameters.csv", fs::path("data") / "rectangle" / "tests" / "bin_packing_with_leftovers_area" / "solution.csv", + }, { + // The same instance with the leftover value type 'Depth': the + // items are packed in two columns, leaving a single 6 x 10 + // rectangle, instead of a 3 x 3 block leaving an L-shape of + // larger area. + fs::path("data") / "rectangle" / "tests" / "bin_packing_with_leftovers_depth" / "items.csv", + fs::path("data") / "rectangle" / "tests" / "bin_packing_with_leftovers_depth" / "bins.csv", + fs::path(""), + fs::path("data") / "rectangle" / "tests" / "bin_packing_with_leftovers_depth" / "parameters.csv", + fs::path("data") / "rectangle" / "tests" / "bin_packing_with_leftovers_depth" / "solution.csv", }, { fs::path("data") / "rectangle" / "tests" / "bin_packing_with_leftovers_x" / "items.csv", fs::path("data") / "rectangle" / "tests" / "bin_packing_with_leftovers_x" / "bins.csv", diff --git a/test/rectangleguillotine/rectangleguillotine_test.cpp b/test/rectangleguillotine/rectangleguillotine_test.cpp index ff5bbd084..fb72e738e 100644 --- a/test/rectangleguillotine/rectangleguillotine_test.cpp +++ b/test/rectangleguillotine/rectangleguillotine_test.cpp @@ -331,6 +331,104 @@ TEST(RectangleGuillotine, SolutionItemInSoftTrim) EXPECT_TRUE(solution_2.feasible()); } +TEST(RectangleGuillotine, VariableSizedBinPackingWithLeftovers) +{ + // A 100 x 100 bin with 2 copies, a 60 x 60 bin and two 50 x 50 items. + // The leftovers of a bin are the plate after its last 1-cut and the + // sub-plate after the last 2-cut of its last first-level sub-plate. The + // leftover value factor is 1 / 10000. + for (bool costs: {false, true}) { + InstanceBuilder instance_builder; + instance_builder.set_objective(packingsolver::Objective::VariableSizedBinPackingWithLeftovers); + packingsolver::BinTypeId large_bin_type_id = instance_builder.add_bin_type(100, 100); + instance_builder.set_bin_type_copies(large_bin_type_id, 2); + packingsolver::BinTypeId small_bin_type_id = instance_builder.add_bin_type(60, 60); + if (costs) { + instance_builder.set_bin_type_cost(large_bin_type_id, 1); + instance_builder.set_bin_type_cost(small_bin_type_id, 10); + } + packingsolver::ItemTypeId item_type_id = instance_builder.add_item_type(50, 50); + instance_builder.set_item_type_copies(item_type_id, 2); + const Instance instance = instance_builder.build(); + EXPECT_DOUBLE_EQ(instance.leftover_value_factor(), 1.0 / 10000); + + // One item in the small bin and one item in a large bin. + SolutionBuilder small_solution_builder(instance); + small_solution_builder.add_bin(small_bin_type_id, 1, CutOrientation::Vertical); + small_solution_builder.add_node(1, 50); + small_solution_builder.add_node(2, 50); + small_solution_builder.set_last_node_item(item_type_id); + small_solution_builder.add_bin(large_bin_type_id, 1, CutOrientation::Vertical); + small_solution_builder.add_node(1, 50); + small_solution_builder.add_node(2, 50); + small_solution_builder.set_last_node_item(item_type_id); + const Solution small_solution = small_solution_builder.build(); + // Both items in the same large bin. + SolutionBuilder large_solution_builder(instance); + large_solution_builder.add_bin(large_bin_type_id, 1, CutOrientation::Vertical); + large_solution_builder.add_node(1, 50); + large_solution_builder.add_node(2, 50); + large_solution_builder.set_last_node_item(item_type_id); + large_solution_builder.add_node(2, 100); + large_solution_builder.set_last_node_item(item_type_id); + const Solution large_solution = large_solution_builder.build(); + // Each item in its own large bin: the leftovers of the first bin, + // which isn't the last one, count as well. + SolutionBuilder two_solution_builder(instance); + for (int bin_pos = 0; bin_pos < 2; ++bin_pos) { + two_solution_builder.add_bin(large_bin_type_id, 1, CutOrientation::Vertical); + two_solution_builder.add_node(1, 50); + two_solution_builder.add_node(2, 50); + two_solution_builder.set_last_node_item(item_type_id); + } + const Solution two_solution = two_solution_builder.build(); + ASSERT_TRUE(small_solution.feasible()); + ASSERT_TRUE(large_solution.feasible()); + ASSERT_TRUE(two_solution.feasible()); + + // The stock left. + double large_bin = 10000.0 * 10000.0; + double used_large_bin = 5000.0 * 5000.0 + 2500.0 * 2500.0; + double full_large_bin = 5000.0 * 5000.0; + double small_bin = 3600.0 * 3600.0; + double used_small_bin = 600.0 * 600.0 + 500.0 * 500.0; + EXPECT_EQ(small_solution.total_leftover_value(), large_bin + used_large_bin + used_small_bin); + EXPECT_EQ(large_solution.total_leftover_value(), large_bin + full_large_bin + small_bin); + EXPECT_EQ(two_solution.total_leftover_value(), 2 * used_large_bin + small_bin); + if (costs) { + // The large bins are much cheaper. + double small_price = 10.0 / 3600; + double large_price = 1.0 / 10000; + EXPECT_NEAR(small_solution.net_cost(), + 10 - small_price * used_small_bin / 10000 + + 1 - large_price * used_large_bin / 10000, 1e-9); + EXPECT_NEAR(large_solution.net_cost(), 1 - large_price * full_large_bin / 10000, 1e-9); + EXPECT_NEAR(two_solution.net_cost(), 2 * (1 - large_price * used_large_bin / 10000), 1e-9); + EXPECT_TRUE(small_solution < large_solution); + EXPECT_TRUE(two_solution < large_solution); + EXPECT_TRUE(small_solution < two_solution); + } else { + // The cost of a bin is its area. + EXPECT_NEAR(small_solution.net_cost(), + 3600 - used_small_bin / 10000 + 10000 - used_large_bin / 10000, 1e-9); + EXPECT_NEAR(large_solution.net_cost(), 10000 - full_large_bin / 10000, 1e-9); + EXPECT_NEAR(two_solution.net_cost(), 2 * (10000 - used_large_bin / 10000), 1e-9); + EXPECT_TRUE(small_solution < large_solution); + EXPECT_TRUE(two_solution < small_solution); + EXPECT_FALSE(large_solution < small_solution); + EXPECT_FALSE(small_solution < two_solution); + + OptimizeParameters parameters; + parameters.optimization_mode = packingsolver::OptimizationMode::NotAnytimeSequential; + const Output output = optimize(instance, parameters); + ASSERT_TRUE(output.solution_pool.best().feasible()); + EXPECT_EQ(output.solution_pool.best().number_of_items(), 2); + EXPECT_EQ(output.solution_pool.best().total_leftover_value(), large_bin + full_large_bin + small_bin); + EXPECT_NEAR(output.solution_pool.best().net_cost(), 10000 - full_large_bin / 10000, 1e-9); + } + } +} + TEST(RectangleGuillotine, SolutionRoadef2018ExtraCut) { // With the 'Roadef2018' cut type, the extra cut of the last stage diff --git a/wasm/tests/results.test.mjs b/wasm/tests/results.test.mjs index 74e98a01a..5ae130155 100644 --- a/wasm/tests/results.test.mjs +++ b/wasm/tests/results.test.mjs @@ -66,7 +66,15 @@ test("results: tiles", () => { output: output({YMax: 60, DensityX: 0.8, DensityY: 0.5, FullWastePercentage: 0.9}), objective: "open-dimension-y", totalItems: 3}); assert.strictEqual(tiles.find((tile) => tile.label === "Density").value, "50%"); - // Irregular, bin packing with leftovers: items over bins minus leftover. + // Irregular, bin packing with leftovers: items over bins minus the area + // of the leftover (the leftover value isn't an area). + tiles = results.summaryTiles({ + output: output({ItemArea: 600, BinArea: 2000, LeftoverArea: 1200, LeftoverValue: 5000, + DensityX: 0.8, FullWastePercentage: 0.7}), + objective: "bin-packing-with-leftovers", totalItems: 3}); + assert.strictEqual(tiles.find((tile) => tile.label === "Density").value, "75%"); + // A solution stored before 'LeftoverArea' was added, when the leftover + // value was an area. tiles = results.summaryTiles({ output: output({ItemArea: 600, BinArea: 2000, LeftoverValue: 1200, DensityX: 0.8, FullWastePercentage: 0.7}), objective: "bin-packing-with-leftovers", totalItems: 3}); diff --git a/wasm/web/app.js b/wasm/web/app.js index c3269bb62..7c64b79ae 100644 --- a/wasm/web/app.js +++ b/wasm/web/app.js @@ -1412,8 +1412,12 @@ function describeSolution(output, objective) { parts.push(`${solution.NumberOfBins} bins`); if (objective === "knapsack" && solution.ItemProfit !== undefined) parts.push(`profit ${format(solution.ItemProfit)}`); - if (objective === "variable-sized-bin-packing" && solution.BinCost !== undefined) + if ((objective === "variable-sized-bin-packing" + || objective === "variable-sized-bin-packing-with-leftovers") + && solution.BinCost !== undefined) parts.push(`cost ${format(solution.BinCost)}`); + if (objective === "variable-sized-bin-packing-with-leftovers" && solution.NetCost !== undefined) + parts.push(`net cost ${format(solution.NetCost)}`); if (objective === "bin-packing-with-leftovers" && solution.LeftoverValue !== undefined) parts.push(`leftover ${format(solution.LeftoverValue)}`); if (objective === "bin-packing-cutting-cost" && solution.CuttingCost !== undefined) diff --git a/wasm/web/form.js b/wasm/web/form.js index ce16a2c47..0e9aa9958 100644 --- a/wasm/web/form.js +++ b/wasm/web/form.js @@ -26,6 +26,15 @@ export function detailsNumber(key, label, placeholder, options = {}) { return {key, label, type: "number", value: "", optional: true, details: true, placeholder, ...options}; } +// Objectives optimized as variable-sized bin packing: the bin types have a +// cost and a minimum number of copies. +export const VARIABLE_SIZED_BIN_PACKING_OBJECTIVES = [ + "variable-sized-bin-packing", "variable-sized-bin-packing-with-leftovers"]; + +// Objectives for which the leftovers of the bins are valued. +export const LEFTOVER_OBJECTIVES = [ + "bin-packing-with-leftovers", "variable-sized-bin-packing-with-leftovers"]; + // Copies of a bin or item type, which can be unlimited ('copies' -1, with a // checkbox next to them): bin types except for the knapsack objective, item // types only for the knapsack objective. And the minimum number of copies to @@ -39,7 +48,7 @@ export function copiesColumns(isItem) { copies.unlimited = isItem? (objective) => objective === "knapsack": (objective) => objective !== "knapsack" && !openDimension(objective); - const objectives = isItem? ["knapsack"]: ["variable-sized-bin-packing"]; + const objectives = isItem? ["knapsack"]: VARIABLE_SIZED_BIN_PACKING_OBJECTIVES; return [copies, detailsNumber("copies_min", "Minimum copies", "0", {objectives})]; } @@ -102,7 +111,7 @@ export function binColumns(problemType) { ...DIMENSIONS[problemType].map((d) => numberColumn(d, 100)), ...copiesColumns(false), // The cost of the bins only matters for variable-sized bin packing. - {...numberColumn(["cost", "Cost"], "", true), objectives: ["variable-sized-bin-packing"]}, + {...numberColumn(["cost", "Cost"], "", true), objectives: VARIABLE_SIZED_BIN_PACKING_OBJECTIVES}, ]; if (WEIGHTS.includes(problemType)) columns.push({...numberColumn(["maximum_weight", "Maximum weight"], "", true), placeholder: "none"}); @@ -226,8 +235,14 @@ export const INSTANCE_PARAMETERS = { // measured (see 'box::LeftoverMode'). {key: "leftover_mode", label: "Leftover", type: "select", value: "xyz", options: [["xyz", "Along X, Y and Z"], ["xy", "Along X and Y"], ["xz", "Along X and Z"], - ["yz", "Along Y and Z"], ["x", "Along X"], ["y", "Along Y"], ["z", "Along Z"]], - objectives: ["bin-packing-with-leftovers"]}, + ["yz", "Along Y and Z"], ["x", "Along X"], ["y", "Along Y"], ["z", "Along Z"], + ["xyz-cut", "Along X, Y and Z, cut"], ["xy-cut", "Along X and Y, cut"], + ["xz-cut", "Along X and Z, cut"], ["yz-cut", "Along Y and Z, cut"], ["staircase", "Staircase"]], + objectives: LEFTOVER_OBJECTIVES}, + // How the value of the leftover is computed (see 'LeftoverValueType'). + {key: "leftover_value_type", label: "Leftover value", type: "select", value: "squared-area", + options: [["squared-area", "Squared area"], ["depth", "Depth (favors compact leftovers)"]], + objectives: LEFTOVER_OBJECTIVES}, // The items of each bin must be in static mechanical equilibrium. {key: "static_stability", label: "Static stability", type: "checkbox", value: false}, ], @@ -235,8 +250,13 @@ export const INSTANCE_PARAMETERS = { // The dimensions along which the leftover of the last bin is // measured (see 'boxstacks::LeftoverMode'). {key: "leftover_mode", label: "Leftover", type: "select", value: "xy", - options: [["xy", "Along X and Y"], ["x", "Along X"], ["y", "Along Y"]], - objectives: ["bin-packing-with-leftovers"]}, + options: [["xy", "Along X and Y"], ["x", "Along X"], ["y", "Along Y"], + ["xy-cut", "Along X and Y, cut"], ["staircase", "Staircase"]], + objectives: LEFTOVER_OBJECTIVES}, + // How the value of the leftover is computed (see 'LeftoverValueType'). + {key: "leftover_value_type", label: "Leftover value", type: "select", value: "squared-area", + options: [["squared-area", "Squared area"], ["depth", "Depth (favors compact leftovers)"]], + objectives: LEFTOVER_OBJECTIVES}, {key: "unloading_constraint", label: "Unloading constraint", type: "select", value: "none", options: UNLOADING_CONSTRAINTS, structural: true}, // The weight constraints are not checked for the items of these @@ -246,8 +266,13 @@ export const INSTANCE_PARAMETERS = { ], rectangle: [ {key: "leftover_mode", label: "Leftover", type: "select", value: "area", - options: [["area", "Area"], ["x", "Along X"], ["y", "Along Y"]], - objectives: ["bin-packing-with-leftovers"]}, + options: [["area", "Area"], ["x", "Along X"], ["y", "Along Y"], ["area-cut", "Area, cut"], + ["staircase", "Staircase"]], + objectives: LEFTOVER_OBJECTIVES}, + // How the value of the leftover is computed (see 'LeftoverValueType'). + {key: "leftover_value_type", label: "Leftover value", type: "select", value: "squared-area", + options: [["squared-area", "Squared area"], ["depth", "Depth (favors compact leftovers)"]], + objectives: LEFTOVER_OBJECTIVES}, {key: "unloading_constraint", label: "Unloading constraint", type: "select", value: "none", options: UNLOADING_CONSTRAINTS, structural: true}, ], @@ -280,14 +305,26 @@ export const INSTANCE_PARAMETERS = { {key: "maximum_number_2_cuts", label: "Maximum number of 2-cuts", type: "number", unlimited: true, integer: true, shown: TWO_CUTS}, {key: "cut_through_defects", label: "Cut through defects", type: "checkbox", value: false}, + // How the value of the leftovers is computed (see 'LeftoverValueType'); + // the leftovers are the plates left after the last cuts of each bin. + {key: "leftover_value_type", label: "Leftover value", type: "select", value: "squared-area", + options: [["squared-area", "Squared area"], ["depth", "Depth (favors compact leftovers)"]], + objectives: ["variable-sized-bin-packing-with-leftovers"]}, ], irregular: [ // The corner or side from which the leftover is measured. {key: "leftover_mode", label: "Leftover", type: "select", value: "bottom-left", inParameters: true, options: [["bottom-left", "Bottom left"], ["bottom-right", "Bottom right"], ["top-left", "Top left"], ["top-right", "Top right"], ["left", "Left"], ["right", "Right"], ["bottom", "Bottom"], - ["top", "Top"]], - objectives: ["bin-packing-with-leftovers"]}, + ["top", "Top"], ["bottom-left-cut", "Bottom left, cut"], ["bottom-right-cut", "Bottom right, cut"], + ["top-left-cut", "Top left, cut"], ["top-right-cut", "Top right, cut"], + ["bottom-left-staircase", "Bottom left, staircase"], ["bottom-right-staircase", "Bottom right, staircase"], + ["top-left-staircase", "Top left, staircase"], ["top-right-staircase", "Top right, staircase"]], + objectives: LEFTOVER_OBJECTIVES}, + // How the value of the leftover is computed (see 'LeftoverValueType'). + {key: "leftover_value_type", label: "Leftover value", type: "select", value: "squared-area", inParameters: true, + options: [["squared-area", "Squared area"], ["depth", "Depth (favors compact leftovers)"]], + objectives: LEFTOVER_OBJECTIVES}, // Required: the objective isn't supported without it. {key: "open_dimension_xy_aspect_ratio", label: "Aspect ratio (height / width)", type: "number", value: "1", required: true, positive: true, inParameters: true, @@ -412,6 +449,9 @@ export const OBJECTIVES = [ ["bin-packing", "Bin packing: minimize the number of bins"], ["bin-packing-with-leftovers", "Bin packing with leftovers"], ["variable-sized-bin-packing", "Variable-sized bin packing: minimize the cost of the bins"], + ["variable-sized-bin-packing-with-leftovers", + "Variable-sized bin packing with leftovers: minimize the cost of the bins minus the value of their leftovers", + ["rectangleguillotine", "rectangle", "box", "boxstacks", "irregular"]], ["bin-packing-cutting-cost", "Bin packing with cutting costs: minimize the cost of the cuts", ["rectangleguillotine"]], ["open-dimension-x", "Open dimension X: minimize the length", @@ -521,7 +561,8 @@ export function resourceConsumptions(resource, itemRows) { // Objectives for which the bin types created have unlimited copies. export const UNLIMITED_BINS_OBJECTIVES = [ - "bin-packing", "bin-packing-with-leftovers", "variable-sized-bin-packing", "bin-packing-cutting-cost"]; + "bin-packing", "bin-packing-with-leftovers", "variable-sized-bin-packing", + "variable-sized-bin-packing-with-leftovers", "bin-packing-cutting-cost"]; export function newBinRow(type, objective) { const row = (type === "irregular")? irregularForm.defaultBinRow(): defaultRow(binColumns(type)); @@ -767,6 +808,7 @@ const OBJECTIVE_SPELLINGS = Object.fromEntries([ ["open-dimension-xy", "OpenDimensionXY", "ODXY"], ["knapsack", "Knapsack", "KP"], ["variable-sized-bin-packing", "VariableSizedBinPacking", "VBPP"], + ["variable-sized-bin-packing-with-leftovers", "VariableSizedBinPackingWithLeftovers", "VBPPL"], ["bin-packing-cutting-cost", "BinPackingCuttingCost", "BPPCC"], ].flatMap((spellings) => spellings.map((spelling) => [spelling, spellings[0]]))); @@ -780,7 +822,16 @@ const SELECT_SPELLINGS = { leftover_mode: {area: "area", x: "x", y: "y", z: "z", xy: "xy", xz: "xz", yz: "yz", xyz: "xyz", bottomleft: "bottom-left", bl: "bottom-left", bottomright: "bottom-right", br: "bottom-right", topleft: "top-left", tl: "top-left", topright: "top-right", tr: "top-right", - left: "left", l: "left", right: "right", r: "right", bottom: "bottom", b: "bottom", top: "top", t: "top"}, + left: "left", l: "left", right: "right", r: "right", bottom: "bottom", b: "bottom", top: "top", t: "top", + areacut: "area-cut", xycut: "xy-cut", xzcut: "xz-cut", yzcut: "yz-cut", xyzcut: "xyz-cut", + bottomleftcut: "bottom-left-cut", blc: "bottom-left-cut", bottomrightcut: "bottom-right-cut", + brc: "bottom-right-cut", topleftcut: "top-left-cut", tlc: "top-left-cut", + toprightcut: "top-right-cut", trc: "top-right-cut", staircase: "staircase", + bottomleftstaircase: "bottom-left-staircase", bls: "bottom-left-staircase", + bottomrightstaircase: "bottom-right-staircase", brs: "bottom-right-staircase", + topleftstaircase: "top-left-staircase", tls: "top-left-staircase", + toprightstaircase: "top-right-staircase", trs: "top-right-staircase"}, + leftover_value_type: {squaredarea: "squared-area", depth: "depth"}, trim_type: {h: "hard", hard: "hard", 0: "hard", s: "soft", soft: "soft", 1: "soft"}, }; diff --git a/wasm/web/irregular_form.js b/wasm/web/irregular_form.js index 0d81cbbfb..444ab14e2 100644 --- a/wasm/web/irregular_form.js +++ b/wasm/web/irregular_form.js @@ -7,6 +7,12 @@ import * as dxf from "./dxf.js"; import * as svg from "./svg.js"; +// Objectives optimized as variable-sized bin packing: the bin types have a +// cost and a minimum number of copies (as 'VARIABLE_SIZED_BIN_PACKING_OBJECTIVES' +// of 'form.js', which imports this module). +const VARIABLE_SIZED_BIN_PACKING_OBJECTIVES = [ + "variable-sized-bin-packing", "variable-sized-bin-packing-with-leftovers"]; + // Shapes of a row, and the fields of their dimensions. export const SHAPES = { rectangle: "Rectangle", @@ -1031,16 +1037,16 @@ function rowCopies(row, objective, isItem) { } // Whether the minimum number of copies of the items (bins) is used for an -// objective: only for the knapsack (variable-sized bin packing) objective +// objective: only for the knapsack (variable-sized bin packing) objectives // (all the items must be packed with the other objectives). export function copiesMinUsed(objective, isItem) { - return objective === (isItem? "knapsack": "variable-sized-bin-packing"); + return isItem? objective === "knapsack": VARIABLE_SIZED_BIN_PACKING_OBJECTIVES.includes(objective); } // Whether the profit of the items (cost of the bins) is used for an -// objective: only for the knapsack (variable-sized bin packing) objective. +// objective: only for the knapsack (variable-sized bin packing) objectives. export function valueUsed(objective, isItem) { - return objective === (isItem? "knapsack": "variable-sized-bin-packing"); + return isItem? objective === "knapsack": VARIABLE_SIZED_BIN_PACKING_OBJECTIVES.includes(objective); } // The copies of a row, and if they can be unlimited, a checkbox which diff --git a/wasm/web/results.js b/wasm/web/results.js index d59175317..0541c95a4 100644 --- a/wasm/web/results.js +++ b/wasm/web/results.js @@ -20,6 +20,7 @@ export const OBJECTIVE_VALUES = { "bin-packing": {label: "Bins", value: (s) => s.NumberOfBins}, "variable-sized-bin-packing": {label: "Cost", value: (s) => s.BinCost}, "bin-packing-with-leftovers": {label: "Leftover", value: (s) => s.LeftoverValue}, + "variable-sized-bin-packing-with-leftovers": {label: "Net cost", value: (s) => s.NetCost}, "bin-packing-cutting-cost": {label: "Cutting cost", value: (s) => s.CuttingCost}, "open-dimension-x": {label: "Length", value: (s) => (s.XMax !== undefined)? s.XMax: s.Width}, "open-dimension-y": {label: "Length", value: (s) => (s.YMax !== undefined)? s.YMax: s.Height}, @@ -92,7 +93,9 @@ export function formatPercent(ratio) { // along the open dimension: 'DensityX' / 'DensityY' (only the irregular // solutions have them). Otherwise, the space used is the items plus 'Waste' // (the space used minus the items), or for irregular, which has no 'Waste', -// 'BinArea' minus 'LeftoverValue'. With nesting lengths (onedimensional), the +// 'BinArea' minus 'LeftoverArea' ('LeftoverValue' for the solutions stored +// before 'LeftoverArea' was added, when it was an area). With nesting lengths +// (onedimensional), the // items occupy less than their length: 'ItemNestedLength'. function density(solution, objective) { const openDimensionDensity = {"open-dimension-x": solution.DensityX, "open-dimension-y": solution.DensityY}[objective]; @@ -106,6 +109,8 @@ function density(solution, objective) { let used = null; if (finite(solution.Waste) !== null) used = occupied + solution.Waste; + else if (finite(solution.BinArea) !== null && finite(solution.LeftoverArea) !== null) + used = solution.BinArea - solution.LeftoverArea; else if (finite(solution.BinArea) !== null && finite(solution.LeftoverValue) !== null) used = solution.BinArea - solution.LeftoverValue; return (used !== null && used > 0)? occupied / used: null;