Changeset 2447 for trunk/sources
- Timestamp:
- 10/27/09 09:47:03 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 9 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.Operators/3.3/Initialization/ProbabilisticTreeCreator.cs
r2222 r2447 27 27 namespace HeuristicLab.GP.Operators { 28 28 public class ProbabilisticTreeCreator : OperatorBase { 29 private int MAX_TRIES { get { return 100; } }29 private static int MAX_TRIES { get { return 100; } } 30 30 31 31 public override string Description { … … 50 50 int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data; 51 51 52 int treeSize = random.Next(minTreeSize, maxTreeSize + 1); 53 IFunctionTree root; 54 int tries = 0; 55 TreeGardener gardener = new TreeGardener(random, funLibrary); 56 do { 57 root = gardener.PTC2(treeSize, maxTreeHeight); 58 if (tries++ >= MAX_TRIES) { 59 // try a different size 60 treeSize = random.Next(minTreeSize, maxTreeSize + 1); 61 tries = 0; 62 } 63 } while (root.GetSize() > maxTreeSize || root.GetHeight() > maxTreeHeight); 64 52 IFunctionTree root = Create(random, funLibrary, minTreeSize, maxTreeSize, maxTreeHeight); 65 53 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("FunctionTree"), new GeneticProgrammingModel(root))); 66 54 return Util.CreateInitializationOperation(TreeGardener.GetAllSubTrees(root), scope); 67 55 } 68 56 69 } 57 58 public static IFunctionTree Create(IRandom random, FunctionLibrary funLib, int minSize, int maxSize, int maxHeight) { 59 int treeSize = random.Next(minSize, maxSize + 1); 60 IFunctionTree root; 61 int tries = 0; 62 TreeGardener gardener = new TreeGardener(random, funLib); 63 do { 64 root = gardener.PTC2(treeSize, maxHeight); 65 if (tries++ >= MAX_TRIES) { 66 // try a different size 67 treeSize = random.Next(minSize, maxSize + 1); 68 tries = 0; 69 } 70 } while (root.GetSize() > maxHeight || root.GetHeight() > maxHeight); 71 return root; 72 } 73 } 70 74 } -
trunk/sources/HeuristicLab.sln
r2441 r2447 252 252 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALGLIB", "ALGLIB\ALGLIB.csproj", "{44456535-5DB5-454A-BE2B-7426DA6700B6}" 253 253 EndProject 254 Global254 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.GP.Tests", "HeuristicLab.GP.Tests\HeuristicLab.GP.Tests.csproj", "{6EDEE199-61FC-48E1-AEDA-AF1C2E722063}"EndProjectGlobal 255 255 GlobalSection(SolutionConfigurationPlatforms) = preSolution 256 256 CEDMA Debug|Any CPU = CEDMA Debug|Any CPU … … 4013 4013 {44456535-5DB5-454A-BE2B-7426DA6700B6}.Modeling Debug|Any CPU.Build.0 = Debug|Any CPU 4014 4014 {44456535-5DB5-454A-BE2B-7426DA6700B6}.Modeling Debug|x64.ActiveCfg = Debug|Any CPU 4015 {44456535-5DB5-454A-BE2B-7426DA6700B6}.Modeling Debug|x86.ActiveCfg = Debug| Any CPU4016 {44456535-5DB5-454A-BE2B-7426DA6700B6}. Release|Any CPU.ActiveCfg = Release|Any CPU4015 {44456535-5DB5-454A-BE2B-7426DA6700B6}.Modeling Debug|x86.ActiveCfg = Debug|x86 4016 {44456535-5DB5-454A-BE2B-7426DA6700B6}.Modeling Debug|x86.Build.0 = Debug|x86 {44456535-5DB5-454A-BE2B-7426DA6700B6}.Release|Any CPU.ActiveCfg = Release|Any CPU 4017 4017 {44456535-5DB5-454A-BE2B-7426DA6700B6}.Release|Any CPU.Build.0 = Release|Any CPU 4018 4018 {44456535-5DB5-454A-BE2B-7426DA6700B6}.Release|x64.ActiveCfg = Release|x64 … … 4028 4028 {44456535-5DB5-454A-BE2B-7426DA6700B6}.Visualization Debug|x64.ActiveCfg = Debug|Any CPU 4029 4029 {44456535-5DB5-454A-BE2B-7426DA6700B6}.Visualization Debug|x86.ActiveCfg = Debug|Any CPU 4030 EndGlobalSection4030 {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.CEDMA Debug|Any CPU.ActiveCfg = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.CEDMA Debug|Any CPU.Build.0 = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.CEDMA Debug|x64.ActiveCfg = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.CEDMA Debug|x86.ActiveCfg = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Debug|Any CPU.Build.0 = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Debug|x64.ActiveCfg = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Debug|x86.ActiveCfg = Debug|x86 {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Modeling Debug|Any CPU.ActiveCfg = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Modeling Debug|Any CPU.Build.0 = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Modeling Debug|x64.ActiveCfg = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Modeling Debug|x86.ActiveCfg = Debug|x86 {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Release|Any CPU.ActiveCfg = Release|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Release|Any CPU.Build.0 = Release|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Release|x64.ActiveCfg = Release|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Release|x86.ActiveCfg = Release|x86 {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.v3.2 Debug|Any CPU.ActiveCfg = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.v3.2 Debug|Any CPU.Build.0 = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.v3.2 Debug|x64.ActiveCfg = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.v3.2 Debug|x86.ActiveCfg = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Visualization Debug|Any CPU.ActiveCfg = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Visualization Debug|Any CPU.Build.0 = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Visualization Debug|x64.ActiveCfg = Debug|Any CPU {6EDEE199-61FC-48E1-AEDA-AF1C2E722063}.Visualization Debug|x86.ActiveCfg = Debug|Any CPU EndGlobalSection 4031 4031 GlobalSection(SolutionProperties) = preSolution 4032 4032 HideSolutionNode = FALSE … … 4122 4122 {589BECAE-69B0-4EB1-8C06-C073531762B7} = {410732DB-725A-4824-896B-C298978343C0} 4123 4123 {44456535-5DB5-454A-BE2B-7426DA6700B6} = {410732DB-725A-4824-896B-C298978343C0} 4124 { A9E282EA-180F-4233-B809-AEDF0787545C} = {78982D7C-D63D-4A3D-AE1F-F58AC007603B}4124 {6EDEE199-61FC-48E1-AEDA-AF1C2E722063} = {410732DB-725A-4824-896B-C298978343C0} {A9E282EA-180F-4233-B809-AEDF0787545C} = {78982D7C-D63D-4A3D-AE1F-F58AC007603B} 4125 4125 {BF7D9494-A586-457B-8DF9-ED599F9E6A71} = {78982D7C-D63D-4A3D-AE1F-F58AC007603B} 4126 4126 {C36BD924-A541-4A00-AFA8-41701378DDC5} = {78982D7C-D63D-4A3D-AE1F-F58AC007603B}
Note: See TracChangeset
for help on using the changeset viewer.