Changeset 12264
 Timestamp:
 03/28/15 09:02:13 (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs
r12262 r12264 287 287 // make sum(x0..xn) / n 288 288 var sum = original.Subtrees 289 .Select( x => GetSimplifiedTree(x))290 .Aggregate( (a, b) => MakeSum(a, b));289 .Select(GetSimplifiedTree) 290 .Aggregate(MakeSum); 291 291 return MakeFraction(sum, MakeConstant(original.Subtrees.Count())); 292 292 } … … 299 299 // simplify expressions x0..xn 300 300 // make multiplication (x0 * 1/(x1 * x1 * .. * xn)) 301 var first = original.Subtrees.First(); 302 var remaining = original.Subtrees.Skip(1); 301 var first = original.GetSubtree(0); 302 var second = original.GetSubtree(1); 303 var remaining = original.Subtrees.Skip(2); 303 304 return 304 MakeProduct(GetSimplifiedTree(first), Invert(remaining.Aggregate( (a, b) => MakeProduct(a, GetSimplifiedTree(b)))));305 MakeProduct(GetSimplifiedTree(first), Invert(remaining.Aggregate(GetSimplifiedTree(second), (a, b) => MakeProduct(a, GetSimplifiedTree(b))))); 305 306 } 306 307 } … … 831 832 private void MergeVariablesInSum(ISymbolicExpressionTreeNode sum) { 832 833 var subtrees = new List<ISymbolicExpressionTreeNode>(sum.Subtrees); 833 while (sum.Subtrees. Count() > 0) sum.RemoveSubtree(0);834 while (sum.Subtrees.Any()) sum.RemoveSubtree(0); 834 835 var groupedVarNodes = from node in subtrees.OfType<VariableTreeNode>() 835 836 let lag = (node is LaggedVariableTreeNode) ? ((LaggedVariableTreeNode)node).Lag : 0 … … 949 950 private void MergeVariablesAndConstantsInProduct(ISymbolicExpressionTreeNode prod) { 950 951 var subtrees = new List<ISymbolicExpressionTreeNode>(prod.Subtrees); 951 while (prod.Subtrees. Count() > 0) prod.RemoveSubtree(0);952 while (prod.Subtrees.Any()) prod.RemoveSubtree(0); 952 953 var groupedVarNodes = from node in subtrees.OfType<VariableTreeNode>() 953 954 let lag = (node is LaggedVariableTreeNode) ? ((LaggedVariableTreeNode)node).Lag : 0 … … 1004 1005 } else if (IsAddition(x)) { 1005 1006 // (x0 + x1 + .. + xn) * 1 => (x0 + x1 + .. + xn) 1006 List<ISymbolicExpressionTreeNode>subtrees = new List<ISymbolicExpressionTreeNode>(x.Subtrees);1007 while (x.Subtrees. Count() > 0) x.RemoveSubtree(0);1007 var subtrees = new List<ISymbolicExpressionTreeNode>(x.Subtrees); 1008 while (x.Subtrees.Any()) x.RemoveSubtree(0); 1008 1009 foreach (var subtree in subtrees) { 1009 1010 x.AddSubtree(Negate(subtree));
Note: See TracChangeset
for help on using the changeset viewer.