Thread Subject: Simple Optimization Problem

Subject: Simple Optimization Problem

From: Neal Gordon

Date: 14 Mar, 2009 03:33:01

Message: 1 of 3

OK, here is my question. A simple example: Say you have 4 people who each spend a certain amount.
Bob - $50
Tim - $5
Sal - $95
Jon - $200
Together they spent $350, so thats an average of $87.5/person.
Find a solution to minimize the number of transactions between the people so that everyone has spent the same amount.

example solution
Tim pays Jon $82.5
Bob pays Jon $30
Bob pays Sal $7.5

Thanks.
-Neal

Subject: Simple Optimization Problem

From: ImageAnalyst

Date: 14 Mar, 2009 03:39:34

Message: 2 of 3

On Mar 13, 11:33=A0pm, "Neal Gordon" <gordon....@osu.edu> wrote:
> OK, here is my question. A simple example: Say you have 4 people who each=
 spend a certain amount.
> Bob - $50
> Tim - $5
> Sal - $95
> Jon - $200
> Together they spent $350, so thats an average of $87.5/person.
> Find a solution to minimize the number of transactions between the people=
 so that everyone has spent the same amount.
>
> example solution
> Tim pays Jon $82.5
> Bob pays Jon $30
> Bob pays Sal $7.5
>
> Thanks.
> -Neal
---------------------------------------------------------------------------=
------------------
I don't understand. If Tim pays $5 total, or even $5 per transaction,
then how can he spend $82.5 which is not a multiple of $5? And in
your example solution, not everybody has paid the same amount. Tim
paid $82.50, Bob paid $37.50, and Jon and Sal didn't pay(spend)
anything. Are you sure you're explaining this correctly?

Subject: Simple Optimization Problem

From: Neal Gordon

Date: 14 Mar, 2009 04:08:01

Message: 3 of 3

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <84a25b13-1e98-4886-bfa2-f1454477e057@l39g2000yqn.googlegroups.com>...
> On Mar 13, 11:33=A0pm, "Neal Gordon" <gordon....@osu.edu> wrote:
> > OK, here is my question. A simple example: Say you have 4 people who each=
> spend a certain amount.
> > Bob - $50
> > Tim - $5
> > Sal - $95
> > Jon - $200
> > Together they spent $350, so thats an average of $87.5/person.
> > Find a solution to minimize the number of transactions between the people=
> so that everyone has spent the same amount.
> >
> > example solution
> > Tim pays Jon $82.5
> > Bob pays Jon $30
> > Bob pays Sal $7.5
> >
> > Thanks.
> > -Neal
> ---------------------------------------------------------------------------=
> ------------------
> I don't understand. If Tim pays $5 total, or even $5 per transaction,
> then how can he spend $82.5 which is not a multiple of $5? And in
> your example solution, not everybody has paid the same amount. Tim
> paid $82.50, Bob paid $37.50, and Jon and Sal didn't pay(spend)
> anything. Are you sure you're explaining this correctly?

Original amount spent:
Bob - $50
Tim - $5
Sal - $95
Jon - $200
Together, as a group, they spent $350 = 50+5+95+200, so thats an average of $87.5/person.

So, to clarify, we would like to find the quickest way for everyone in the group to have spent the same amount overall. Now, I will show the iterations with the current amount spent per person.
--iteration 0--
Bob : $50
Tim : $5
Sal : $95
Jon : $200

--iteration 1--Tim pays Jon $82.5--
Bob : $50
Tim : $5 + $82.5 = $87.5
Sal : $95
Jon : $200 - $82.5 = $117.5

iteration 2--Bob pays Jon $30--
Bob : $50 + $30 = $80
Tim : $87.5
Sal : $95
Jon : $117.5 - $30 = $87.5

iteration 3--Bob pays Sal $7.5--
Bob : $80 + $7.5 = $87.5
Tim : $87.5
Sal : $95 - $7.5 = $87.5
Jon : $87.5

final spending with 3 iterations(transactions):
Bob : $87.5
Tim : $87.5
Sal : $87.5
Jon : $87.5

I hope this helps. This solution is trivial, but I am interested in the solution of 15+ people while trying to achieve less iterations than the "Number of people minus 1", which in this case is 3 obvious iterations.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
friend_payer Neal Gordon 13 Mar, 2009 23:35:03
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com