Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/01/11 10:12:37 (14 years ago)
Author:
gkronber
Message:

#1418 fixed bugs in symbolic data analysis expression tree interpreter regarding evaluation of models with lagged variables and dynamic symbols.

File:
1 edited

Legend:

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

    r5897 r5923  
    339339        case OpCodes.TimeLag: {
    340340            var timeLagTreeNode = (LaggedTreeNode)currentInstr.dynamicNode;
    341             if (row + timeLagTreeNode.Lag < 0 || row + timeLagTreeNode.Lag >= dataset.Rows)
    342               return double.NaN;
    343 
    344341            row += timeLagTreeNode.Lag;
    345342            double result = Evaluate(dataset, ref row, state);
     
    350347            int savedPc = state.ProgramCounter;
    351348            var timeLagTreeNode = (LaggedTreeNode)currentInstr.dynamicNode;
    352             if (row + timeLagTreeNode.Lag < 0 || row + timeLagTreeNode.Lag >= dataset.Rows)
    353               return double.NaN;
    354349            double sum = 0.0;
    355350            for (int i = 0; i < Math.Abs(timeLagTreeNode.Lag); i++) {
     
    368363        // y' = 1/8h (f_i + 2f_i-1, -2 f_i-3 - f_i-4)
    369364        case OpCodes.Derivative: {
    370             if (row - 4 < 0) return double.NaN;
    371365            int savedPc = state.ProgramCounter;
    372366            double f_0 = Evaluate(dataset, ref row, state); ; row--;
     
    408402          }
    409403        case OpCodes.Variable: {
     404            if (row < 0 || row >= dataset.Rows)
     405              return double.NaN;
    410406            var variableTreeNode = currentInstr.dynamicNode as VariableTreeNode;
    411407            return dataset[row, currentInstr.iArg0] * variableTreeNode.Weight;
     
    414410            var laggedVariableTreeNode = currentInstr.dynamicNode as LaggedVariableTreeNode;
    415411            int actualRow = row + laggedVariableTreeNode.Lag;
    416             if (actualRow < 0 || actualRow >= dataset.Rows) throw new ArgumentException("Out of range access to dataset row: " + row);
     412            if (actualRow < 0 || actualRow >= dataset.Rows)
     413              return double.NaN;
    417414            return dataset[actualRow, currentInstr.iArg0] * laggedVariableTreeNode.Weight;
    418415          }
     
    425422        //to determine the relative amounts of the true and false branch see http://en.wikipedia.org/wiki/Logistic_function
    426423        case OpCodes.VariableCondition: {
     424            if (row < 0 || row >= dataset.Rows)
     425              return double.NaN;
    427426            var variableConditionTreeNode = (VariableConditionTreeNode)currentInstr.dynamicNode;
    428427            double variableValue = dataset[row, currentInstr.iArg0];
Note: See TracChangeset for help on using the changeset viewer.