Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to allocate a product bought at different prices to different clients in a fair way. Initially, each of the $n$ client asked for a specific quantity of the product $a_1\ldots a_n$

The goods were bought in $m$ batches, every batch having a different quantity of goods $q$ which was paid a different price $p$ : $(q_1,p_1)\cdots(q_m,p_m)$

Obviously, the total quantity of items bought matches what was initially ordered $\sum a = \sum e$

I'm trying to find a matrix M(x,y) for which :

  1. Each client receives the quantity of goods he ordered : $\sum M(i,y) = a_i$

  2. The average price paid par each client is as close as possible to the "fair price", which is the average price of the global order $ |\frac {\sum M(i,y) p_i )}{ a_i} - \frac { \sum q_m,p_m }{ \sum a_n } |= \epsilon$

What would be an efficient way of doing that? I've looked into the simplex algorithm, but I'm not sure it would be adapted in that case.

share|cite|improve this question
Thank you so much for asking this question! Did you also discover this problem as part of financial order execution (filling brokerage orders for multiple accounts)? – Prashant Kumar Mar 6 '13 at 2:48

Why not calculate the average cost of an item by summing the total spent and dividing by the number of items? Then charge each customer that number times the quantity shipped to them.

share|cite|improve this answer
Unfortunately I can't do that. The "goods" I'm talking about are financial products, and they need to be sold to the end client at the exact price they were bought at. – Brann May 25 '12 at 21:10
The trick here is that you have to be accountable for each individual and indivisible unit allocated. Thus, we are still solving for the integer values of the matrix $M(x,y)$ – Prashant Kumar Mar 6 '13 at 2:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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