Changeset 7996 for trunk/sources/HeuristicLab.Selection
- Timestamp:
- 06/13/12 09:09:36 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Selection/3.3/ProportionalSelector.cs
r7995 r7996 69 69 // prepare qualities for proportional selection 70 70 var qualities = QualityParameter.ActualValue.Select(x => x.Value); 71 //check if list with indexes is as long as the original scope list 72 //otherwise invalid quality values were filtered 73 if (!qualities.All(IsValidQuality)) { 74 throw new ArgumentException("The scopes contain invalid quality values (either infinity or double.NaN) on which the selector cannot operate."); 71 double minQuality = double.MaxValue; 72 double maxQuality = double.MinValue; 73 foreach (var quality in qualities) { 74 if (!IsValidQuality(quality)) throw new ArgumentException("The scopes contain invalid quality values (either infinity or double.NaN) on which the selector cannot operate."); 75 if (quality < minQuality) minQuality = quality; 76 if (quality > maxQuality) maxQuality = quality; 75 77 } 76 78 77 double minQuality = qualities.Min();78 double maxQuality = qualities.Max();79 79 if (minQuality == maxQuality) { // all quality values are equal 80 80 qualities = qualities.Select(x => 1.0); … … 95 95 96 96 List<double> list = qualities.ToList(); 97 double qualitySum = qualities.Sum();97 double qualitySum = list.Sum(); 98 98 for (int i = 0; i < count; i++) { 99 99 double selectedQuality = random.NextDouble() * qualitySum;
Note: See TracChangeset
for help on using the changeset viewer.