Created
April 23, 2021 14:48
-
-
Save samirsaci/dc3ea79f4b429cb474375ce227b70357 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Function Solver | |
| def solver(n_812, n_1012, bins): | |
| # Pallets to load | |
| rectangles = [pal_812 for i in range(n_812)] + [pal_1012 for i in range(n_1012)] | |
| # Build the Packer | |
| pack = newPacker() | |
| # Add the rectangles to packing queue | |
| for r in rectangles: | |
| pack.add_rect(*r) | |
| # Add the bins where the rectangles will be placed | |
| for b in bins: | |
| pack.add_bin(*b) | |
| # Start packing | |
| pack.pack() | |
| # Full rectangle list with coordinates | |
| all_rects = pack.rect_list() | |
| # Pallets with dimensions | |
| all_pals = [sorted([p[3], p[4]]) for p in all_rects] | |
| # Count number of 80 x 120 / of 100 x 120 | |
| p_812, p_1012 = all_pals.count(pal_812), all_pals.count(pal_1012) | |
| print("{:,}/{:,} Pallets 80 x 120 (cm) | {:,}/{:,} Pallets 100 x 120 (cm)".format(p_812, n_812, p_1012, n_1012)) | |
| return all_rects, all_pals |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment