Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/19/11 13:52:12 (14 years ago)
Author:
mkommend
Message:

#1532:

  • Enabled renaming of symbols
  • Fixed cloning of grammers
  • Added readonly attribute in grammars to lock grammars during the algorithm run
  • Removed useless clone method in cloner
  • Changed CheckedItemCollectionViews to enable scrolling during the locked state
File:
1 edited

Legend:

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

    r5942 r6233  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    26 using HeuristicLab.Data;
    2727using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HeuristicLab.Operators;
    29 using HeuristicLab.Parameters;
    3028using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    31 using HeuristicLab.Optimization;
    32 using System;
    3329
    3430namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
     
    149145      } else {
    150146        var mainBranch = startNode.GetSubtree(0);
     147        var product = MakeProduct(mainBranch, beta);
    151148        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);
    153153        startNode.AddSubtree(scaledMainBranch);
    154154      }
     
    159159        return treeNode;
    160160      } 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();
    162164        var alphaConst = MakeConstant(alpha);
    163165        node.AddSubtree(treeNode);
     
    167169    }
    168170
    169     private static ISymbolicExpressionTreeNode MakeProduct(double beta, ISymbolicExpressionTreeNode treeNode) {
     171    private static ISymbolicExpressionTreeNode MakeProduct(ISymbolicExpressionTreeNode treeNode, double beta) {
    170172      if (beta.IsAlmost(1.0)) {
    171173        return treeNode;
    172174      } 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();
    174178        var betaConst = MakeConstant(beta);
    175179        node.AddSubtree(treeNode);
Note: See TracChangeset for help on using the changeset viewer.