简体   繁体   English

优化2D布局的算法

[英]Algorithm for optimal 2D layout

Is there a Javascript algorithm for finding the optimal layouts? 有没有找到最佳布局的Javascript算法?

There is a fixed width and finite number of rectangular shapes, the goal is to find the shortest length required to fit all the shapes in. 有固定的宽度和有限数量的矩形,目标是找到适合所有形状的最短长度。

We need to answer the following sort of query. 我们需要回答以下类型的查询。

The width is 4,000 units and the following shapes are required, 10 lots of 450 x 750, 6 lots of 2,500 x 1,200 and 5 lots of 900 x 1,500. 宽度为4,000个单位,并且需要以下形状:10批450 x 750、6批2,500 x 1200和5批900 x 1,500。 What is the optimal layout of the shapes and the length required to fit them all in. 形状的最佳布局是什么,以及完全适合它们所需的长度。

I'm not sure how best to approach this if starting from scratch and am hoping that there is something out there already so as to avoid simply doing this via brute force. 如果从头开始,我不确定如何最好地解决这个问题,并希望已经有了一些东西,以避免简单地通过蛮力做到这一点。

Is there a Javascript algorithm for finding the optimal layouts? 有没有找到最佳布局的Javascript算法?

The question should rather be "Is there an (efficient) algorithm which happens to be available as JavaScript implementation". 问题应该是“是否有(有效的)算法可以作为JavaScript实现使用”。 I personally would post it on Math SE or the professional Math site, you might add RPP for "Rectangle Packing Problem". 我个人会将其发布在Math SE或专业Math网站上,您可以为“矩形包装问题”添加RPP。

There is a fixed width and finite number of rectangular shapes, the goal is to find the shortest length required to fit all the shapes in. 有固定的宽度和有限数量的矩形,目标是找到适合所有形状的最短长度。

The width is 4,000 units and the following shapes are required, 10 lots of 450 x 750, 6 lots of 2,500 x 1,200 and 5 lots of 900 x 1,500. 宽度为4,000个单位,并且需要以下形状:10批450 x 750、6批2,500 x 1200和5批900 x 1,500。 What is the optimal layout of the shapes and the length required to fit them all in. 形状的最佳布局是什么,以及完全适合它们所需的长度。

Are there constraints on the orientation of the rectangles? 矩形的方向是否受到限制? (Have a fun look here ). 在这里看起来很有趣)。

The naive algorithm would be to try out all configurations which honor the constraints and pick an optimal one. 天真的算法是尝试所有符合约束条件的配置并选择最佳配置。 This is usually not possible due to too many configurations. 由于配置太多,通常是不可能的。

So one sticks to heuristics (eg here ). 因此,我们坚持启发式(例如here )。 You might end up with research level maths while I have the feeling you are looking for some "good enough" optimizer. 当我感觉到您正在寻找某种“足够好”的优化器时,您可能会得到研究级数学。

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

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