Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6769


Ignore:
Timestamp:
09/15/11 16:12:10 (13 years ago)
Author:
gkronber
Message:

#1640 fixed a bug in the interpretation of lagged variables introduced with r6740.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeInterpreter.cs

    r6740 r6769  
    415415            if (actualRow < 0 || actualRow >= dataset.Rows)
    416416              return double.NaN;
    417             return ((IList<double>)currentInstr.iArg0)[row] * laggedVariableTreeNode.Weight;
     417            return ((IList<double>)currentInstr.iArg0)[actualRow] * laggedVariableTreeNode.Weight;
    418418          }
    419419        case OpCodes.Constant: {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tests/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs

    r6755 r6769  
    292292      Evaluate(interpreter, ds, "(mean -1.0 1.0 -1.0)", 0, -1.0 / 3.0);
    293293
     294      // lag
     295      Evaluate(interpreter, ds, "(lagVariable 1.0 a -1) ", 1, ds.GetDoubleValue("A", 0));
     296      Evaluate(interpreter, ds, "(lagVariable 1.0 a -1) ", 2, ds.GetDoubleValue("A", 1));
     297      Evaluate(interpreter, ds, "(lagVariable 1.0 a 0) ", 2, ds.GetDoubleValue("A", 2));
     298      Evaluate(interpreter, ds, "(lagVariable 1.0 a 1) ", 0, ds.GetDoubleValue("A", 1));
    294299    }
    295300
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tests/SymbolicExpressionImporter.cs

    r5809 r6769  
    2929  internal class SymbolicExpressionImporter {
    3030    private const string VARSTART = "VAR";
     31    private const string LAGGEDVARSTART = "LAG";
    3132    private const string DEFUNSTART = "DEFUN";
    3233    private const string ARGSTART = "ARG";
     
    5859    Constant constant = new Constant();
    5960    Variable variable = new Variable();
     61    LaggedVariable laggedVariable = new LaggedVariable();
    6062    Defun defun = new Defun();
    6163
     
    9698        if (tokens.Peek().StringValue.StartsWith(VARSTART)) {
    9799          tree = ParseVariable(tokens);
     100        } else if (tokens.Peek().StringValue.StartsWith(LAGGEDVARSTART)) {
     101          tree = ParseLaggedVariable(tokens);
    98102        } else if (tokens.Peek().StringValue.StartsWith(DEFUNSTART)) {
    99103          tree = ParseDefun(tokens);
     
    157161    }
    158162
     163    private ISymbolicExpressionTreeNode ParseLaggedVariable(Queue<Token> tokens) {
     164      Token varTok = tokens.Dequeue();
     165      Debug.Assert(varTok.StringValue == "LAGVARIABLE");
     166      LaggedVariableTreeNode t = (LaggedVariableTreeNode)laggedVariable.CreateTreeNode();
     167      t.Weight = tokens.Dequeue().DoubleValue;
     168      t.VariableName = tokens.Dequeue().StringValue;
     169      t.Lag = (int)tokens.Dequeue().DoubleValue;
     170      return t;
     171    }
     172
    159173    private ISymbolicExpressionTreeNode CreateTree(Token token) {
    160174      if (token.Symbol != TokenSymbol.SYMB) throw new FormatException("Expected function symbol, but got: " + token.StringValue);
Note: See TracChangeset for help on using the changeset viewer.