Changeset 11205 for branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter
- Timestamp:
- 07/18/14 13:44:53 (10 years ago)
- Location:
- branches/HiveStatistics/sources
- Files:
-
- 6 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/InterpreterState.cs
r11203 r11205 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs
r11203 r11205 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 46 46 public const byte OR = 14; 47 47 public const byte NOT = 15; 48 public const byte XOR = 45; 48 49 49 50 … … 99 100 { typeof(Or), OpCodes.OR }, 100 101 { typeof(Not), OpCodes.NOT}, 102 { typeof(Xor),OpCodes.XOR}, 101 103 { typeof(Average), OpCodes.Average}, 102 104 { typeof(InvokeFunction), OpCodes.Call }, -
branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs
r11203 r11205 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 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; … … 449 449 return; 450 450 } 451 case OpCodes.XOR: { 452 CompileInstructions(il, state, ds); 453 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0); 454 il.Emit(System.Reflection.Emit.OpCodes.Cgt);// > 0 455 456 for (int i = 1; i < nArgs; i++) { 457 CompileInstructions(il, state, ds); 458 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0); 459 il.Emit(System.Reflection.Emit.OpCodes.Cgt);// > 0 460 il.Emit(System.Reflection.Emit.OpCodes.Xor); 461 } 462 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 2.0); // * 2 463 il.Emit(System.Reflection.Emit.OpCodes.Mul); 464 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 1.0); // - 1 465 il.Emit(System.Reflection.Emit.OpCodes.Sub); 466 return; 467 } 451 468 case OpCodes.GT: { 452 469 CompileInstructions(il, state, ds); … … 566 583 VariableTreeNode varNode = (VariableTreeNode)currentInstr.dynamicNode; 567 584 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // load columns array 568 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr. iArg0);585 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr.data); 569 586 // load correct column of the current variable 570 587 il.Emit(System.Reflection.Emit.OpCodes.Ldelem_Ref); … … 600 617 LaggedVariableTreeNode varNode = (LaggedVariableTreeNode)currentInstr.dynamicNode; 601 618 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // load columns array 602 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr. iArg0);619 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr.data); 603 620 // load correct column of the current variable 604 621 il.Emit(System.Reflection.Emit.OpCodes.Ldelem_Ref); -
branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs
r11203 r11205 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 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) { … … 343 343 case OpCodes.NOT: { 344 344 return Evaluate(dataset, ref row, state) > 0.0 ? -1.0 : 1.0; 345 } 346 case OpCodes.XOR: { 347 //mkommend: XOR on multiple inputs is defined as true if the number of positive signals is odd 348 // this is equal to a consecutive execution of binary XOR operations. 349 int positiveSignals = 0; 350 for (int i = 0; i < currentInstr.nArguments; i++) { 351 if (Evaluate(dataset, ref row, state) > 0.0) positiveSignals++; 352 } 353 return positiveSignals % 2 != 0 ? 1.0 : -1.0; 345 354 } 346 355 case OpCodes.GT: { … … 406 415 int savedPc = state.ProgramCounter; 407 416 // set pc to start of function 408 state.ProgramCounter = (ushort)currentInstr. iArg0;417 state.ProgramCounter = (ushort)currentInstr.data; 409 418 // evaluate the function 410 419 double v = Evaluate(dataset, ref row, state); … … 418 427 } 419 428 case OpCodes.Arg: { 420 return state.GetStackFrameValue((ushort)currentInstr. iArg0);429 return state.GetStackFrameValue((ushort)currentInstr.data); 421 430 } 422 431 case OpCodes.Variable: { 423 432 if (row < 0 || row >= dataset.Rows) return double.NaN; 424 433 var variableTreeNode = (VariableTreeNode)currentInstr.dynamicNode; 425 return ((IList<double>)currentInstr. iArg0)[row] * variableTreeNode.Weight;434 return ((IList<double>)currentInstr.data)[row] * variableTreeNode.Weight; 426 435 } 427 436 case OpCodes.LagVariable: { … … 429 438 int actualRow = row + laggedVariableTreeNode.Lag; 430 439 if (actualRow < 0 || actualRow >= dataset.Rows) return double.NaN; 431 return ((IList<double>)currentInstr. iArg0)[actualRow] * laggedVariableTreeNode.Weight;440 return ((IList<double>)currentInstr.data)[actualRow] * laggedVariableTreeNode.Weight; 432 441 } 433 442 case OpCodes.Constant: { … … 441 450 if (row < 0 || row >= dataset.Rows) return double.NaN; 442 451 var variableConditionTreeNode = (VariableConditionTreeNode)currentInstr.dynamicNode; 443 double variableValue = ((IList<double>)currentInstr. iArg0)[row];452 double variableValue = ((IList<double>)currentInstr.data)[row]; 444 453 double x = variableValue - variableConditionTreeNode.Threshold; 445 454 double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x));
Note: See TracChangeset
for help on using the changeset viewer.