- Timestamp:
- 05/19/11 13:52:12 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationModel.cs
r5942 r6233 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 using HeuristicLab.Data;27 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Operators;29 using HeuristicLab.Parameters;30 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Optimization;32 using System;33 29 34 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification { … … 149 145 } else { 150 146 var mainBranch = startNode.GetSubtree(0); 147 var product = MakeProduct(mainBranch, beta); 151 148 startNode.RemoveSubtree(0); 152 var scaledMainBranch = MakeSum(MakeProduct(beta, mainBranch), alpha); 149 startNode.AddSubtree(product); 150 151 var scaledMainBranch = MakeSum(product, alpha); 152 startNode.RemoveSubtree(0); 153 153 startNode.AddSubtree(scaledMainBranch); 154 154 } … … 159 159 return treeNode; 160 160 } else { 161 var node = (new Addition()).CreateTreeNode(); 161 var addition = treeNode.Grammar.Symbols.OfType<Addition>().FirstOrDefault(); 162 if (addition == null) addition = new Addition(); 163 var node = addition.CreateTreeNode(); 162 164 var alphaConst = MakeConstant(alpha); 163 165 node.AddSubtree(treeNode); … … 167 169 } 168 170 169 private static ISymbolicExpressionTreeNode MakeProduct( double beta, ISymbolicExpressionTreeNode treeNode) {171 private static ISymbolicExpressionTreeNode MakeProduct(ISymbolicExpressionTreeNode treeNode, double beta) { 170 172 if (beta.IsAlmost(1.0)) { 171 173 return treeNode; 172 174 } else { 173 var node = (new Multiplication()).CreateTreeNode(); 175 var multipliciation = treeNode.Grammar.Symbols.OfType<Multiplication>().FirstOrDefault(); 176 if (multipliciation == null) multipliciation = new Multiplication(); 177 var node = multipliciation.CreateTreeNode(); 174 178 var betaConst = MakeConstant(beta); 175 179 node.AddSubtree(treeNode);
Note: See TracChangeset
for help on using the changeset viewer.