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:
parent
ee73118f20
commit
800112b3d6
2 changed files with 6 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue