- Timestamp:
- 02/12/11 15:27:58 (14 years ago)
- 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 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 81 81 this.viewHost.Caption = "View"; 82 82 this.viewHost.Content = null; 83 this.viewHost.Enabled = false; 83 84 this.viewHost.Location = new System.Drawing.Point(6, 16); 84 85 this.viewHost.Name = "viewHost"; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/InteractiveSymbolicRegressionSolutionSimplifierView.cs
r5445 r5455 93 93 94 94 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 } 95 105 // show only interesting part of solution 96 106 this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0].SubTrees[0]); … … 158 168 SymbolicExpressionTreeNode subTree = treeNode.SubTrees[i]; 159 169 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); 167 171 } 168 172 } … … 179 183 180 184 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."); 181 196 } 182 197
Note: See TracChangeset
for help on using the changeset viewer.