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) {
|
private void searchSchrimpfAndRegister(VehicleRoutingAlgorithm vra) {
|
||||||
|
boolean schrimpfAdded = false;
|
||||||
for(SearchStrategy strategy : vra.getSearchStrategyManager().getStrategies()){
|
for(SearchStrategy strategy : vra.getSearchStrategyManager().getStrategies()){
|
||||||
SolutionAcceptor acceptor = strategy.getSolutionAcceptor();
|
SolutionAcceptor acceptor = strategy.getSolutionAcceptor();
|
||||||
if(acceptor instanceof SchrimpfAcceptance){
|
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.");
|
throw new IllegalStateException("strategy is null. make sure adding a valid strategy.");
|
||||||
}
|
}
|
||||||
if(id2index.keySet().contains(strategy.getId())){
|
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){
|
if(weight < 0.0){
|
||||||
throw new IllegalStateException("weight is lower than zero.");
|
throw new IllegalStateException("weight is lower than zero.");
|
||||||
|
|
|
||||||
|
|
@ -612,6 +612,9 @@ public class VehicleRoutingAlgorithms {
|
||||||
if(termination != null) metaAlgorithm.addTerminationCriterion(termination);
|
if(termination != null) metaAlgorithm.addTerminationCriterion(termination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for(PrioritizedVRAListener l : algorithmListeners){
|
||||||
|
metaAlgorithm.getAlgorithmListeners().add(l);
|
||||||
|
}
|
||||||
return metaAlgorithm;
|
return metaAlgorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
<strategy>
|
<strategy>
|
||||||
<memory>1</memory>
|
<memory>1</memory>
|
||||||
<searchStrategies>
|
<searchStrategies>
|
||||||
<searchStrategy name="radialRuinAndRecreate">
|
<searchStrategy name="randomRR">
|
||||||
<selector name="selectBest"/>
|
<selector name="selectBest"/>
|
||||||
<acceptor name="schrimpfAcceptance">
|
<acceptor name="schrimpfAcceptance">
|
||||||
<alpha>0.2</alpha>
|
<alpha>0.2</alpha>
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
<probability>0.2</probability>
|
<probability>0.2</probability>
|
||||||
</searchStrategy>
|
</searchStrategy>
|
||||||
|
|
||||||
<searchStrategy name="radialRuinAndRecreate">
|
<searchStrategy name="radialRR">
|
||||||
<selector name="selectBest"/>
|
<selector name="selectBest"/>
|
||||||
<acceptor name="schrimpfAcceptance"/>
|
<acceptor name="schrimpfAcceptance"/>
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@
|
||||||
<probability>0.2</probability>
|
<probability>0.2</probability>
|
||||||
</searchStrategy>
|
</searchStrategy>
|
||||||
|
|
||||||
<searchStrategy name="radialRuinAndRecreate">
|
<searchStrategy name="smallRadialRR">
|
||||||
<selector name="selectBest"/>
|
<selector name="selectBest"/>
|
||||||
<acceptor name="schrimpfAcceptance"/>
|
<acceptor name="schrimpfAcceptance"/>
|
||||||
<modules>
|
<modules>
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
<memory>1</memory>
|
<memory>1</memory>
|
||||||
<searchStrategies>
|
<searchStrategies>
|
||||||
|
|
||||||
<searchStrategy name="randomRuinAndRecreate">
|
<searchStrategy name="randomRR">
|
||||||
<selector name="selectBest"/>
|
<selector name="selectBest"/>
|
||||||
<acceptor name="greedyAcceptance"/>
|
<acceptor name="greedyAcceptance"/>
|
||||||
<modules>
|
<modules>
|
||||||
|
|
@ -40,13 +40,13 @@
|
||||||
<ruin name="randomRuin">
|
<ruin name="randomRuin">
|
||||||
<share>0.5</share>
|
<share>0.5</share>
|
||||||
</ruin>
|
</ruin>
|
||||||
<insertion name="bestInsertion"/>
|
<insertion name="regretInsertion"/>
|
||||||
</module>
|
</module>
|
||||||
</modules>
|
</modules>
|
||||||
<probability>0.5</probability>
|
<probability>0.5</probability>
|
||||||
</searchStrategy>
|
</searchStrategy>
|
||||||
|
|
||||||
<searchStrategy name="radialRuinAndRecreate">
|
<searchStrategy name="radialRR">
|
||||||
<selector name="selectBest"/>
|
<selector name="selectBest"/>
|
||||||
<acceptor name="greedyAcceptance"/>
|
<acceptor name="greedyAcceptance"/>
|
||||||
<modules>
|
<modules>
|
||||||
|
|
@ -54,7 +54,7 @@
|
||||||
<ruin name="radialRuin">
|
<ruin name="radialRuin">
|
||||||
<share>0.3</share>
|
<share>0.3</share>
|
||||||
</ruin>
|
</ruin>
|
||||||
<insertion name="bestInsertion"/>
|
<insertion name="regretInsertion"/>
|
||||||
</module>
|
</module>
|
||||||
</modules>
|
</modules>
|
||||||
<probability>0.5</probability>
|
<probability>0.5</probability>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue