Changeset 16130 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/LinearModelToTreeConverter.cs
- Timestamp:
- 09/10/18 10:05:10 (6 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/LinearModelToTreeConverter.cs
r14843 r16130 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 6Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 37 37 string[] variableNames, double[] coefficients, 38 38 double @const = 0) { 39 39 40 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; 41 44 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; 45 47 } 48 49 // Create tree for string variables 50 ISymbolicExpressionTree factorTree = null; 46 51 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 } 49 55 50 // combine51 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 56 62 throw new ArgumentException(); 57 63 }
Note: See TracChangeset
for help on using the changeset viewer.