Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/09/10 17:28:32 (14 years ago)
Author:
gkronber
Message:

Added first version of architecture altering operators for ADFs. #290 (Implement ADFs)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/AntInterpreter.cs

    r3239 r3294  
    2121
    2222using System;
     23using System.Linq;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2425using HeuristicLab.Data;
    2526using System.Collections.Generic;
     27using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.GeneralSymbols;
    2628
    2729namespace HeuristicLab.Problems.ArtificialAnt {
     
    8082      // expression evaluated completly => start at root again
    8183      if (nodeStack.Count == 0)
    82         nodeStack.Push(Expression.Root.SubTrees[0]);
     84        nodeStack.Push(Expression.ResultProducingExpression);
    8385      var currentNode = nodeStack.Pop();
    8486      if (currentNode.Symbol is Left) {
     
    112114        nodeStack.Push(currentNode.SubTrees[0]);
    113115        return;
     116      } else if (currentNode.Symbol is InvokeFunction) {
     117        var invokeNode = currentNode as InvokeFunctionTreeNode;
     118        var funBranch = (from node in expression.Root.SubTrees
     119                         let funNode = node as DefunTreeNode
     120                         where funNode != null
     121                         where funNode.Name == invokeNode.InvokedFunctionName
     122                         select funNode).FirstOrDefault();
     123        if (funBranch == null) throw new InvalidOperationException("Can't find definition of function " + invokeNode.InvokedFunctionName);
     124        nodeStack.Push(funBranch.SubTrees[0]);
     125        foreach (var subTree in invokeNode.SubTrees)
     126          nodeStack.Push(subTree);
     127      } else if(currentNode.Symbol is Argument) {
     128        // do nothing
    114129      } else {
    115130        throw new InvalidOperationException(currentNode.Symbol.ToString());
Note: See TracChangeset for help on using the changeset viewer.