Changeset 7961
- Timestamp:
- 06/05/12 10:02:25 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs
r7259 r7961 161 161 .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i)) 162 162 .ToList(); 163 var selectedSymbol = possibleSymbols.SelectRandom(random); 163 var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList(); 164 var selectedSymbol = possibleSymbols.SelectRandom(weights, random); 164 165 var tree = selectedSymbol.CreateTreeNode(); 165 166 if (tree.HasLocalParameters) tree.ResetLocalParameters(random); … … 192 193 if (!possibleSymbols.Any()) 193 194 throw new InvalidOperationException("No symbols are available for the tree."); 194 195 var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList(); 195 196 var selectedSymbol = possibleSymbols.SelectRandom(random); 196 197 var tree = selectedSymbol.CreateTreeNode(); -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs
r7259 r7961 160 160 .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i)) 161 161 .ToList(); 162 var selectedSymbol = possibleSymbols.SelectRandom(random); 162 var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList(); 163 var selectedSymbol = possibleSymbols.SelectRandom(weights, random); 163 164 var tree = selectedSymbol.CreateTreeNode(); 164 165 if (tree.HasLocalParameters) tree.ResetLocalParameters(random); … … 178 179 throw new ArgumentException("Cannot grow node of arity zero. Expected a function node."); 179 180 180 var allowedSymbols = root.Grammar.AllowedSymbols 181 .Where(s => s.InitialFrequency > 0.0) 182 .ToList(); 181 var allowedSymbols = root.Grammar.AllowedSymbols.Where(s => s.InitialFrequency > 0.0).ToList(); 183 182 184 183 for (var i = 0; i < arity; i++) { … … 187 186 root.Grammar.GetMinimumExpressionDepth(s) - 1 <= maxDepth - currentDepth) 188 187 .ToList(); 188 189 189 if (!possibleSymbols.Any()) 190 190 throw new InvalidOperationException("No symbols are available for the tree."); 191 var selectedSymbol = possibleSymbols.SelectRandom(random); 191 var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList(); 192 var selectedSymbol = possibleSymbols.SelectRandom(weights, random); 192 193 var tree = selectedSymbol.CreateTreeNode(); 193 194 if (tree.HasLocalParameters) tree.ResetLocalParameters(random);
Note: See TracChangeset
for help on using the changeset viewer.