Inventory optimization code written in python