Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/25/11 15:25:54 (13 years ago)
Author:
mkommend
Message:

#1654: Corrected tree creators for symbolic expression encoding.

File:
1 edited

Legend:

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

    r7012 r7076  
    6464    }
    6565
    66     public IntValue MaximumSymbolicExpressionTreeLength { 
     66    public IntValue MaximumSymbolicExpressionTreeLength {
    6767      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
    6868    }
     
    166166        throw new ArgumentException("Cannot grow node of arity zero. Expected a function node.");
    167167
    168 
    169168      for (var i = 0; i != arity; ++i) {
    170         var possibleSymbols = currentDepth < maxDepth
    171                                 ? root.Grammar.GetAllowedChildSymbols(root.Symbol,i).Where(s => s.InitialFrequency > 0.0)
    172                                 : root.Grammar.GetAllowedChildSymbols(root.Symbol,i).Where(
    173                                   s => s.InitialFrequency > 0.0 && root.Grammar.GetMaximumSubtreeCount(s) == 0);
     169        var possibleSymbols = root.Grammar.GetAllowedChildSymbols(root.Symbol, i);
     170        possibleSymbols = possibleSymbols.Where(s => s.InitialFrequency > 0.0 &&
     171                                          root.Grammar.GetMinimumExpressionDepth(s) - 1 <= maxDepth - currentDepth);
     172        if (!possibleSymbols.Any()) throw new InvalidOperationException("No symbols are available for the tree.");
    174173        var selectedSymbol = possibleSymbols.SelectRandom(random);
    175174        var tree = selectedSymbol.CreateTreeNode();
Note: See TracChangeset for help on using the changeset viewer.