Changeset 5733 for branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentCreater.cs
- Timestamp:
- 03/17/11 14:07:47 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentCreater.cs
r5686 r5733 124 124 // the branch at the cut point is to be replaced by a new argument node 125 125 var cutPoints = (from node in defunBranch.IterateNodesPrefix() 126 where node.Sub Trees.Count() > 0127 from subtree in node.Sub Trees126 where node.Subtrees.Count() > 0 127 from subtree in node.Subtrees 128 128 select new CutPoint(node, subtree)).ToList(); 129 129 … … 134 134 // replace the branch at the cut point with an argument node 135 135 var replacedBranch = selectedCutPoint.Child; 136 selectedCutPoint.Parent.RemoveSub Tree(selectedCutPoint.ChildIndex);137 selectedCutPoint.Parent.InsertSub Tree(selectedCutPoint.ChildIndex, newArgumentNode);136 selectedCutPoint.Parent.RemoveSubtree(selectedCutPoint.ChildIndex); 137 selectedCutPoint.Parent.InsertSubtree(selectedCutPoint.ChildIndex, newArgumentNode); 138 138 139 139 // find all old invocations of the selected ADF and attach a cloned version of the replaced branch (with all argument-nodes expanded) … … 141 141 var invocationNodes = (from node in tree.IterateNodesPostfix().OfType<InvokeFunctionTreeNode>() 142 142 where node.Symbol.FunctionName == defunBranch.FunctionName 143 where node.Sub Trees.Count() == defunBranch.NumberOfArguments143 where node.Subtrees.Count() == defunBranch.NumberOfArguments 144 144 select node).ToList(); 145 145 // do this repeatedly until no matching invocations are found … … 148 148 foreach (var invocationNode in invocationNodes) { 149 149 // check that the invocation node really has the correct number of arguments 150 if (invocationNode.Sub Trees.Count() != defunBranch.NumberOfArguments) throw new InvalidOperationException();150 if (invocationNode.Subtrees.Count() != defunBranch.NumberOfArguments) throw new InvalidOperationException(); 151 151 // append a new argument branch after expanding all argument nodes 152 152 var clonedBranch = (ISymbolicExpressionTreeNode)replacedBranch.Clone(); 153 clonedBranch = ReplaceArgumentsInBranch(clonedBranch, invocationNode.Sub Trees);154 invocationNode.InsertSub Tree(newArgumentNode.Symbol.ArgumentIndex, clonedBranch);153 clonedBranch = ReplaceArgumentsInBranch(clonedBranch, invocationNode.Subtrees); 154 invocationNode.InsertSubtree(newArgumentNode.Symbol.ArgumentIndex, clonedBranch); 155 155 newlyAddedBranches.Add(clonedBranch); 156 156 } … … 159 159 from node in newlyAddedBranch.IterateNodesPostfix().OfType<InvokeFunctionTreeNode>() 160 160 where node.Symbol.FunctionName == defunBranch.FunctionName 161 where node.Sub Trees.Count() == defunBranch.NumberOfArguments161 where node.Subtrees.Count() == defunBranch.NumberOfArguments 162 162 select node).ToList(); 163 163 } … … 173 173 defunBranch.Grammar.AddAllowedChildSymbol(symb, newArgumentNode.Symbol, i); 174 174 } 175 foreach (var subtree in tree.Root.Sub Trees) {175 foreach (var subtree in tree.Root.Subtrees) { 176 176 // when the changed function is known in the branch then update the number of arguments 177 177 var matchingSymbol = subtree.Grammar.Symbols.OfType<InvokeFunction>().Where(s => s.FunctionName == defunBranch.FunctionName).SingleOrDefault(); … … 196 196 } else { 197 197 // call recursively for all subtree 198 List<ISymbolicExpressionTreeNode> subtrees = new List<ISymbolicExpressionTreeNode>(branch.Sub Trees);199 while (branch.Sub Trees.Count() > 0) branch.RemoveSubTree(0);198 List<ISymbolicExpressionTreeNode> subtrees = new List<ISymbolicExpressionTreeNode>(branch.Subtrees); 199 while (branch.Subtrees.Count() > 0) branch.RemoveSubtree(0); 200 200 foreach (var subtree in subtrees) { 201 branch.AddSub Tree(ReplaceArgumentsInBranch(subtree, argumentTrees));201 branch.AddSubtree(ReplaceArgumentsInBranch(subtree, argumentTrees)); 202 202 } 203 203 return branch;
Note: See TracChangeset
for help on using the changeset viewer.