- Timestamp:
- 02/17/10 00:30:46 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Selection/3.3/TournamentSelector.cs
r2805 r2817 40 40 public TournamentSelector() : base() { 41 41 Parameters.Add(new ValueLookupParameter<IntData>("GroupSize", "The size of the tournament group.", new IntData(2))); 42 CopySelected.Value = true; 42 43 } 43 44 44 protected override void Select(ScopeList source, ScopeList target) {45 protected override ScopeList Select(ScopeList scopes) { 45 46 int count = NumberOfSelectedSubScopesParameter.ActualValue.Value; 46 47 bool copy = CopySelectedParameter.Value.Value; … … 49 50 List<DoubleData> qualities = new List<DoubleData>(QualityParameter.ActualValue); 50 51 int groupSize = GroupSizeParameter.ActualValue.Value; 52 ScopeList selected = new ScopeList(); 51 53 52 54 for (int i = 0; i < count; i++) { 53 int best = random.Next(s ource.Count);55 int best = random.Next(scopes.Count); 54 56 int index; 55 57 for (int j = 1; j < groupSize; j++) { 56 index = random.Next(s ource.Count);58 index = random.Next(scopes.Count); 57 59 if (((maximization) && (qualities[index].Value > qualities[best].Value)) || 58 60 ((!maximization) && (qualities[index].Value < qualities[best].Value))) { … … 62 64 63 65 if (copy) 64 target.Add((IScope)source[best].Clone());66 selected.Add((IScope)scopes[best].Clone()); 65 67 else { 66 target.Add(source[best]);67 s ource.RemoveAt(best);68 selected.Add(scopes[best]); 69 scopes.RemoveAt(best); 68 70 qualities.RemoveAt(best); 69 71 } 70 72 } 73 return selected; 71 74 } 72 75 }
Note: See TracChangeset
for help on using the changeset viewer.