Suppose I have 4 agents and 8 tasks and I would like to assign each agent 2 tasks each. Is there a way to use the Hungarian Algorithm to solve this problem?

I worked it out with 2 agents and 4 tasks by hand by creating 2 additional dummy rows. I think I arrived at an optimal solution but I'm not entirely sure. Is it simply as easy as just adding dummy rows and then running the algorithm normally?

If the Hungarian Algorithm does not work, what's another algorithm that can guarantee me an optimal solution where there are n agents and k*n tasks and each agent gets assigned k tasks?


You can duplicate the agents (split each agent into two). Of course another approach would be to use an LP (Linear Programming) solver. Then you could write more directly:

$$\begin{align} \min & \sum_{i,j} c_{i,j} x_{i,j}\\ & \sum_j x_{i,j} = 2 \> \> \forall i \\ & \sum_i x_{i,j} = 1 \> \> \forall j \\ & 0 \le x_{i,j} \le 1 \end{align} $$

I once did an (unfair) comparison between a simple Hungarian Algorithm and an advanced LP solver.

  • $\begingroup$ Is there a way to deal with time conflicts using on the hungarian algorithm? Like suppose I have 8 tasks and 4 agents so each get assigned two tasks. However, some tasks occur at the same time. If I end up with a solution where an agent has two tasks that cannot be completed at the same time how could I alleviate this? Would I have to turn to linear programming at this point? $\endgroup$ – Jesse Martinez Mar 9 '16 at 22:43
  • $\begingroup$ No overlap constraints make it more like a scheduling model. These typically end up containing binary variables, and thus requiring a MIP (Mixed Integer Programming) solver. $\endgroup$ – Erwin Kalvelagen Mar 9 '16 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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