0 votes

An ice cream shop is looking to minimize their operation costs, under the given constraints:

They are faced with costs of purchasing ice cream from a local distributor, where each order has a (potentially large) fixed delivery cost shipping _ cost as well as the price price for each pint

to minimize delivery costs, they can buy more ice cream than needed for a given day, and keep it stored it in their freezer overnight

their freezer can store max capacity pints of ice cream at any time (includes both the shipment as well as any pints stored overnight)

However, storing extra ice cream overnight is not free, and it costs them overnight cost dollars per pint (per night) to keep any additional ice cream frozen if they buy in advance

Given a list of daily demand (in pints) of ice cream for the next num_days days, what is the minimum cost for the shop to be stocked up ready to meet their demands each day?

Inputs

An integer num _ days , for the number of days

A list of n integers demands, separated by a space, for the pints of ice cream demanded each day

An integer max _ capacity , for the max capacity of their freezer

An integer shipping _ cost , for the fixed cost of each shipment taken

An integer price, for the price they pay for each pint of ice cream

An integer overnight_cost, the cost of storing a pint of ice cream for a day

in Dynamic Programming by (132 points)
edited by

2 Answers

+1 vote

minCost[n] = the minimize cost on the nth day.

iceCream[n] = the pints of ice cream demanded on the nth day

the whole price of ice cream should be the sum of pints * price, it will never change. 

on day 1, the shop must pay shipping fee. minCost[0] = shipping_cost.

if the remaining ice cream cannot satisfy the demand on that day, the shop has to ship more, cost = shipping_cost + overnight_cost, so they should avoid this situation. Therefore, we only compare shipping_cost with overnight_cost.

minCost[n] = min { shipping_cost + minCost[n-1], overnight_cost * iceCream[n] + minCost[n-1] }

however, when max_capacity is not big enough, the remaining ice cream cannot satisfy the demand on next day, they have to ship.

if( ( max_capacity - iceCream[n-1] ) < iceCream[n] )

minCost[n] = shipping_cost + minCost[n-1]

Am I right?

by (132 points)
0 votes
In fact, it is far more complicated than your model. The shipped goods are not necessarily consumed in one day. The consumption of the same volume of ice cream is not linear.
by AlgoMeister (948 points)

Related questions

+1 vote
3 answers
0 votes
5 answers
asked Jun 16, 2020 in Dynamic Programming by Amrinder Arora AlgoMeister (1.6k points)
+1 vote
2 answers
The Book: Analysis and Design of Algorithms | Presentations on Slideshare | Lecture Notes, etc
...