首页 > 解决方案 > Excel Solver - 单位 5 后每份的价格变化

问题描述

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

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

谢谢

标签: excellinear-programmingsolver

解决方案


这可以建模为:

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

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

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

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


推荐阅读