- Timestamp:
- 10/21/16 17:59:36 (8 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs
r14185 r14345 614 614 case OpCodes.VariableCondition: { 615 615 var variableConditionTreeNode = (VariableConditionTreeNode)node; 616 if (variableConditionTreeNode.Symbol.IgnoreSlope) throw new NotSupportedException("Strict variable conditionals are not supported"); 616 617 var variableName = variableConditionTreeNode.VariableName; 617 618 var indexExpr = Expression.Constant(variableIndices[variableName]); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs
r14185 r14345 471 471 if (row < 0 || row >= dataset.Rows) return double.NaN; 472 472 var variableConditionTreeNode = (VariableConditionTreeNode)currentInstr.dynamicNode; 473 double variableValue = ((IList<double>)currentInstr.data)[row]; 474 double x = variableValue - variableConditionTreeNode.Threshold; 475 double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x)); 476 477 double trueBranch = Evaluate(dataset, ref row, state); 478 double falseBranch = Evaluate(dataset, ref row, state); 479 480 return trueBranch * p + falseBranch * (1 - p); 473 if (!variableConditionTreeNode.Symbol.IgnoreSlope) { 474 double variableValue = ((IList<double>)currentInstr.data)[row]; 475 double x = variableValue - variableConditionTreeNode.Threshold; 476 double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x)); 477 478 double trueBranch = Evaluate(dataset, ref row, state); 479 double falseBranch = Evaluate(dataset, ref row, state); 480 481 return trueBranch * p + falseBranch * (1 - p); 482 } else { 483 // strict threshold 484 double variableValue = ((IList<double>)currentInstr.data)[row]; 485 if (variableValue <= variableConditionTreeNode.Threshold) { 486 var left = Evaluate(dataset, ref row, state); 487 state.SkipInstructions(); 488 return left; 489 } else { 490 state.SkipInstructions(); 491 return Evaluate(dataset, ref row, state); 492 } 493 } 481 494 } 482 495 default: -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs
r14282 r14345 126 126 private readonly object syncRoot = new object(); 127 127 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) { 128 if (!rows.Any()) return Enumerable.Empty<double>(); 128 129 if (CheckExpressionsWithIntervalArithmetic) 129 130 throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter."); … … 159 160 if (row < 0 || row >= dataset.Rows) instr.value = double.NaN; 160 161 var variableConditionTreeNode = (VariableConditionTreeNode)instr.dynamicNode; 161 double variableValue = ((IList<double>)instr.data)[row]; 162 double x = variableValue - variableConditionTreeNode.Threshold; 163 double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x)); 164 165 double trueBranch = code[instr.childIndex].value; 166 double falseBranch = code[instr.childIndex + 1].value; 167 168 instr.value = trueBranch * p + falseBranch * (1 - p); 162 if (!variableConditionTreeNode.Symbol.IgnoreSlope) { 163 double variableValue = ((IList<double>)instr.data)[row]; 164 double x = variableValue - variableConditionTreeNode.Threshold; 165 double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x)); 166 167 double trueBranch = code[instr.childIndex].value; 168 double falseBranch = code[instr.childIndex + 1].value; 169 170 instr.value = trueBranch * p + falseBranch * (1 - p); 171 } else { 172 double variableValue = ((IList<double>)instr.data)[row]; 173 if (variableValue <= variableConditionTreeNode.Threshold) { 174 instr.value = code[instr.childIndex].value; 175 } else { 176 instr.value = code[instr.childIndex + 1].value; 177 } 178 } 169 179 } else if (instr.opCode == OpCodes.Add) { 170 180 double s = code[instr.childIndex].value; … … 411 421 for (int j = 1; j != seq.Length; ++j) 412 422 seq[j].skip = true; 413 }414 break;423 break; 424 } 415 425 } 416 426 #endregion
Note: See TracChangeset
for help on using the changeset viewer.