From 787a6835fac4ebfb60ac227d9c7cb6d16bf9ed3b Mon Sep 17 00:00:00 2001 From: oblonski Date: Wed, 19 Jun 2019 10:04:14 +0200 Subject: [PATCH] clean up --- .../RegretInsertionConcurrentFast.java | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/RegretInsertionConcurrentFast.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/RegretInsertionConcurrentFast.java index be4f5d11..6dbfd14f 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/RegretInsertionConcurrentFast.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/RegretInsertionConcurrentFast.java @@ -93,7 +93,7 @@ public class RegretInsertionConcurrentFast extends AbstractInsertionStrategy { } private Set getInitialVehicleIds(VehicleRoutingProblem vehicleRoutingProblem) { - Set ids = new HashSet(); + Set ids = new HashSet<>(); for(VehicleRoute r : vehicleRoutingProblem.getInitialVehicleRoutes()){ ids.add(r.getVehicle().getId()); } @@ -114,7 +114,7 @@ public class RegretInsertionConcurrentFast extends AbstractInsertionStrategy { */ @Override public Collection insertUnassignedJobs(Collection routes, Collection unassignedJobs) { - List badJobs = new ArrayList(unassignedJobs.size()); + List badJobs = new ArrayList<>(unassignedJobs.size()); Iterator jobIterator = unassignedJobs.iterator(); while (jobIterator.hasNext()){ @@ -136,12 +136,12 @@ public class RegretInsertionConcurrentFast extends AbstractInsertionStrategy { } } - List jobs = new ArrayList(unassignedJobs); + List jobs = new ArrayList<>(unassignedJobs); TreeSet[] priorityQueues = new TreeSet[vrp.getJobs().values().size() + 2]; VehicleRoute lastModified = null; boolean firstRun = true; int updateRound = 0; - Map updates = new HashMap(); + Map updates = new HashMap<>(); while (!jobs.isEmpty()) { List unassignedJobList = new ArrayList<>(jobs); List badJobList = new ArrayList<>(); @@ -170,7 +170,7 @@ public class RegretInsertionConcurrentFast extends AbstractInsertionStrategy { } private void updateInsertionData(final TreeSet[] priorityQueues, final Collection routes, List unassignedJobList, final int updateRound, final boolean firstRun, final VehicleRoute lastModified, Map updates) { - List> tasks = new ArrayList>(); + List> tasks = new ArrayList<>(); boolean updatedAllRoutes = false; for (final Job unassignedJob : unassignedJobList) { if(priorityQueues[unassignedJob.getIndex()] == null){ @@ -178,7 +178,7 @@ public class RegretInsertionConcurrentFast extends AbstractInsertionStrategy { } if(firstRun) { updatedAllRoutes = true; - makeCallables(tasks, updatedAllRoutes, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes, lastModified); + makeCallables(tasks, true, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes, lastModified); } else{ if(dependencyTypes == null || dependencyTypes[unassignedJob.getIndex()] == null){ @@ -188,7 +188,7 @@ public class RegretInsertionConcurrentFast extends AbstractInsertionStrategy { DependencyType dependencyType = dependencyTypes[unassignedJob.getIndex()]; if (dependencyType.equals(DependencyType.INTER_ROUTE) || dependencyType.equals(DependencyType.INTRA_ROUTE)) { updatedAllRoutes = true; - makeCallables(tasks, updatedAllRoutes, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes, lastModified); + makeCallables(tasks, true, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes, lastModified); } else { makeCallables(tasks, updatedAllRoutes, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes, lastModified); } @@ -211,20 +211,10 @@ public class RegretInsertionConcurrentFast extends AbstractInsertionStrategy { private void makeCallables(List> tasks, boolean updateAll, final TreeSet priorityQueue, final int updateRound, final Job unassignedJob, final Collection routes, final VehicleRoute lastModified) { if(updateAll) { - tasks.add(new Callable() { - @Override - public Boolean call() throws Exception { - return InsertionDataUpdater.update(switchAllowed, initialVehicleIds, fleetManager, insertionCostsCalculator, priorityQueue, updateRound, unassignedJob, routes); - } - }); + tasks.add(() -> InsertionDataUpdater.update(switchAllowed, initialVehicleIds, fleetManager, insertionCostsCalculator, priorityQueue, updateRound, unassignedJob, routes)); } else { - tasks.add(new Callable() { - @Override - public Boolean call() throws Exception { - return InsertionDataUpdater.update(switchAllowed, initialVehicleIds, fleetManager, insertionCostsCalculator, priorityQueue, updateRound, unassignedJob, Arrays.asList(lastModified)); - } - }); + tasks.add(() -> InsertionDataUpdater.update(switchAllowed, initialVehicleIds, fleetManager, insertionCostsCalculator, priorityQueue, updateRound, unassignedJob, Arrays.asList(lastModified))); } }