Failure test case
apremalal opened this issue · comments
arr := [][]float64{
{1, 2, 3, 100, 11},
{4, 5, 6, 10, 20},
{7, 8, 9, 0, 44},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
}
Answer solveMaX outputs a wrong result
Correct one should be
0:100, 1:6, 2:44,3:0,4:0
Hi, thank u for this issue, I'll try to solve this when there will be more time.
By debugging the output of solveMax it should be clear where the error. Suppose this is because of similarity of results ex.: 0, 0 etc, but it is just a presumption.
See u soon )
UPD:
It is working well though, what I've got from output in this test with data you trying to put in input is:
map[0:map[3:100] 1:map[4:20] 2:map[4:44] 3:map[1:0] 4:map[0:0 2:0]]
The bug is also prominent in case where we expecting only 1 value per key, but got 1+k.
It seems like removeExtra
fixes the "extra element" bug, will issue patch
@arthurkushman thanks for quickly attending to the issue.
Correct answer should be.
map[0:map[3:100] 1:map[2:6] 2:map[4:44] 3:map[1:0] 4:map[2:0]]
It is in master, resulting:
=== RUN TestSolveMax
map[0:map[3:100] 1:map[4:20] 2:map[4:44] 3:map[1:0] 4:map[2:0]]
which is inappropriate because of the same result in 1 and 2 keys.
I'll back to this problem later.
Fixed the main issue in solveMax func algo with conflicting/collisions keys, though it is not always gives the same result - it definitely solves the problem in ML kinda way (when it finds collisions - shift to another with nearest possible maximum value)
map[0:map[3:100] 1:map[4:20] 2:map[0:7] 3:map[1:0] 4:map[2:0]]
map[0:map[3:100] 1:map[4:20] 2:map[2:9] 3:map[0:0] 4:map[1:0]]
map[0:map[3:100] 1:map[0:4] 2:map[4:44] 3:map[2:0] 4:map[1:0]]
Patch: https://github.com/arthurkushman/go-hungarian/releases/tag/0.1.2
PS Yet, I understand that this is not exactly what u would like to get as a result, but for now it solves (not in perfect way) the problem excluding errors and doubling.