Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hungarian algorithm: multiple jobs per worker

Is there an extension of the Hungarian algorithm that caters for the assignment of multiple jobs per worker? In its simplest form, the algorithm assigns a single job to a single worker.

My application is a profit maximization problem, with 3 workers and 180 jobs. I'll add constraints as well (minimum of 50 jobs assigned to each worker).

I've managed to implement the Hungarian algorithm using the mungres library in Python, which works very well. I'm just struggling to find literature related to multiple assignments per worker.

https://pypi.python.org/pypi/munkres

https://en.wikipedia.org/wiki/Hungarian_algorithm

https://en.wikipedia.org/wiki/Generalized_assignment_problem

I've tried the standard numpy method listed in the comments, but was unable to extend it to multiple assignments per worker. If my matrix is rectangular (i.e. 3 workers and 4 jobs) only the first 3 jobs are assigned to the workers. I've also tried adding dummy variables to create a square matrix, but then jobs are assigned to those dummy workers rather than the actual workers

like image 713
Richard Ball Avatar asked Jan 05 '18 06:01

Richard Ball


2 Answers

This can be solved by formulating it as a transportation problem with the workers having bounds of [50,inf). Correct me if I am wrong, approach 1 from peter's solution is for when a person can do a maximum of 50, not minimum.

like image 199
Bhargav Chereddy Avatar answered Nov 14 '22 08:11

Bhargav Chereddy


Approach 1

One simple way of doing this is to make, for example, 50 clones of each worker and solve the problem as normal.

To find worker 1's jobs, you can then collect all the jobs assigned to the clones of worker 1. There are only 50 clones, so worker 1 will be assigned to at most 50 jobs.

Approach 2

This kind of assignment problem can be expressed as a min-cost flow problem where there is flow from a worker to a job if the worker does a job.

In this formulation, each worker is supplied with a capacity of 1 flow unit. You can then increase the number of jobs by simply increasing the capacity as required.

This approach is likely to be more efficient (as the graph is smaller) but requires modification of the underlying algorithm, whereas approach 1 should be trivial to implement.

like image 20
Peter de Rivaz Avatar answered Nov 14 '22 09:11

Peter de Rivaz