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.
Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
Files:
2 edited

Legend:

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

    r6732 r6740  
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Core;
     28using HeuristicLab.Data;
    2829using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     30using HeuristicLab.Parameters;
    2931using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    30 using HeuristicLab.Data;
    31 using HeuristicLab.Parameters;
    3232
    3333namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    224224        if (instr.opCode == OpCodes.Variable) {
    225225          var variableTreeNode = instr.dynamicNode as VariableTreeNode;
    226           instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
     226          instr.iArg0 = dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName);
    227227          code[i] = instr;
    228228        } else if (instr.opCode == OpCodes.LagVariable) {
    229229          var variableTreeNode = instr.dynamicNode as LaggedVariableTreeNode;
    230           instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
     230          instr.iArg0 = dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName);
    231231          code[i] = instr;
    232232        } else if (instr.opCode == OpCodes.VariableCondition) {
    233233          var variableConditionTreeNode = instr.dynamicNode as VariableConditionTreeNode;
    234           instr.iArg0 = (ushort)dataset.GetVariableIndex(variableConditionTreeNode.VariableName);
     234          instr.iArg0 = dataset.GetReadOnlyDoubleValues(variableConditionTreeNode.VariableName);
    235235        } else if (instr.opCode == OpCodes.Call) {
    236236          necessaryArgStackSize += instr.nArguments + 1;
     
    468468          }
    469469        case OpCodes.Variable: {
    470             VariableTreeNode varNode = (VariableTreeNode)currentInstr.dynamicNode;
    471             il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // load dataset
    472             il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, 0); // sampleOffset
    473             il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // sampleIndex
    474             il.Emit(System.Reflection.Emit.OpCodes.Add); // row = sampleIndex + sampleOffset
    475             il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, currentInstr.iArg0); // load var
    476             il.Emit(System.Reflection.Emit.OpCodes.Call, datasetGetValue); // dataset.GetValue
    477             il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, varNode.Weight); // load weight
    478             il.Emit(System.Reflection.Emit.OpCodes.Mul);
     470            //VariableTreeNode varNode = (VariableTreeNode)currentInstr.dynamicNode;
     471            //il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // load dataset
     472            //il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, 0); // sampleOffset
     473            //il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // sampleIndex
     474            //il.Emit(System.Reflection.Emit.OpCodes.Add); // row = sampleIndex + sampleOffset
     475            //il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, currentInstr.iArg0); // load var
     476            //il.Emit(System.Reflection.Emit.OpCodes.Call, datasetGetValue); // dataset.GetValue
     477            //il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, varNode.Weight); // load weight
     478            //il.Emit(System.Reflection.Emit.OpCodes.Mul);
    479479            return;
    480480          }
  • 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.