- Timestamp:
- 07/10/15 11:51:51 (10 years ago)
- Location:
- stable
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
-
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs
r12009 r12702 134 134 parent0.Root.ForEachNodePostfix((n) => { 135 135 if (n.SubtreeCount > 0 && n != parent0.Root) { 136 foreach (var child in n.Subtrees) { 136 //avoid linq to reduce memory pressure 137 for (int i = 0; i < n.SubtreeCount; i++) { 138 var child = n.GetSubtree(i); 137 139 if (child.GetLength() <= maxBranchLength && 138 140 child.GetDepth() <= maxBranchDepth) { -
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammarBase.cs
r12009 r12702 330 330 List<string> temp; 331 331 if (allowedChildSymbols.TryGetValue(parent.Name, out temp)) { 332 if (temp.SelectMany(s => GetSymbol(s).Flatten()).Any(s => s.Name == child.Name)) { 333 cachedIsAllowedChildSymbol.Add(key, true); 334 return true; 332 for (int i = 0; i < temp.Count; i++) { 333 var symbol = GetSymbol(temp[i]); 334 foreach (var s in symbol.Flatten()) 335 if (s.Name == child.Name) { 336 cachedIsAllowedChildSymbol.Add(key, true); 337 return true; 338 } 335 339 } 336 340 } … … 357 361 List<string> temp; 358 362 if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(parent.Name, argumentIndex), out temp)) { 359 if (temp.SelectMany(s => GetSymbol(s).Flatten()).Any(s => s.Name == child.Name)) { 360 cachedIsAllowedChildSymbolIndex.Add(key, true); 361 return true; 363 for (int i = 0; i < temp.Count; i++) { 364 var symbol = GetSymbol(temp[i]); 365 foreach (var s in symbol.Flatten()) 366 if (s.Name == child.Name) { 367 cachedIsAllowedChildSymbolIndex.Add(key, true); 368 return true; 369 } 362 370 } 363 371 } -
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs
r12009 r12702 175 175 176 176 public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth() { 177 var list = new List<ISymbolicExpressionTreeNode>( ) { this };177 var list = new List<ISymbolicExpressionTreeNode>(GetLength()) { this }; 178 178 int i = 0; 179 179 while (i != list.Count) { … … 193 193 public void ForEachNodePrefix(Action<ISymbolicExpressionTreeNode> a) { 194 194 a(this); 195 if (Subtrees != null) { 196 foreach (var subtree in Subtrees) { 197 subtree.ForEachNodePrefix(a); 195 if (subtrees != null) { 196 //avoid linq to reduce memory pressure 197 for (int i = 0; i < subtrees.Count; i++) { 198 subtrees[i].ForEachNodePrefix(a); 198 199 } 199 200 } … … 207 208 208 209 public void ForEachNodePostfix(Action<ISymbolicExpressionTreeNode> a) { 209 if (Subtrees != null) { 210 foreach (var subtree in Subtrees) { 211 subtree.ForEachNodePostfix(a); 210 if (subtrees != null) { 211 //avoid linq to reduce memory pressure 212 for (int i = 0; i < subtrees.Count; i++) { 213 subtrees[i].ForEachNodePostfix(a); 212 214 } 213 215 }
Note: See TracChangeset
for help on using the changeset viewer.