Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/17/10 00:30:46 (15 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on selection
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Selection/3.3/RandomSelector.cs

    r2805 r2817  
    3636    public RandomSelector() : base() { }
    3737
    38     protected override void Select(ScopeList source, ScopeList target) {
     38    protected override ScopeList Select(ScopeList scopes) {
    3939      int count = NumberOfSelectedSubScopesParameter.ActualValue.Value;
    4040      bool copy = CopySelectedParameter.Value.Value;
    4141      IRandom random = RandomParameter.ActualValue;
     42      ScopeList selected = new ScopeList();
    4243
    4344      for (int i = 0; i < count; i++) {
    4445        if (copy)
    45           target.Add((IScope)source[random.Next(source.Count)].Clone());
     46          selected.Add((IScope)scopes[random.Next(scopes.Count)].Clone());
    4647        else {
    47           int index = random.Next(source.Count);
    48           target.Add(source[index]);
    49           source.RemoveAt(index);
     48          int index = random.Next(scopes.Count);
     49          selected.Add(scopes[index]);
     50          scopes.RemoveAt(index);
    5051        }
    5152      }
     53      return selected;
    5254    }
    5355  }
Note: See TracChangeset for help on using the changeset viewer.