- Timestamp:
- 04/11/14 15:05:55 (11 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 10407,10465-10466,10474
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.VehicleRouting
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.VehicleRouting merged: 10474
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Manipulators/BiasedMultiVRPSolutionManipulator.cs
r10507 r10743 30 30 using HeuristicLab.Parameters; 31 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 using HeuristicLab.Random; 32 33 33 34 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { … … 140 141 if (checkedOperators.Count() > 0) { 141 142 // select a random operator from the checked operators 142 double sum = (from indexedItem in checkedOperators select probabilities[indexedItem.Index]).Sum(); 143 if (sum == 0) throw new InvalidOperationException(Name + ": All selected operators have zero probability."); 144 double r = random.NextDouble() * sum; 145 sum = 0; 146 foreach (var indexedItem in checkedOperators) { 147 sum += probabilities[indexedItem.Index]; 148 if (sum > r) { 149 successor = indexedItem.Value; 150 break; 151 } 152 } 143 successor = 144 checkedOperators.SampleProportional(random, 1, probabilities, false, false).First().Value; 153 145 } 154 146
Note: See TracChangeset
for help on using the changeset viewer.