- Timestamp:
- 11/18/15 13:01:38 (9 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 13227,13235-13236
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding merged: 13227
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs
r12706 r13246 74 74 } 75 75 76 public static ISymbolicExpressionTree CreateExpressionTree(IRandom random, ISymbolicExpressionGrammar grammar, int targetLength, 77 int maxTreeDepth) { 78 SymbolicExpressionTree tree = new SymbolicExpressionTree(); 79 var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode(); 80 if (rootNode.HasLocalParameters) rootNode.ResetLocalParameters(random); 81 rootNode.SetGrammar(grammar.CreateExpressionTreeGrammar()); 82 83 var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode(); 84 if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random); 85 startNode.SetGrammar(grammar.CreateExpressionTreeGrammar()); 86 87 rootNode.AddSubtree(startNode); 88 bool success = TryCreateFullTreeFromSeed(random, startNode, targetLength - 2, maxTreeDepth - 1); 89 if (!success) throw new InvalidOperationException(string.Format("Could not create a tree with target length {0} and max depth {1}", targetLength, maxTreeDepth)); 90 91 tree.Root = rootNode; 92 return tree; 93 94 } 95 76 96 private class TreeExtensionPoint { 77 97 public ISymbolicExpressionTreeNode Parent { get; set; } … … 107 127 } else { 108 128 // clean seedNode 109 while (seedNode.Subtrees. Count() > 0) seedNode.RemoveSubtree(0);129 while (seedNode.Subtrees.Any()) seedNode.RemoveSubtree(0); 110 130 } 111 131 // try a different length MAX_TRIES times
Note: See TracChangeset
for help on using the changeset viewer.