2

Here is the problem. Suppose we have N workers and N jobs. We want to assign each job exactly one worker. For each worker i, he could do some jobs on some cost. Our goal is to minimize the total cost on the condition that any single cost should be less than some value.

For example, 10 workers and 10 jobs. Worker 1 can do job 1 with $0.8, job 2 with $2.3, job 3 with $15.8, jobs 4 to 8 with $100, job 9 with $3.2, job 10 with $15.3.

Worker 2 can do job 1 with $3.5, job 2 with $2.3, job 3 with $4.6, job 4 with $17, etc.

Our goal is to find a matching or we can call it an assignment such that the total cost is minimized but any single cost of the corresponding pair/matching between work i and job i is less than a value like $50.

I would very much like to solve it in MATLAB if possible.

4
  • 1
    Maybe I miss something, but the problem seems to be very simple. For every Job find the cheapest worker, check if the pair of job and worker is has costs below $50, assign job. Commented Oct 23, 2013 at 23:14
  • 2
    @DanielR: You are missing something. For example, worker 1 might be more expensive on job 1 than some other, but putting him on job 1 might still give the lowest overall cost (e.g., he's $0.01 extra on job 1, but costs $1.0 extra on any other job). Commented Oct 23, 2013 at 23:20
  • 1
    @JerryCoffin: You are right, if there is a limit of 1 job per worker. Don't know what is intended. Commented Oct 23, 2013 at 23:24
  • @DanielR That idea is pretty much like the Greedy algorithm. It is useful. I was trying to find the minimum so that may not be the optimal solution. Commented Oct 23, 2013 at 23:46

1 Answer 1

3

This is a slight variation of the Assignment Problem. To handle your additional constraint that no single job cost should be more than some value, just change all entries in the matrix of costs that are greater than this threshold to a huge value (bigger than the sum of all other entries will suffice), and solve as usual, using e.g. the Hungarian Algorithm.

Sign up to request clarification or add additional context in comments.

13 Comments

@AppalachianMath: You're welcome :) Sure, it works for non-integer costs. It might be described in terms of maximising a sum of weights, rather than minimising them, in which case just swap all ">"s for "<"s and vice versa (or alternatively make all your numbers negative).
Do you mean that it only goes slow if you change the values that are greater than the threshold? In any case I would expect it to take a while for a 1000x1000 matrix as it's an O(n^3) algorithm! You might be able to solve the assignment problem using a different algorithm, or get a linear program solver like lp_solve to solve it faster.
I wrote that first sentence because I was trying to figure out why you wrote "There is a problem when I change all entries that are greater than the threshold into a larger value" instead of just "There is a problem". I suggested LP because it might be faster -- but probably only if the LP solver is smart enough to detect that this is a variant of the assignment problem, and apply a special solution technique for it. Commercial (I)LP solvers, like Gurobi, have a lot of this kind of stuff built in :)
If you use LP, then you would just omit any pairings that exceed the threshold, rather than setting them to a huge value. If there are a large number of pairings that exceed the threshold, ordinary simplex or barrier LP methods might well solve the problem faster than the Hungarian method -- have to try and see!
No I don't sorry -- it's been years since I touched MATLAB. I seem to recall there was an "Optimization Toolbox" or something for it though. That might have something like this.
|

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.