Changeset 6009 for trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
- Timestamp:
- 04/13/11 16:02:40 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
r5809 r6009 229 229 230 230 public virtual IEnumerable<ISymbol> GetAllowedChildSymbols(ISymbol parent) { 231 return from s in Symbols where IsAllowedChildSymbol(parent, s) select s;231 return from s in AllowedSymbols where IsAllowedChildSymbol(parent, s) select s; 232 232 } 233 233 … … 265 265 cachedMinExpressionLength[symbol.Name] = int.MaxValue; // prevent infinite recursion 266 266 long sumOfMinExpressionLengths = 1 + (from argIndex in Enumerable.Range(0, GetMinimumSubtreeCount(symbol)) 267 let minForSlot = (long)(from s in Symbols267 let minForSlot = (long)(from s in AllowedSymbols 268 268 where IsAllowedChildSymbol(symbol, s, argIndex) 269 269 select GetMinimumExpressionLength(s)).DefaultIfEmpty(0).Min() … … 282 282 cachedMaxExpressionLength[symbol.Name] = int.MaxValue; // prevent infinite recursion 283 283 long sumOfMaxTrees = 1 + (from argIndex in Enumerable.Range(0, GetMaximumSubtreeCount(symbol)) 284 let maxForSlot = (long)(from s in Symbols284 let maxForSlot = (long)(from s in AllowedSymbols 285 285 where IsAllowedChildSymbol(symbol, s, argIndex) 286 286 select GetMaximumExpressionLength(s)).DefaultIfEmpty(0).Max() 287 287 select maxForSlot).DefaultIfEmpty(0).Sum(); 288 long limit = int.MaxValue; 289 cachedMaxExpressionLength[symbol.Name] = (int)Math.Min(sumOfMaxTrees, limit); 288 cachedMaxExpressionLength[symbol.Name] = (int)Math.Min(sumOfMaxTrees, int.MaxValue); 290 289 return cachedMaxExpressionLength[symbol.Name]; 291 290 } … … 298 297 if (!cachedMinExpressionDepth.TryGetValue(symbol.Name, out temp)) { 299 298 cachedMinExpressionDepth[symbol.Name] = int.MaxValue; // prevent infinite recursion 300 cachedMinExpressionDepth[symbol.Name] = 1 + (from argIndex in Enumerable.Range(0, GetMinimumSubtreeCount(symbol)) 301 let minForSlot = (from s in Symbols 302 where IsAllowedChildSymbol(symbol, s, argIndex) 303 select GetMinimumExpressionDepth(s)).DefaultIfEmpty(0).Min() 304 select minForSlot).DefaultIfEmpty(0).Max(); 299 long minDepth = 1 + (from argIndex in Enumerable.Range(0, GetMinimumSubtreeCount(symbol)) 300 let minForSlot = (long)(from s in AllowedSymbols 301 where IsAllowedChildSymbol(symbol, s, argIndex) 302 select GetMinimumExpressionDepth(s)).DefaultIfEmpty(0).Min() 303 select minForSlot).DefaultIfEmpty(0).Max(); 304 cachedMinExpressionDepth[symbol.Name] = (int)Math.Min(minDepth, int.MaxValue); 305 305 return cachedMinExpressionDepth[symbol.Name]; 306 306 }
Note: See TracChangeset
for help on using the changeset viewer.