From d2327fa968cc18214163617eec86bded16951cdf Mon Sep 17 00:00:00 2001 From: oblonski Date: Tue, 6 Jan 2015 19:33:43 +0100 Subject: [PATCH] add SearchStrategyManager to params of StrategySelectedListener --- .../algorithm/VehicleRoutingAlgorithm.java | 6 +- .../listener/StrategySelectedListener.java | 3 +- .../VehicleRoutingAlgorithmListeners.java | 5 +- .../test/resources/infiniteWriterV2Test.xml | 81 +++++++------------ 4 files changed, 35 insertions(+), 60 deletions(-) diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/VehicleRoutingAlgorithm.java b/jsprit-core/src/main/java/jsprit/core/algorithm/VehicleRoutingAlgorithm.java index a2c83f89..0b353507 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/VehicleRoutingAlgorithm.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/VehicleRoutingAlgorithm.java @@ -205,7 +205,7 @@ public class VehicleRoutingAlgorithm { SearchStrategy strategy = searchStrategyManager.getRandomStrategy(); DiscoveredSolution discoveredSolution = strategy.run(problem, solutions); memorizeIfBestEver(discoveredSolution); - selectedStrategy(strategy.getId(),problem, solutions); + selectedStrategy(strategy.getId(),searchStrategyManager,problem, solutions); if(terminationManager.isPrematureBreak(discoveredSolution)){ logger.info("premature algorithm termination at iteration "+ (i+1)); noIterationsThisAlgoIsRunning = (i+1); @@ -233,8 +233,8 @@ public class VehicleRoutingAlgorithm { } - private void selectedStrategy(String name, VehicleRoutingProblem problem, Collection solutions) { - algoListeners.selectedStrategy(name,problem, solutions); + private void selectedStrategy(String name, SearchStrategyManager searchStrategyManager, VehicleRoutingProblem problem, Collection solutions) { + algoListeners.selectedStrategy(name, searchStrategyManager, problem, solutions); } /** diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/listener/StrategySelectedListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/StrategySelectedListener.java index 47015856..1f0dc127 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/listener/StrategySelectedListener.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/StrategySelectedListener.java @@ -18,6 +18,7 @@ package jsprit.core.algorithm.listener; import java.util.Collection; +import jsprit.core.algorithm.SearchStrategyManager; import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.solution.VehicleRoutingProblemSolution; @@ -26,6 +27,6 @@ import jsprit.core.problem.solution.VehicleRoutingProblemSolution; public interface StrategySelectedListener extends VehicleRoutingAlgorithmListener{ - void informSelectedStrategy(String strategyId, VehicleRoutingProblem problem, Collection solutions); + void informSelectedStrategy(String strategyId, SearchStrategyManager searchStrategyManager, VehicleRoutingProblem problem, Collection solutions); } diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/listener/VehicleRoutingAlgorithmListeners.java b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/VehicleRoutingAlgorithmListeners.java index 9301c847..7a964a93 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/listener/VehicleRoutingAlgorithmListeners.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/VehicleRoutingAlgorithmListeners.java @@ -23,6 +23,7 @@ import java.util.Comparator; import java.util.List; import java.util.TreeSet; +import jsprit.core.algorithm.SearchStrategyManager; import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.solution.VehicleRoutingProblemSolution; @@ -176,10 +177,10 @@ public class VehicleRoutingAlgorithmListeners { } } - public void selectedStrategy(String name, VehicleRoutingProblem problem, Collection solutions) { + public void selectedStrategy(String name, SearchStrategyManager searchStrategyManager, VehicleRoutingProblem problem, Collection solutions) { for(PrioritizedVRAListener l : algorithmListeners){ if(l.getListener() instanceof StrategySelectedListener){ - ((StrategySelectedListener)l.getListener()).informSelectedStrategy(name, problem, solutions); + ((StrategySelectedListener)l.getListener()).informSelectedStrategy(name, searchStrategyManager, problem, solutions); } } } diff --git a/jsprit-core/src/test/resources/infiniteWriterV2Test.xml b/jsprit-core/src/test/resources/infiniteWriterV2Test.xml index 2d9058ab..07c5406a 100644 --- a/jsprit-core/src/test/resources/infiniteWriterV2Test.xml +++ b/jsprit-core/src/test/resources/infiniteWriterV2Test.xml @@ -2,9 +2,24 @@ - INFINITE + FINITE + + v2 + vehType2 + + loc + + + loc + + + 0.0 + 1.7976931348623157E308 + + true + v1 vehType @@ -33,58 +48,16 @@ + + vehType2 + + 200 + + + 0.0 + 1.0 + + + - - - - loc - - - 1 - - 2.0 - - - 0.0 - 1.7976931348623157E308 - - - - - - loc2 - - - 1 - - 4.0 - - - 0.0 - 1.7976931348623157E308 - - - - - - - 10.0 - - - noDriver - v1 - 0.0 - - 1 - 0.0 - 0.0 - - 0.0 - - - - - - -