Free cookie consent management tool by TermsFeed Policy Generator

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/AntInterpreter.cs

    r5517 r5733  
    5151
    5252    private SymbolicExpressionTreeNode FindMatchingFunction(string name) {
    53       foreach (var defunBranch in expression.Root.SubTrees.OfType<DefunTreeNode>()) {
     53      foreach (var defunBranch in expression.Root.Subtrees.OfType<DefunTreeNode>()) {
    5454        if (defunBranch.FunctionName == name) return defunBranch;
    5555      }
     
    9393      // expression evaluated completly => start at root again
    9494      if (nodeStack.Count == 0) {
    95         nodeStack.Push(Expression.Root.GetSubTree(0).GetSubTree(0));
     95        nodeStack.Push(Expression.Root.GetSubtree(0).GetSubtree(0));
    9696      }
    9797
     
    114114        NextField(out nextAntLocationRow, out nextAntLocationColumn);
    115115        if (World[nextAntLocationRow, nextAntLocationColumn]) {
    116           nodeStack.Push(currentNode.GetSubTree(0));
     116          nodeStack.Push(currentNode.GetSubtree(0));
    117117        } else {
    118           nodeStack.Push(currentNode.GetSubTree(1));
     118          nodeStack.Push(currentNode.GetSubtree(1));
    119119        }
    120120      } else if (currentNode.Symbol is Prog2) {
    121         nodeStack.Push(currentNode.GetSubTree(1));
    122         nodeStack.Push(currentNode.GetSubTree(0));
     121        nodeStack.Push(currentNode.GetSubtree(1));
     122        nodeStack.Push(currentNode.GetSubtree(0));
    123123        return;
    124124      } else if (currentNode.Symbol is Prog3) {
    125         nodeStack.Push(currentNode.GetSubTree(2));
    126         nodeStack.Push(currentNode.GetSubTree(1));
    127         nodeStack.Push(currentNode.GetSubTree(0));
     125        nodeStack.Push(currentNode.GetSubtree(2));
     126        nodeStack.Push(currentNode.GetSubtree(1));
     127        nodeStack.Push(currentNode.GetSubtree(0));
    128128        return;
    129129      } else if (currentNode.Symbol is InvokeFunction) {
     
    131131        var functionDefinition = (SymbolicExpressionTreeNode)FindMatchingFunction(invokeNode.Symbol.FunctionName).Clone();
    132132        var argumentCutPoints = (from node in functionDefinition.IterateNodesPrefix()
    133                                  where node.SubTrees.Count() > 0
    134                                  from subtree in node.SubTrees
     133                                 where node.Subtrees.Count() > 0
     134                                 from subtree in node.Subtrees
    135135                                 where subtree is ArgumentTreeNode
    136                                  select new { Parent = node, Argument = subtree.Symbol as Argument, ChildIndex = node.IndexOfSubTree(subtree) }).ToList();
     136                                 select new { Parent = node, Argument = subtree.Symbol as Argument, ChildIndex = node.IndexOfSubtree(subtree) }).ToList();
    137137        foreach (var cutPoint in argumentCutPoints) {
    138           cutPoint.Parent.RemoveSubTree(cutPoint.ChildIndex);
    139           cutPoint.Parent.InsertSubTree(cutPoint.ChildIndex, (SymbolicExpressionTreeNode)invokeNode.GetSubTree(cutPoint.Argument.ArgumentIndex).Clone());
     138          cutPoint.Parent.RemoveSubtree(cutPoint.ChildIndex);
     139          cutPoint.Parent.InsertSubtree(cutPoint.ChildIndex, (SymbolicExpressionTreeNode)invokeNode.GetSubtree(cutPoint.Argument.ArgumentIndex).Clone());
    140140        }
    141         nodeStack.Push(functionDefinition.GetSubTree(0));
     141        nodeStack.Push(functionDefinition.GetSubtree(0));
    142142      } else {
    143143        throw new InvalidOperationException(currentNode.Symbol.ToString());
Note: See TracChangeset for help on using the changeset viewer.