Changeset 7085 for branches/RegressionBenchmarks/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
- Timestamp:
- 11/28/11 13:47:28 (12 years ago)
- Location:
- branches/RegressionBenchmarks
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RegressionBenchmarks
- Property svn:ignore
-
old new 4 4 *.suo 5 5 *.vsp 6 Doxygen 6 7 Google.ProtocolBuffers-0.9.1.dll 7 8 HeuristicLab 3.3.5.1.ReSharper.user 8 9 HeuristicLab 3.3.6.0.ReSharper.user 9 10 HeuristicLab.4.5.resharper.user 11 HeuristicLab.ExtLibs.6.0.ReSharper.user 10 12 HeuristicLab.resharper.user 11 13 ProtoGen.exe … … 16 18 bin 17 19 protoc.exe 18 HeuristicLab.ExtLibs.6.0.ReSharper.user19 Doxygen
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/RegressionBenchmarks/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
r6911 r7085 82 82 cachedMaxExpressionLength = new Dictionary<Tuple<string, int>, int>(); 83 83 cachedMinExpressionDepth = new Dictionary<string, int>(); 84 cachedMaxExpressionDepth = new Dictionary<string, int>(); 84 85 85 86 cachedIsAllowedChildSymbol = new Dictionary<Tuple<string, string>, bool>(); … … 94 95 cachedMaxExpressionLength = new Dictionary<Tuple<string, int>, int>(); 95 96 cachedMinExpressionDepth = new Dictionary<string, int>(); 97 cachedMaxExpressionDepth = new Dictionary<string, int>(); 96 98 97 99 cachedIsAllowedChildSymbol = new Dictionary<Tuple<string, string>, bool>(); … … 117 119 cachedMaxExpressionLength = new Dictionary<Tuple<string, int>, int>(); 118 120 cachedMinExpressionDepth = new Dictionary<string, int>(); 121 cachedMaxExpressionDepth = new Dictionary<string, int>(); 119 122 120 123 cachedIsAllowedChildSymbol = new Dictionary<Tuple<string, string>, bool>(); … … 134 137 foreach (var s in symbol.Flatten()) { 135 138 symbols.Add(s.Name, s); 136 symbolSubtreeCount.Add(s.Name, Tuple.Create(s.MinimumArity, s.MaximumArity)); 139 int maxSubTreeCount = Math.Min(s.MinimumArity + 1, s.MaximumArity); 140 symbolSubtreeCount.Add(s.Name, Tuple.Create(s.MinimumArity, maxSubTreeCount)); 137 141 } 138 142 ClearCaches(); … … 371 375 cachedMaxExpressionLength.Clear(); 372 376 cachedMinExpressionDepth.Clear(); 377 cachedMaxExpressionDepth.Clear(); 373 378 374 379 cachedIsAllowedChildSymbol.Clear(); … … 427 432 } 428 433 434 private readonly Dictionary<string, int> cachedMaxExpressionDepth; 435 public int GetMaximumExpressionDepth(ISymbol symbol) { 436 int temp; 437 if (!cachedMaxExpressionDepth.TryGetValue(symbol.Name, out temp)) { 438 cachedMaxExpressionDepth[symbol.Name] = int.MaxValue; 439 long maxDepth = 1 + (from argIndex in Enumerable.Range(0, GetMaximumSubtreeCount(symbol)) 440 let maxForSlot = (long)(from s in GetAllowedChildSymbols(symbol, argIndex) 441 where s.InitialFrequency > 0.0 442 select GetMaximumExpressionDepth(s)).DefaultIfEmpty(0).Max() 443 select maxForSlot).DefaultIfEmpty(0).Max(); 444 cachedMaxExpressionDepth[symbol.Name] = (int)Math.Min(maxDepth, int.MaxValue); 445 return cachedMaxExpressionDepth[symbol.Name]; 446 } 447 return temp; 448 } 449 429 450 public event EventHandler Changed; 430 451 protected virtual void OnChanged() {
Note: See TracChangeset
for help on using the changeset viewer.