Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/13/10 19:31:02 (15 years ago)
Author:
gkronber
Message:

Fixed bugs in network transformation operator. Added test cases. #833.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Networks/3.2/NetworkToFunctionTransformer.cs

    r2624 r2625  
    9494        return tree;
    9595      } else if (tree.Function is Flip) {
    96         return InvertChain(tree.SubTrees[0]);
     96        if (tree.SubTrees[0].Function is OpenParameter) return tree.SubTrees[0];
     97        else return ApplyFlips(InvertChain(tree.SubTrees[0]));
    9798      } else {
    9899        IFunctionTree tmp = ApplyFlips(tree.SubTrees[0]);
     
    134135      }
    135136      // append open param at the end
    136       invParent.AddSubTree(openParam);
     137      invParent.InsertSubTree(0, openParam);
    137138      return root;
    138139    }
     
    194195    private static IFunctionTree AppendLeft(IFunctionTree tree, IFunctionTree node) {
    195196      IFunctionTree originalTree = tree;
    196       while (tree.SubTrees[0].SubTrees.Count > 0) tree = tree.SubTrees[0];
     197      while (!IsBottomLeft(tree)) tree = tree.SubTrees[0];
    197198      tree.InsertSubTree(0, node);
    198199      return originalTree;
     200    }
     201
     202    private static bool IsBottomLeft(IFunctionTree tree) {
     203      if(tree.SubTrees.Count==0) return true;
     204      else if(tree.SubTrees[0].Function is Variable) return true;
     205      else if(tree.SubTrees[0].Function is Constant) return true;
     206      else return false;
    199207    }
    200208
Note: See TracChangeset for help on using the changeset viewer.