Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/11/14 15:05:55 (11 years ago)
Author:
abeham
Message:

#2146: merged r10407,r10465,r10466,r10474,r10503,r10504,r10646 into stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.VehicleRouting

  • stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/BiasedMultiVRPSolutionCrossover.cs

    r10507 r10743  
    3030using HeuristicLab.Parameters;
    3131using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     32using HeuristicLab.Random;
    3233
    3334namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
     
    140141      if (checkedOperators.Count() > 0) {
    141142        // 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 = checkedOperators.SampleProportional(random, 1, probabilities, false, false).First().Value;
    153144      }
    154145
Note: See TracChangeset for help on using the changeset viewer.