# Designing a rationing algorithm for a store

Suppose I have a store and I have n units of item x. I want to sell all n units at the end of the day. I do not know how many customers will be coming in today. One customer could theoretically come in and buy all remaining units. This would not be desirable, as the next customer would not be able to buy this item, and would end up frustrated that we do not keep enough in stock.

In general, how does one design a rationing algorithm that balances the need to sell as much quantity as possible with serving the most amount of (unknown number of) customers? Is this even possible?

• Are the customers themselves ordered? If so, I don't think you've yet set enough constraints onto this problem for it to have an answer. – Ben I. Jun 25 '19 at 20:24
• They come one after the other, you don't ever know if the current one is the last. This is actually a real world problem. – Adam Carpentieri Jun 26 '19 at 0:11
• Is this really desirable? You're trading the possibility that a future customer will be frustrated that you've out of stock against the certainty that the present customer is frustrated by your refusal to sell them what they want. I don't see how you could possibly answer this question without a good model of customer demand. But if you had a good model of customer demand, why do you need to ration? Wouldn't you just stock enough goods to meet that demand? The only case I can think of is if overall supply of the good isn't enough to meet demand. – David Richerby Jun 26 '19 at 14:28
• Its not that the overall supply isn't high - its that getting new supply takes a few days. And the various items are purchased randomly - the past purchasing patterns do not predict the future. – Adam Carpentieri Jun 26 '19 at 16:04
• This seems to be a statistics problem. You need a model to present the number of costumers and the probability of them buying the items for different prices and then optimizing the number of bought elements (so that all buy but no one buys everything). – narek Bojikian Nov 23 '19 at 13:38