-
Notifications
You must be signed in to change notification settings - Fork 78
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-optimal results for test case with DBL_MAX in diagonal #20
Comments
RAND_MAX = 2147483647 = 2^31 for this example. |
Your comment seems reasonable, thank you for catching this! I can reproduce the same result with your input data.
I don't have the answer why this happened, but it looks like this is consequences of internal matrix resize which performed to convert non-square matrices to square (because algorithm works only for square matrices). |
I have tried this with several non-square matrix sizes. As I understand it, the smaller dimension is mapped to "agents" and the other dimension is mapped to "jobs". The algorithm stops when each agent is mapped to a job, thus, there will be unassigned jobs. I initially thought that the program was unable to handle double, so I changed the diagonal entry to FLT_MAX. That didn't pass either. It seems to work when the diagonals are less than 3.0e24. |
It looks like I have some progress. If we add test for transposed matrix:
And run both tests Also if we swap two lines in
broken test also will be changed! |
The code handles doubles well.
I think this is because other items are about Xe08. |
I've push changes which cover your input data. But I've found out other data sets for non-square matrices which performs with non-optimal result. |
After careful analysis of the issue, I'm pretty sure that the real problem is connected with non-square matrices but not with DBL_MAX. It would be logical to rename the issue, but since such issue already exists, I've decided close this issue and reopen the earlier. P.S. Many thanks to @louiev for notice about the problem. As I can see he has joined to the GitHub specially to report the problem! |
The current implementation tries to help users to implement the required API. A stub of the `resize` member function allows skipping of overriding when it is not necessary. But at the same time, this stub implementation adds dependencies from exceptions that may be inappropriate in some cases (embedded systems, etc). It is proposed to remove the exception from the base class and if a stub implementation is required a user will have to implement it. Test: build Issue: saebyn#20 Signed-off-by: Gluttton <[email protected]>
The current implementation tries to help users to implement the required API. A stub of the `resize` member function allows skipping of overriding when it is not necessary. But at the same time, this stub implementation adds dependencies from exceptions that may be inappropriate in some cases (embedded systems, etc). It is proposed to remove the exception from the base class and if a stub implementation is required a user will have to implement it. Test: build Issue: saebyn#20 Signed-off-by: Gluttton <[email protected]>
The program generates the following results for the example matrix below:
Input cost matrix =
1.79769e+308 7.33184e+08 9.41561e+08 2.79247e+08
3.06449e+08 1.79769e+308 3.3464e+08 7.06878e+08
9.93296e+08 1.9414e+08 1.79769e+308 1.14174e+08
3.51623e+08 2.48635e+08 7.81242e+08 1.79769e+308
7.02639e+08 8.51663e+08 9.37382e+08 4.96945e+07
7.58851e+08 8.58445e+08 8.7235e+07 5.47076e+08
Munkres assignment =
-1 -1 -1 0
0 -1 -1 -1
-1 -1 -1 -1
-1 0 -1 -1
-1 -1 -1 -1
-1 -1 0 -1
Munkres cost = 9.21566e+08
= 3.06449e8 + 2.48635e8 + 8.7235e7 + 2.79247e8
Alternate assignment =
0 0 0 0
1 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
0 0 1 0
Alternate cost = 6.37518e+08
= 3.06449e8 + 1.9414e8 + 8.7235e7 + 4.96945e7
Munkres cost = 9.21566e+08
Alternate cost = 6.37518e+08
The input values were generated using
(rand() % 10^9) + 1.0
with DBL_MAX forcibly inserted into the diagonal.
The alternate and Munkres results match when the diagonal values are less than 3.0e24.
The text was updated successfully, but these errors were encountered: