理论部分请参考下方链接:
第四部分 供应链库存的计划和管理(二)供应链的不确定性管理:安全库存https://blog.csdn.net/weixin_56917624/article/details/131585778
1.给定补货策略下安全库存的计算
假设MoonLight公司的产品手机的周需求服从正态分布,且均值为2500部,标准差为500部。制造商满足MoonLight公司的订单需要2周时间。门店经理采取连续盘点的策略,每当店内手机库存下降至6000部时就发出批量为10000部的采购订单。计算MoonLight公司持有的安全库存和平均库存,以及每部手机在MoonLight公司的平均存放时间。
public class GivenStratetyData {
//周需求均值为2500
double avgWeekDemand = 2500;
//标准差为500
double standardDeviation = 500;
//补货提前期
int meetTime = 2;
//再订购点
double recorderPoint = 6000;
//平均订货批量
double batchBuyCount = 10000;
}
public class GivenStratetyModel {
private GivenStratetyData data;
public GivenStratetyModel(GivenStratetyData data) {
this.data = data;
}
public void calculate(){
//安全库存
double ss = data.recorderPoint - data.avgWeekDemand * data.meetTime;
System.out.println("安全库存ss=" + ss);
//周转库存
double cycleInventory = data.batchBuyCount / data.meetTime;
System.out.println("周转库存=" + cycleInventory);
//平均库存
double avgInventory = ss + cycleInventory;
System.out.println("平均库存=" + avgInventory);
//平均流动时间
double avgFlowTime = avgInventory / data.avgWeekDemand;
System.out.println("平均流动时间=" + avgFlowTime);
}
}
public class Test {
public static void main(String[] args) {
GivenStratetyData givenStratetyData = new GivenStratetyData();
GivenStratetyModel givenStratetyModel = new GivenStratetyModel(givenStratetyData);
givenStratetyModel.calculate();
}
}
结果如下:
2.给定再订货点时的周期服务水平的计算
所有数据与例一完全相同,但现假设每周的需求相互独立。求该策略下的CSL。
package utils;
import org.apache.commons.math3.distribution.NormalDistribution;
public class NormDist {
private double mean;// 平均值
private double sd; // 标准差
private double x;// 要计算概率密度函数的值
private boolean cumulative;// 是否计算累积分布函数(CDF),而不是概率密度函数(PDF)
public NormDist(double mean, double sd, double x, boolean cumulative) {
this.mean = mean;
this.sd = sd;
this.x = x;
this.cumulative = cumulative;
}
public double getResult(){
NormalDistribution normalDistribution = new NormalDistribution(mean, sd);
double result;
if (cumulative) {
result = normalDistribution.cumulativeProbability(x);
} else {
result = normalDistribution.density(x);
}
return result;
}
}
import utils.NormDist;
public class CSLModel {
private GivenStratetyData data;
public CSLModel(GivenStratetyData data) {
this.data = data;
}
public void calculate(){
//计算正态分布的均值和标准差
double DL = data.meetTime * data.avgWeekDemand;
double SL = Math.round(Math.pow(2,0.5) * data.standardDeviation);
System.out.println("均值为:" + DL);
System.out.println("标准差为:" + SL);
NormDist normDist = new NormDist(DL, SL, data.recorderPoint, true);
double CSL = normDist.getResult();
System.out.println("CSL=" + CSL);
}
}
public class Test {
public static void main(String[] args) {
GivenStratetyData givenStratetyData = new GivenStratetyData();
CSLModel cslModel = new CSLModel(givenStratetyData);
cslModel.calculate();
}
}
结果如下:
3.给定期望周期服务水平下安全库存的计算
所有数据与例一完全相同,但现在假设Moolight采用连续盘点策略,要达到90%的周期服务水平,应该持有多少安全库存。
package utils;
import org.apache.commons.math3.distribution.NormalDistribution;
public class NormsInv {
private double mean;// 平均值
private double sd; // 标准差
private double prob;
public NormsInv(double mean, double sd, double prob) {
this.mean = mean;
this.sd = sd;
this.prob = prob;
}
public double getResult(){
NormalDistribution normalDistribution = new NormalDistribution(mean, sd);
double zValue = normalDistribution.inverseCumulativeProbability(prob);
return zValue;
}
}
import utils.NormsInv;
public class GivenCSLModel {
private GivenStratetyData data;
public GivenCSLModel(GivenStratetyData data) {
this.data = data;
}
public void calculate(){
//计算正态分布的均值和标准差
double DL = data.meetTime * data.avgWeekDemand;
double SL = Math.round(Math.pow(2,0.5) * data.standardDeviation);
System.out.println("均值为:" + DL);
System.out.println("标准差为:" + SL);
NormsInv normsInv = new NormsInv(0, 1, 0.9);
double ss = normsInv.getResult() * SL;
System.out.println("安全库存ss=" + ss);
}
}
public class Test {
public static void main(String[] args) {
GivenStratetyData givenStratetyData = new GivenStratetyData();
GivenCSLModel givenCSLModel = new GivenCSLModel(givenStratetyData);
givenCSLModel.calculate();
}
}
结果如下:
4.给定再订货点时满足率的计算
所有数据与例一完全相同,但现假设每周的需求相互独立。计算这种订货策略下的满足率。
import utils.NormDist;
public class FrInGivenRPModel {
private GivenStratetyData data;
public FrInGivenRPModel(GivenStratetyData data) {
this.data = data;
}
public void calculate(){
//计算安全库存
double DL = data.meetTime * data.avgWeekDemand;
double SL = Math.round(Math.pow(2,0.5) * data.standardDeviation);
double ss = data.recorderPoint - DL;
System.out.println("安全库存ss=" + ss);
//计算补货周期平均预期缺货量
double FS = new NormDist(0, 1, ss/SL, true).getResult();
double fs = new NormDist(0, 1, ss/SL, false).getResult();
double ESC = -ss * (1-FS) + SL * fs;
System.out.println("ESC=" + ESC);
//计算满足率
double fr = (data.batchBuyCount - ESC) / data.batchBuyCount;
System.out.println("fr=" + fr);
}
}
public class Test {
public static void main(String[] args) {
GivenStratetyData givenStratetyData = new GivenStratetyData();
FrInGivenRPModel frInGivenRPModel = new FrInGivenRPModel(givenStratetyData);
frInGivenRPModel.calculate();
}
}
结果如下:
5.给定期望满足率下的安全库存的计算
假设MoonLight公司的产品手机的周需求服从正态分布,且均值为2500部,标准差为500部。制造商满足MoonLight公司的订单需要2周时间。门店经理采取连续盘点的策略,目前补货批量为10000部,为达到97.5%的满足率,门店需要持有多少安全库存。
public class GivenFrData {
//周需求均值为2500
double avgWeekDemand = 2500;
//标准差为500
double standardDeviation = 500;
//补货提前期
int meetTime = 2;
//平均订货批量
double batchBuyCount = 10000;
//期望满足率
double fr = 0.975;
}
import utils.NormDist;
public class GivenFrModel {
private GivenFrData data;
public GivenFrModel(GivenFrData data) {
this.data = data;
}
public void calculate(){
double SL = Math.round(Math.pow(2,0.5) * data.standardDeviation);
double ESC = Math.round((1-data.fr) * data.batchBuyCount);
System.out.println("ESC=" + ESC);
//暴力求解(存在优化空间)
double ss = 0;
for (int i = 0; i < data.avgWeekDemand; i++) {
NormDist normDist1 = new NormDist(0, 1, i / SL, true);
double ndResult1 = normDist1.getResult();
NormDist normDist2 = new NormDist(0, 1, i / SL, false);
double ndResult2 = normDist2.getResult();
double result = ESC + i * (1 - ndResult1) - SL * ndResult2;
if(result > -1 && result < 0.1){
ss = i;
break;
}
}
System.out.println("安全库存ss=" + ss);
}
}
public class Test {
public static void main(String[] args) {
GivenFrData givenFrData = new GivenFrData();
GivenFrModel givenFrModel = new GivenFrModel(givenFrData);
givenFrModel.calculate();
}
}
结果如下:
6.提前期的不确定性对安全库存的影响
MoonLight是一家汽车销售商,每周的汽车需求服从正态分布,且均值为2500辆,标准差为500辆。目前供应商补货的提前期为7天,且要求达到95%的周期服务水平。如果提前期的标准差为7天,计算必须持有多少安全库存。同时计算不同标准差下的安全库存。
public class UncertaintyOfMeetTimeData {
//日需求均值为2500
double avgDayDemand = 2500;
//标准差为500
double standardDeviation = 500;
//补货提前期(天)
int meetTime = 7;
//再订购点
double recorderPoint = 6000;
//周期服务水平
double CSL = 0.9;
}
import utils.NormDist;
import utils.NormsInv;
public class UncertaintyOfMeetTimeModel {
private UncertaintyOfMeetTimeData data;
public UncertaintyOfMeetTimeModel(UncertaintyOfMeetTimeData data) {
this.data = data;
}
public void calculate(){
//计算提前期内的需求分布
//(1)提前期内的平均需求
double DL = data.avgDayDemand * data.meetTime;
//(2)提前期内的需求标准差
for (int i = 7; i > -1; i--) {
double SL = Math.pow(data.meetTime*Math.pow(data.standardDeviation,2) + Math.pow(data.avgDayDemand,2) * Math.pow(i,2),0.5);
//计算安全库存
NormsInv normsInv = new NormsInv(0, 1, 0.9);
double ss = normsInv.getResult() * SL;
System.out.println("提前期:" + i + " 提前期内需求的标准差:" + SL + " 安全库存:" + ss);
}
}
}
public class Test {
public static void main(String[] args) {
UncertaintyOfMeetTimeData uncertaintyOfMeetTimeData = new UncertaintyOfMeetTimeData();
UncertaintyOfMeetTimeModel uncertaintyOfMeetTimeModel = new UncertaintyOfMeetTimeModel(uncertaintyOfMeetTimeData);
uncertaintyOfMeetTimeModel.calculate();
}
}
结果如下:
7.相关性对集中策略价值的影响
MoonLight汽车公司有四个汽车公司,服务于整个山东地区(分散策略)。每个零售商的需求均服从正态分布,均值为25辆,标准差为5辆。制造商的补货提前期L=2周。每家零售店负责一个独立的区域,每两个不不同区域之间的需求的相关系数为ρ。经销商正在考虑将4家零售店合成1家零售店的可能性(集中策略)。假设整合后的中央零售店的需求为4个区域的需求之和。经销商周期服务水平的目标值为0.9。当相关系数再0~1之间变动时,比较两种策略下的安全库存。
public class RelevanceOnCenterValueData {
//均值
double[] mean = {25,25,25,25};
//标准差
double[] sd = {5,5,5,5};
//补货提前期
double mt = 2;
//周期服务水平
double[] csl = {0.9,0.9,0.9,0.9};
//相关系数
double[][] relevances = {
{1,0.8,0.8,0.8},
{0.8,1,0.8,0.8},
{0.8,0.8,1,0.8},
{0.8,0.8,0.8,1},
};
}
import utils.NormsInv;
public class RelevanceOnCenterValueModel {
private RelevanceOnCenterValueData data;
public RelevanceOnCenterValueModel(RelevanceOnCenterValueData data) {
this.data = data;
}
public void calculate(){
//计算分散策略下的安全库存
double ss = 0;
NormsInv normsInv = new NormsInv(0, 1, 0.9);
double ni = normsInv.getResult();
for (int i = 0; i < data.mean.length; i++) {
ss += ni * Math.pow(data.mt,0.5) * data.sd[i];
}
System.out.println("分散策略下的安全库存ss=" + ss);
//计算集中策略下的安全库存
double sd1 = 0;
for (int i = 0; i < data.mean.length; i++) {
sd1 += Math.pow(data.sd[i],2);
}
double sd2 = 0;
for (int i = 0; i < data.mean.length; i++) {
for (int j = 0; j < data.mean.length; j++) {
if (i>j){
sd2 += data.relevances[i][j] * data.sd[i] * data.sd[j];
}
}
}
double ss2 = ni * Math.pow(data.mt,0.5) * Math.pow(sd1+2*sd2,0.5);
System.out.println(ss2);
}
}
public class Test {
public static void main(String[] args) {
RelevanceOnCenterValueData relevanceOnCenterValueData = new RelevanceOnCenterValueData();
RelevanceOnCenterValueModel relevanceOnCenterValueModel = new RelevanceOnCenterValueModel(relevanceOnCenterValueData);
relevanceOnCenterValueModel.calculate();
}
}
结果如下:
8.周期盘点策略下的安全库存的计算
MoonLight是一家汽车销售商,每周的汽车需求服从正态分布,且均值为2500辆,标准差为500辆。补货提前期为2周,4周盘点一次库存。假设实行周期盘点策略,要想提供90%的CSL,应持有多少安全库存,并计算该策略下的目标最大库存水平。
public class GivenCycleData {
double mean = 2500;
double sd = 500;
double mt = 2;
double csl = 0.9;
//盘点间隔期
double ct = 4;
}
import utils.NormsInv;
public class GivenCycleModel {
private GivenCycleData data;
public GivenCycleModel(GivenCycleData data) {
this.data = data;
}
public void calculate(){
//计算mt + ct的正太分布
double DTL = (data.mt + data.ct) * data.mean;
double SDTL = Math.pow(data.mt + data.ct,0.5) * data.sd;
//计算安全库存
NormsInv normsInv = new NormsInv(0, 1, 0.9);
double ni = normsInv.getResult();
double ss = ni * SDTL;
System.out.println("安全库存ss=" + ss);
//最大库存水平
double OUL = DTL + ss;
System.out.println("最大库存水平=" + OUL);
}
}
public class Test {
public static void main(String[] args) {
GivenCycleData givenCycleData = new GivenCycleData();
GivenCycleModel givenCycleModel = new GivenCycleModel(givenCycleData);
givenCycleModel.calculate();
}
}
结果如下:
版权归原作者 Maja2333 所有, 如有侵权,请联系我们删除。