Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Result is inappropriate #6

Open
lugingf opened this issue Feb 3, 2021 · 3 comments
Open

Result is inappropriate #6

lugingf opened this issue Feb 3, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@lugingf
Copy link

lugingf commented Feb 3, 2021

fmt.Println("1:", hungarian.SolveMin([][]float64{
	{3.16, 0, 0, 0, 0},
	{2.58, 0, 0, 0, 0},
	{2.35, 0, 0, 0, 0},
	{1.76, 0, 0, 0, 0},
	{70.9, 0, 0, 0, 0},
}))

First try:
map[0:map[1:0] 1:map[2:0] 2:map[3:0] 3:map[0:1.76] 4:map[4:0]]
Another try:
map[0:map[3:0] 1:map[2:0] 2:map[4:0] 3:map[1:0] 4:map[0:70.9]]

I believe it should be the same map[0:1.76] at least in every run. But currently if I run algo with zeros in whole column it give me diff sum result

@arthurkushman
Copy link
Owner

arthurkushman commented Feb 3, 2021

Hi @lugingf, yes, it definitely gives diff results right now, but it works pretty well for standard cases (though volatile).
Actually I have no time at this moment, probably this bug is related to the recursive call, where if the same value found it has been replaced by extra traverse:

b.checkAndReplace()

@arthurkushman arthurkushman added the bug Something isn't working label Feb 3, 2021
@carsonfeng
Copy link

Hello arthurkushman, is this bug fixed?

@carsonfeng
Copy link

carsonfeng commented Aug 28, 2024

fmt.Println("1:", hungarian.SolveMin([][]float64{
	{3.16, 0, 0, 0, 0},
	{2.58, 0, 0, 0, 0},
	{2.35, 0, 0, 0, 0},
	{1.76, 0, 0, 0, 0},
	{70.9, 0, 0, 0, 0},
}))

First try: map[0:map[1:0] 1:map[2:0] 2:map[3:0] 3:map[0:1.76] 4:map[4:0]] Another try: map[0:map[3:0] 1:map[2:0] 2:map[4:0] 3:map[1:0] 4:map[0:70.9]]

I believe it should be the same map[0:1.76] at least in every run. But currently if I run algo with zeros in whole column it give me diff sum result

After analysis, I found that the instability occurred because the key order was not guaranteed during the map iteration process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants