Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/29/15 23:40:57 (10 years ago)
Author:
bburlacu
Message:

#1772: Some more work on subtree sample counting.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/Analyzers/SymbolicDataAnalysisSubtreeSampleCountAnalyzer.cs

    r12225 r12265  
    1 #region License Information
     1#region License information
    22/* HeuristicLab
    33 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     
    2626using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2727using HeuristicLab.EvolutionTracking;
     28using HeuristicLab.Parameters;
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2930
     
    3233  [StorableClass]
    3334  public class SymbolicDataAnalysisSubtreeSampleCountAnalyzer : EvolutionTrackingAnalyzer<ISymbolicExpressionTree> {
     35    private const string CacheTraceNodesParameterName = "CacheTraceNodes";
    3436    private readonly TraceCalculator traceCalculator = new TraceCalculator { UpdateVertexWeights = true, UpdateSubtreeWeights = true, CacheTraceNodes = true };
    3537
     38    #region parameters
     39    public IFixedValueParameter<BoolValue> CacheTraceNodesParameter {
     40      get { return (IFixedValueParameter<BoolValue>)Parameters[CacheTraceNodesParameterName]; }
     41    }
     42    #endregion
     43
     44    #region parameter properties
     45    public bool CacheTraceNodes {
     46      get { return CacheTraceNodesParameter.Value.Value; }
     47      set { CacheTraceNodesParameter.Value.Value = value; }
     48    }
     49    #endregion
     50
    3651    public SymbolicDataAnalysisSubtreeSampleCountAnalyzer() {
    37       UpdateCounterParameter.ActualName = "TraceOverlapAnalyzerUpdateCounter";
     52      UpdateCounterParameter.ActualName = "SubtreeSampleCountAnalyzerUpdateCounter";
     53
     54      Parameters.Add(new FixedValueParameter<BoolValue>(CacheTraceNodesParameterName, new BoolValue(true)));
    3855    }
    3956
     
    7794        return base.Apply();
    7895
    79       double avgTraceOverlap = 0;
    80 
     96      traceCalculator.CacheTraceNodes = CacheTraceNodes;
    8197      if (Generation.Value > 0) {
    8298        var rank = PopulationGraph.GetByRank(Generation.Value).Cast<IGenealogyGraphNode<ISymbolicExpressionTree>>().ToList();
    83         foreach (var n in rank) {
    84           // during the trace the SymbolicExpressionTreeNode weights will be updated behind the scenes
    85           // the weights represent the sample count of each subtree
    86           var trace = traceCalculator.Trace(n, 2, false);
    87           foreach (var v in trace.Vertices) {
    88             var g = PopulationGraph.GetByContent(v.Data);
    89             g.Weight = v.Weight;
    90           }
     99        foreach (var n in rank)
     100          traceCalculator.Trace(n, 2, false); // during this call weights will be updated
     101
     102        foreach (var v in traceCalculator.TraceGraph.Vertices) {
     103          var g = PopulationGraph.GetByContent(v.Data);
     104          g.Weight = v.Weight;
    91105        }
    92106      }
Note: See TracChangeset for help on using the changeset viewer.