Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/23/10 17:12:30 (14 years ago)
Author:
gkronber
Message:

Merged r4458, r4459,r4462,r4464 from data analysis exploration branch into trunk. #1142

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/InteractiveSymbolicRegressionSolutionSimplifierView.cs

    r4068 r4477  
    8383        SymbolicSimplifier simplifier = new SymbolicSimplifier();
    8484        simplifiedExpressionTree = simplifier.Simplify(Content.Model.SymbolicExpressionTree);
    85         SymbolicExpressionTreeNode root = new ProgramRootSymbol().CreateTreeNode();
    86         SymbolicExpressionTreeNode start = new StartSymbol().CreateTreeNode();
    87         root.AddSubTree(start);
    88         start.AddSubTree(simplifiedExpressionTree.Root);
    8985        int samplesStart = Content.ProblemData.TrainingSamplesStart.Value;
    9086        int samplesEnd = Content.ProblemData.TrainingSamplesEnd.Value;
    9187        double originalTrainingMeanSquaredError = SymbolicRegressionMeanSquaredErrorEvaluator.Calculate(
    92             Content.Model.Interpreter, new SymbolicExpressionTree(root), Content.LowerEstimationLimit, Content.UpperEstimationLimit,
     88            Content.Model.Interpreter, simplifiedExpressionTree, Content.LowerEstimationLimit, Content.UpperEstimationLimit,
    9389            Content.ProblemData.Dataset, Content.ProblemData.TargetVariable.Value,
    9490            Enumerable.Range(samplesStart, samplesEnd - samplesStart));
     
    9692        this.CalculateReplacementNodes();
    9793
    98         this.CalculateNodeImpacts(new SymbolicExpressionTree(root), start, originalTrainingMeanSquaredError);
    99         this.treeChart.Tree = simplifiedExpressionTree;
     94        this.CalculateNodeImpacts(simplifiedExpressionTree, simplifiedExpressionTree.Root.SubTrees[0], originalTrainingMeanSquaredError);
     95        // show only interesting part of solution
     96        this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0].SubTrees[0]);
    10097        this.PaintNodeImpacts();
    10198      }
     
    110107      SymbolicExpressionTree tree = new SymbolicExpressionTree(root);
    111108      foreach (SymbolicExpressionTreeNode node in this.simplifiedExpressionTree.IterateNodesPrefix()) {
    112         while (start.SubTrees.Count > 0) start.RemoveSubTree(0);
    113         start.AddSubTree(node);
    114         double constantTreeNodeValue = interpreter.GetSymbolicExpressionTreeValues(tree, Content.ProblemData.Dataset, trainingSamples).Median();
    115         ConstantTreeNode constantTreeNode = MakeConstantTreeNode(constantTreeNodeValue);
    116         replacementNodes[node] = constantTreeNode;
     109        if (!(node.Symbol is ProgramRootSymbol || node.Symbol is StartSymbol)) {
     110          while (start.SubTrees.Count > 0) start.RemoveSubTree(0);
     111          start.AddSubTree(node);
     112          double constantTreeNodeValue = interpreter.GetSymbolicExpressionTreeValues(tree, Content.ProblemData.Dataset, trainingSamples).Median();
     113          ConstantTreeNode constantTreeNode = MakeConstantTreeNode(constantTreeNodeValue);
     114          replacementNodes[node] = constantTreeNode;
     115        }
    117116      }
    118117    }
     
    169168        }
    170169      }
    171       this.treeChart.Tree = simplifiedExpressionTree;
    172 
    173       SymbolicExpressionTreeNode root = new ProgramRootSymbol().CreateTreeNode();
    174       SymbolicExpressionTreeNode start = new StartSymbol().CreateTreeNode();
    175       root.AddSubTree(start);
    176       SymbolicExpressionTree tree = new SymbolicExpressionTree(root);
    177       start.AddSubTree(simplifiedExpressionTree.Root);
     170
     171      // show only interesting part of solution
     172      this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0].SubTrees[0]);
     173
     174      SymbolicExpressionTree tree = (SymbolicExpressionTree)simplifiedExpressionTree.Clone();
    178175
    179176      this.Content.ModelChanged -= new EventHandler(Content_ModelChanged);
     
    189186      double min = impacts.Min();
    190187      foreach (SymbolicExpressionTreeNode treeNode in simplifiedExpressionTree.IterateNodesPostfix()) {
    191         if (!(treeNode is ConstantTreeNode)) {
     188        if (!(treeNode is ConstantTreeNode) && nodeImpacts.ContainsKey(treeNode)) {
    192189          double impact = this.nodeImpacts[treeNode];
    193190          double replacementValue = this.replacementNodes[treeNode].Value;
     
    211208        if (treeNode is ConstantTreeNode && replacementNodes.ContainsValue((ConstantTreeNode)treeNode))
    212209          this.treeChart.GetVisualSymbolicExpressionTreeNode(treeNode).LineColor = Color.DarkOrange;
    213         else
    214           this.treeChart.GetVisualSymbolicExpressionTreeNode(treeNode).LineColor = Color.Black;
     210        else {
     211          VisualSymbolicExpressionTreeNode visNode = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode);
     212          if (visNode != null)
     213            visNode.LineColor = Color.Black;
     214        }
    215215      }
    216216    }
Note: See TracChangeset for help on using the changeset viewer.