Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/12/11 15:27:58 (14 years ago)
Author:
gkronber
Message:

#1227 Merged changesets r4878 and r4880 from branch into trunk.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/InteractiveSymbolicRegressionSolutionSimplifierView.Designer.cs

    r5445 r5455  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    8181      this.viewHost.Caption = "View";
    8282      this.viewHost.Content = null;
     83      this.viewHost.Enabled = false;
    8384      this.viewHost.Location = new System.Drawing.Point(6, 16);
    8485      this.viewHost.Name = "viewHost";
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/InteractiveSymbolicRegressionSolutionSimplifierView.cs

    r5445 r5455  
    9393
    9494        this.CalculateNodeImpacts(simplifiedExpressionTree, simplifiedExpressionTree.Root.SubTrees[0], originalTrainingMeanSquaredError);
     95        // automatically fold all branches with impact = 1
     96        List<SymbolicExpressionTreeNode> nodeList = simplifiedExpressionTree.Root.SubTrees[0].IterateNodesPrefix().ToList();
     97        foreach (var parent in nodeList) {
     98          for (int subTreeIndex = 0; subTreeIndex < parent.SubTrees.Count; subTreeIndex++) {
     99            var child = parent.SubTrees[subTreeIndex];
     100            if (!(child.Symbol is Constant) && nodeImpacts[child].IsAlmost(1.0)) {
     101              ReplaceNodeWithConstant(parent, subTreeIndex);
     102            }
     103          }
     104        }
    95105        // show only interesting part of solution
    96106        this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0].SubTrees[0]);
     
    158168          SymbolicExpressionTreeNode subTree = treeNode.SubTrees[i];
    159169          if (subTree == visualTreeNode.SymbolicExpressionTreeNode) {
    160             treeNode.RemoveSubTree(i);
    161             if (replacementNodes.ContainsKey(subTree))
    162               treeNode.InsertSubTree(i, replacementNodes[subTree]);
    163             else if (subTree is ConstantTreeNode && replacementNodes.ContainsValue((ConstantTreeNode)subTree))
    164               treeNode.InsertSubTree(i, replacementNodes.Where(v => v.Value == subTree).Single().Key);
    165             else if (!(subTree is ConstantTreeNode))
    166               throw new InvalidOperationException("Could not find replacement value.");
     170            ReplaceNodeWithConstant(treeNode, i);
    167171          }
    168172        }
     
    179183
    180184      this.PaintNodeImpacts();
     185    }
     186
     187    private void ReplaceNodeWithConstant(SymbolicExpressionTreeNode parent, int subTreeIndex) {
     188      SymbolicExpressionTreeNode subTree = parent.SubTrees[subTreeIndex];
     189      parent.RemoveSubTree(subTreeIndex);
     190      if (replacementNodes.ContainsKey(subTree))
     191        parent.InsertSubTree(subTreeIndex, replacementNodes[subTree]);
     192      else if (subTree is ConstantTreeNode && replacementNodes.ContainsValue((ConstantTreeNode)subTree))
     193        parent.InsertSubTree(subTreeIndex, replacementNodes.Where(v => v.Value == subTree).Single().Key);
     194      else if (!(subTree is ConstantTreeNode))
     195        throw new InvalidOperationException("Could not find replacement value.");
    181196    }
    182197
Note: See TracChangeset for help on using the changeset viewer.