Changeset 4106 for trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureManipulators/ArgumentCreater.cs
- Timestamp:
- 07/26/10 16:18:45 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureManipulators/ArgumentCreater.cs
r4068 r4106 83 83 selectedCutPoint.Parent.RemoveSubTree(selectedCutPoint.ReplacedChildIndex); 84 84 selectedCutPoint.Parent.InsertSubTree(selectedCutPoint.ReplacedChildIndex, newArgNode); 85 85 86 // find all invocations of the selected ADF and attach a cloned version of the replaced branch (with all argument-nodes expanded) 86 87 var invocationNodes = from node in symbolicExpressionTree.IterateNodesPrefix().OfType<InvokeFunctionTreeNode>() 87 88 where node.Symbol.FunctionName == selectedDefunBranch.FunctionName 89 where node.SubTrees.Count == selectedDefunBranch.NumberOfArguments 88 90 select node; 89 foreach (var invocationNode in invocationNodes) { 90 // append a new argument branch after expanding all argument nodes 91 var clonedBranch = (SymbolicExpressionTreeNode)replacedBranch.Clone(); 92 clonedBranch = ReplaceArgumentsInBranch(clonedBranch, invocationNode.SubTrees); 93 invocationNode.InsertSubTree(newArgumentIndex, clonedBranch); 91 // do this repeatedly until no matching invocations are found 92 while (invocationNodes.Count() > 0) { 93 List<SymbolicExpressionTreeNode> newlyAddedBranches = new List<SymbolicExpressionTreeNode>(); 94 foreach (var invocationNode in invocationNodes) { 95 // append a new argument branch after expanding all argument nodes 96 var clonedBranch = (SymbolicExpressionTreeNode)replacedBranch.Clone(); 97 clonedBranch = ReplaceArgumentsInBranch(clonedBranch, invocationNode.SubTrees); 98 invocationNode.InsertSubTree(newArgumentIndex, clonedBranch); 99 newlyAddedBranches.Add(clonedBranch); 100 } 101 invocationNodes = from newlyAddedBranch in newlyAddedBranches 102 from node in newlyAddedBranch.IterateNodesPrefix().OfType<InvokeFunctionTreeNode>() 103 where node.Symbol.FunctionName == selectedDefunBranch.FunctionName 104 where node.SubTrees.Count == selectedDefunBranch.NumberOfArguments 105 select node; 94 106 } 95 107 // increase expected number of arguments of function defining branch
Note: See TracChangeset
for help on using the changeset viewer.