Excel 求解器 - 第 5 单元后每份价格发生变化

Excel Solver - price per serving change after unit 5

我创建了以下 excel 文件,该文件使用求解器根据卡路里、脂肪、蛋白质和碳水化合物的限制提出最便宜的饮食。 File here

我想添加另一个约束,其中土豆的价格在第五个单位后变为 0.40 而不是 0.15。在 excel 中如何以线性方式建模此约束?

谢谢

这可以建模为:

 potatoes = cheap_potatoes + expensive_potatoes
 cheap_potatoes <= 5
 potatoes, cheap_potatoes, expensive_potatoes >= 0

在 objective 函数中,将 0.15*potatoes 替换为 0.15*cheap_potatoes + 0.4*expensive_potatoes。由于 cheap_potatoes 更便宜,objective(成本最小化)将自动尝试首先使用这些。

这在您的电子表格中实施应该不会太困难。

PS。反过来(前 5 个贵,后 5 个便宜)也很常见(批量折扣)。这有点难以建模(需要二进制变量)。