def __init__(self, quantity, time_unit='Y'): Validate.required(quantity, "quantity") Validate.non_negative(quantity, "quantity") self.quantity = quantity Validate.one_of_allowable(time_unit, ['Y', 'M', 'W', 'D'], "time_unit") self.time_unit = time_unit
def shortage_cost(shortage_cost, shortage_quantity): """ Calculate the shortage cost - the total cost of not having units in stock, including costs due to backorder, lost sales, lost customers, and operational disruptions. Parameters ---------- shortage_cost : int or float Cost per unit of shortage, in dollars shortage_quantity : int The number of units of shortage, in units Returns ------- shortage_cost : float """ Validate.required(shortage_cost, "shortage_cost") Validate.non_negative(shortage_cost, "shortage_cost") Validate.required(shortage_quantity, "shortage_quantity") Validate.non_negative(shortage_quantity, "shortage_quantity") return shortage_cost * shortage_quantity
def ordering_cost(ordering_cost, demand_quantity, order_quantity): """ Calculate the ordering cost - the total cost of placing, receiving, and processing orders needed to fulfill a given amount of demand. Parameters ---------- ordering_cost : int or float Cost per order, in dollars demand_quantity : int The amount of demand, in units order_quantity : int The number of units purchased per order, in units Returns ------- ordering_cost: float """ Validate.required(ordering_cost, "ordering_cost") Validate.non_negative(ordering_cost, "ordering_cost") Validate.required(demand_quantity, "demand_quantity") Validate.non_negative(demand_quantity, "demand_quantity") Validate.required(order_quantity, "order_quantity") Validate.positive(order_quantity, "order_quantity") return ordering_cost * (demand_quantity / order_quantity)
def validate_init_values(unit_cost, ordering_cost, holding_rate, holding_cost, holding_time_unit, shortage_cost): Validate.required(unit_cost, "unit_cost") Validate.non_negative(unit_cost, "unit_cost") Validate.required(ordering_cost, "ordering_cost") Validate.non_negative(ordering_cost, "ordering_cost") # accept holding_rate or holding_cost, but not both # (at least one is required) Validate.one_only([holding_rate, holding_cost], ["holding_rate", "holding_cost"]) if holding_rate is not None: Validate.non_negative(holding_rate, "holding_rate") else: Validate.non_negative(holding_cost, holding_cost) Validate.one_of_allowable(holding_time_unit, RawCosts.supported_time_units, "holding_time_unit") Validate.required(shortage_cost, "shortage_cost") Validate.non_negative(shortage_cost, "shortage_cost")
def holding_cost(holding_cost, order_quantity): """ Calculate the holding cost - the total cost of holding excess inventory, including storage, service costs, risk costs, and capital costs. Parameters ---------- holding_cost : int or float Cost per unit of inventory per time period, in dollars order_quantity : int The number of units purchased per order, in units Returns ------- holding_cost: float """ Validate.required(holding_cost, "holding_cost") Validate.non_negative(holding_cost, "holding_cost") Validate.required(order_quantity, "order_quantity") Validate.non_negative(order_quantity, "order_quantity") return holding_cost * (order_quantity / 2)
def purchase_cost(unit_cost, demand_quantity): """ Calculate the purchase cost - the total landed cost for acquiring product needed to satisfy a given amount of demand. Parameters ---------- unit_cost : int or float Cost per unit, in dollars demand_quantity : int The amount of demand, in units Returns ------- purchase_cost: float """ Validate.required(unit_cost, "unit_cost") Validate.non_negative(unit_cost, "unit_cost") Validate.required(demand_quantity, "demand_quantity") Validate.non_negative(demand_quantity, "demand_quantity") return unit_cost * demand_quantity