- Timestamp:
- 06/13/12 09:01:31 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Selection/3.3
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Selection/3.3/BestSelector.cs
r7259 r7995 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) { -
trunk/sources/HeuristicLab.Selection/3.3/GeneralizedRankSelector.cs
r7259 r7995 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; -
trunk/sources/HeuristicLab.Selection/3.3/LinearRankSelector.cs
r7259 r7995 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; -
trunk/sources/HeuristicLab.Selection/3.3/ProportionalSelector.cs
r7259 r7995 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."); 75 } 76 71 77 double minQuality = qualities.Min(); 72 78 double maxQuality = qualities.Max(); -
trunk/sources/HeuristicLab.Selection/3.3/SingleObjectiveSelector.cs
r7259 r7995 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 } -
trunk/sources/HeuristicLab.Selection/3.3/TournamentSelector.cs
r7259 r7995 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++) { -
trunk/sources/HeuristicLab.Selection/3.3/WorstSelector.cs
r7259 r7995 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.