Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/17/11 14:07:47 (13 years ago)
Author:
mkommend
Message:

#1418: Corrected problem interfaces & unified naming of subtrees.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentCreater.cs

    r5686 r5733  
    124124      // the branch at the cut point is to be replaced by a new argument node
    125125      var cutPoints = (from node in defunBranch.IterateNodesPrefix()
    126                        where node.SubTrees.Count() > 0
    127                        from subtree in node.SubTrees
     126                       where node.Subtrees.Count() > 0
     127                       from subtree in node.Subtrees
    128128                       select new CutPoint(node, subtree)).ToList();
    129129
     
    134134      // replace the branch at the cut point with an argument node
    135135      var replacedBranch = selectedCutPoint.Child;
    136       selectedCutPoint.Parent.RemoveSubTree(selectedCutPoint.ChildIndex);
    137       selectedCutPoint.Parent.InsertSubTree(selectedCutPoint.ChildIndex, newArgumentNode);
     136      selectedCutPoint.Parent.RemoveSubtree(selectedCutPoint.ChildIndex);
     137      selectedCutPoint.Parent.InsertSubtree(selectedCutPoint.ChildIndex, newArgumentNode);
    138138
    139139      // find all old invocations of the selected ADF and attach a cloned version of the replaced branch (with all argument-nodes expanded)
     
    141141      var invocationNodes = (from node in tree.IterateNodesPostfix().OfType<InvokeFunctionTreeNode>()
    142142                             where node.Symbol.FunctionName == defunBranch.FunctionName
    143                              where node.SubTrees.Count() == defunBranch.NumberOfArguments
     143                             where node.Subtrees.Count() == defunBranch.NumberOfArguments
    144144                             select node).ToList();
    145145      // do this repeatedly until no matching invocations are found     
     
    148148        foreach (var invocationNode in invocationNodes) {
    149149          // check that the invocation node really has the correct number of arguments
    150           if (invocationNode.SubTrees.Count() != defunBranch.NumberOfArguments) throw new InvalidOperationException();
     150          if (invocationNode.Subtrees.Count() != defunBranch.NumberOfArguments) throw new InvalidOperationException();
    151151          // append a new argument branch after expanding all argument nodes
    152152          var clonedBranch = (ISymbolicExpressionTreeNode)replacedBranch.Clone();
    153           clonedBranch = ReplaceArgumentsInBranch(clonedBranch, invocationNode.SubTrees);
    154           invocationNode.InsertSubTree(newArgumentNode.Symbol.ArgumentIndex, clonedBranch);
     153          clonedBranch = ReplaceArgumentsInBranch(clonedBranch, invocationNode.Subtrees);
     154          invocationNode.InsertSubtree(newArgumentNode.Symbol.ArgumentIndex, clonedBranch);
    155155          newlyAddedBranches.Add(clonedBranch);
    156156        }
     
    159159                           from node in newlyAddedBranch.IterateNodesPostfix().OfType<InvokeFunctionTreeNode>()
    160160                           where node.Symbol.FunctionName == defunBranch.FunctionName
    161                            where node.SubTrees.Count() == defunBranch.NumberOfArguments
     161                           where node.Subtrees.Count() == defunBranch.NumberOfArguments
    162162                           select node).ToList();
    163163      }
     
    173173          defunBranch.Grammar.AddAllowedChildSymbol(symb, newArgumentNode.Symbol, i);
    174174        }
    175       foreach (var subtree in tree.Root.SubTrees) {
     175      foreach (var subtree in tree.Root.Subtrees) {
    176176        // when the changed function is known in the branch then update the number of arguments
    177177        var matchingSymbol = subtree.Grammar.Symbols.OfType<InvokeFunction>().Where(s => s.FunctionName == defunBranch.FunctionName).SingleOrDefault();
     
    196196      } else {
    197197        // call recursively for all subtree
    198         List<ISymbolicExpressionTreeNode> subtrees = new List<ISymbolicExpressionTreeNode>(branch.SubTrees);
    199         while (branch.SubTrees.Count() > 0) branch.RemoveSubTree(0);
     198        List<ISymbolicExpressionTreeNode> subtrees = new List<ISymbolicExpressionTreeNode>(branch.Subtrees);
     199        while (branch.Subtrees.Count() > 0) branch.RemoveSubtree(0);
    200200        foreach (var subtree in subtrees) {
    201           branch.AddSubTree(ReplaceArgumentsInBranch(subtree, argumentTrees));
     201          branch.AddSubtree(ReplaceArgumentsInBranch(subtree, argumentTrees));
    202202        }
    203203        return branch;
Note: See TracChangeset for help on using the changeset viewer.