How inventory optimization works, from EOQ and the safety stock formula to multi-echelon methods, where the classic assumptions break, and what AI changes.