Optimizing costs in a changing world