# Cost allocation (allocate pay across places)

## Main Question or Discussion Point

I have business problem that I need to address. In short, I need to allocate pay for multiple people across multiple locations. For the purpose of providing a simple example, I restricted my thoughts to two people and two places.

Given:

Let a = Hours to allocate to Place01 for Sue
Let b = Hours to allocate to Place02 for Sue
Let c = Hours to allocate to Place01 for Bob
Let d = Hours to allocate to Place02 for Bob

Bob's Hourly rate = 500 dollars/hour
Sue's Hourly rate = 1000 dollars/hour
Bob's Hours worked = 70 Hours
Sue's Hours worked= 90 Hours

The following must be true in any reasonable solution:
a>0
b>0
c>0
d>0

1000*a + 500*c = $50,000 where 1000 represents Sue's hourly rate and 500 represents Bob's hourly rate. 1000*b + 500*d =$75,000 where 1000 represents Sue's hourly rate and 500 represents Bob's hourly rate.
c+d = 70 hours
a+b = 90 hours

The Problem

I need to distribute the 160 total hours as evenly as possible across Place01 and Place02 for each Person. Thus, in math terms I would like to minimize the absolute difference between a and b. I would also like to minimize the absolute difference between c and d subject to the constraints listed above.
e.g. I want to select the solution from the universe of possible solutions such that:
|a-b| is at a minimum and |c-d| is also minimized

Notice that the total dollars allocated $125,000 = total dollars paid =$125,000. Normally, to do this I would just split the hours for each person between each place. But as noted above, I now have the constraint that Place01 must get exactly $50,000 allocated and place two must get$75,000. How can I solve this in the best way possible that distributes the hours as evenly as possible for each employee across the two Places? Bear in mind that the solution will need to be scalable in the sense that I actually have about 100 places and as many people. Rates and hours for each person are known in advance and are constant. I simplified the example for the purpose of illustrating the problem at hand.

I first attempted to solve this using a matrix, but then realized I did not understand how to even out the allocation.