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 optimal_cycle_time(raw_costs, demand): """ Calculate optimal cycle time (T*) given raw costs and demand. Parameters ---------- raw_costs : RawCosts A `RawCosts` object, containing a set of raw cost values demand : Demand A `Demand` object, containing demand quantity and time frame Returns ------- optimal_cycle_time: float """ Validate.required(raw_costs, "raw_costs") Validate.required(demand, "demand") Validate.positive(demand.quantity, "demand.quantity") Validate.positive(raw_costs.holding_cost, "raw_costs.holding_cost") numerator = 2 * raw_costs.ordering_cost denominator = demand.quantity * raw_costs.holding_cost return math.sqrt(numerator / denominator)