Skip to content

Instantly share code, notes, and snippets.

@samirsaci
Created April 23, 2021 14:48
Show Gist options
  • Select an option

  • Save samirsaci/dc3ea79f4b429cb474375ce227b70357 to your computer and use it in GitHub Desktop.

Select an option

Save samirsaci/dc3ea79f4b429cb474375ce227b70357 to your computer and use it in GitHub Desktop.
# 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