带有需要考虑约束的物品的背包

发布于 2024-09-28 13:01:04 字数 138 浏览 3 评论 0原文

我有项目 I1、I2、I3、I4,其权重为 W1...W4,值为 V1...V4。我想以最小的权重最大化价值。这是传统的背包。然而,有一些小限制,有些物品不能放在一起。所以可以说 I2 和 I3 不能在一起。任何人都可以提供动态编程解决方案或任何其他解决方案吗?

I have items I1, I2, I3, I4 with weights W1...W4 and Values V1...V4. I want to maximize values with minimum weights. This is a traditional Knapsack. However there is small constraint some items cannot go together. So lets say I2 and I3 cannot go together. Can anyone provide a dynamic programming solution or any other solution for the same.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

可是我不能没有你 2024-10-05 13:01:04

有了这个约束,问题就变成了强 NP 难问题(与离散背包相反,离散背包只是弱 NP 难问题)。假设您所有物品的重量为 1,价值为 1。

决定是否可以实现价值 k(假设背包容量 >= k)相当于查找 k< /em> 之间没有约束的项目。这是一个已知的 NP 难题:独立集

如果您对约束的性质有一些额外的了解,这可能会更容易。

With this constraint, the problem becomes strongly (as opposed to discrete knapsack, which is only weakly NP-hard) NP-hard. Suppose all your items have weight 1 and value 1.

Deciding whether you can achieve value k (assuming knapsack capacity >= k) is equivalent to finding k items that have no constraint between them. This is a known NP-hard problem: independent set.

This might be easier if you have some additional knowledge about the nature of the constraints.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文