Commit 287c5ce 1 parent 775e098 commit 287c5ce Copy full SHA for 287c5ce
File tree 1 file changed +5
-5
lines changed
jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -103,15 +103,15 @@ private void updateSumWeights() {
103
103
public SearchStrategy getRandomStrategy () {
104
104
if (random == null )
105
105
throw new IllegalStateException ("randomizer is null. make sure you set random object correctly" );
106
- double randomFig = random .nextDouble ();
107
- double sumProbabilities = 0.0 ;
106
+ double randomValue = random .nextDouble ();
107
+ double cumulativeProbability = 0.0 ;
108
108
for (int i = 0 ; i < weights .size (); i ++) {
109
- sumProbabilities += weights .get (i ) / sumWeights ;
110
- if (randomFig < sumProbabilities ) {
109
+ cumulativeProbability += weights .get (i ) / sumWeights ;
110
+ if (randomValue < cumulativeProbability ) {
111
111
return strategies .get (i );
112
112
}
113
113
}
114
- throw new IllegalStateException ( "no search-strategy found" );
114
+ return strategies . get ( strategies . size () - 1 );
115
115
}
116
116
117
117
public void addSearchStrategyListener (SearchStrategyListener strategyListener ) {
You can’t perform that action at this time.
0 commit comments