1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

Unassigned job reason tracker returns the last failed constraint instead of the most likely

This commit is contained in:
Iuliia Loikova 2017-11-09 23:31:30 +01:00
parent a714312685
commit 288f6023a3

View file

@ -32,12 +32,13 @@ public class UnassignedJobReasonTracker implements JobUnassignedListener {
public static String getMostLikelyFailedConstraintName(Frequency failedConstraintNamesFrequency) { public static String getMostLikelyFailedConstraintName(Frequency failedConstraintNamesFrequency) {
if (failedConstraintNamesFrequency == null) return "no reason found"; if (failedConstraintNamesFrequency == null) return "no reason found";
Iterator<Map.Entry<Comparable<?>, Long>> entryIterator = failedConstraintNamesFrequency.entrySetIterator(); Iterator<Map.Entry<Comparable<?>, Long>> entryIterator = failedConstraintNamesFrequency.entrySetIterator();
int maxCount = 0; long maxCount = 0;
String mostLikely = null; String mostLikely = null;
while (entryIterator.hasNext()) { while (entryIterator.hasNext()) {
Map.Entry<Comparable<?>, Long> entry = entryIterator.next(); Map.Entry<Comparable<?>, Long> entry = entryIterator.next();
if (entry.getValue() > maxCount) { if (entry.getValue() > maxCount) {
Comparable<?> key = entry.getKey(); Comparable<?> key = entry.getKey();
maxCount = entry.getValue();
mostLikely = key.toString(); mostLikely = key.toString();
} }
} }