Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/21/08 11:45:52 (16 years ago)
Author:
gkronber
Message:

changed boolean variable BalanceTrees to double BalancedTreesRate (ticket #11)

File:
1 edited

Legend:

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

    r2 r23  
    4141      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
    4242      AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
    43       AddVariableInfo(new VariableInfo("BalanceTrees", "Determines if the trees should be balanced", typeof(BoolData), VariableKind.In));
     43      AddVariableInfo(new VariableInfo("BalancedTreesRate", "Determines how many trees should be balanced", typeof(DoubleData), VariableKind.In));
    4444      AddVariableInfo(new VariableInfo("OperatorTree", "The tree to manipulate", typeof(IOperator), VariableKind.In));
    4545      AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
     
    5454      int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data;
    5555      int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data;
    56       bool balanceTrees = GetVariableValue<BoolData>("BalanceTrees", scope, true).Data;
     56      double balancedTreesRate = GetVariableValue<DoubleData>("BalancedTreesRate", scope, true).Data;
    5757      int treeSize = GetVariableValue<IntData>("TreeSize", scope, true).Data;
    5858      int treeHeight = GetVariableValue<IntData>("TreeHeight", scope, true).Data;
     
    6666
    6767        // create a new random operator tree
    68         IOperator newOperatorTree = gardener.CreateRandomTree(gardener.AllOperators, maxTreeSize, maxTreeHeight, balanceTrees);
     68
     69        IOperator newOperatorTree;
     70        if(random.NextDouble() <= balancedTreesRate) {
     71          newOperatorTree = gardener.CreateRandomTree(gardener.AllOperators, maxTreeSize, maxTreeHeight, true);
     72        } else {
     73          newOperatorTree = gardener.CreateRandomTree(gardener.AllOperators, maxTreeSize, maxTreeHeight, false);
     74        }
    6975
    7076        if(!gardener.IsValidTree(newOperatorTree)) {
     
    100106
    101107        // get a random operatorTree
    102         IOperator newOperatorTree = gardener.CreateRandomTree(allowedOperators, maxSubTreeSize, maxSubTreeHeight, balanceTrees);
     108        IOperator newOperatorTree;
     109        if(random.NextDouble() <= balancedTreesRate) {
     110          newOperatorTree = gardener.CreateRandomTree(allowedOperators, maxSubTreeSize, maxSubTreeHeight, true);
     111        } else {
     112          newOperatorTree = gardener.CreateRandomTree(allowedOperators, maxSubTreeSize, maxSubTreeHeight, false);
     113        }
    103114
    104115        IOperator oldChild = parent.SubOperators[childIndex];
Note: See TracChangeset for help on using the changeset viewer.