1D Packing Problem of Different Lengths into Multiple Identical Larger Sections

I’m trying to build a Python script to return the optimal packing of different values into a set value sum. The end goal is to make a tool that can take the wholesale Length of a building material (e.g. Rebar (sold in 20′ sections) or Aluminum Extrusion (sold in 16′ sections)) and input specific pieces specified by a design (e.g. the design calls for 2 x 4-1/4″ sections, 5 x 48-1/2″, and 4 x 24-3/8″ pieces). The goal is to reduce wastage by varying the arrangement and how many plans are built (e.g., multiple houses, cabinets, or picture frames). I’m trying to find out what the optimal bulk quantity of the plan to offer to reduce material wastage.

Here’s a simple example of a picture frame:

The picture frame is a rectangle and needs only 4 pieces (1 per side). The left and right pieces are 5″ long, and the top and bottom pieces are 3″ long. If the material used is sold in 8′ sections, what would the optimal organization and number of picture-frames be to reduce wastage (below 100 pieces, to put an upper limit on it)?

2 x 5″ Pieces

2 x 3″ Pieces

Sold in 8″ (96″) Lengths

piecelens = [5, 5, 3, 3] 
wholesalelen = 96  

Solve for layout of pieces on 8′ sections

FOR AN optimal number of picture frames to make

WITH THE GOAL OF Reducing wasted material (unused)

AND Keeping number of picture frames below 100

Real usages would include more than just two different lengths and fractional(or decimal equiv.) lengths, like this:

A metal enclosure made of aluminum extrusion needs an upper and lower frame that fit into each other. The bottom frame is a smaller rectangle where the left and right pieces are 48-1/8″ long, and the top and bottom pieces are 24-1/8″ long. The top frame is a larger rectangle where the left and right pieces are 48-3/16″ long, and the top and bottom pieces are 24-3/16″ long. The box also needs braces for each corner made of the same material that end up being 1-7/16″ long. If the extrusion is sold in 16′ sections, what would the optimal organization and number of enclosures to build at a time to minimize material wastage (below a quantity of 20) and (below a quantity of 200).

2 x 48-1/8″ pieces

2 x 24-1/8″ pieces

2 x 48-3/16″ pieces

2 x 24-3/16″ pieces

4 x 1-7/16″ pieces

Sold in 16′ (192″) Lengths

piecelens = [48.125, 48.125, 24.125, 24.125, 48.1875, 48.1875, 24.1875, 24.1875, 1.4375, 1.4375, 1.4375, 1.4375]
wholesalelen = 192  

Solve for layout of pieces on 16′ sections

FOR AN optimal number of enclosures to make

WITH THE GOAL OF Reducing wasted material (unused)

AND Keeping number of enclosures below 20

REPEAT for a number of enclosures below 200

I have a fairly good grasp of python, but not enough math background to even know where to start. I looked up similar examples of packing problems, but all the answers I found were well above my math understanding and seemed to be for 2d or 3d applications, where I only need a 1d application (length of material only). I was hoping there was a simpler model for 1d applications, although I’m not sure. My research into Bin-Packing problem (which seemed similar) was interesting, but I don’t understand it enough to implement it for my scenario (in 1 dimension and where the set of pieces is variable by a discrete factor). Any help would be greatly appreciated!

New contributor

Sean Pragmatic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật