Changeset 5060 for branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionInterpreter.cs
- Timestamp:
- 12/07/10 14:11:12 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionInterpreter.cs
r5052 r5060 71 71 public const byte Integral = 23; 72 72 public const byte Derivative = 24; 73 74 public const byte VariableCondition = 25; 73 75 } 74 76 … … 97 99 { typeof(TimeLag), OpCodes.TimeLag}, 98 100 { typeof(Integral), OpCodes.Integral}, 99 { typeof(Derivative), OpCodes.Derivative} 101 { typeof(Derivative), OpCodes.Derivative}, 102 { typeof(VariableCondition),OpCodes.VariableCondition} 100 103 }; 101 104 private const int ARGUMENT_STACK_SIZE = 1024; … … 147 150 var variableTreeNode = instr.dynamicNode as LaggedVariableTreeNode; 148 151 instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName); 152 } else if (instr.opCode == OpCodes.VariableCondition) { 153 var variableConditionTreeNode = instr.dynamicNode as VariableConditionTreeNode; 154 instr.iArg0 = (ushort)dataset.GetVariableIndex(variableConditionTreeNode.VariableName); 149 155 } 150 156 return instr; … … 344 350 return (f_0 + 2 * f_1 - 2 * f_3 - f_4) / 8; // h = 1 345 351 } 352 353 //mkommend: this symbol uses the logistic function f(x) = 1 / (1 + e^(-alpha * x) ) 354 //to determine the relative amounts of the true and false branch see http://en.wikipedia.org/wiki/Logistic_function 355 case OpCodes.VariableCondition: { 356 var variableConditionTreeNode = (VariableConditionTreeNode)currentInstr.dynamicNode; 357 double variableValue = dataset[row, currentInstr.iArg0]; 358 double x = variableValue - variableConditionTreeNode.Threshold; 359 double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x)); 360 361 double trueBranch = Evaluate(); 362 double falseBranch = Evaluate(); 363 364 return trueBranch * p + falseBranch * (1 - p); 365 } 346 366 default: throw new NotSupportedException(); 347 367 }
Note: See TracChangeset
for help on using the changeset viewer.