mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
allow constraints to be ignored
This commit is contained in:
parent
f455da3230
commit
185980d8c0
1 changed files with 7 additions and 0 deletions
|
|
@ -35,6 +35,8 @@ public class UnassignedJobReasonTracker implements JobUnassignedListener {
|
|||
|
||||
Map<String, Integer> failedConstraintNamesToCode = new HashMap<>();
|
||||
|
||||
Set<String> constraintsToBeIgnored = new HashSet<>();
|
||||
|
||||
public UnassignedJobReasonTracker() {
|
||||
codesToReason.put(1, "cannot serve required skill");
|
||||
codesToReason.put(2, "cannot be visited within time window");
|
||||
|
|
@ -49,12 +51,17 @@ public class UnassignedJobReasonTracker implements JobUnassignedListener {
|
|||
failedConstraintNamesToCode.put("MaxDistanceConstraint", 4);
|
||||
}
|
||||
|
||||
public void ignore(String simpleNameOfConstraint) {
|
||||
constraintsToBeIgnored.add(simpleNameOfConstraint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void informJobUnassigned(Job unassigned, Collection<String> failedConstraintNames) {
|
||||
if (!this.reasons.containsKey(unassigned.getId())) {
|
||||
this.reasons.put(unassigned.getId(), new Frequency());
|
||||
}
|
||||
for (String r : failedConstraintNames) {
|
||||
if (constraintsToBeIgnored.contains(r)) continue;
|
||||
this.reasons.get(unassigned.getId()).addValue(r);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue