- Timestamp:
- 05/19/11 13:52:12 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionModel.cs
r5942 r6233 21 21 22 22 using System.Collections.Generic; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 94 95 } else { 95 96 var mainBranch = startNode.GetSubtree(0); 97 var product = MakeProduct(mainBranch, beta); 96 98 startNode.RemoveSubtree(0); 97 var scaledMainBranch = MakeSum(MakeProduct(beta, mainBranch), alpha); 99 startNode.AddSubtree(product); 100 101 var scaledMainBranch = MakeSum(product, alpha); 102 startNode.RemoveSubtree(0); 98 103 startNode.AddSubtree(scaledMainBranch); 99 104 } … … 104 109 return treeNode; 105 110 } else { 106 var node = (new Addition()).CreateTreeNode(); 111 var addition = treeNode.Grammar.Symbols.OfType<Addition>().FirstOrDefault(); 112 if (addition == null) addition = new Addition(); 113 var node = addition.CreateTreeNode(); 107 114 var alphaConst = MakeConstant(alpha); 108 115 node.AddSubtree(treeNode); … … 112 119 } 113 120 114 private static ISymbolicExpressionTreeNode MakeProduct( double beta, ISymbolicExpressionTreeNode treeNode) {121 private static ISymbolicExpressionTreeNode MakeProduct(ISymbolicExpressionTreeNode treeNode, double beta) { 115 122 if (beta.IsAlmost(1.0)) { 116 123 return treeNode; 117 124 } else { 118 var node = (new Multiplication()).CreateTreeNode(); 125 var multipliciation = treeNode.Grammar.Symbols.OfType<Multiplication>().FirstOrDefault(); 126 if (multipliciation == null) multipliciation = new Multiplication(); 127 var node = multipliciation.CreateTreeNode(); 119 128 var betaConst = MakeConstant(beta); 120 129 node.AddSubtree(treeNode); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs
r5975 r6233 75 75 } 76 76 77 private newvoid RecalculateResults() {77 private void RecalculateResults() { 78 78 ModelLength = Model.SymbolicExpressionTree.Length; 79 79 ModelDepth = Model.SymbolicExpressionTree.Depth;
Note: See TracChangeset
for help on using the changeset viewer.