Changeset 285 for trunk/sources/HeuristicLab.StructureIdentification
- Timestamp:
- 06/03/08 13:17:31 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.StructureIdentification/RandomTreeCreator.cs
r280 r285 38 38 AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In)); 39 39 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)); 40 41 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));42 42 AddVariableInfo(new VariableInfo("BalancedTreesRate", "Determines how many trees should be balanced", typeof(DoubleData), VariableKind.In)); 43 43 AddVariableInfo(new VariableInfo("FunctionTree", "The created tree", typeof(IFunctionTree), VariableKind.New | VariableKind.Out)); … … 49 49 IRandom random = GetVariableValue<IRandom>("Random", scope, true); 50 50 GPOperatorLibrary opLibrary = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true); 51 int minTreeHeight = GetVariableValue<IntData>("MinTreeHeight", scope, true).Data; 51 52 int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data; 52 int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data;53 53 double balancedTreesRate = GetVariableValue<DoubleData>("BalancedTreesRate", scope, true).Data; 54 54 55 55 TreeGardener gardener = new TreeGardener(random, opLibrary); 56 56 57 int treeHeight = random.Next(1, maxTreeHeight + 1); 58 int treeSize = random.Next(1, maxTreeSize + 1); 57 int treeHeight = random.Next(minTreeHeight, maxTreeHeight + 1); 59 58 IFunctionTree root; 60 59 if(random.NextDouble() <= balancedTreesRate) { 61 root = gardener.CreateBalancedRandomTree( treeSize, treeHeight);60 root = gardener.CreateBalancedRandomTree(Int32.MaxValue, treeHeight); 62 61 } else { 63 root = gardener.CreateUnbalancedRandomTree( treeSize, treeHeight);62 root = gardener.CreateUnbalancedRandomTree(Int32.MaxValue, treeHeight); 64 63 } 65 64 … … 73 72 if(!gardener.IsValidTree(root)) { throw new InvalidProgramException(); } 74 73 75 if(actualTreeSize > maxTreeSize || 76 actualTreeHeight > maxTreeHeight) { 74 if(actualTreeHeight > maxTreeHeight) { 77 75 throw new InvalidProgramException(); 78 76 }
Note: See TracChangeset
for help on using the changeset viewer.