Changeset 7000 for branches/Benchmarking/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs
- Timestamp:
- 11/16/11 15:07:36 (12 years ago)
- Location:
- branches/Benchmarking
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Benchmarking
- Property svn:mergeinfo changed
/trunk (added) merged: 6918-6919,6921-6923,6928-6930,6933,6935,6938-6939,6942,6944,6949-6954,6959,6961-6964,6974-6983,6985-6986,6993-6995,6997-6999
- Property svn:mergeinfo changed
-
branches/Benchmarking/sources
- Property svn:mergeinfo changed
/trunk/sources (added) merged: 6918-6919,6921-6923,6928-6930,6935,6938-6939,6942,6944,6949-6954,6959,6961-6964,6974-6983,6986,6993-6995,6997-6999
- Property svn:mergeinfo changed
-
branches/Benchmarking/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs
r6888 r7000 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.ComponentModel;25 23 using System.Linq; 26 24 using HeuristicLab.Common; … … 134 132 var arity = SampleArity(random, seedNode); 135 133 // throw an exception if the seedNode happens to be a terminal, since in this case we cannot grow a tree 136 if (arity <= 0) 137 throw new ArgumentException("Cannot grow tree. Seed node shouldn't have arity zero."); 134 if (arity <= 0) 135 throw new ArgumentException("Cannot grow tree. Seed node shouldn't have arity zero."); 138 136 139 var possibleSymbols = seedNode.Grammar.GetAllowedChildSymbols(seedNode.Symbol).Where(s => s.InitialFrequency > 0.0).ToList();140 137 141 138 for (var i = 0; i != arity; ++i) { 139 var possibleSymbols = seedNode.Grammar.GetAllowedChildSymbols(seedNode.Symbol, i).Where(s => s.InitialFrequency > 0.0); 142 140 var selectedSymbol = possibleSymbols.SelectRandom(random); 143 141 var tree = selectedSymbol.CreateTreeNode(); … … 157 155 throw new ArgumentException("Cannot grow node of arity zero. Expected a function node."); 158 156 159 var possibleSymbols = currentDepth < maxDepth ?160 root.Grammar.GetAllowedChildSymbols(root.Symbol).Where(s => s.InitialFrequency > 0.0).ToList() :161 root.Grammar.GetAllowedChildSymbols(root.Symbol).Where(s => s.InitialFrequency > 0.0 && root.Grammar.GetMaximumSubtreeCount(s) == 0).ToList();162 157 163 158 for (var i = 0; i != arity; ++i) { 159 var possibleSymbols = currentDepth < maxDepth 160 ? 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); 164 163 var selectedSymbol = possibleSymbols.SelectRandom(random); 165 164 var tree = selectedSymbol.CreateTreeNode();
Note: See TracChangeset
for help on using the changeset viewer.