Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/29/18 09:44:07 (6 years ago)
Author:
jkarder
Message:

#2839: merged [16057-16091/trunk] into branch

Location:
branches/2839_HiveProjectManagement
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2839_HiveProjectManagement

  • branches/2839_HiveProjectManagement/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/2839_HiveProjectManagement/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/LinearModelToTreeConverter.cs

    r16057 r16092  
    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.