I am trying to create an algorithm that can help me calculate reording point (ROP) based on:
- Ordering Dates (OD)
- Delivery Dates (DD)
- Store Forecast (Fcst)
I have been trying for weeks but cannot find the way to do this efficiently because I will be running this simulations for 1 million item-store combinations.
The logic is simple:
We have to sum the forecast from the nearest delivery date upto the following delivery date. (Starting from the ordering dates)
Nearest delivery date will never be the same ordering date
The example:
library(data.table)
set.seed(1)
sim_days <- 30
start_Date <- as.Date("2022-01-01")
seq_days <- seq.Date(start_Date,start_Date + 30, by="days")
OD <- c(0,0,1,0,0,1,0,0,1,1,0,0,1,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,1)
DD <- c(0,0,0,0,1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,0,1,0,0,0,0,1,0,1,0,0,0)
Forecast <- c(100,230,300,417,170,414,430,331,320,121,172,161,340,234,369,274,351,447,233,372,427,174,328,143,193,235,104,233,404,219,268)
Expected_Result <- c("","",1014,"","",1202,"","",293,907,"","",877,"","","",1032,"","",1500,"","","",572,"","",1124,"","","","")
OD <- rbind(as.character(seq_days),as.numeric(OD)); colnames(OD) <- as.character(seq_days); OD <- OD[-1,]
DD <- rbind(as.character(seq_days),as.numeric(DD)); colnames(DD) <- as.character(seq_days); DD <- DD[-1,]
rbind(OD,DD,Forecast,Expected_Result)[]