Steve Myles
January 2016
EOQ: \[ Q^* = \sqrt{\frac{2CR}{H}} = \sqrt{\frac{2CR}{PF}} \]
EPQ: \[ Q^* = \sqrt{\frac{2CRp}{H(p - r)}} \]
eoq <- function(demand, order_cost, holding_cost_percent, unit_cost) {
sqrt(2 * order_cost * demand /
## avoid division by 0 by setting 0% holding cost to 0.001
(ifelse(holding_cost_percent == 0, 0.001, holding_cost_percent) * unit_cost)) }
demand <- 1000; order_cost <- 10; holding_cost_percent <- 0.1; unit_cost <- 5
eoqty <- eoq(demand, order_cost, holding_cost_percent, unit_cost)
eoqty
[1] 200
demand_rate <- function(demand) {demand / 250}
epq <- function(demand, order_cost, holding_cost_percent, unit_cost, production_rate) {
sqrt(2 * order_cost * demand * production_rate /
((ifelse(holding_cost_percent == 0, 0.001, holding_cost_percent)
* unit_cost) * (production_rate - demand_rate(demand)))) }
production_rate <- 5 ## the other parameters are the same as those in the EOQ example
epqty <- epq(demand, order_cost, holding_cost_percent, unit_cost, production_rate)
epqty
[1] 447.2136