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

Cost Problem #19

Open
xcTorres opened this issue Jan 10, 2020 · 4 comments
Open

Cost Problem #19

xcTorres opened this issue Jan 10, 2020 · 4 comments

Comments

@xcTorres
Copy link

Thank you for your library, it is very fast. But when I calculate this matrix the result seems like not true.
-625.000 2187.500 -156.25 1000000
-2500.000 1000000 -2500.00 -2500.0
-1015.625 - 1015.625 1000000 1000000
1000000 1000000 1000000 1000000
the answer is x = [2, 3, 1, 0] , y = [3, 2, 0, 1],
But the true result should be x = [0, 2, 1, 3].
The method I used is lapjv(extend_cost=False)

@emanuele
Copy link

emanuele commented Jan 10, 2020 via email

@xcTorres
Copy link
Author

xcTorres commented Jan 10, 2020

maybe it is not the reason. Actually 1000000 is a large num used to fill np.inf in my case.
For this matrix in which there is no negatives, but the assign result is also not correct.

[ 0.4 1.0 0.5 1000000
0.0 1000000 0.0 0.0
0.3166 0.3166 1000000 1000000
1000000 1000000 1000000 1000000 ]

By the way, if I use np.inf directly, the result is also wrong. But if using 100,000 to fill np.inf, the result is true.

@jvlmdr
Copy link

jvlmdr commented Feb 1, 2020

It seems to be due to the constant LARGE = 1000000 defined here:

#define LARGE 1000000

I was able to make the test pass with this change:
master...jvlmdr:issue19

However, I didn't remove LARGE completely because I didn't take the time to understand how it is employed in lapmod. It seems to be exported to python.

@gatagat
Copy link
Owner

gatagat commented Feb 13, 2020

The issue here is that for the extension to a square matrix to work, costs are expected to be less than the constant LARGE.

You can preprocess the input cost as follows:

from lap import LARGE
cost[np.inf(cost)] = LARGE-1

Ideally lapjv/lapmod should take an optional check_bounds argument that would check the input cost and raise a verbose exception if there are any values greater or equal than LARGE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants