Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/25/11 16:51:30 (14 years ago)
Author:
mkommend
Message:

ticket #1256 - Merged new timeseries symbols from branch to trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionSolution.cs

    r5287 r5373  
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Core;
     28using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2930using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
     
    7677
    7778    protected override void RecalculateEstimatedValues() {
    78       int minLag = 0;
    79       var laggedTreeNodes = Model.SymbolicExpressionTree.IterateNodesPrefix().OfType<LaggedVariableTreeNode>();
    80       if (laggedTreeNodes.Any())
    81         minLag = laggedTreeNodes.Min(node => node.Lag);
     79      int minLag = GetMinimumLagFromTree(Model.SymbolicExpressionTree.Root);
    8280      IEnumerable<double> calculatedValues =
    8381          from x in Model.GetEstimatedValues(ProblemData, 0 - minLag, ProblemData.Dataset.Rows)
     
    9391        yield return estimatedValues[row];
    9492    }
     93
     94    protected int GetMinimumLagFromTree(SymbolicExpressionTreeNode node) {
     95      if (node == null) return 0;
     96      int lag = 0;
     97
     98      var laggedTreeNode = node as ILaggedTreeNode;
     99      if (laggedTreeNode != null) lag += laggedTreeNode.Lag;
     100      if (node.Symbol is Derivative) lag -= 4;
     101
     102      int subtreeLag = 0;
     103      foreach (var subtree in node.SubTrees) {
     104        subtreeLag = Math.Min(subtreeLag, GetMinimumLagFromTree(subtree));
     105      }
     106      return lag + subtreeLag;
     107    }
    95108  }
    96109}
Note: See TracChangeset for help on using the changeset viewer.