打包
打包问题的目标是找到将一组给定大小的项打包到具有固定packing的容器中的最佳方式。packing典型应用是高效地将箱子加载到货车上。
通常,由于容量限制,无法打包所有商品。在这种情况下,问题是找出总大小不超过最大可容纳在容器中的项的子集。
打包问题有多种类型。其中最重要的两个是“背包问题”和“装箱问题”。
背包问题
在简单的背包问题中,只有一个容器(背包)。这些项具有值和尺寸,目标是打包具有最高总价值的部分项。
对于值等于大小的特殊情况,目标是使打包商品的总大小最大化。
OR-Tools 在其算法库中为背包问题提供了多种求解器。
此外,背包问题还有更普通的版本。以下是几个示例:
请注意,您可能是针对单个背包的多维问题,也可能是只有一个维度的多维背包问题。
装箱问题
最广为人知的打包问题之一是装箱,即装箱时有多个容量相同的容器(称为装箱)。bin-packingbin-packing与多背包问题不同,箱子的数量并非固定的。相反,目标是找到容纳所有项的最小数量的分箱。
下面这个简单的示例说明了多背包问题和装箱问题之间的区别。假设一家公司有货运卡车,每辆卡车的承重能力为 18,000 磅,需要运送 130,000 磅的商品。
以下各部分介绍如何使用 OR-Tools 解决各种类型的打包问题,从背包问题开始。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-08-09。
[null,null,["最后更新时间 (UTC):2024-08-09。"],[[["Packing problems involve finding the best way to pack items into containers, often with capacity constraints."],["Knapsack problems focus on maximizing the value of packed items within a single or multiple containers with limited capacity."],["Bin packing aims to minimize the number of containers needed to pack all items, using bins of equal capacity."],["Multidimensional and multiple knapsack problems are variations that consider additional item properties or multiple containers."],["OR-Tools provides solvers and algorithms for tackling various packing problem types, including knapsack and bin packing."]]],["Packing problems aim to pack items into containers with fixed capacities, often maximizing the total size or value of packed items. Key problem types include knapsack problems, where items have values and the goal is to maximize the total value in a single container, and bin-packing, which minimizes the number of containers needed to hold all items. Variations like multidimensional and multiple knapsack problems exist, with additional constraints or containers. OR-Tools offers solvers for these problems.\n"]]