Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/23/16 09:44:29 (8 years ago)
Author:
gkronber
Message:

#2650: merged r14332:14350 from trunk to branch

Location:
branches/symbreg-factors-2650
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/symbreg-factors-2650

  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs

    r14185 r14351  
    614614        case OpCodes.VariableCondition: {
    615615            var variableConditionTreeNode = (VariableConditionTreeNode)node;
     616            if (variableConditionTreeNode.Symbol.IgnoreSlope) throw new NotSupportedException("Strict variable conditionals are not supported");
    616617            var variableName = variableConditionTreeNode.VariableName;
    617618            var indexExpr = Expression.Constant(variableIndices[variableName]);
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs

    r14251 r14351  
    488488            if (row < 0 || row >= dataset.Rows) return double.NaN;
    489489            var variableConditionTreeNode = (VariableConditionTreeNode)currentInstr.dynamicNode;
    490             double variableValue = ((IList<double>)currentInstr.data)[row];
    491             double x = variableValue - variableConditionTreeNode.Threshold;
    492             double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x));
    493 
    494             double trueBranch = Evaluate(dataset, ref row, state);
    495             double falseBranch = Evaluate(dataset, ref row, state);
    496 
    497             return trueBranch * p + falseBranch * (1 - p);
     490            if (!variableConditionTreeNode.Symbol.IgnoreSlope) {
     491              double variableValue = ((IList<double>)currentInstr.data)[row];
     492              double x = variableValue - variableConditionTreeNode.Threshold;
     493              double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x));
     494
     495              double trueBranch = Evaluate(dataset, ref row, state);
     496              double falseBranch = Evaluate(dataset, ref row, state);
     497
     498              return trueBranch * p + falseBranch * (1 - p);
     499            } else {
     500              // strict threshold
     501              double variableValue = ((IList<double>)currentInstr.data)[row];
     502              if (variableValue <= variableConditionTreeNode.Threshold) {
     503                var left = Evaluate(dataset, ref row, state);
     504                state.SkipInstructions();
     505                return left;
     506              } else {
     507                state.SkipInstructions();
     508                return Evaluate(dataset, ref row, state);
     509              }
     510            }
    498511          }
    499512        default:
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs

    r14330 r14351  
    126126    private readonly object syncRoot = new object();
    127127    public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) {
     128      if (!rows.Any()) return Enumerable.Empty<double>();
    128129      if (CheckExpressionsWithIntervalArithmetic)
    129130        throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter.");
     
    171172          if (row < 0 || row >= dataset.Rows) instr.value = double.NaN;
    172173          var variableConditionTreeNode = (VariableConditionTreeNode)instr.dynamicNode;
    173           double variableValue = ((IList<double>)instr.data)[row];
    174           double x = variableValue - variableConditionTreeNode.Threshold;
    175           double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x));
    176 
    177           double trueBranch = code[instr.childIndex].value;
    178           double falseBranch = code[instr.childIndex + 1].value;
    179 
    180           instr.value = trueBranch * p + falseBranch * (1 - p);
     174          if (!variableConditionTreeNode.Symbol.IgnoreSlope) {
     175            double variableValue = ((IList<double>)instr.data)[row];
     176            double x = variableValue - variableConditionTreeNode.Threshold;
     177            double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x));
     178
     179            double trueBranch = code[instr.childIndex].value;
     180            double falseBranch = code[instr.childIndex + 1].value;
     181
     182            instr.value = trueBranch * p + falseBranch * (1 - p);
     183          } else {
     184            double variableValue = ((IList<double>)instr.data)[row];
     185            if (variableValue <= variableConditionTreeNode.Threshold) {
     186              instr.value = code[instr.childIndex].value;
     187            } else {
     188              instr.value = code[instr.childIndex + 1].value;
     189            }
     190          }
    181191        } else if (instr.opCode == OpCodes.Add) {
    182192          double s = code[instr.childIndex].value;
     
    433443              for (int j = 1; j != seq.Length; ++j)
    434444                seq[j].skip = true;
    435             }
    436             break;
     445              break;
     446            }
    437447        }
    438448        #endregion
Note: See TracChangeset for help on using the changeset viewer.