Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3873


Ignore:
Timestamp:
05/31/10 08:31:29 (14 years ago)
Author:
gkronber
Message:

Removed fields for tree size and tree height in GeneticProgrammingModel instead iterate through the tree to determine the size/height whenever it is needed. #1025 (Incorrect size/height values for trees)

Location:
branches/3.2/sources
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/sources/HeuristicLab.GP.Interfaces/3.3/IGeneticProgrammingModel.cs

    r2222 r3873  
    2828  public interface IGeneticProgrammingModel : IItem {
    2929    IFunctionTree FunctionTree { get; set; }
    30     int Size { get; set; }
    31     int Height { get; set; }
     30    int Size { get; }
     31    int Height { get; }
    3232  }
    3333}
  • branches/3.2/sources/HeuristicLab.GP.Operators/3.3/Manipulation/ChangeNodeTypeManipulation.cs

    r3823 r3873  
    9393          parent.InsertSubTree(selectedChildIndex, newFunctionTree);
    9494        }
    95         // update size and height
    96         gpModel.Size = gpModel.Size - oldChildSize + newChildSize;
    97         gpModel.Height = gpModel.FunctionTree.GetHeight(); // must recalculate height because we can't know wether the manipulated branch was the deepest branch
    9895        // check if whole tree is ok
    9996        Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
  • branches/3.2/sources/HeuristicLab.GP.Operators/3.3/Manipulation/CutOutNodeManipulation.cs

    r2222 r3873  
    8484        parent.InsertSubTree(childIndex, selectedChild);
    8585        Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
    86         // recalculate the size and height of our tree
    87         gpModel.Size = gpModel.FunctionTree.GetSize();
    88         gpModel.Height = gpModel.FunctionTree.GetHeight();
    8986        // don't need to schedule initialization operations
    9087        return null;
     
    10198        parent.InsertSubTree(childIndex, newFunctionTree);
    10299        Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
    103         // recalculate size and height
    104         gpModel.Size = gpModel.FunctionTree.GetSize();
    105         gpModel.Height = gpModel.FunctionTree.GetHeight();
    106100        // schedule an initialization operation for the new function-tree
    107101        return Util.CreateInitializationOperation(TreeGardener.GetAllSubTrees(newFunctionTree), scope);
  • branches/3.2/sources/HeuristicLab.GP.Operators/3.3/Manipulation/DeleteSubTreeManipulation.cs

    r2222 r3873  
    6565
    6666        Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
    67         // recalculate size and height
    68         gpModel.Size = gpModel.FunctionTree.GetSize();
    69         gpModel.Height = gpModel.FunctionTree.GetHeight();
    7067        // root hasn't changed so don't need to update 'FunctionTree' variable
    7168        return null;
     
    7774        parent.InsertSubTree(childIndex, newFunctionTree);
    7875        Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
    79         // recalculate size and height
    80         gpModel.Size = gpModel.FunctionTree.GetSize();
    81         gpModel.Height = gpModel.FunctionTree.GetHeight();
    8276        // return an initialization operation for the newly created tree
    8377        return Util.CreateInitializationOperation(TreeGardener.GetAllSubTrees(newFunctionTree), scope);
  • branches/3.2/sources/HeuristicLab.GP.Operators/3.3/Manipulation/SubstituteSubTreeManipulation.cs

    r2222 r3873  
    7373
    7474        Debug.Assert(gardener.IsValidTree(gpModel.FunctionTree));
    75         // update the values of treeSize and treeHeight
    76         gpModel.Size = gpModel.FunctionTree.GetSize();
    77         gpModel.Height = gpModel.FunctionTree.GetHeight();
    7875        // the root hasn't changed so we don't need to update
    7976        // return a CompositeOperation that randomly initializes all nodes of the new subtree
  • branches/3.2/sources/HeuristicLab.GP/3.3/GeneticProgrammingModel.cs

    r2787 r3873  
    3636      set {
    3737        functionTree = value;
    38         Size = functionTree.GetSize();
    39         Height = functionTree.GetHeight();
    4038      }
    4139    }
    42     public int Size { get; set; }
    43     public int Height { get; set; }
     40    public int Size { get { return functionTree.GetSize(); } }
     41    public int Height { get { return functionTree.GetHeight(); } }
    4442
    4543    public GeneticProgrammingModel()
     
    9997      // check if there is data for the tree node that needs to be restored and restore the data if needed
    10098      var dataNode = fNode.SelectSingleNode("Data");
    101       if (dataNode!=null) tree.Populate(dataNode, restoredObjects);
     99      if (dataNode != null) tree.Populate(dataNode, restoredObjects);
    102100      nodeIndex++;
    103101      for (int i = 0; i < subTrees; i++) {
Note: See TracChangeset for help on using the changeset viewer.