Changeset 7076 for trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs
- Timestamp:
- 11/25/11 15:25:54 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs
r7012 r7076 64 64 } 65 65 66 public IntValue MaximumSymbolicExpressionTreeLength { 66 public IntValue MaximumSymbolicExpressionTreeLength { 67 67 get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; } 68 68 } … … 166 166 throw new ArgumentException("Cannot grow node of arity zero. Expected a function node."); 167 167 168 169 168 for (var i = 0; i != arity; ++i) { 170 var possibleSymbols = currentDepth < maxDepth171 ? 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."); 174 173 var selectedSymbol = possibleSymbols.SelectRandom(random); 175 174 var tree = selectedSymbol.CreateTreeNode();
Note: See TracChangeset
for help on using the changeset viewer.