Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/22/08 20:28:26 (16 years ago)
Author:
gkronber
Message:

fixed #119

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.StructureIdentification/Manipulation/SubstituteSubTreeManipulation.cs

    r155 r163  
    4242      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
    4343      AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
    44       AddVariableInfo(new VariableInfo("BalancedTreesRate", "Determines how many trees should be balanced", typeof(DoubleData), VariableKind.In));
    4544      AddVariableInfo(new VariableInfo("FunctionTree", "The tree to manipulate", typeof(IFunctionTree), VariableKind.In | VariableKind.Out));
    4645      AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.In | VariableKind.Out));
     
    5453      int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data;
    5554      int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data;
    56       double balancedTreesRate = GetVariableValue<DoubleData>("BalancedTreesRate", scope, true).Data;
    5755      int treeSize = GetVariableValue<IntData>("TreeSize", scope, true).Data;
    5856      int treeHeight = GetVariableValue<IntData>("TreeHeight", scope, true).Data;
    59 
    6057      TreeGardener gardener = new TreeGardener(random, library);
    61 
    6258      IFunctionTree parent = gardener.GetRandomParentNode(root);
    6359      if(parent == null) {
    6460        // parent == null means we should subsitute the whole tree
    6561        // => create a new random tree
    66 
    67         // create a new random function tree
    68         IFunctionTree newTree;
    69         if(random.NextDouble() <= balancedTreesRate) {
    70           newTree = gardener.CreateRandomTree(gardener.AllFunctions, maxTreeSize, maxTreeHeight, true);
    71         } else {
    72           newTree = gardener.CreateRandomTree(gardener.AllFunctions, maxTreeSize, maxTreeHeight, false);
    73         }
    74 
     62        IFunctionTree newTree = gardener.CreateRandomTree(gardener.AllFunctions, maxTreeSize, maxTreeHeight);
    7563        if(!gardener.IsValidTree(newTree)) {
    7664          throw new InvalidProgramException();
     
    9886        // it will be inserted
    9987        int parentLevel = gardener.GetBranchLevel(root, parent);
    100 
    10188        int maxSubTreeHeight = maxTreeHeight - parentLevel;
    10289        int maxSubTreeSize = maxTreeSize - (treeSize - gardener.GetTreeSize(parent.SubTrees[childIndex]));
    10390
    10491        // create a random function tree
    105         IFunctionTree newTree;
    106         if(random.NextDouble() <= balancedTreesRate) {
    107           newTree = gardener.CreateRandomTree(allowedFunctions, maxSubTreeSize, maxSubTreeHeight, true);
    108         } else {
    109           newTree = gardener.CreateRandomTree(allowedFunctions, maxSubTreeSize, maxSubTreeHeight, false);
    110         }
    111 
     92        IFunctionTree newTree = gardener.CreateRandomTree(allowedFunctions, maxSubTreeSize, maxSubTreeHeight);
    11293        parent.RemoveSubTree(childIndex);
    11394        parent.InsertSubTree(childIndex, newTree);
Note: See TracChangeset for help on using the changeset viewer.