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?

  • 2
    $\begingroup$ 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. $\endgroup$
    – Ben I.
    Commented Jun 25, 2019 at 20:24
  • $\begingroup$ 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. $\endgroup$ Commented Jun 26, 2019 at 0:11
  • $\begingroup$ 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. $\endgroup$ Commented Jun 26, 2019 at 14:28
  • $\begingroup$ 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. $\endgroup$ Commented Jun 26, 2019 at 16:04
  • 1
    $\begingroup$ 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). $\endgroup$ Commented Nov 23, 2019 at 13:38

1 Answer 1


This sounds like a maximization problem. The algoritm should try to maximize something, let us call it utility. What You need to start with is to define the utility funktion: is it better to sell all to first customer or end the day with unsold goods?

  • $\begingroup$ That's the problem - I am trying to maximize two things. This is a "fuzzy" problem. I don't expect that there will be a clear cut answer, but rather an approach that limits the downside of each possible bad outcome. $\endgroup$ Commented Jun 26, 2019 at 13:09
  • 1
    $\begingroup$ The point is that If you cannot set a ”price” on the utility for customers and shop there is no way to know if you at the end of the day had done a good job. Any decision will include a trade off between different goals. Of course if you know that the shop never sells out all it is a trivial problem. $\endgroup$
    – ghellquist
    Commented Jun 26, 2019 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.