1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

enable search with different insertion strategies

This commit is contained in:
oblonski 2014-12-10 21:03:30 +01:00
parent 593cd5e841
commit 51c14afd73
5 changed files with 16 additions and 9 deletions

View file

@ -135,10 +135,14 @@ public class PrettyAlgorithmBuilder {
}
private void searchSchrimpfAndRegister(VehicleRoutingAlgorithm vra) {
boolean schrimpfAdded = false;
for(SearchStrategy strategy : vra.getSearchStrategyManager().getStrategies()){
SolutionAcceptor acceptor = strategy.getSolutionAcceptor();
if(acceptor instanceof SchrimpfAcceptance){
vra.addListener((SchrimpfAcceptance)acceptor);
if(!schrimpfAdded) {
vra.addListener((SchrimpfAcceptance) acceptor);
schrimpfAdded = true;
}
}
}
}

View file

@ -70,7 +70,7 @@ public class SearchStrategyManager {
throw new IllegalStateException("strategy is null. make sure adding a valid strategy.");
}
if(id2index.keySet().contains(strategy.getId())){
throw new IllegalStateException("strategyId " + strategy.getId() + " already in use");
throw new IllegalStateException("strategyId " + strategy.getId() + " already in use. replace strateId in your config file or code with a unique strategy id");
}
if(weight < 0.0){
throw new IllegalStateException("weight is lower than zero.");

View file

@ -612,6 +612,9 @@ public class VehicleRoutingAlgorithms {
if(termination != null) metaAlgorithm.addTerminationCriterion(termination);
}
}
for(PrioritizedVRAListener l : algorithmListeners){
metaAlgorithm.getAlgorithmListeners().add(l);
}
return metaAlgorithm;
}