diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/VehicleRoutingAlgorithm.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/VehicleRoutingAlgorithm.java index f0c7a383..d8a66285 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/VehicleRoutingAlgorithm.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/VehicleRoutingAlgorithm.java @@ -115,7 +115,7 @@ public class VehicleRoutingAlgorithm { super(); this.problem = problem; this.searchStrategyManager = searchStrategyManager; - initialSolutions = new ArrayList(); + initialSolutions = new ArrayList<>(); objectiveFunction = null; } @@ -131,7 +131,7 @@ public class VehicleRoutingAlgorithm { super(); this.problem = problem; this.searchStrategyManager = searchStrategyManager; - initialSolutions = new ArrayList(); + initialSolutions = new ArrayList<>(); this.objectiveFunction = objectiveFunction; } @@ -153,7 +153,7 @@ public class VehicleRoutingAlgorithm { //this method may lead to errors if tour activities in the solution are different to the ones in the VRP //(including differences in indexing) private void verifyAndAdaptSolution(VehicleRoutingProblemSolution solution) { - Set jobsNotInSolution = new HashSet(problem.getJobs().values()); + Set jobsNotInSolution = new HashSet<>(problem.getJobs().values()); jobsNotInSolution.removeAll(solution.getUnassignedJobs()); for (VehicleRoute route : solution.getRoutes()) { jobsNotInSolution.removeAll(route.getTourActivities().getJobs()); @@ -225,7 +225,7 @@ public class VehicleRoutingAlgorithm { double now = System.currentTimeMillis(); int noIterationsThisAlgoIsRunning = maxIterations; counter.reset(); - Collection solutions = new ArrayList(initialSolutions); + Collection solutions = new ArrayList<>(initialSolutions); algorithmStarts(problem, solutions); bestEver = Solutions.bestOf(solutions); if (logger.isTraceEnabled()) { diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/box/Jsprit.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/box/Jsprit.java index 5aeb4224..9fefc151 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/box/Jsprit.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/box/Jsprit.java @@ -353,11 +353,11 @@ public class Jsprit { } - private StateManager stateManager = null; + private StateManager stateManager; - private ConstraintManager constraintManager = null; + private ConstraintManager constraintManager; - private ExecutorService es = null; + private ExecutorService es; private Integer noThreads; @@ -365,7 +365,7 @@ public class Jsprit { private boolean addCoreConstraints; - private SolutionCostCalculator objectiveFunction = null; + private SolutionCostCalculator objectiveFunction; private Properties properties; @@ -612,13 +612,10 @@ public class Jsprit { if (properties.containsKey(Parameter.THRESHOLD_INI_ABS.toString())) { schrimpfAcceptance.setInitialThreshold(Double.valueOf(properties.getProperty(Parameter.THRESHOLD_INI_ABS.toString()))); } else { - schrimpfThreshold = new IterationStartsListener() { - @Override - public void informIterationStarts(int i, VehicleRoutingProblem problem, Collection solutions) { - if (i == 1) { - double initialThreshold = Solutions.bestOf(solutions).getCost() * toDouble(getProperty(Parameter.THRESHOLD_INI.toString())); - schrimpfAcceptance.setInitialThreshold(initialThreshold); - } + schrimpfThreshold = (i, problem, solutions) -> { + if (i == 1) { + double initialThreshold = Solutions.bestOf(solutions).getCost() * toDouble(getProperty(Parameter.THRESHOLD_INI.toString())); + schrimpfAcceptance.setInitialThreshold(initialThreshold); } }; }