- Timestamp:
- 09/12/11 13:48:31 (13 years ago)
- 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 26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Core; 28 using HeuristicLab.Data; 28 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 30 using HeuristicLab.Parameters; 29 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Data;31 using HeuristicLab.Parameters;32 32 33 33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 224 224 if (instr.opCode == OpCodes.Variable) { 225 225 var variableTreeNode = instr.dynamicNode as VariableTreeNode; 226 instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);226 instr.iArg0 = dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName); 227 227 code[i] = instr; 228 228 } else if (instr.opCode == OpCodes.LagVariable) { 229 229 var variableTreeNode = instr.dynamicNode as LaggedVariableTreeNode; 230 instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);230 instr.iArg0 = dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName); 231 231 code[i] = instr; 232 232 } else if (instr.opCode == OpCodes.VariableCondition) { 233 233 var variableConditionTreeNode = instr.dynamicNode as VariableConditionTreeNode; 234 instr.iArg0 = (ushort)dataset.GetVariableIndex(variableConditionTreeNode.VariableName);234 instr.iArg0 = dataset.GetReadOnlyDoubleValues(variableConditionTreeNode.VariableName); 235 235 } else if (instr.opCode == OpCodes.Call) { 236 236 necessaryArgStackSize += instr.nArguments + 1; … … 468 468 } 469 469 case OpCodes.Variable: { 470 VariableTreeNode varNode = (VariableTreeNode)currentInstr.dynamicNode;471 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // load dataset472 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, 0); // sampleOffset473 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // sampleIndex474 il.Emit(System.Reflection.Emit.OpCodes.Add); // row = sampleIndex + sampleOffset475 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, currentInstr.iArg0); // load var476 il.Emit(System.Reflection.Emit.OpCodes.Call, datasetGetValue); // dataset.GetValue477 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, varNode.Weight); // load weight478 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); 479 479 return; 480 480 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeInterpreter.cs
r6732 r6740 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; 26 using HeuristicLab.Data; 26 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Parameters; 27 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Data;29 using HeuristicLab.Parameters;30 30 31 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 208 208 if (instr.opCode == OpCodes.Variable) { 209 209 var variableTreeNode = instr.dynamicNode as VariableTreeNode; 210 instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);210 instr.iArg0 = dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName); 211 211 code[i] = instr; 212 212 } 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); 215 215 code[i] = instr; 216 216 } else if (instr.opCode == OpCodes.VariableCondition) { 217 217 var variableConditionTreeNode = instr.dynamicNode as VariableConditionTreeNode; 218 instr.iArg0 = (ushort)dataset.GetVariableIndex(variableConditionTreeNode.VariableName);218 instr.iArg0 = dataset.GetReadOnlyDoubleValues(variableConditionTreeNode.VariableName); 219 219 } else if (instr.opCode == OpCodes.Call) { 220 220 necessaryArgStackSize += instr.nArguments + 1; … … 390 390 int savedPc = state.ProgramCounter; 391 391 // set pc to start of function 392 state.ProgramCounter = currentInstr.iArg0;392 state.ProgramCounter = (ushort)currentInstr.iArg0; 393 393 // evaluate the function 394 394 double v = Evaluate(dataset, ref row, state); … … 402 402 } 403 403 case OpCodes.Arg: { 404 return state.GetStackFrameValue( currentInstr.iArg0);404 return state.GetStackFrameValue((ushort)currentInstr.iArg0); 405 405 } 406 406 case OpCodes.Variable: { 407 407 if (row < 0 || row >= dataset.Rows) 408 408 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; 411 411 } 412 412 case OpCodes.LagVariable: { 413 var laggedVariableTreeNode = currentInstr.dynamicNode as LaggedVariableTreeNode;413 var laggedVariableTreeNode = (LaggedVariableTreeNode)currentInstr.dynamicNode; 414 414 int actualRow = row + laggedVariableTreeNode.Lag; 415 415 if (actualRow < 0 || actualRow >= dataset.Rows) 416 416 return double.NaN; 417 return dataset[actualRow, currentInstr.iArg0] * laggedVariableTreeNode.Weight;417 return ((IList<double>)currentInstr.iArg0)[row] * laggedVariableTreeNode.Weight; 418 418 } 419 419 case OpCodes.Constant: { … … 428 428 return double.NaN; 429 429 var variableConditionTreeNode = (VariableConditionTreeNode)currentInstr.dynamicNode; 430 double variableValue = dataset[row, currentInstr.iArg0];430 double variableValue = ((IList<double>)currentInstr.iArg0)[row]; 431 431 double x = variableValue - variableConditionTreeNode.Threshold; 432 432 double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x));
Note: See TracChangeset
for help on using the changeset viewer.