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

remove empty routes after insertion (#67)

* remove empty routes after insertion

* fixes
This commit is contained in:
kandelirina 2018-10-25 10:55:27 +03:00 committed by GitHub
parent ee73118f20
commit 800112b3d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View file

@ -52,13 +52,10 @@ public class RuinAndRecreateModule implements SearchStrategyModule {
Set<Job> ruinedJobSet = new HashSet<>();
ruinedJobSet.addAll(ruinedJobs);
ruinedJobSet.addAll(vrpSolution.getUnassignedJobs());
removeEmptyRoutes(vrpSolution.getRoutes());
Collection<Job> unassignedJobs = insertion.insertJobs(vrpSolution.getRoutes(), ruinedJobSet);
vrpSolution.getUnassignedJobs().clear();
vrpSolution.getUnassignedJobs().addAll(getUnassignedJobs(vrpSolution, unassignedJobs));
removeEmptyRoutes(vrpSolution.getRoutes());
return vrpSolution;
}

View file

@ -68,14 +68,17 @@ public class RandomInsertion extends AbstractInsertionStrategy {
double bestInsertionCost = Double.MAX_VALUE;
boolean inserted = false;
for (VehicleRoute vehicleRoute : routes) {
InsertionData iData = bestInsertionCostCalculator.getInsertionData(vehicleRoute, unassignedJob, NO_NEW_VEHICLE_YET, NO_NEW_DEPARTURE_TIME_YET, NO_NEW_DRIVER_YET, bestInsertionCost);
InsertionData iData;
final boolean isNewRoute = vehicleRoute.equals(newRoute);
if (isNewRoute)
iData = bestInsertionCostCalculator.getInsertionData(vehicleRoute, unassignedJob, NO_NEW_VEHICLE_YET, NO_NEW_DEPARTURE_TIME_YET, NO_NEW_DRIVER_YET, bestInsertionCost);
else iData = bestInsertionCostCalculator.getInsertionData(vehicleRoute, unassignedJob, vehicleRoute.getVehicle(), vehicleRoute.getDepartureTime(), vehicleRoute.getDriver(), bestInsertionCost);
if (iData instanceof InsertionData.NoInsertionFound) {
empty.getFailedConstraintNames().addAll(iData.getFailedConstraintNames());
continue;
}
inserted = true;
final boolean isNewRoute = vehicleRoute.getActivities().size() == 0;
if (isNewRoute) {
updateNewRouteInsertionData(iData);
vehicleRoutes.add(vehicleRoute);