Pātuhitia tēnei: Dynamic programming and inventory control