问题描述
我有美国各地的10个仓库。他们每个人都可能会或可能不会有产品A,B,C,D,E的股票。有人下令所有五个项目从我的网站。
I have 10 warehouses across the US. Each of them may or may not have product A, B, C, D, E in stock. Someone orders all five items from my website.
我希望尽量减少出货量我送的数量。如何识别船舶从哪个仓库哪些项目?
I want to minimize the number of shipments I'm sending. How do I identify which items to ship from which warehouses?
例如,有人订购A,B,C,D和E
For example, someone orders A, B, C, D and E.
- 在我有A和B(但没有其他人)在纽约举行。
- 在我有A和B和C(但没有其他人)在波士顿。
- 在我有D和E(但没有其他)芝加哥。
- I have A and B (but no others) in New York.
- I have A and B and C(but no others) in Boston.
- I have D and E (but no others) inChicago.
我试图开发一种算法,将创建三个项目从波士顿装运和2项来自芝加哥出货。
I'm trying to develop an algorithm that will create a shipment of three items from Boston and a shipment of 2 items from Chicago.
我不想2项来自纽约,1从波士顿和2来自芝加哥。
I don't want 2 items from New York, 1 from Boston and 2 from Chicago.
所有的项目都在一个中央数据库。
All the items are in one central database.
推荐答案
您的问题,正是经典的集合覆盖优化问题,这是一个NP难;的宇宙是一组在用户希望的项目,和候选集是仓库。
Your problem is exactly the classical set cover optimization problem, which is NP-hard; the "universe" is the set of items that the user wants, and the candidate sets are the warehouses.
该算法通过@ user384706 和的是贪心算法那里讨论,这是一个好的近似。
The algorithm proposed by @user384706 and @Kickaha is the greedy algorithm discussed there, which is an okay approximation.
如果你想找到实际的最佳解决方案,最好的办法是使用整数线性规划制定并插入一些ILP求解器。
If you want to find the actual optimal solution, your best bet is to use the integer linear programming formulation and plug into some ILP solver.
你说你不关心的地方,但是如果你做了集合覆盖问题也占了wiki页面上每个仓库的成本( C(S)
),将重新present更远,远的仓库是不太最佳采摘。
You say you don't care about distances, but if you did the set cover problem also accounts for a cost per warehouse (c(s)
on the wiki page) that would represent farther-away warehouses being less optimal to pick.
这篇关于算法以最小化从多个仓库发货数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!