Changeset 12262 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs
 Timestamp:
 03/27/15 16:06:31 (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs
r12227 r12262 299 299 // simplify expressions x0..xn 300 300 // make multiplication (x0 * 1/(x1 * x1 * .. * xn)) 301 var simplifiedTrees = original.Subtrees.Select(GetSimplifiedTree).ToArray(); 301 var first = original.Subtrees.First(); 302 var remaining = original.Subtrees.Skip(1); 302 303 return 303 MakeProduct( simplifiedTrees.First(), Invert(simplifiedTrees.Skip(1).Aggregate(MakeProduct)));304 MakeProduct(GetSimplifiedTree(first), Invert(remaining.Aggregate((a, b) => MakeProduct(a, GetSimplifiedTree(b))))); 304 305 } 305 306 } … … 310 311 } else { 311 312 return original.Subtrees 312 .Select(GetSimplifiedTree) .ToArray()313 .Select(GetSimplifiedTree) 313 314 .Aggregate(MakeProduct); 314 315 } … … 321 322 // simplify expressions x0..xn 322 323 // make addition (x0,x1..xn) 323 var simplifiedTrees = original.Subtrees.Select(GetSimplifiedTree).ToArray(); 324 return simplifiedTrees.Take(1) 325 .Concat(simplifiedTrees.Skip(1).Select(Negate)) 326 .Aggregate(MakeSum); 324 var first = original.Subtrees.First(); 325 var remaining = original.Subtrees.Skip(1); 326 return remaining.Aggregate(GetSimplifiedTree(first), (a, b) => MakeSum(a, Negate(GetSimplifiedTree(b)))); 327 327 } 328 328 } … … 335 335 // make addition (x0..xn) 336 336 return original.Subtrees 337 .Select(GetSimplifiedTree) .ToArray()337 .Select(GetSimplifiedTree) 338 338 .Aggregate(MakeSum); 339 339 } … … 345 345 private ISymbolicExpressionTreeNode SimplifyOr(ISymbolicExpressionTreeNode original) { 346 346 return original.Subtrees 347 .Select( x => GetSimplifiedTree(x))348 .Aggregate( (a, b) => MakeOr(a, b));347 .Select(GetSimplifiedTree) 348 .Aggregate(MakeOr); 349 349 } 350 350 private ISymbolicExpressionTreeNode SimplifyAnd(ISymbolicExpressionTreeNode original) { 351 351 return original.Subtrees 352 .Select( x => GetSimplifiedTree(x))353 .Aggregate( (a, b) => MakeAnd(a, b));352 .Select(GetSimplifiedTree) 353 .Aggregate(MakeAnd); 354 354 } 355 355 private ISymbolicExpressionTreeNode SimplifyLessThan(ISymbolicExpressionTreeNode original) {
Note: See TracChangeset
for help on using the changeset viewer.