Changeset 9444 for branches/HivePerformance/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Timestamp:
- 05/06/13 12:30:18 (12 years ago)
- Location:
- branches/HivePerformance/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HivePerformance/sources
- Property svn:mergeinfo changed
/trunk/sources (added) merged: 9376,9379,9388,9390,9396,9402-9410,9413,9417,9426-9429,9432-9433,9435-9439,9441-9443
- Property svn:mergeinfo changed
-
branches/HivePerformance/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding (added) merged: 9402-9403
- Property svn:mergeinfo changed
-
branches/HivePerformance/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
r7660 r9444 387 387 private readonly Dictionary<string, int> cachedMinExpressionLength; 388 388 public int GetMinimumExpressionLength(ISymbol symbol) { 389 int res; 390 if (cachedMinExpressionLength.TryGetValue(symbol.Name, out res)) 391 return res; 392 393 res = GetMinimumExpressionLengthRec(symbol); 394 foreach (var entry in cachedMinExpressionLength.Where(e => e.Value >= int.MaxValue).ToList()) { 395 if (entry.Key != symbol.Name) cachedMinExpressionLength.Remove(entry.Key); 396 } 397 return res; 398 } 399 400 private int GetMinimumExpressionLengthRec(ISymbol symbol) { 389 401 int temp; 390 402 if (!cachedMinExpressionLength.TryGetValue(symbol.Name, out temp)) { … … 393 405 let minForSlot = (long)(from s in GetAllowedChildSymbols(symbol, argIndex) 394 406 where s.InitialFrequency > 0.0 395 select GetMinimumExpressionLength (s)).DefaultIfEmpty(0).Min()407 select GetMinimumExpressionLengthRec(s)).DefaultIfEmpty(0).Min() 396 408 select minForSlot).DefaultIfEmpty(0).Sum(); 397 409 … … 422 434 private readonly Dictionary<string, int> cachedMinExpressionDepth; 423 435 public int GetMinimumExpressionDepth(ISymbol symbol) { 436 int res; 437 if (cachedMinExpressionDepth.TryGetValue(symbol.Name, out res)) 438 return res; 439 440 res = GetMinimumExpressionDepthRec(symbol); 441 foreach (var entry in cachedMinExpressionDepth.Where(e => e.Value >= int.MaxValue).ToList()) { 442 if (entry.Key != symbol.Name) cachedMinExpressionDepth.Remove(entry.Key); 443 } 444 return res; 445 } 446 private int GetMinimumExpressionDepthRec(ISymbol symbol) { 424 447 int temp; 425 448 if (!cachedMinExpressionDepth.TryGetValue(symbol.Name, out temp)) { … … 428 451 let minForSlot = (long)(from s in GetAllowedChildSymbols(symbol, argIndex) 429 452 where s.InitialFrequency > 0.0 430 select GetMinimumExpressionDepth (s)).DefaultIfEmpty(0).Min()453 select GetMinimumExpressionDepthRec(s)).DefaultIfEmpty(0).Min() 431 454 select minForSlot).DefaultIfEmpty(0).Max(); 432 455 cachedMinExpressionDepth[symbol.Name] = (int)Math.Min(minDepth, int.MaxValue);
Note: See TracChangeset
for help on using the changeset viewer.