- Timestamp:
- 07/31/13 14:47:13 (11 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs
r9456 r9828 168 168 if (instr.opCode == OpCodes.Variable) { 169 169 var variableTreeNode = (VariableTreeNode)instr.dynamicNode; 170 instr. iArg0= doubleVariableNames[variableTreeNode.VariableName];170 instr.data = doubleVariableNames[variableTreeNode.VariableName]; 171 171 } else if (instr.opCode == OpCodes.LagVariable) { 172 172 var laggedVariableTreeNode = (LaggedVariableTreeNode)instr.dynamicNode; 173 instr. iArg0= doubleVariableNames[laggedVariableTreeNode.VariableName];173 instr.data = doubleVariableNames[laggedVariableTreeNode.VariableName]; 174 174 } else if (instr.opCode == OpCodes.VariableCondition) { 175 175 var variableConditionTreeNode = (VariableConditionTreeNode)instr.dynamicNode; 176 instr. iArg0= doubleVariableNames[variableConditionTreeNode.VariableName];176 instr.data = doubleVariableNames[variableConditionTreeNode.VariableName]; 177 177 } else if (instr.opCode == OpCodes.Call) { 178 178 necessaryArgStackSize += instr.nArguments + 1; … … 566 566 VariableTreeNode varNode = (VariableTreeNode)currentInstr.dynamicNode; 567 567 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // load columns array 568 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr. iArg0);568 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr.data); 569 569 // load correct column of the current variable 570 570 il.Emit(System.Reflection.Emit.OpCodes.Ldelem_Ref); … … 600 600 LaggedVariableTreeNode varNode = (LaggedVariableTreeNode)currentInstr.dynamicNode; 601 601 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // load columns array 602 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr. iArg0);602 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr.data); 603 603 // load correct column of the current variable 604 604 il.Emit(System.Reflection.Emit.OpCodes.Ldelem_Ref); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs
r9456 r9828 117 117 if (instr.opCode == OpCodes.Variable) { 118 118 var variableTreeNode = (VariableTreeNode)instr.dynamicNode; 119 instr. iArg0= dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName);119 instr.data = dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName); 120 120 } else if (instr.opCode == OpCodes.LagVariable) { 121 121 var laggedVariableTreeNode = (LaggedVariableTreeNode)instr.dynamicNode; 122 instr. iArg0= dataset.GetReadOnlyDoubleValues(laggedVariableTreeNode.VariableName);122 instr.data = dataset.GetReadOnlyDoubleValues(laggedVariableTreeNode.VariableName); 123 123 } else if (instr.opCode == OpCodes.VariableCondition) { 124 124 var variableConditionTreeNode = (VariableConditionTreeNode)instr.dynamicNode; 125 instr. iArg0= dataset.GetReadOnlyDoubleValues(variableConditionTreeNode.VariableName);125 instr.data = dataset.GetReadOnlyDoubleValues(variableConditionTreeNode.VariableName); 126 126 } else if (instr.opCode == OpCodes.Call) { 127 127 necessaryArgStackSize += instr.nArguments + 1; … … 132 132 133 133 134 p rotectedvirtual double Evaluate(Dataset dataset, ref int row, InterpreterState state) {134 public virtual double Evaluate(Dataset dataset, ref int row, InterpreterState state) { 135 135 Instruction currentInstr = state.NextInstruction(); 136 136 switch (currentInstr.opCode) { … … 406 406 int savedPc = state.ProgramCounter; 407 407 // set pc to start of function 408 state.ProgramCounter = (ushort)currentInstr. iArg0;408 state.ProgramCounter = (ushort)currentInstr.data; 409 409 // evaluate the function 410 410 double v = Evaluate(dataset, ref row, state); … … 418 418 } 419 419 case OpCodes.Arg: { 420 return state.GetStackFrameValue((ushort)currentInstr. iArg0);420 return state.GetStackFrameValue((ushort)currentInstr.data); 421 421 } 422 422 case OpCodes.Variable: { 423 423 if (row < 0 || row >= dataset.Rows) return double.NaN; 424 424 var variableTreeNode = (VariableTreeNode)currentInstr.dynamicNode; 425 return ((IList<double>)currentInstr. iArg0)[row] * variableTreeNode.Weight;425 return ((IList<double>)currentInstr.data)[row] * variableTreeNode.Weight; 426 426 } 427 427 case OpCodes.LagVariable: { … … 429 429 int actualRow = row + laggedVariableTreeNode.Lag; 430 430 if (actualRow < 0 || actualRow >= dataset.Rows) return double.NaN; 431 return ((IList<double>)currentInstr. iArg0)[actualRow] * laggedVariableTreeNode.Weight;431 return ((IList<double>)currentInstr.data)[actualRow] * laggedVariableTreeNode.Weight; 432 432 } 433 433 case OpCodes.Constant: { … … 441 441 if (row < 0 || row >= dataset.Rows) return double.NaN; 442 442 var variableConditionTreeNode = (VariableConditionTreeNode)currentInstr.dynamicNode; 443 double variableValue = ((IList<double>)currentInstr. iArg0)[row];443 double variableValue = ((IList<double>)currentInstr.data)[row]; 444 444 double x = variableValue - variableConditionTreeNode.Threshold; 445 445 double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x)); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs
r9826 r9828 73 73 } 74 74 75 private SymbolicDataAnalysisExpressionTreeLinearInterpreter( 76 SymbolicDataAnalysisExpressionTreeLinearInterpreter original, Cloner cloner) 75 private SymbolicDataAnalysisExpressionTreeLinearInterpreter(SymbolicDataAnalysisExpressionTreeLinearInterpreter original, Cloner cloner) 77 76 : base(original, cloner) { 78 interpreter = original.interpreter;77 interpreter = cloner.Clone(original.interpreter); 79 78 } 80 79 … … 90 89 } 91 90 92 private SymbolicDataAnalysisExpressionTreeLinearInterpreter(string name, string description)93 : base(name, description) {94 Parameters.Add(new ValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false)));95 Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));96 interpreter = new SymbolicDataAnalysisExpressionTreeInterpreter();97 }98 99 91 [StorableHook(HookType.AfterDeserialization)] 100 92 private void AfterDeserialization() { 101 if (!Parameters.ContainsKey(EvaluatedSolutionsParameterName))102 Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));103 93 if (interpreter == null) interpreter = new SymbolicDataAnalysisExpressionTreeInterpreter(); 104 94 } 105 95 106 96 #region IStatefulItem 107 108 97 public void InitializeState() { 109 98 EvaluatedSolutions.Value = 0; 110 99 } 111 100 112 public void ClearState() { 113 } 114 101 public void ClearState() { } 115 102 #endregion 116 103
Note: See TracChangeset
for help on using the changeset viewer.