mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
add human readable reason
This commit is contained in:
parent
9144a05886
commit
fb78e1574b
1 changed files with 7 additions and 2 deletions
|
|
@ -29,8 +29,11 @@ import java.util.*;
|
|||
*/
|
||||
public class UnassignedJobReasonTracker implements JobUnassignedListener {
|
||||
|
||||
private final static String NO_REASON = "cannot determine a particular reason";
|
||||
|
||||
public static String getMostLikelyFailedConstraintName(Frequency failedConstraintNamesFrequency) {
|
||||
if (failedConstraintNamesFrequency == null) return "no reason found";
|
||||
if (failedConstraintNamesFrequency == null || failedConstraintNamesFrequency.getUniqueCount() == 0)
|
||||
return NO_REASON;
|
||||
Iterator<Map.Entry<Comparable<?>, Long>> entryIterator = failedConstraintNamesFrequency.entrySetIterator();
|
||||
long maxCount = 0;
|
||||
String mostLikely = null;
|
||||
|
|
@ -54,6 +57,7 @@ public class UnassignedJobReasonTracker implements JobUnassignedListener {
|
|||
Set<String> failedConstraintNamesToBeIgnored = new HashSet<>();
|
||||
|
||||
public UnassignedJobReasonTracker() {
|
||||
codesToHumanReadableReason.put(-1, NO_REASON);
|
||||
codesToHumanReadableReason.put(1, "cannot serve required skill");
|
||||
codesToHumanReadableReason.put(2, "cannot be visited within time window");
|
||||
codesToHumanReadableReason.put(3, "does not fit into any vehicle due to capacity");
|
||||
|
|
@ -165,8 +169,9 @@ public class UnassignedJobReasonTracker implements JobUnassignedListener {
|
|||
* @return
|
||||
*/
|
||||
public String getMostLikelyReason(String jobId) {
|
||||
if (!this.failedConstraintNamesFrequencyMapping.containsKey(jobId)) return "no reason found";
|
||||
if (!this.failedConstraintNamesFrequencyMapping.containsKey(jobId)) return codesToHumanReadableReason.get(-1);
|
||||
Frequency reasons = this.failedConstraintNamesFrequencyMapping.get(jobId);
|
||||
|
||||
String mostLikelyReason = getMostLikelyFailedConstraintName(reasons);
|
||||
int code = toCode(mostLikelyReason);
|
||||
if (code == -1) return mostLikelyReason;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue