The Economic Order Quantity or EOQ represents the optimum purchase quantity for a given product, while aiming to minimise holding costs, shortage costs, and order costs. It’s most commonly calculated using a model known as the Classical EOQ Model.

The Classical EOQ Model assumes that the demand rate is constant and that replenishment is instantaneous and there are no shortages, which arguably isn’t particularly realistic, but it’s still pretty decent for many types of product.

There are several derivatives of the Classical EOQ Model, including the EOQ with Price Breaks model, which includes specific order volumes that generate the retailer a discount (something common in many markets). Other variants can cope with multi-item orders and limitations on storage among other things.

```
import math
def eoq(demand_in_units,
cost_of_ordering,
cost_of_carrying):
"""Return the Economic Order Quantity (EOQ) for a product.
Args:
demand_in_units (int):
cost_of_ordering (float):
cost_of_carrying (float):
Returns:
float: Economic Order Quantity or EOQ based on Classical EOQ model.
"""
return math.sqrt(((demand_in_units * cost_of_ordering) * 2) / cost_of_carrying)
```

```
print('EOQ:', eoq(demand_in_units=12000, cost_of_ordering=100, cost_of_carrying=16))
```

```
EOQ: 387.2983346207417
```

Matt Clarke, Friday, March 12, 2021