Changeset 23 for trunk/sources/HeuristicLab.StructureIdentification/Manipulation/SubstituteSubTreeManipulation.cs
- Timestamp:
- 02/21/08 11:45:52 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.StructureIdentification/Manipulation/SubstituteSubTreeManipulation.cs
r2 r23 41 41 AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In)); 42 42 AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); 43 AddVariableInfo(new VariableInfo("Balance Trees", "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)); 44 44 AddVariableInfo(new VariableInfo("OperatorTree", "The tree to manipulate", typeof(IOperator), VariableKind.In)); 45 45 AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); … … 54 54 int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data; 55 55 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; 57 57 int treeSize = GetVariableValue<IntData>("TreeSize", scope, true).Data; 58 58 int treeHeight = GetVariableValue<IntData>("TreeHeight", scope, true).Data; … … 66 66 67 67 // 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 } 69 75 70 76 if(!gardener.IsValidTree(newOperatorTree)) { … … 100 106 101 107 // 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 } 103 114 104 115 IOperator oldChild = parent.SubOperators[childIndex];
Note: See TracChangeset
for help on using the changeset viewer.