Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/05/12 10:02:25 (12 years ago)
Author:
bburlacu
Message:

#1866: Fixed bug where initial frequencies of grammar symbols were not taken into account by the tree creators.

File:
1 edited

Legend:

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

    r7259 r7961  
    161161          .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i))
    162162          .ToList();
    163         var selectedSymbol = possibleSymbols.SelectRandom(random);
     163        var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList();
     164        var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
    164165        var tree = selectedSymbol.CreateTreeNode();
    165166        if (tree.HasLocalParameters) tree.ResetLocalParameters(random);
     
    192193        if (!possibleSymbols.Any())
    193194          throw new InvalidOperationException("No symbols are available for the tree.");
    194 
     195        var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList();
    195196        var selectedSymbol = possibleSymbols.SelectRandom(random);
    196197        var tree = selectedSymbol.CreateTreeNode();
Note: See TracChangeset for help on using the changeset viewer.