Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/18/08 16:20:26 (16 years ago)
Author:
gkronber
Message:

added Size and Height properties to interface IFunctionTree and removed the helper methods from TreeGardener (specific implementations of size and height properties in classes implementing IFunctionTree can be more efficient than the general functions in TreeGardener)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.StructureIdentification/Recombination/SizeFairCrossOver.cs

    r238 r324  
    8989
    9090
    91       int newTreeSize = gardener.GetTreeSize(newTree);
    92       int newTreeHeight = gardener.GetTreeHeight(newTree);
     91      int newTreeSize = newTree.Size;
     92      int newTreeHeight = newTree.Height;
    9393      child.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("FunctionTree"), newTree));
    9494      child.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TreeSize"), new IntData(newTreeSize)));
     
    133133
    134134        // recalculate the size and height of tree1 (the one that we want to insert) because we need to check constraints later on
    135         tree1Size = gardener.GetTreeSize(tree1);
    136         tree1Height = gardener.GetTreeHeight(tree1);
     135        tree1Size = tree1.Size;
     136        tree1Height = tree1.Height;
    137137
    138138        List<int> possibleChildIndices = new List<int>();
     
    143143        // find the list of allowed indices (regarding allowed sub-trees, maxTreeSize and maxTreeHeight)
    144144        for(int i = 0; i < tree0.SubTrees.Count; i++) {
    145           int subTreeSize = gardener.GetTreeSize(tree0.SubTrees[i]);
     145          int subTreeSize = tree0.SubTrees[i].Size;
    146146
    147147          // the index is ok when the function is allowed as sub-tree and we don't violate the maxSize and maxHeight constraints
     
    170170            // go down in node2:
    171171            tree1 = tree1.SubTrees[random.Next(tree1.SubTrees.Count)];
    172             tree1Size = gardener.GetTreeSize(tree1);
    173             tree1Height = gardener.GetTreeHeight(tree1);
     172            tree1Size = tree1.Size;
     173            tree1Height = tree1.Height;
    174174          } else {
    175175            // could neither go up or down ... don't know what to do ... give up
     
    180180          possibleChildIndices.Clear();
    181181          for(int i = 0; i < tree0.SubTrees.Count; i++) {
    182             int subTreeSize = gardener.GetTreeSize(tree0.SubTrees[i]);
     182            int subTreeSize = tree0.SubTrees[i].Size;
    183183
    184184            // when the function is allowed as sub-tree and we don't violate the maxSize and maxHeight constraints
Note: See TracChangeset for help on using the changeset viewer.