Changeset 5993 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs
- Timestamp:
- 04/08/11 21:41:53 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs
r5942 r5993 60 60 protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) { 61 61 Dictionary<ISymbolicExpressionTreeNode, double> replacementValues = new Dictionary<ISymbolicExpressionTreeNode, double>(); 62 foreach (ISymbolicExpressionTreeNode node in tree.IterateNodesPrefix()) { 63 if (!(node.Symbol is ProgramRootSymbol || node.Symbol is StartSymbol)) { 64 replacementValues[node] = CalculateReplacementValue(node); 65 } 62 foreach (ISymbolicExpressionTreeNode node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) { 63 replacementValues[node] = CalculateReplacementValue(node, tree); 66 64 } 67 65 return replacementValues; … … 84 82 foreach (ISymbolicExpressionTreeNode node in nodes) { 85 83 var parent = node.Parent; 86 constantNode.Value = CalculateReplacementValue(node );84 constantNode.Value = CalculateReplacementValue(node, tree); 87 85 ISymbolicExpressionTreeNode replacementNode = constantNode; 88 86 SwitchNode(parent, node, replacementNode); … … 100 98 } 101 99 102 private double CalculateReplacementValue(ISymbolicExpressionTreeNode node) { 100 private double CalculateReplacementValue(ISymbolicExpressionTreeNode node, ISymbolicExpressionTree sourceTree) { 101 // remove old ADFs 102 while (tempTree.Root.SubtreesCount > 1) tempTree.Root.RemoveSubtree(1); 103 // clone ADFs of source tree 104 for (int i = 1; i < sourceTree.Root.SubtreesCount; i++) { 105 tempTree.Root.AddSubtree((ISymbolicExpressionTreeNode)sourceTree.Root.GetSubtree(i).Clone()); 106 } 103 107 var start = tempTree.Root.GetSubtree(0); 104 108 while (start.SubtreesCount > 0) start.RemoveSubtree(0);
Note: See TracChangeset
for help on using the changeset viewer.