![](/img/trans.png)
[英]How to use the hungarian algorithm when there are more workers than jobs and how to link the copies of jobs back to the original?
[英]How to solve the assignment problem with the hungarian algorithm when there is more than one optimum solution
我正在嘗試用 Java 實現匈牙利算法。 我能夠為具有單一最佳解決方案的 maticies 解決它。 但是,當有多個最佳解決方案時,我不知道如何解決它(從編程上講)。
以示例矩陣為例。
3 1 1 4
4 2 2 5
5 3 4 8
4 2 5 9
在執行行和列縮減之后。 矩陣看起來像。
0 0 0 0
0 0 0 0
0 0 1 2
0 0 3 4
現在顯然有多種解決方案,例如
0 0 0 0*
0 0 0* 0
0 0* 1 2
0* 0 3 4
和
0 0 0* 0
0 0 0 0*
0* 0 1 2
0 0* 3 4
如何編寫一種至少找到這些解決方案之一的方法? 任意分配初始 0 通常會迫使您進入死胡同。 例如,如果分配了位置 0,0 處的 0,則會發生以下情況。
0* 0- 0- 0-
0- 0- 0* 0-
0- 0* 1- 2-
0- 0- 3- 4-
那么我如何智能地選擇最佳解決方案位置?
如果遇到“死胡同”,則需要尋找增廣路徑,就像未加權的最大匹配算法一樣。 參見例如這些講義。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.