Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6234 for trunk/sources


Ignore:
Timestamp:
05/19/11 15:45:34 (14 years ago)
Author:
mkommend
Message:

#1532: Corrected bug in scaling of trees.

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationModel.cs

    r6233 r6234  
    145145      } else {
    146146        var mainBranch = startNode.GetSubtree(0);
    147         var product = MakeProduct(mainBranch, beta);
    148147        startNode.RemoveSubtree(0);
    149         startNode.AddSubtree(product);
    150 
    151         var scaledMainBranch = MakeSum(product, alpha);
    152         startNode.RemoveSubtree(0);
     148        var scaledMainBranch = MakeSum(MakeProduct(mainBranch, beta), alpha);
    153149        startNode.AddSubtree(scaledMainBranch);
    154150      }
     
    159155        return treeNode;
    160156      } else {
    161         var addition = treeNode.Grammar.Symbols.OfType<Addition>().FirstOrDefault();
    162         if (addition == null) addition = new Addition();
     157        var addition = new Addition();
    163158        var node = addition.CreateTreeNode();
    164159        var alphaConst = MakeConstant(alpha);
     
    173168        return treeNode;
    174169      } else {
    175         var multipliciation = treeNode.Grammar.Symbols.OfType<Multiplication>().FirstOrDefault();
    176         if (multipliciation == null) multipliciation = new Multiplication();
     170        var multipliciation = new Multiplication();
    177171        var node = multipliciation.CreateTreeNode();
    178172        var betaConst = MakeConstant(beta);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionModel.cs

    r6233 r6234  
    2121
    2222using System.Collections.Generic;
    23 using System.Linq;
    2423using HeuristicLab.Common;
    2524using HeuristicLab.Core;
     
    9594      } else {
    9695        var mainBranch = startNode.GetSubtree(0);
    97         var product = MakeProduct(mainBranch, beta);
    9896        startNode.RemoveSubtree(0);
    99         startNode.AddSubtree(product);
    100 
    101         var scaledMainBranch = MakeSum(product, alpha);
    102         startNode.RemoveSubtree(0);
     97        var scaledMainBranch = MakeSum(MakeProduct(mainBranch, beta), alpha);
    10398        startNode.AddSubtree(scaledMainBranch);
    10499      }
     
    109104        return treeNode;
    110105      } else {
    111         var addition = treeNode.Grammar.Symbols.OfType<Addition>().FirstOrDefault();
    112         if (addition == null) addition = new Addition();
     106        var addition = new Addition();
    113107        var node = addition.CreateTreeNode();
    114108        var alphaConst = MakeConstant(alpha);
     
    123117        return treeNode;
    124118      } else {
    125         var multipliciation = treeNode.Grammar.Symbols.OfType<Multiplication>().FirstOrDefault();
    126         if (multipliciation == null) multipliciation = new Multiplication();
     119        var multipliciation = new Multiplication();
    127120        var node = multipliciation.CreateTreeNode();
    128121        var betaConst = MakeConstant(beta);
Note: See TracChangeset for help on using the changeset viewer.