1

I'm trying to re-write a python algorithm to Java for some needs.

In python algorithm I have the following code :

row_ind, col_ind = linear_sum_assignment(cost)

linear_sum_assignment is a scipy function

Do you guys know an equivalent of that function in java ? I found this one but I didn't get the row indice and column indice in this one.

4

2 回答 2

1

我终于设法用这个HungarianAlgorithms和以下代码做到了:

// Using Hungarian Algorithm assign the correct detected measurements
// to predicted tracks
int[] assigmentL = new HungarianAlgorithm(cost).execute();
List<Integer> assigment = Lists.newArrayList(Ints.asList(assigmentL));
于 2018-04-26T09:27:58.860 回答
1

如果有人感兴趣,我会根据相同的匈牙利算法在 kotlin 中分享一个答案:

val costMat = arrayOf(
    doubleArrayOf(0.5, 0.8, 0.6),
    doubleArrayOf(0.3, 0.2, 0.5),
    doubleArrayOf(0.1, 0.3, 0.7)
)
val assignmentL = HungarianAlgorithm(costMat).execute()
val assignment = listOf(costMat.indices.toList(), assignmentL.toList())
于 2021-04-16T09:28:53.000 回答