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

Non-square matrix with infinite costs in lapjv #20

Open
jvlmdr opened this issue Feb 1, 2020 · 0 comments
Open

Non-square matrix with infinite costs in lapjv #20

jvlmdr opened this issue Feb 1, 2020 · 0 comments

Comments

@jvlmdr
Copy link

jvlmdr commented Feb 1, 2020

Hey, thanks for lapjv and lapmod, they are awesome.

I think I found a small bug. Consider the cost matrix

[[inf,  11,   8],
 [  8, inf,   7]]

The minimum cost is 8 + 8 = 16. However, the result I get from lapjv is 18 (test case below).

I guess the problem arises in the extension since inf + 1 => inf.

[[inf,  11,   8, inf, inf],
 [  8, inf,   7, inf, inf],
 [inf, inf, inf,   0,   0],
 [inf, inf, inf,   0,   0],
 [inf, inf, inf,   0,   0]]

The minimum cost of this matrix is inf since we can select at most 1 finite value from each of the first 2 rows, 1 finite value from each of the last 2 columns and then we must select an inf edge to complete the matching. I suppose the problem is that all matchings in the extended problem have the same sum (i.e. inf).

Here is a test case:

def test_lapjv_extension_with_inf():
    cost = np.asarray([[np.inf, 11, 8], [8, np.inf, 7]], dtype=float)
    ret = lapjv(cost, extend_cost=True)
    assert ret[0] == 16.0
    np.testing.assert_equal(ret[1], [2, 0])
    np.testing.assert_equal(ret[2], [1, -1, 0])
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

1 participant