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

updated job indexing: lower indices for unplanned jobs, higher for jobs in initial routes

This commit is contained in:
Michal Maciejewski 2017-11-14 11:10:48 +01:00
parent 0ea1a87dfe
commit 36d0b644a0
No known key found for this signature in database
GPG key ID: 015947E60A2AD77B

View file

@ -116,8 +116,6 @@ public class VehicleRoutingProblem {
};
private int jobIndexCounter = 1;
private int vehicleIndexCounter = 1;
private int activityIndexCounter = 1;
@ -132,10 +130,6 @@ public class VehicleRoutingProblem {
private final DefaultTourActivityFactory serviceActivityFactory = new DefaultTourActivityFactory();
private void incJobIndexCounter() {
jobIndexCounter++;
}
private void incActivityIndexCounter() {
activityIndexCounter++;
}
@ -235,8 +229,6 @@ public class VehicleRoutingProblem {
throw new IllegalArgumentException("vehicle routing problem already contains a service or shipment with id " + job.getId() + ". make sure you use unique ids for all services and shipments");
if (!(job instanceof Service || job instanceof Shipment))
throw new IllegalArgumentException("job must be either a service or a shipment");
job.setIndex(jobIndexCounter);
incJobIndexCounter();
tentativeJobs.put(job.getId(), job);
addLocationToTentativeLocations(job);
return this;
@ -441,6 +433,15 @@ public class VehicleRoutingProblem {
addJobToFinalJobMapAndCreateActivities(job);
}
}
int jobIndexCounter = 1;
for (Job job : jobs.values()) {
((AbstractJob)job).setIndex(jobIndexCounter++);
}
for (String jobId : jobsInInitialRoutes) {
((AbstractJob)tentativeJobs.get(jobId)).setIndex(jobIndexCounter++);
}
boolean hasBreaks = addBreaksToActivityMap();
if (hasBreaks && fleetSize.equals(FleetSize.INFINITE))
throw new UnsupportedOperationException("breaks are not yet supported when dealing with infinite fleet. either set it to finite or omit breaks.");