【问题标题】:Formulate algorithm to evenly distribute delivery quantities using linear programming使用线性规划制定算法以均匀分配交货数量
【发布时间】:2018-05-02 19:34:38
【问题描述】:

我正在尝试使用优化和线性规划来解决供应链问题。

我不是优化专家,我无法使用变量、约束和目标制定解决方案。

这只是一个概念证明,我已经尝试过 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);

我希望这能为我的问题提供更多背景信息。

【问题讨论】:

  • 太宽泛了!只有文本,没有数学模型(您部分解决的任务)。不能这样回答。我们甚至不知道您的模型中产品的数量是多少(因此建议,例如:将差异范数最小化为均值(不是 LP)只是猜测)。
  • 抱歉太笼统了。新手错误,不是数学。产品数量是包含每种产品的容器数量。它不一定是 LP 解决方案,我一直在阅读有关最小化差异规范的内容,但不确定如何使用 Microsoft Solver Foundation 来解决这个问题。我建议使用 LP,因为我是新手,并且尽可能保持简单。

标签: optimization mathematical-optimization linear-programming ms-solver-foundation operations-research


【解决方案1】:

一些注意事项:

  • Microsoft Solver Foundation 多年前已停止使用。如果这不仅仅是一次性模型,您可能需要查看其他工具。
  • 通常我们对许多相关变量(如数组)使用索引。一大堆标量变量和方程很快就会变得乏味。
  • 可以使用松弛来对与单个值的偏差进行惩罚。例如。 BaselineDeliver + Over[t] - Under[t](与Over[t],Under[t]&gt;=0)。然后在目标 penalty * sum (Over[t]+Under[t]) 中添加一个术语。
  • 在开始编码之前写下数学优化模型通常会有所帮助。有时从一张纸而不是电脑屏幕开始是个好主意。

【讨论】:

  • 感谢 Erwin 的提示。我了解无国界医生。我将更新我的算法并试一试。您会推荐基于 .Net c#(并且免费/开源)的 MSF 替代方案吗?
  • MSF 从来就不是免费的或开源的(除了具有有限数量的变量和约束的“演示”版本)。许多商业 LP/MIP 求解器都有 .NET 接口(有些有免费的“演示”或“社区”版本)。
  • 嗨欧文。对不起,我是个笨蛋,但我正在努力完成这项工作。您能否详细说明 BaselineDeliver + Over[t] - Under[t] 的含义。我理解(我认为)这应该是一个等式,那么等式的右侧是什么来将其变成一个约束?
  • q[t] = BaselineDeliver + Over[t] - Under[t] 其中q[t] 是在t 天交付的数量。我希望这很明显。
  • 对不起 Erwin,当你在处理一个小飞象时,没有什么是显而易见的。你真的给了我我需要的东西,我真的很感谢你的帮助(和耐心)!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-15
  • 2010-10-09
相关资源
最近更新 更多