Changeset 4106 for trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureManipulators/ArgumentDuplicater.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/ArgumentDuplicater.cs
r4068 r4106 25 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols; 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using System.Collections.Generic; 27 28 28 29 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators { … … 80 81 var invocationNodes = from node in symbolicExpressionTree.IterateNodesPrefix().OfType<InvokeFunctionTreeNode>() 81 82 where node.Symbol.FunctionName == selectedDefunBranch.FunctionName 83 where node.SubTrees.Count == selectedDefunBranch.NumberOfArguments 82 84 select node; 83 foreach (var invokeNode in invocationNodes) { 84 var argumentBranch = invokeNode.SubTrees[selectedArgumentSymbol.ArgumentIndex]; 85 var clonedArgumentBranch = (SymbolicExpressionTreeNode)argumentBranch.Clone(); 86 invokeNode.InsertSubTree(newArgumentIndex, clonedArgumentBranch); 85 // do this repeatedly until no matching invocations are found 86 while (invocationNodes.Count() > 0) { 87 List<SymbolicExpressionTreeNode> newlyAddedBranches = new List<SymbolicExpressionTreeNode>(); 88 foreach (var invokeNode in invocationNodes) { 89 var argumentBranch = invokeNode.SubTrees[selectedArgumentSymbol.ArgumentIndex]; 90 var clonedArgumentBranch = (SymbolicExpressionTreeNode)argumentBranch.Clone(); 91 invokeNode.InsertSubTree(newArgumentIndex, clonedArgumentBranch); 92 newlyAddedBranches.Add(clonedArgumentBranch); 93 } 94 invocationNodes = from newlyAddedBranch in newlyAddedBranches 95 from node in newlyAddedBranch.IterateNodesPrefix().OfType<InvokeFunctionTreeNode>() 96 where node.Symbol.FunctionName == selectedDefunBranch.FunctionName 97 where node.SubTrees.Count == selectedDefunBranch.NumberOfArguments 98 select node; 87 99 } 88 100 // register the new argument symbol and increase the number of arguments of the ADF
Note: See TracChangeset
for help on using the changeset viewer.