Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/06/13 12:30:18 (12 years ago)
Author:
pfleck
Message:

#2030
Switched Text encoding to Mtom encoding for better performance for binary data.
Merged trunk into branch.

Location:
branches/HivePerformance/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HivePerformance/sources

  • branches/HivePerformance/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding

  • branches/HivePerformance/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs

    r7660 r9444  
    387387    private readonly Dictionary<string, int> cachedMinExpressionLength;
    388388    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) {
    389401      int temp;
    390402      if (!cachedMinExpressionLength.TryGetValue(symbol.Name, out temp)) {
     
    393405                                              let minForSlot = (long)(from s in GetAllowedChildSymbols(symbol, argIndex)
    394406                                                                      where s.InitialFrequency > 0.0
    395                                                                       select GetMinimumExpressionLength(s)).DefaultIfEmpty(0).Min()
     407                                                                      select GetMinimumExpressionLengthRec(s)).DefaultIfEmpty(0).Min()
    396408                                              select minForSlot).DefaultIfEmpty(0).Sum();
    397409
     
    422434    private readonly Dictionary<string, int> cachedMinExpressionDepth;
    423435    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) {
    424447      int temp;
    425448      if (!cachedMinExpressionDepth.TryGetValue(symbol.Name, out temp)) {
     
    428451                             let minForSlot = (long)(from s in GetAllowedChildSymbols(symbol, argIndex)
    429452                                                     where s.InitialFrequency > 0.0
    430                                                      select GetMinimumExpressionDepth(s)).DefaultIfEmpty(0).Min()
     453                                                     select GetMinimumExpressionDepthRec(s)).DefaultIfEmpty(0).Min()
    431454                             select minForSlot).DefaultIfEmpty(0).Max();
    432455        cachedMinExpressionDepth[symbol.Name] = (int)Math.Min(minDepth, int.MaxValue);
Note: See TracChangeset for help on using the changeset viewer.