组合优化 - 背包的变体
这是一个现实世界的组合优化问题。
我们获得了某种产品的大量价值主张。价值主张有不同的类型,但每种类型都是独立的,并且为整体产品带来同等的好处。在构建产品时,我们可以包含每种类型的任何非负整数“单元”。然而,在添加某种类型的第一个单元之后,该类型的附加单元的边际效益不断减小。事实上,新单元的边际效益是添加新单元后该类型单元数量的倒数。我们的产品必须至少有一个某种类型的单位,并且由于这一要求,我们必须对整体价值进行一个小的修正。
令 T[]
为一个数组,表示产品的某个生产运行中每种类型的数量。那么总价值V
由(伪代码)给出:
V = 1
For Each t in T
V = V * (t + 1)
Next t
V = V - 1 // correction
在成本方面,相同类型的单元具有相同的成本。但不同类型的单位都有独特的、不合理的成本。类型的数量很大,但我们给出了一个按从最小到最大排序的类型成本 C[]
数组。我们进一步假设类型数量数组 T[]
也按成本从小到大排序。那么总成本U
就是每个单位成本的总和:
U = 0
For i = 0, i < NumOfValueTypes
U = U + T[i] * C[i]
Next i
到目前为止一切顺利。所以问题是:给定具有值 V
和成本 U
的产品 P
,找到具有以下值的产品 Q
:成本U'
和值V'
,具有最小U'
使得U'> U
,V'/U'> V/U
。
Here is a real-world combinatorial optimization problem.
We are given a large set of value propositions for a certain product. The value propositions are of different types but each type is independent and adds equal benefit to the overall product. In building the product, we can include any non-negative integer number of "units" of each type. However, after adding the first unit of a certain type, the marginal benefit of additional units of that type continually decreases. In fact, the marginal benefit of a new unit is the inverse of the number of units of that type, after adding the new unit. Our product must have a least one unit of some type, and there is a small correction that we must make to the overall value because of this requirement.
Let T[]
be an array representing the number of each type in a certain production run of the product. Then the overall value V
is given by (pseudo code):
V = 1
For Each t in T
V = V * (t + 1)
Next t
V = V - 1 // correction
On cost side, units of the same type have the same cost. But units of different types each have unique, irrational costs. The number of types is large, but we are given an array of type costs C[]
that is sorted from smallest to largest. Let's further assume that the type quantity array T[]
is also sorted by cost from smallest to largest. Then the overall cost U
is simply the sum of each unit cost:
U = 0
For i = 0, i < NumOfValueTypes
U = U + T[i] * C[i]
Next i
So far so good. So here is the problem: Given product P
with value V
and cost U
, find the product Q
with the cost U'
and value V'
, having the minimal U'
such that U' > U
, V'/U' > V/U
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您描述的问题是非线性整数规划问题,因为它包含整数变量
t
的乘积。由于严格的不等式,它的可行性集不是封闭的,可以通过使用非严格的不等式并向右侧添加一个小的正数(epsilon)来解决。然后问题可以在 AMPL 中表述如下:这个问题可以使用非线性整数规划求解器来解决,例如 Couenne 。
The problem you've described is nonlinear integer programming problem because it contains a product of integer variables
t
. Its feasibility set is not closed because of strict inequalities which can be worked around by using non-strict inequalities and adding a small positive number (epsilon) to the right hand sides. Then the problem can be formulated in AMPL as follows:This problem can be solved using a nonlinear integer programming solver such as Couenne.
老实说,我认为没有简单的方法可以解决这个问题。最好的办法是编写系统并用求解器求解(Excel 求解器可以解决问题,但您可以使用 Ampl 来解决这个非线性程序。)
该程序:
它与 Excel 配合良好:您只需替换
>U
经过>=U+d
其中d
是成本的有效数字(即如果C=[1.1, 1.8, 3.0, 9.3] d =0.1< /code>) 因为 Excel 不允许求解器中存在严格的不等式。
我想使用像 Ampl 这样的真正的解算器,它会完美地工作。
希望有帮助,
Honestly I don't think there is an easy way to solve this. The best thing would be to write the system and solve it with a solver (Excel solver will do the trick, but you can use Ampl to solve this non-linear program.)
The Program:
It works well with Excel: you just replace
>U
by>=U+d
whered
is the significative number of the costs (i.e ifC=[1.1, 1.8, 3.0, 9.3] d =0.1
) since Excel doesn't allow strict inequalities in the solver.I guess with a real solver like Ampl it will work perfectly.
Hope it helps,