【发布时间】: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