最小消息长度算法
我有成捆的不同大小的对象(很多对象可以具有相同的大小,例如:我有 54 个 6B 的对象、76 个 10B 的对象、79 个 24B 的对象等。
对象的大小为 6、8、10 .... 字节)。我需要将该包打包成几条消息(每条消息的最大长度为 256 字节)。
问题是如何用最少的消息数得到解决方案?
有没有已知的算法?我需要 Hopfield 神经网络吗?
I have bundles of objects different size ( lot of objects can have same size, example: I have 54 object of 6B, 76 of 10B, 79 of 24B etc.
The size of the objects are 6, 8 ,10 .... bytes ). I need to pack that bundle in couple messages ( each message has maximum length 256 bytes).
Problem is how to get the solution with the minimum number of messages?
Is there any known algorithm for this? Do I need Hopfield neural network for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是装箱问题的一个示例,它是一个组合 NP 困难问题。最简单的算法是“First Fit Decreasing (FFD)”,其中首先按大小递减对对象进行排序,然后将每个对象插入到列表中具有足够剩余空间的第一条消息中。
This is an example of the bin packing problem which is a combinatorial NP-hard problem. The simplest algorithm is "First Fit Decreasing (FFD)" in which you would first sort your objects by decreasing size, and then insert each object into the first message in the list with sufficient remaining space.
这是一种背包问题,但不是背包问题。这是装箱问题,其中不同体积的物品被装进最少数量的箱子中,它们的尺寸都相同。它是 NP 困难的。
This is a kind of knapsack problem, but not the knapsack problem. It's the Bin packing problem, in which items of different volumes are packing into the minimum number of bins, which are all the same size. It is NP-hard.
首次拟合递减 (FFD) 算法不是最优的(但是是一个非常好的开始)。如果您有更多执行时间和更多开发时间,请将其与模拟退火、禁忌搜索或遗传算法。忽略暴力或分支定界:它们的扩展范围不会超出玩具问题。
The First Fit Decreasing (FFD) algorithm isn't optimal (but a very good start). If you have more execution time and more development time, chain it with simulated annealing, tabu search or genetic algorithms. Ignore brute force or branch and bound: they don't scale beyond a toy problem.