我正在尝试使用优化和线性规划来解决供应链问题。
我不是优化专家,我在使用变量、约束和目标制定解决方案时遇到了麻烦。
这只是一个概念证明,我已经尝试过 Microsoft Solver Foundation 和 Optano 来创建演示。
我需要将产品交付给客户。我在固定的日子交货。我需要确保客户的货架上每天有最低约定的库存水平。
客户每周进行一次库存检查,并告诉我每周每种产品的起始库存水平。每种产品的平均每日使用量是一个已知参数。
到目前为止,一切都很好。我有一个解决方案。下一个要求是我卡住的地方。
出于后勤原因,供应商希望每次交付的产品总量大致相同。
在特殊的日子里,库存水平可能会低于通常商定的库存水平。至少它必须是平均每日使用量,并且到周末交付的总量必须是该周商定的库存水平。
根据我读过的文章和探索过的例子,我尝试了许多实验。我还没有找到一种方法来制定约束和目标来解决平均分配每天交付的数量的要求。
我想这是一个相当普遍的供应链问题,我真的(真的)会很感激一些指导吗?
更新: 这是使用 Microsoft Solver Foundation(求解器服务 API)的基本实现。我与无国界医生无关。它计算每天交付的数量和每天结束时货架上的预期库存量。
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);
我希望这能为我的问题提供更多背景信息。