Free cookie consent management tool by TermsFeed Policy Generator

Changeset 450 for trunk/sources


Ignore:
Timestamp:
08/05/08 16:31:40 (16 years ago)
Author:
gkronber
Message:

removed the balanced-tree parameter for method CreateRandomTree because it doesn't have an effect (ticket #225)

Location:
trunk/sources/HeuristicLab.StructureIdentification
Files:
2 edited

Legend:

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

    r444 r450  
    240240        if(allowedTrees.Count() == 0) {
    241241          var allowedFunctions = gardener.GetAllowedSubFunctions(parent.Function, slot);
    242           selectedFunctionTrees[slot] = gardener.CreateRandomTree(allowedFunctions, 1, 1, true);
     242          selectedFunctionTrees[slot] = gardener.CreateRandomTree(allowedFunctions, 1, 1);
    243243          newBranches.AddRange(gardener.GetAllSubTrees(selectedFunctionTrees[slot]));
    244244        } else {
  • trunk/sources/HeuristicLab.StructureIdentification/TreeGardener.cs

    r449 r450  
    180180    /// <returns>New random unbalanced tree</returns>
    181181    internal IFunctionTree CreateRandomTree(ICollection<IFunction> allowedFunctions, int maxTreeSize, int maxTreeHeight) {
    182       // default is non-balanced trees
    183       return CreateRandomTree(allowedFunctions, maxTreeSize, maxTreeHeight, false);
    184     }
    185 
    186     /// <summary>
    187     /// Selects a random function from allowedFunctions and creates a (un)balanced random tree with maximal size and height.
    188     /// Max-size and max-height are not accepted as hard constraints, if all functions in the set of allowed functions would
    189     /// lead to a bigger tree then the limits are automatically extended to guarantee that we can build a tree.
    190     /// </summary>
    191     /// <param name="allowedFunctions">Set of allowed functions.</param>
    192     /// <param name="maxTreeSize">Maximal size of the tree (number of nodes).</param>
    193     /// <param name="maxTreeHeight">Maximal height of the tree.</param>
    194     /// <param name="balanceTrees">Flag determining whether the tree should be balanced or not.</param>
    195     /// <returns>New random tree</returns>
    196     internal IFunctionTree CreateRandomTree(ICollection<IFunction> allowedFunctions, int maxTreeSize, int maxTreeHeight, bool balanceTrees) {
    197182      // get the minimal needed height based on allowed functions and extend the max-height if necessary
    198183      int minTreeHeight = allowedFunctions.Select(f => GetMinimalTreeHeight(f)).Min();
     
    215200      // build the tree
    216201      IFunctionTree root;
    217       if(balanceTrees) {
    218         root = PTC2(random, selectedFunction, maxTreeSize -1, maxTreeHeight - 1);
    219       } else {
    220         root = PTC2(random, selectedFunction, maxTreeSize - 1, maxTreeHeight - 1);
    221       }
     202      root = PTC2(random, selectedFunction, maxTreeSize - 1, maxTreeHeight - 1);
    222203      return root;
    223204    }
     
    483464        for(int i = 0; i < actualArity; i++) {
    484465          // first try to find a function that fits into the maxHeight limit
    485           IFunction[] possibleFunctions = GetAllowedSubFunctions(parent, i).Where(f => GetMinimalTreeHeight(f) <= maxTreeHeight && 
     466          IFunction[] possibleFunctions = GetAllowedSubFunctions(parent, i).Where(f => GetMinimalTreeHeight(f) <= maxTreeHeight &&
    486467            !IsTerminal(f)).ToArray();
    487468          // no possible function found => extend function set to terminals
Note: See TracChangeset for help on using the changeset viewer.