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:
parent
0ea1a87dfe
commit
36d0b644a0
1 changed files with 9 additions and 8 deletions
|
|
@ -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.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue