mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
make reason tracker more robust
This commit is contained in:
parent
1f4f9a0e58
commit
b9da9b9a06
1 changed files with 3 additions and 0 deletions
|
|
@ -114,6 +114,7 @@ public class UnassignedJobReasonTracker implements JobUnassignedListener {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getMostLikelyReasonCode(String jobId) {
|
public int getMostLikelyReasonCode(String jobId) {
|
||||||
|
if (!this.reasons.containsKey(jobId)) return -1;
|
||||||
Frequency reasons = this.reasons.get(jobId);
|
Frequency reasons = this.reasons.get(jobId);
|
||||||
String mostLikelyReason = getMostLikely(reasons);
|
String mostLikelyReason = getMostLikely(reasons);
|
||||||
return toCode(mostLikelyReason);
|
return toCode(mostLikelyReason);
|
||||||
|
|
@ -126,6 +127,7 @@ public class UnassignedJobReasonTracker implements JobUnassignedListener {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getMostLikelyReason(String jobId) {
|
public String getMostLikelyReason(String jobId) {
|
||||||
|
if (!this.reasons.containsKey(jobId)) return "no reason found";
|
||||||
Frequency reasons = this.reasons.get(jobId);
|
Frequency reasons = this.reasons.get(jobId);
|
||||||
String mostLikelyReason = getMostLikely(reasons);
|
String mostLikelyReason = getMostLikely(reasons);
|
||||||
int code = toCode(mostLikelyReason);
|
int code = toCode(mostLikelyReason);
|
||||||
|
|
@ -140,6 +142,7 @@ public class UnassignedJobReasonTracker implements JobUnassignedListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMostLikely(Frequency reasons) {
|
private String getMostLikely(Frequency reasons) {
|
||||||
|
if (reasons == null) return "no reason found";
|
||||||
Iterator<Map.Entry<Comparable<?>, Long>> entryIterator = reasons.entrySetIterator();
|
Iterator<Map.Entry<Comparable<?>, Long>> entryIterator = reasons.entrySetIterator();
|
||||||
int maxCount = 0;
|
int maxCount = 0;
|
||||||
String mostLikely = null;
|
String mostLikely = null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue