我的库存线性程序中有一个约束:
x[next period] = x[this period] + purchases[this period] - sold[this period]
决策变量是购买[本期]和售出[本期]。用滚动水平周期解决了几个周期。
当我像这样将它放入 PuLP 时,除第一个(常量输入,例如 12345)之外的所有 x[t] 最终都为 0。
T = range(0,7)
x = [0 for t in T]
x[0] = 12345
for t in T:
prob += x[t] + p[t] - s[t] == x[t+1], "some label %s"(t)
prob += x[t+1] >= 0