Changeset 8085 for branches/GP-MoveOperators/HeuristicLab.Selection
- Timestamp:
- 06/21/12 18:02:33 (13 years ago)
- Location:
- branches/GP-MoveOperators
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-MoveOperators
- Property svn:ignore
-
old new 20 20 bin 21 21 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/GP-MoveOperators/HeuristicLab.Selection/3.3/BestSelector.cs
r7259 r8085 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 54 55 55 56 // create a list for each scope that contains the scope's index in the original scope list 56 var temp = qualities. Select((x, index) => new { index, x.Value });57 var temp = qualities.Where(x => IsValidQuality(x.Value)).Select((x, index) => new { index, x.Value }); 57 58 if (maximization) 58 59 temp = temp.OrderByDescending(x => x.Value); … … 60 61 temp = temp.OrderBy(x => x.Value); 61 62 var list = temp.ToList(); 63 64 //check if list with indexes is as long as the original scope list 65 //otherwise invalid quality values were filtered 66 if (list.Count != scopes.Count) { 67 throw new ArgumentException("The scopes contain invalid quality values (either infinity or double.NaN) on which the selector cannot operate."); 68 } 62 69 63 70 if (copy) { -
branches/GP-MoveOperators/HeuristicLab.Selection/3.3/GeneralizedRankSelector.cs
r7259 r8085 63 63 double pressure = PressureParameter.ActualValue.Value; 64 64 65 var ordered = qualities. Select((x, index) => new KeyValuePair<int, double>(index, x.Value)).OrderBy(x => x.Value).ToList();65 var ordered = qualities.Where(x => IsValidQuality(x.Value)).Select((x, index) => new KeyValuePair<int, double>(index, x.Value)).OrderBy(x => x.Value).ToList(); 66 66 if (maximization) ordered.Reverse(); 67 68 //check if list with indexes is as long as the original scope list 69 //otherwise invalid quality values were filtered 70 if (ordered.Count != scopes.Count) { 71 throw new ArgumentException("The scopes contain invalid quality values (either infinity or double.NaN) on which the selector cannot operate."); 72 } 67 73 68 74 int m = scopes.Count; -
branches/GP-MoveOperators/HeuristicLab.Selection/3.3/LinearRankSelector.cs
r7259 r8085 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 54 55 55 56 // create a list for each scope that contains the scope's index in the original scope list and its lots 56 var temp = qualities. Select((x, index) => new { index, x.Value });57 var temp = qualities.Where(x => IsValidQuality(x.Value)).Select((x, index) => new { index, x.Value }); 57 58 if (maximization) 58 59 temp = temp.OrderBy(x => x.Value); … … 60 61 temp = temp.OrderByDescending(x => x.Value); 61 62 var list = temp.Select((x, index) => new { x.index, lots = index + 1 }).ToList(); 63 64 //check if list with indexes is as long as the original scope list 65 //otherwise invalid quality values were filtered 66 if (list.Count != scopes.Count) { 67 throw new ArgumentException("The scopes contain invalid quality values (either infinity or double.NaN) on which the selector cannot operate."); 68 } 62 69 63 70 int lotSum = list.Count * (list.Count + 1) / 2; -
branches/GP-MoveOperators/HeuristicLab.Selection/3.3/ProportionalSelector.cs
r7259 r8085 69 69 // prepare qualities for proportional selection 70 70 var qualities = QualityParameter.ActualValue.Select(x => x.Value); 71 double minQuality = qualities.Min(); 72 double maxQuality = qualities.Max(); 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; 77 } 78 73 79 if (minQuality == maxQuality) { // all quality values are equal 74 80 qualities = qualities.Select(x => 1.0); … … 89 95 90 96 List<double> list = qualities.ToList(); 91 double qualitySum = qualities.Sum();97 double qualitySum = list.Sum(); 92 98 for (int i = 0; i < count; i++) { 93 99 double selectedQuality = random.NextDouble() * qualitySum; -
branches/GP-MoveOperators/HeuristicLab.Selection/3.3/SingleObjectiveSelector.cs
r7259 r8085 63 63 CopySelectedParameter.Hidden = true; 64 64 } 65 66 protected bool IsValidQuality(double quality) { 67 return !double.IsNaN(quality) && !double.IsInfinity(quality); 68 } 65 69 } 66 70 } -
branches/GP-MoveOperators/HeuristicLab.Selection/3.3/TournamentSelector.cs
r7259 r8085 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 57 58 IRandom random = RandomParameter.ActualValue; 58 59 bool maximization = MaximizationParameter.ActualValue.Value; 59 List<double> qualities = QualityParameter.ActualValue. Select(x => x.Value).ToList();60 List<double> qualities = QualityParameter.ActualValue.Where(x => IsValidQuality(x.Value)).Select(x => x.Value).ToList(); 60 61 int groupSize = GroupSizeParameter.ActualValue.Value; 61 62 IScope[] selected = new IScope[count]; 63 64 //check if list with indexes is as long as the original scope list 65 //otherwise invalid quality values were filtered 66 if (qualities.Count != scopes.Count) { 67 throw new ArgumentException("The scopes contain invalid quality values (either infinity or double.NaN) on which the selector cannot operate."); 68 } 62 69 63 70 for (int i = 0; i < count; i++) { -
branches/GP-MoveOperators/HeuristicLab.Selection/3.3/WorstSelector.cs
r7259 r8085 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 51 52 52 53 // create a list for each scope that contains the scope's index in the original scope list 53 var temp = qualities. Select((x, index) => new { index, x.Value });54 var temp = qualities.Where(x => IsValidQuality(x.Value)).Select((x, index) => new { index, x.Value }); 54 55 if (maximization) 55 56 temp = temp.OrderBy(x => x.Value); … … 57 58 temp = temp.OrderByDescending(x => x.Value); 58 59 var list = temp.ToList(); 60 61 //check if list with indexes is as long as the original scope list 62 //otherwise invalid quality values were filtered 63 if (list.Count != scopes.Count) { 64 throw new ArgumentException("The scopes contain invalid quality values (either infinity or double.NaN) on which the selector cannot operate."); 65 } 59 66 60 67 if (copy) {
Note: See TracChangeset
for help on using the changeset viewer.