- Timestamp:
- 05/31/10 15:58:04 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SymbolicSimplifier.cs
r3494 r3876 67 67 // return the correct argument sub-tree (already macro-expanded) 68 68 return (SymbolicExpressionTreeNode)argumentTrees[argSym.ArgumentIndex].Clone(); 69 } else if (node.Symbol is StartSymbol) {69 } else if (node.Symbol is StartSymbol) { 70 70 return MacroExpand(root, subtrees[0], argumentTrees); 71 71 } else { … … 136 136 return 137 137 MakeMultiplication(simplifiedTrees.First(), Invert(simplifiedTrees.Skip(1).Aggregate((a, b) => MakeMultiplication(a, b)))); 138 } 139 } else if (IsAverage(original)) { 140 if (original.SubTrees.Count == 1) { 141 return GetSimplifiedTree(original.SubTrees[0]); 142 } else { 143 // simpliy expressions x0..xn 144 // make sum(x0..xn) / n 145 Trace.Assert(original.SubTrees.Count > 1); 146 var sum = original.SubTrees 147 .Select(x => GetSimplifiedTree(x)) 148 .Aggregate((a, b) => MakeAddition(a, b)); 149 return MakeDivision(sum, MakeConstant(original.SubTrees.Count)); 138 150 } 139 151 } else { … … 297 309 } else if (IsConstant(b) && IsAddition(a)) { 298 310 return a.SubTrees.Select(x => MakeMultiplication(x, b)).Aggregate((c, d) => MakeAddition(c, d)); 311 } else if(IsDivision(a) && IsDivision(b)) { 312 return MakeDivision(MakeMultiplication(a.SubTrees[0], b.SubTrees[0]), MakeMultiplication(a.SubTrees[1], b.SubTrees[1])); 299 313 } else if (IsDivision(a)) { 300 314 Trace.Assert(a.SubTrees.Count == 2); … … 351 365 return original.Symbol is Constant; 352 366 } 367 368 private bool IsAverage(SymbolicExpressionTreeNode original) { 369 return original.Symbol is Average; 370 } 353 371 #endregion 354 372
Note: See TracChangeset
for help on using the changeset viewer.