Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/19/10 02:15:10 (15 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on operators and SGA
  • improved performance
File:
1 edited

Legend:

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

    r2818 r2830  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3334    public RandomSelector() : base() { }
    3435
    35     protected override ScopeList Select(ScopeList scopes) {
     36    protected override IScope[] Select(List<IScope> scopes) {
    3637      int count = NumberOfSelectedSubScopesParameter.ActualValue.Value;
    3738      bool copy = CopySelectedParameter.Value.Value;
    3839      IRandom random = RandomParameter.ActualValue;
    39       ScopeList selected = new ScopeList();
     40      IScope[] selected = new IScope[count];
    4041
    4142      for (int i = 0; i < count; i++) {
    4243        if (copy)
    43           selected.Add((IScope)scopes[random.Next(scopes.Count)].Clone());
     44          selected[i] = (IScope)scopes[random.Next(scopes.Count)].Clone();
    4445        else {
    4546          int index = random.Next(scopes.Count);
    46           selected.Add(scopes[index]);
     47          selected[i] = scopes[index];
    4748          scopes.RemoveAt(index);
    4849        }
Note: See TracChangeset for help on using the changeset viewer.