Changeset 17603
 Timestamp:
 06/16/20 13:37:57 (4 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/VectorTreeSimplifier.cs
r17602 r17603 1399 1399 1400 1400 private ISymbolicExpressionTreeNode MakeSumAggregation(ISymbolicExpressionTreeNode node) { 1401 if (Is Constant(node)) { // assumes scalar constant1401 if (IsScalarNode(node)) { 1402 1402 return node; 1403 1403 } else if (IsAddition(node)  IsSubtraction(node)) { … … 1467 1467 1468 1468 private ISymbolicExpressionTreeNode MakeMeanAggregation(ISymbolicExpressionTreeNode node) { 1469 if (Is Constant(node)) { // assumes scalar constant1469 if (IsScalarNode(node)) { 1470 1470 return node; 1471 1471 } else if (IsAddition(node)  IsSubtraction(node)) { … … 1532 1532 1533 1533 private ISymbolicExpressionTreeNode MakeLengthAggregation(ISymbolicExpressionTreeNode node) { 1534 if (Is Constant(node)) { // assumes scalar constant1534 if (IsScalarNode(node)) { 1535 1535 return MakeConstant(1.0); 1536 1536 } else if (IsAddition(node)  IsSubtraction(node)) { … … 1584 1584 1585 1585 private ISymbolicExpressionTreeNode MakeStandardDeviationAggregation(ISymbolicExpressionTreeNode node) { 1586 if (Is Constant(node)) {1586 if (IsScalarNode(node)) { 1587 1587 return MakeConstant(0.0); 1588 } else if (IsAddition(node)  IsSubtraction(node)) { // scalars drop out 1589 var terms = node.Subtrees; 1590 1591 var scalarTerms = terms.Where(IsScalarNode).ToList(); 1592 var remainingTerms = terms.Except(scalarTerms).ToList(); 1593 1594 if (remainingTerms.Any()) { 1595 var vectorNode = remainingTerms.Aggregate(MakeSum); 1596 1597 var stdevNode = standardDeviationSymbol.CreateTreeNode(); 1598 stdevNode.AddSubtree(vectorNode); 1599 1600 return stdevNode; 1601 } else if (scalarTerms.Any()) { 1602 return MakeConstant(0.0); 1603 } else 1604 throw new InvalidOperationException("Addition does not contain any terms to simplify."); 1588 1605 } else if (IsMultiplication(node)  IsDivision(node)) { 1589 1606 var factors = node.Subtrees; … … 1625 1642 1626 1643 private ISymbolicExpressionTreeNode MakeVarianceAggregation(ISymbolicExpressionTreeNode node) { 1627 if (Is Constant(node)) {1644 if (IsScalarNode(node)) { 1628 1645 return MakeConstant(0.0); 1646 } else if (IsAddition(node)  IsSubtraction(node)) { // scalars drop out 1647 var terms = node.Subtrees; 1648 1649 var scalarTerms = terms.Where(IsScalarNode).ToList(); 1650 var remainingTerms = terms.Except(scalarTerms).ToList(); 1651 1652 if (remainingTerms.Any()) { 1653 var vectorNode = remainingTerms.Aggregate(MakeSum); 1654 1655 var varNode = varianceSymbol.CreateTreeNode(); 1656 varNode.AddSubtree(vectorNode); 1657 1658 return varNode; 1659 } else if (scalarTerms.Any()) { 1660 return MakeConstant(0.0); 1661 } else 1662 throw new InvalidOperationException("Addition does not contain any terms to simplify."); 1629 1663 } else if (IsMultiplication(node)  IsDivision(node)) { 1630 1664 var factors = node.Subtrees;
Note: See TracChangeset
for help on using the changeset viewer.