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:
parent
593cd5e841
commit
51c14afd73
5 changed files with 16 additions and 9 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.");
|
||||
|
|
|
|||
|
|
@ -612,6 +612,9 @@ public class VehicleRoutingAlgorithms {
|
|||
if(termination != null) metaAlgorithm.addTerminationCriterion(termination);
|
||||
}
|
||||
}
|
||||
for(PrioritizedVRAListener l : algorithmListeners){
|
||||
metaAlgorithm.getAlgorithmListeners().add(l);
|
||||
}
|
||||
return metaAlgorithm;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
<strategy>
|
||||
<memory>1</memory>
|
||||
<searchStrategies>
|
||||
<searchStrategy name="radialRuinAndRecreate">
|
||||
<searchStrategy name="randomRR">
|
||||
<selector name="selectBest"/>
|
||||
<acceptor name="schrimpfAcceptance">
|
||||
<alpha>0.2</alpha>
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
<probability>0.2</probability>
|
||||
</searchStrategy>
|
||||
|
||||
<searchStrategy name="radialRuinAndRecreate">
|
||||
<searchStrategy name="radialRR">
|
||||
<selector name="selectBest"/>
|
||||
<acceptor name="schrimpfAcceptance"/>
|
||||
|
||||
|
|
@ -65,7 +65,7 @@
|
|||
<probability>0.2</probability>
|
||||
</searchStrategy>
|
||||
|
||||
<searchStrategy name="radialRuinAndRecreate">
|
||||
<searchStrategy name="smallRadialRR">
|
||||
<selector name="selectBest"/>
|
||||
<acceptor name="schrimpfAcceptance"/>
|
||||
<modules>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
<memory>1</memory>
|
||||
<searchStrategies>
|
||||
|
||||
<searchStrategy name="randomRuinAndRecreate">
|
||||
<searchStrategy name="randomRR">
|
||||
<selector name="selectBest"/>
|
||||
<acceptor name="greedyAcceptance"/>
|
||||
<modules>
|
||||
|
|
@ -40,13 +40,13 @@
|
|||
<ruin name="randomRuin">
|
||||
<share>0.5</share>
|
||||
</ruin>
|
||||
<insertion name="bestInsertion"/>
|
||||
<insertion name="regretInsertion"/>
|
||||
</module>
|
||||
</modules>
|
||||
<probability>0.5</probability>
|
||||
</searchStrategy>
|
||||
|
||||
<searchStrategy name="radialRuinAndRecreate">
|
||||
<searchStrategy name="radialRR">
|
||||
<selector name="selectBest"/>
|
||||
<acceptor name="greedyAcceptance"/>
|
||||
<modules>
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
<ruin name="radialRuin">
|
||||
<share>0.3</share>
|
||||
</ruin>
|
||||
<insertion name="bestInsertion"/>
|
||||
<insertion name="regretInsertion"/>
|
||||
</module>
|
||||
</modules>
|
||||
<probability>0.5</probability>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue