Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/10/15 10:49:31 (9 years ago)
Author:
mkommend
Message:

#2320: Marked SymbolicExpressionTreeEncoding.EnumberableExtensions as obsolete and called the methods in Random.RandomEnumerable whereever possible.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDuplicater.cs

    r12012 r12420  
    2828using HeuristicLab.Data;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Random;
    3031
    3132namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    5960      ISymbolicExpressionTree symbolicExpressionTree,
    6061      int maxFunctionDefinitions, int maxFunctionArguments) {
    61       var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>();
    62       if (functionDefiningBranches.Count() == 0 || functionDefiningBranches.Count() == maxFunctionDefinitions)
     62      var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>().ToList();
     63      if (!functionDefiningBranches.Any() || functionDefiningBranches.Count() == maxFunctionDefinitions)
    6364        // no function defining branches to duplicate or already reached the max number of ADFs
    6465        return false;
     
    6768      var allowedFunctionNames = from index in Enumerable.Range(0, maxFunctionDefinitions)
    6869                                 select "ADF" + index.ToString(formatString);
    69       var selectedBranch = functionDefiningBranches.SelectRandom(random);
     70
     71      var selectedBranch = functionDefiningBranches.SampleRandom(random);
    7072      var duplicatedDefunBranch = (DefunTreeNode)selectedBranch.Clone();
    7173      string newFunctionName = allowedFunctionNames.Except(UsedFunctionNames(symbolicExpressionTree)).First();
Note: See TracChangeset for help on using the changeset viewer.