Changeset 4880 for branches/SymbolicSimplifier
- Timestamp:
- 11/20/10 22:40:45 (14 years ago)
- Location:
- branches/SymbolicSimplifier/HeuristicLab.Problems.DataAnalysis.Views
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/SymbolicSimplifier/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/InteractiveSymbolicRegressionSolutionSimplifierView.Designer.cs
r3927 r4880 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"; -
branches/SymbolicSimplifier/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/InteractiveSymbolicRegressionSolutionSimplifierView.cs
r4477 r4880 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.