Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/17/10 00:30:46 (14 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/TournamentSelector.cs

    r2805 r2817  
    4040    public TournamentSelector() : base() {
    4141      Parameters.Add(new ValueLookupParameter<IntData>("GroupSize", "The size of the tournament group.", new IntData(2)));
     42      CopySelected.Value = true;
    4243    }
    4344
    44     protected override void Select(ScopeList source, ScopeList target) {
     45    protected override ScopeList Select(ScopeList scopes) {
    4546      int count = NumberOfSelectedSubScopesParameter.ActualValue.Value;
    4647      bool copy = CopySelectedParameter.Value.Value;
     
    4950      List<DoubleData> qualities = new List<DoubleData>(QualityParameter.ActualValue);
    5051      int groupSize = GroupSizeParameter.ActualValue.Value;
     52      ScopeList selected = new ScopeList();
    5153
    5254      for (int i = 0; i < count; i++) {
    53         int best = random.Next(source.Count);
     55        int best = random.Next(scopes.Count);
    5456        int index;
    5557        for (int j = 1; j < groupSize; j++) {
    56           index = random.Next(source.Count);
     58          index = random.Next(scopes.Count);
    5759          if (((maximization) && (qualities[index].Value > qualities[best].Value)) ||
    5860              ((!maximization) && (qualities[index].Value < qualities[best].Value))) {
     
    6264
    6365        if (copy)
    64           target.Add((IScope)source[best].Clone());
     66          selected.Add((IScope)scopes[best].Clone());
    6567        else {
    66           target.Add(source[best]);
    67           source.RemoveAt(best);
     68          selected.Add(scopes[best]);
     69          scopes.RemoveAt(best);
    6870          qualities.RemoveAt(best);
    6971        }
    7072      }
     73      return selected;
    7174    }
    7275  }
Note: See TracChangeset for help on using the changeset viewer.