Changeset 12515 for branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Timestamp:
- 06/25/15 18:21:19 (10 years ago)
- Location:
- branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding (added) merged: 12480,12509
- Property svn:mergeinfo changed
-
branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs
r12422 r12515 135 135 parent0.Root.ForEachNodePostfix((n) => { 136 136 if (n.SubtreeCount > 0 && n != parent0.Root) { 137 foreach (var child in n.Subtrees) { 137 //avoid linq to reduce memory pressure 138 for (int i = 0; i < n.SubtreeCount; i++) { 139 var child = n.GetSubtree(i); 138 140 if (child.GetLength() <= maxBranchLength && 139 141 child.GetDepth() <= maxBranchDepth) { -
branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SymbolicExpressionTreeCrossover.cs
r12422 r12515 68 68 69 69 public abstract ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1); 70 71 72 [StorableHook(HookType.AfterDeserialization)] 73 private void AfterDeserialization() { 74 // BackwardsCompatibility3.4 75 #region Backwards compatible code, remove with 3.5 76 if (Parameters.ContainsKey("Child")) { 77 var oldChildParameter = (ILookupParameter<ISymbolicExpressionTree>)Parameters["Child"]; 78 Parameters.Remove("Child"); 79 SymbolicExpressionTreeParameter.ActualName = oldChildParameter.ActualName; 80 } 81 #endregion 82 } 70 83 } 71 84 } -
branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammarBase.cs
r12422 r12515 338 338 List<string> temp; 339 339 if (allowedChildSymbols.TryGetValue(parent.Name, out temp)) { 340 if (temp.SelectMany(s => GetSymbol(s).Flatten()).Any(s => s.Name == child.Name)) { 341 cachedIsAllowedChildSymbol.Add(key, true); 342 return true; 340 for (int i = 0; i < temp.Count; i++) { 341 var symbol = GetSymbol(temp[i]); 342 foreach (var s in symbol.Flatten()) 343 if (s.Name == child.Name) { 344 cachedIsAllowedChildSymbol.Add(key, true); 345 return true; 346 } 343 347 } 344 348 } … … 365 369 List<string> temp; 366 370 if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(parent.Name, argumentIndex), out temp)) { 367 if (temp.SelectMany(s => GetSymbol(s).Flatten()).Any(s => s.Name == child.Name)) { 368 cachedIsAllowedChildSymbolIndex.Add(key, true); 369 return true; 371 for (int i = 0; i < temp.Count; i++) { 372 var symbol = GetSymbol(temp[i]); 373 foreach (var s in symbol.Flatten()) 374 if (s.Name == child.Name) { 375 cachedIsAllowedChildSymbolIndex.Add(key, true); 376 return true; 377 } 370 378 } 371 379 } -
branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs
r12012 r12515 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.