Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12844


Ignore:
Timestamp:
08/11/15 13:54:46 (9 years ago)
Author:
mkommend
Message:

#2458: Adapted tree creators to work with the same depth restriction as the PTC2 (excluding the root symbol).

Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs

    r12422 r12844  
    7777      rootNode.AddSubtree(startNode);
    7878
    79       Create(random, startNode, maxTreeDepth - 2);
     79      Create(random, startNode, maxTreeDepth-1);
    8080      tree.Root = rootNode;
    8181      return tree;
     
    9999      for (var i = 0; i < arity; i++) {
    100100        var possibleSymbols = allowedSymbols
    101           .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i))
     101          .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i)
     102                   && seedNode.Grammar.GetMinimumExpressionDepth(s) <= maxDepth
     103                   && seedNode.Grammar.GetMaximumExpressionDepth(s) >= maxDepth)
    102104          .ToList();
    103105        var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList();
     
    142144        var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
    143145#pragma warning restore 612, 618
    144        
     146
    145147        var tree = selectedSymbol.CreateTreeNode();
    146148        if (tree.HasLocalParameters) tree.ResetLocalParameters(random);
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs

    r12422 r12844  
    7474      rootNode.AddSubtree(startNode);
    7575
    76       Create(random, startNode, maxTreeDepth - 2);
     76      Create(random, startNode, maxTreeDepth - 1);
    7777      tree.Root = rootNode;
    7878      return tree;
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4/FullTreeCreatorTest.cs

    r12012 r12844  
    5353      foreach (var tree in randomTrees) {
    5454        Util.IsValid(tree);
    55         Assert.IsTrue(tree.Depth == MAX_TREE_DEPTH);
     55        Assert.IsTrue(tree.Depth-1 == MAX_TREE_DEPTH);
    5656        if (maxLength < tree.Length)
    5757          maxLength = tree.Length;
Note: See TracChangeset for help on using the changeset viewer.