1
0
Fork 0
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:
oblonski 2017-03-14 13:09:03 +01:00
parent f455da3230
commit 185980d8c0
No known key found for this signature in database
GPG key ID: 179DE487285680D1

View file

@ -35,6 +35,8 @@ public class UnassignedJobReasonTracker implements JobUnassignedListener {
Map<String, Integer> failedConstraintNamesToCode = new HashMap<>(); Map<String, Integer> failedConstraintNamesToCode = new HashMap<>();
Set<String> constraintsToBeIgnored = new HashSet<>();
public UnassignedJobReasonTracker() { public UnassignedJobReasonTracker() {
codesToReason.put(1, "cannot serve required skill"); codesToReason.put(1, "cannot serve required skill");
codesToReason.put(2, "cannot be visited within time window"); codesToReason.put(2, "cannot be visited within time window");
@ -49,12 +51,17 @@ public class UnassignedJobReasonTracker implements JobUnassignedListener {
failedConstraintNamesToCode.put("MaxDistanceConstraint", 4); failedConstraintNamesToCode.put("MaxDistanceConstraint", 4);
} }
public void ignore(String simpleNameOfConstraint) {
constraintsToBeIgnored.add(simpleNameOfConstraint);
}
@Override @Override
public void informJobUnassigned(Job unassigned, Collection<String> failedConstraintNames) { public void informJobUnassigned(Job unassigned, Collection<String> failedConstraintNames) {
if (!this.reasons.containsKey(unassigned.getId())) { if (!this.reasons.containsKey(unassigned.getId())) {
this.reasons.put(unassigned.getId(), new Frequency()); this.reasons.put(unassigned.getId(), new Frequency());
} }
for (String r : failedConstraintNames) { for (String r : failedConstraintNames) {
if (constraintsToBeIgnored.contains(r)) continue;
this.reasons.get(unassigned.getId()).addValue(r); this.reasons.get(unassigned.getId()).addValue(r);
} }
} }