Free cookie consent management tool by TermsFeed Policy Generator

# Changeset 16085

Ignore:
Timestamp:
08/21/18 16:42:23 (6 years ago)
Message:

#2940: Fixed linear model conversion if only factor variable coefficients are present and slightly refactored in according CreateTree method.

File:
1 edited

Unmodified
Added
Removed
• ## trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/LinearModelToTreeConverter.cs

 r15583 string[] variableNames, double[] coefficients, double @const = 0) { if (factorCoefficients.Length == 0 && coefficients.Length == 0) throw new ArgumentException(); ISymbolicExpressionTree p1 = null; // Create tree for double variables ISymbolicExpressionTree tree = null; if (coefficients.Length > 0) { p1 = CreateTree(variableNames, new int[variableNames.Length], coefficients, @const); if (factorCoefficients.Length == 0) return p1; tree = CreateTree(variableNames, new int[variableNames.Length], coefficients, @const); if (factorCoefficients.Length == 0) return tree; } // Create tree for string variables ISymbolicExpressionTree factorTree = null; if (factorCoefficients.Length > 0) { var p2 = CreateTree(factors, factorCoefficients); if (p1 == null) return p2; factorTree = CreateTree(factors, factorCoefficients, @const); if (tree == null) return factorTree; } // combine ISymbolicExpressionTreeNode add = p1.Root.GetSubtree(0).GetSubtree(0); foreach (var binFactorNode in p2.IterateNodesPrefix().OfType()) add.AddSubtree(binFactorNode); return p1; } // Combine both trees ISymbolicExpressionTreeNode add = tree.Root.GetSubtree(0).GetSubtree(0); foreach (var binFactorNode in factorTree.IterateNodesPrefix().OfType()) add.InsertSubtree(add.SubtreeCount - 1, binFactorNode); return tree; throw new ArgumentException(); }
Note: See TracChangeset for help on using the changeset viewer.