- Timestamp:
- 02/19/10 02:15:10 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Selection/3.3/RandomSelector.cs
r2818 r2830 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 33 34 public RandomSelector() : base() { } 34 35 35 protected override ScopeList Select(ScopeListscopes) {36 protected override IScope[] Select(List<IScope> scopes) { 36 37 int count = NumberOfSelectedSubScopesParameter.ActualValue.Value; 37 38 bool copy = CopySelectedParameter.Value.Value; 38 39 IRandom random = RandomParameter.ActualValue; 39 ScopeList selected = new ScopeList();40 IScope[] selected = new IScope[count]; 40 41 41 42 for (int i = 0; i < count; i++) { 42 43 if (copy) 43 selected .Add((IScope)scopes[random.Next(scopes.Count)].Clone());44 selected[i] = (IScope)scopes[random.Next(scopes.Count)].Clone(); 44 45 else { 45 46 int index = random.Next(scopes.Count); 46 selected .Add(scopes[index]);47 selected[i] = scopes[index]; 47 48 scopes.RemoveAt(index); 48 49 }
Note: See TracChangeset
for help on using the changeset viewer.