我正在尝试使用优化和线性编程来解决供应链问题。
我不是优化专家,我在使用变量,约束和目标制定解决方案时遇到了问题。
这只是一个概念证明,我已经尝试过Microsoft Solver Foundation和Optano来创建演示。
我需要向客户提供产品。我定期送货。我需要确保客户每天在货架上达到最低商定库存水平。
客户每周进行一次库存检查,并告诉我本周每种产品的起始库存水平。每种产品的平均每日使用量是一个已知参数。
到目前为止,这么好。我有一个解决方案。下一个要求是我被困住的地方。
出于后勤原因,供应商希望每次交货的产品总量大致相同。
在特殊日子,库存水平可能会低于通常商定的库存水平。至少必须是平均每日使用量,到本周末,交付的总金额必须是本周商定的库存水平。
我根据我读过的文章和我探索过的例子尝试了许多实验。我没有找到一种方法来制定约束和目标,以解决平均分配每天交付数量的要求。
我认为这是一个相当普遍的供应链问题,我真的(真的)赞赏一些指导吗?
更新 这是使用Microsoft Solver Foundation(求解器服务API)的基本实现。我与MSF无关。它计算每天交付的数量以及每天结束时货架上预期的库存量。
SolverContext context = SolverContext.GetContext();
Model model = context.CreateModel();
// these are the quantities to be delivered each day
Decision qMon = new Decision(Domain.IntegerNonnegative, "monQuantity");
Decision qTue = new Decision(Domain.IntegerNonnegative, "tueQuantity");
Decision qWed = new Decision(Domain.IntegerNonnegative, "wedQuantity");
Decision qThu = new Decision(Domain.IntegerNonnegative, "thuQuantity");
Decision qFri = new Decision(Domain.IntegerNonnegative, "friQuantity");
Decision qSat = new Decision(Domain.IntegerNonnegative, "satQuantity");
Decision qSun = new Decision(Domain.IntegerNonnegative, "sunQuantity");
// these are the expected quantities to be found on the shelf
//at the end of each day
Decision sMon = new Decision(Domain.IntegerNonnegative, "monStock");
Decision sTue = new Decision(Domain.IntegerNonnegative, "tueStock");
Decision sWed = new Decision(Domain.IntegerNonnegative, "wedStock");
Decision sThu = new Decision(Domain.IntegerNonnegative, "thuStock");
Decision sFri = new Decision(Domain.IntegerNonnegative, "friStock");
Decision sSat = new Decision(Domain.IntegerNonnegative, "satStock");
Decision sSun = new Decision(Domain.IntegerNonnegative, "sunStock");
model.AddDecisions(qMon, qTue, qWed, qThu, qFri, qSat, qSun);
model.AddDecisions(sMon, sTue, sWed, sThu, sFri, sSat, sSun);
// this is the quantity from the stock count
var initialCount = 0;
// this is the average quantity used per day
var averageUsage = 10;
// the stock level must be greater than agreed minimum (150)
model.AddConstraints("stock",
150 <= sMon, 150 <= sTue,
150 <= sWed, 150 <= sThu,
150 <= sFri, 150 <= sSat,
150 <= sSun);
// apply constraint to calculate the stock left on the shelf
// use supply/demand formula
// a special rule for monday using the inital stock take
// the remaining days rely on stock left over from previous day
model.AddConstraint("initialStock",
sMon + averageUsage == qMon + initialCount);
model.AddConstraints("restStock",
sTue + averageUsage == qTue + sMon,
sWed + averageUsage == qWed + sTue,
sThu + averageUsage == qThu + sWed,
sFri + averageUsage == qFri + sThu,
sSat + averageUsage == qSat + sFri,
sSun + averageUsage == qSun + sSat
);
model.AddGoal("minimiseDeliveries",
GoalKind.Minimize,
qMon + qTue + qWed + qThu + qFri + qSat + qSun);
Solution solution = context.Solve(new SimplexDirective());
// a couple of checks that we found an optimal solution
Assert.Equal(SolverQuality.Optimal, solution.Quality);
Assert.True(sSun.GetDouble() >= 150);
我希望这能为我的问题提供更多背景信息。
答案 0 :(得分:1)
一些注意事项:
BaselineDeliver + Over[t] - Under[t]
(Over[t],Under[t]>=0
)。然后在目标penalty * sum (Over[t]+Under[t])
中添加一个术语。