Free cookie consent management tool by TermsFeed Policy Generator

Changeset 285


Ignore:
Timestamp:
06/03/08 13:17:31 (16 years ago)
Author:
gkronber
Message:
  • removed the randomly selected size-limit from the RandomTreeCreator to force a more uniform distribution of tree-heights.
  • added a parameter minimum tree-height
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.StructureIdentification/RandomTreeCreator.cs

    r280 r285  
    3838      AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In));
    3939      AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(GPOperatorLibrary), VariableKind.In));
     40      AddVariableInfo(new VariableInfo("MinTreeHeight", "The minimal allowed height of the tree", typeof(IntData), VariableKind.In));
    4041      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
    41       AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
    4242      AddVariableInfo(new VariableInfo("BalancedTreesRate", "Determines how many trees should be balanced", typeof(DoubleData), VariableKind.In));
    4343      AddVariableInfo(new VariableInfo("FunctionTree", "The created tree", typeof(IFunctionTree), VariableKind.New | VariableKind.Out));
     
    4949      IRandom random = GetVariableValue<IRandom>("Random", scope, true);
    5050      GPOperatorLibrary opLibrary = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true);
     51      int minTreeHeight = GetVariableValue<IntData>("MinTreeHeight", scope, true).Data;
    5152      int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data;
    52       int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data;
    5353      double balancedTreesRate = GetVariableValue<DoubleData>("BalancedTreesRate", scope, true).Data;
    5454
    5555      TreeGardener gardener = new TreeGardener(random, opLibrary);
    5656
    57       int treeHeight = random.Next(1, maxTreeHeight + 1);
    58       int treeSize = random.Next(1, maxTreeSize + 1);
     57      int treeHeight = random.Next(minTreeHeight, maxTreeHeight + 1);
    5958      IFunctionTree root;
    6059      if(random.NextDouble() <= balancedTreesRate) {
    61         root = gardener.CreateBalancedRandomTree(treeSize, treeHeight);
     60        root = gardener.CreateBalancedRandomTree(Int32.MaxValue, treeHeight);
    6261      } else {
    63         root = gardener.CreateUnbalancedRandomTree(treeSize, treeHeight);
     62        root = gardener.CreateUnbalancedRandomTree(Int32.MaxValue, treeHeight);
    6463      }
    6564
     
    7372      if(!gardener.IsValidTree(root)) { throw new InvalidProgramException(); }
    7473
    75       if(actualTreeSize > maxTreeSize ||
    76         actualTreeHeight > maxTreeHeight) {
     74      if(actualTreeHeight > maxTreeHeight) {
    7775        throw new InvalidProgramException();
    7876      }
Note: See TracChangeset for help on using the changeset viewer.