简体   繁体   English

寻找产品最佳使用的算法

[英]Algorithm for finding optimal use of products

I'm trying to solve a problem in Javascript allowing for optimal use of area with flooring products.我正在尝试解决 Javascript 中的问题,以优化使用地板产品的区域。 I'll be either implementing this or looking for the algorithm in Javascript.我要么实现这个,要么在 Javascript 中寻找算法。 The following is the problem:以下是问题:

Consider that I sell rolled carpets with width dimensions of 12, 13 and 15 ft. The length can be any size (because it's rolled).考虑到我销售宽度尺寸为 12、13 和 15 英尺的卷状地毯。长度可以是任何尺寸(因为它是卷状的)。

Let's say I have 3 rooms:假设我有 3 个房间:

  • 25 x 10 (hallway) 25 x 10(走廊)
  • 30 x 30 (large room) 30 x 30(大房间)
  • 5 x 5 (closet) 5 x 5(壁橱)

How can I determine the minimal amount of product to use based on the available size options?如何根据可用的尺寸选项确定要使用的最小产品量? I'd also like to ensure any wasted cuts are re-used.我还想确保重新使用任何浪费的削减。 For larger rooms it's fine that there are seams to connect the rolled pieces.对于较大的房间,最好有接缝来连接卷材。 For example: in the hallway I can use a 15ft wide product and I'll have a roll remaining of 10 feet.例如:在走廊里,我可以使用 15 英尺宽的产品,我将剩下 10 英尺的卷。 I can use that to fill the closet.我可以用它来填满壁橱。

The goal is to find the most optimal fit of product accounting for waste re-use.目标是找到最适合废物再利用的产品。

For a large room of Width, and starting with our largest roll:对于一个宽大的房间,从我们最大的卷开始:

The integer, k15, of Width / 15ft gives the number of 15ft wide lengths.宽度 / 15 英尺的 integer,k15 给出了 15 英尺宽的长度数。

Get Remaining Width = Width - 15ft x k15.获得剩余宽度 = 宽度 - 15 英尺 x k15。

The integer, k13, of Remaining Width / 13ft gives the number of 13ft wide lengths.剩余宽度 / 13 英尺的 integer,k13 给出了 13 英尺宽的长度数。

Get next Remaining Width" = Remaining Width - 13ft x k13.获取下一个剩余宽度” = 剩余宽度 - 13 英尺 x k13。

The integer, k12, of Remaining Width" / 12ft gives the number of 12ft wide lengths. integer, k12, 剩余宽度”/12 英尺给出了 12 英尺宽的长度。

Assuming that you will never have a room that is an integer of any combination of these three sizes, you will always have offcuts.假设您永远不会拥有这三种尺寸的任意组合的 integer 的房间,那么您将始终有边角料。

I think, area optimization and polgon geometry are two extremly complex fields, but I hope I have gone part way into at least defining your problem.我认为,区域优化和 polgon 几何是两个极其复杂的领域,但我希望我已经在一定程度上至少定义了你的问题。

For three carpet widths of 12ft, 13ft & 15ft:对于 12 英尺、13 英尺和 15 英尺三种地毯宽度:

Assuming three rooms, with carpet rolls infinitly long, the algorithm for determining the most efficient use is:假设三个房间,地毯卷无限长,确定最有效使用的算法是:

Give each room a dimension of: x0" & x1" for room one, y0" & y1" for room two, and z0" & z1" for room three.给每个房间一个尺寸:x0" & x1" 用于房间一,y0" & y1" 用于房间二,z0" & z1" 用于房间三。

Sort this list such that the smallest dimension of each room is written first, and the room with the largest 'smaller' dimension is also written first.对该列表进行排序,使每个房间的最小维度首先写入,并且具有最大“较小”维度的房间也首先写入。

If x1" > x0", write it: (x0", x1") => (x0', x1') If y1" > y0", write it: (y0", y1") => (y0', y1')如果 x1" > x0",写成:(x0", x1") => (x0', x1') 如果 y1" > y0",写成:(y0", y1") => (y0', y1 ')
If z1" > z0", write it: (z0", z1") => (z0', z1')如果 z1" > z0",写成: (z0", z1") => (z0', z1')

And:和:

If z0' > x0' > y0' then write => (x0, x1), (y0, y1) & (z0, z1)如果 z0' > x0' > y0' 然后写 => (x0, x1), (y0, y1) & (z0, z1)

Given this ordered set, begin with the largest room, X, with its smaller dimension as x0, the greater as x1.给定这个有序集合,从最大的房间 X 开始,其较小的维度为 x0,较大的为 x1。

Get the second largest room, Y.得到第二大房间,Y。

We now need to find how we can lay the carpet in room X, such that the OFFCUT will fill room Y in ONE or more lengths.我们现在需要找到如何在房间 X 中铺设地毯,以便 OFFCUT 将房间 Y 填满一个或多个长度。

We need to choose between our three widths, so that the 'offcut will be as wide as room Y'.我们需要在我们的三个宽度之间进行选择,以便“切边将与房间 Y 一样宽”。

If x0 is 30, and y0 is 10, then 12ft + 13ft + 15ft gives us 30ft with 10ft spare to use in room Y.如果 x0 是 30,y0 是 10,那么 12 英尺 + 13 英尺 + 15 英尺给了我们 30 英尺和 10 英尺的备用空间,可以在房间 Y 中使用。

The same carries to room Z. Z房间也是如此。

Problem solved.问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM