组合优化 - 背包的变体

发布于 2024-11-15 00:06:50 字数 897 浏览 2 评论 0原文

这是一个现实世界的组合优化问题。

我们获得了某种产品的大量价值主张。价值主张有不同的类型,但每种类型都是独立的,并且为整体产品带来同等的好处。在构建产品时,我们可以包含每种类型的任何非负整数“单元”。然而,在添加某种类型的第一个单元之后,该类型的附加单元的边际效益不断减小。事实上,新单元的边际效益是添加新单元后该类型单元数量的倒数。我们的产品必须至少有一个某种类型的单位,并且由于这一要求,我们必须对整体价值进行一个小的修正。

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'> UV'/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 技术交流群。

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

发布评论

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

评论(2

负佳期 2024-11-22 00:06:50

您描述的问题是非线性整数规划问题,因为它包含整数变量t的乘积。由于严格的不等式,它的可行性集不是封闭的,可以通过使用非严格的不等式并向右侧添加一个小的正数(epsilon)来解决。然后问题可以在 AMPL 中表述如下:

set Types;
param Costs{Types};      # C
param GivenProductValue; # V
param GivenProductCost;  # U
param Epsilon;

var units{Types} integer >= 0; # T
var productCost = sum {t in Types} units[t] * Costs[t];

minimize cost: productCost;
s.t. greaterCost: productCost >= GivenProductCost + Epsilon;
s.t. greaterValuePerCost:
  prod {t in Types} (units[t] + 1) - 1 >=
    productCost * GivenProductValue / GivenProductCost + Epsilon;

这个问题可以使用非线性整数规划求解器来解决,例如 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:

set Types;
param Costs{Types};      # C
param GivenProductValue; # V
param GivenProductCost;  # U
param Epsilon;

var units{Types} integer >= 0; # T
var productCost = sum {t in Types} units[t] * Costs[t];

minimize cost: productCost;
s.t. greaterCost: productCost >= GivenProductCost + Epsilon;
s.t. greaterValuePerCost:
  prod {t in Types} (units[t] + 1) - 1 >=
    productCost * GivenProductValue / GivenProductCost + Epsilon;

This problem can be solved using a nonlinear integer programming solver such as Couenne.

在巴黎塔顶看东京樱花 2024-11-22 00:06:50

老实说,我认为没有简单的方法可以解决这个问题。最好的办法是编写系统并用求解器求解(Excel 求解器可以解决问题,但您可以使用 Ampl 来解决这个非线性程序。)

该程序:

Define: U;
        V;
        C=[c1,...cn];

Variables: T=[t1,t2,...tn];

Objective Function: SUM(ti.ci)

Constraints:

For all i: ti integer
SUM(ti.ci) > U 
(PROD(ti+1)-1).U > V.SUM(ti.ci)

它与 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:

Define: U;
        V;
        C=[c1,...cn];

Variables: T=[t1,t2,...tn];

Objective Function: SUM(ti.ci)

Constraints:

For all i: ti integer
SUM(ti.ci) > U 
(PROD(ti+1)-1).U > V.SUM(ti.ci)

It works well with Excel: you just replace >U by >=U+d where d is the significative number of the costs (i.e if C=[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,

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