Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/12/11 13:48:31 (13 years ago)
Author:
mkommend
Message:

#1597, #1609, #1640:

  • Corrected TableFileParser to handle empty rows correctly.
  • Refactored DataSet to store values in List<List> instead of a two-dimensional array.
  • Enable importing and storing string and datetime values.
  • Changed data access methods in dataset and adapted all concerning classes.
  • Changed interpreter to store the variable values for all rows during the compilation step.
File:
1 edited

Legend:

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

    r6732 r6740  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
     26using HeuristicLab.Data;
    2627using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     28using HeuristicLab.Parameters;
    2729using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using HeuristicLab.Data;
    29 using HeuristicLab.Parameters;
    3030
    3131namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    208208        if (instr.opCode == OpCodes.Variable) {
    209209          var variableTreeNode = instr.dynamicNode as VariableTreeNode;
    210           instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
     210          instr.iArg0 = dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName);
    211211          code[i] = instr;
    212212        } else if (instr.opCode == OpCodes.LagVariable) {
    213           var variableTreeNode = instr.dynamicNode as LaggedVariableTreeNode;
    214           instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
     213          var laggedVariableTreeNode = instr.dynamicNode as LaggedVariableTreeNode;
     214          instr.iArg0 = dataset.GetReadOnlyDoubleValues(laggedVariableTreeNode.VariableName);
    215215          code[i] = instr;
    216216        } else if (instr.opCode == OpCodes.VariableCondition) {
    217217          var variableConditionTreeNode = instr.dynamicNode as VariableConditionTreeNode;
    218           instr.iArg0 = (ushort)dataset.GetVariableIndex(variableConditionTreeNode.VariableName);
     218          instr.iArg0 = dataset.GetReadOnlyDoubleValues(variableConditionTreeNode.VariableName);
    219219        } else if (instr.opCode == OpCodes.Call) {
    220220          necessaryArgStackSize += instr.nArguments + 1;
     
    390390            int savedPc = state.ProgramCounter;
    391391            // set pc to start of function 
    392             state.ProgramCounter = currentInstr.iArg0;
     392            state.ProgramCounter = (ushort)currentInstr.iArg0;
    393393            // evaluate the function
    394394            double v = Evaluate(dataset, ref row, state);
     
    402402          }
    403403        case OpCodes.Arg: {
    404             return state.GetStackFrameValue(currentInstr.iArg0);
     404            return state.GetStackFrameValue((ushort)currentInstr.iArg0);
    405405          }
    406406        case OpCodes.Variable: {
    407407            if (row < 0 || row >= dataset.Rows)
    408408              return double.NaN;
    409             var variableTreeNode = currentInstr.dynamicNode as VariableTreeNode;
    410             return dataset[row, currentInstr.iArg0] * variableTreeNode.Weight;
     409            var variableTreeNode = (VariableTreeNode)currentInstr.dynamicNode;
     410            return ((IList<double>)currentInstr.iArg0)[row] * variableTreeNode.Weight;
    411411          }
    412412        case OpCodes.LagVariable: {
    413             var laggedVariableTreeNode = currentInstr.dynamicNode as LaggedVariableTreeNode;
     413            var laggedVariableTreeNode = (LaggedVariableTreeNode)currentInstr.dynamicNode;
    414414            int actualRow = row + laggedVariableTreeNode.Lag;
    415415            if (actualRow < 0 || actualRow >= dataset.Rows)
    416416              return double.NaN;
    417             return dataset[actualRow, currentInstr.iArg0] * laggedVariableTreeNode.Weight;
     417            return ((IList<double>)currentInstr.iArg0)[row] * laggedVariableTreeNode.Weight;
    418418          }
    419419        case OpCodes.Constant: {
     
    428428              return double.NaN;
    429429            var variableConditionTreeNode = (VariableConditionTreeNode)currentInstr.dynamicNode;
    430             double variableValue = dataset[row, currentInstr.iArg0];
     430            double variableValue = ((IList<double>)currentInstr.iArg0)[row];
    431431            double x = variableValue - variableConditionTreeNode.Threshold;
    432432            double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x));
Note: See TracChangeset for help on using the changeset viewer.