Changeset 7085 for branches/RegressionBenchmarks/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs
- Timestamp:
- 11/28/11 13:47:28 (12 years ago)
- Location:
- branches/RegressionBenchmarks
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RegressionBenchmarks
- Property svn:ignore
-
old new 4 4 *.suo 5 5 *.vsp 6 Doxygen 6 7 Google.ProtocolBuffers-0.9.1.dll 7 8 HeuristicLab 3.3.5.1.ReSharper.user 8 9 HeuristicLab 3.3.6.0.ReSharper.user 9 10 HeuristicLab.4.5.resharper.user 11 HeuristicLab.ExtLibs.6.0.ReSharper.user 10 12 HeuristicLab.resharper.user 11 13 ProtoGen.exe … … 16 18 bin 17 19 protoc.exe 18 HeuristicLab.ExtLibs.6.0.ReSharper.user19 Doxygen
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/RegressionBenchmarks/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs
r6944 r7085 27 27 using HeuristicLab.Parameters; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.PluginInfrastructure; 29 30 30 31 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 32 [NonDiscoverableType] 31 33 [StorableClass] 32 34 [Item("GrowTreeCreator", "An operator that creates new symbolic expression trees using the 'Grow' method")] … … 60 62 public IntValue MaximumSymbolicExpressionTreeDepth { 61 63 get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; } 64 } 65 66 public IntValue MaximumSymbolicExpressionTreeLength { 67 get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; } 62 68 } 63 69 … … 97 103 98 104 protected override ISymbolicExpressionTree Create(IRandom random) { 99 return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeDepth.Value); 105 return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value); 106 } 107 108 public override ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) { 109 return Create(random, grammar, maxTreeLength, maxTreeDepth); 100 110 } 101 111 … … 107 117 /// <param name="grammar">Available tree grammar</param> 108 118 /// <param name="maxTreeDepth">Maximum tree depth</param> 119 /// <param name="maxTreeLength">Maximum tree length. This parameter is not used.</param> 109 120 /// <returns></returns> 110 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTree Depth) {121 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) { 111 122 var tree = new SymbolicExpressionTree(); 112 123 var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode(); … … 155 166 throw new ArgumentException("Cannot grow node of arity zero. Expected a function node."); 156 167 157 158 168 for (var i = 0; i != arity; ++i) { 159 var possibleSymbols = currentDepth < maxDepth160 ? root.Grammar.GetAllowedChildSymbols(root.Symbol,i).Where(s => s.InitialFrequency > 0.0)161 : root.Grammar.GetAllowedChildSymbols(root.Symbol,i).Where(162 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."); 163 173 var selectedSymbol = possibleSymbols.SelectRandom(random); 164 174 var tree = selectedSymbol.CreateTreeNode();
Note: See TracChangeset
for help on using the changeset viewer.