Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9788


Ignore:
Timestamp:
07/26/13 15:01:41 (9 years ago)
Author:
bburlacu
Message:

#2021: Fixed evaluation bug for LaggedVariable symbols.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.DataAnalysis.Symbolic.LinearInterpreter/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs

    r9776 r9788  
    129129
    130130    private static LinearInstruction[] GetPrefixSequence(LinearInstruction[] code, int startIndex) {
    131       var instr = code[startIndex];
    132       var list = new List<LinearInstruction> { instr };
    133       for (int i = 0; i != instr.nArguments; ++i) {
    134         list.AddRange(GetPrefixSequence(code, instr.childIndex + i));
    135       }
    136       return list.ToArray();
     131      Action<LinearInstruction, List<LinearInstruction>> getPrefix = null;
     132      getPrefix = (instr, list) => {
     133        list.Add(instr);
     134        for (int i = 0; i != instr.nArguments; ++i) {
     135          getPrefix(code[instr.childIndex + i], list);
     136        }
     137      };
     138      var l = new List<LinearInstruction>();
     139      getPrefix(code[startIndex], l);
     140      return l.ToArray();
    137141    }
    138142
     
    199203              var laggedVariableTreeNode = (LaggedVariableTreeNode)instr.dynamicNode;
    200204              int actualRow = row + laggedVariableTreeNode.Lag;
    201               if (actualRow < 0 || actualRow >= dataset.Rows) instr.value = double.NaN;
    202               instr.value = ((IList<double>)instr.iArg0)[actualRow] * laggedVariableTreeNode.Weight;
     205              if (actualRow < 0 || actualRow >= dataset.Rows)
     206                instr.value = double.NaN;
     207              else
     208                instr.value = ((IList<double>)instr.iArg0)[actualRow] * laggedVariableTreeNode.Weight;
    203209            }
    204210            break;
Note: See TracChangeset for help on using the changeset viewer.