mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
add SearchStrategyManager to params of StrategySelectedListener
This commit is contained in:
parent
8d20fe12aa
commit
d2327fa968
4 changed files with 35 additions and 60 deletions
|
|
@ -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<VehicleRoutingProblemSolution> solutions) {
|
||||
algoListeners.selectedStrategy(name,problem, solutions);
|
||||
private void selectedStrategy(String name, SearchStrategyManager searchStrategyManager, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) {
|
||||
algoListeners.selectedStrategy(name, searchStrategyManager, problem, solutions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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<VehicleRoutingProblemSolution> solutions);
|
||||
void informSelectedStrategy(String strategyId, SearchStrategyManager searchStrategyManager, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<VehicleRoutingProblemSolution> solutions) {
|
||||
public void selectedStrategy(String name, SearchStrategyManager searchStrategyManager, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue