Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/20/18 15:05:36 (6 years ago)
Author:
gkronber
Message:

#2940: merged r16085 from trunk to stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/LinearModelToTreeConverter.cs

    r15584 r16166  
    3737      string[] variableNames, double[] coefficients,
    3838      double @const = 0) {
     39
    3940      if (factorCoefficients.Length == 0 && coefficients.Length == 0) throw new ArgumentException();
    40       ISymbolicExpressionTree p1 = null;
     41
     42      // Create tree for double variables
     43      ISymbolicExpressionTree tree = null;     
    4144      if (coefficients.Length > 0) {
    42         p1 = CreateTree(variableNames, new int[variableNames.Length], coefficients, @const);
    43         if (factorCoefficients.Length == 0)
    44           return p1;
     45        tree = CreateTree(variableNames, new int[variableNames.Length], coefficients, @const);
     46        if (factorCoefficients.Length == 0) return tree;
    4547      }
     48
     49      // Create tree for string variables
     50      ISymbolicExpressionTree factorTree = null;     
    4651      if (factorCoefficients.Length > 0) {
    47         var p2 = CreateTree(factors, factorCoefficients);
    48         if (p1 == null) return p2;
     52        factorTree = CreateTree(factors, factorCoefficients, @const);
     53        if (tree == null) return factorTree; 
     54      }
    4955
    50         // combine
    51         ISymbolicExpressionTreeNode add = p1.Root.GetSubtree(0).GetSubtree(0);
    52         foreach (var binFactorNode in p2.IterateNodesPrefix().OfType<BinaryFactorVariableTreeNode>())
    53           add.AddSubtree(binFactorNode);
    54         return p1;
    55       }
     56      // Combine both trees
     57      ISymbolicExpressionTreeNode add = tree.Root.GetSubtree(0).GetSubtree(0);
     58      foreach (var binFactorNode in factorTree.IterateNodesPrefix().OfType<BinaryFactorVariableTreeNode>())
     59        add.InsertSubtree(add.SubtreeCount - 1, binFactorNode);
     60      return tree;
     61
    5662      throw new ArgumentException();
    5763    }
Note: See TracChangeset for help on using the changeset viewer.