Changeset 14029 for branches/crossvalidation-2434/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Timestamp:
- 07/08/16 14:40:02 (9 years ago)
- Location:
- branches/crossvalidation-2434
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/crossvalidation-2434
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
/stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding merged: 13316 /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding merged: 13227,13321,13395,13397,13471,13579
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs
r12422 r14029 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 -
branches/crossvalidation-2434/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SimpleSymbolicExpressionGrammar.cs
r12422 r14029 25 25 26 26 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 27 [StorableClass] 27 28 public sealed class SimpleSymbolicExpressionGrammar : SymbolicExpressionGrammar { 28 29 [StorableConstructor] -
branches/crossvalidation-2434/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Plugin.cs.frame
r12753 r14029 26 26 27 27 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 28 [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4. 8.$WCREV$")]28 [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.9.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Analysis", "3.3")] -
branches/crossvalidation-2434/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Properties/AssemblyInfo.cs.frame
r12753 r14029 45 45 46 46 [assembly: AssemblyVersion("3.4.0.0")] 47 [assembly: AssemblyFileVersion("3.4. 8.$WCREV$")]47 [assembly: AssemblyFileVersion("3.4.9.$WCREV$")] -
branches/crossvalidation-2434/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeEncoding.cs
r12422 r14029 159 159 [StorableConstructor] 160 160 private SymbolicExpressionTreeEncoding(bool deserializing) : base(deserializing) { } 161 public SymbolicExpressionTreeEncoding() : this(new SimpleSymbolicExpressionGrammar()) { } 161 162 public SymbolicExpressionTreeEncoding(ISymbolicExpressionGrammar grammar) : this("SymbolicExpressionTree", grammar, 50, 50) { } 162 163 public SymbolicExpressionTreeEncoding(ISymbolicExpressionGrammar grammar, int maximumLength, int maximumDepth) : this("SymbolicExpressionTree", grammar, maximumLength, maximumDepth) { } -
branches/crossvalidation-2434/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs
r12509 r14029 106 106 if (length > 0) return length; 107 107 else { 108 length= 1;108 ushort l = 1; 109 109 if (subtrees != null) { 110 110 for (int i = 0; i < subtrees.Count; i++) { 111 checked { l ength+= (ushort)subtrees[i].GetLength(); }111 checked { l += (ushort)subtrees[i].GetLength(); } 112 112 } 113 113 } 114 length = l; 114 115 return length; 115 116 } … … 119 120 if (depth > 0) return depth; 120 121 else { 122 ushort d = 0; 121 123 if (subtrees != null) { 122 for (int i = 0; i < subtrees.Count; i++) depth = Math.Max(depth, (ushort)subtrees[i].GetDepth()); 123 } 124 depth++; 124 for (int i = 0; i < subtrees.Count; i++) d = Math.Max(d, (ushort)subtrees[i].GetDepth()); 125 } 126 d++; 127 depth = d; 125 128 return depth; 126 129 }
Note: See TracChangeset
for help on using the changeset viewer.