Changeset 5111 for branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs
- Timestamp:
- 12/15/10 23:41:33 (14 years ago)
- Location:
- branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test
- Property svn:ignore
-
old new 1 1 bin 2 2 obj 3 HeuristicLab.MetaOptimization.Test.csproj.user
-
- Property svn:ignore
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs
r5110 r5111 22 22 namespace HeuristicLab.MetaOptimization.Test { 23 23 class Program { 24 private static int metaAlgorithmPopulationSize = 3;24 private static int metaAlgorithmPopulationSize = 50; 25 25 private static int metaAlgorithmMaxGenerations = 30; 26 private static int metaProblemRepetitions = 3;27 28 private static int baseAlgorithmMaxGenerations = 3;26 private static int metaProblemRepetitions = 6; 27 28 private static int baseAlgorithmMaxGenerations = 250; 29 29 30 30 static void Main(string[] args) { … … 34 34 //TestDoubleSampling(); 35 35 //TestTypeDiscovery(); 36 //TestOperators(); 36 37 37 38 GeneticAlgorithm baseLevelAlgorithm = new GeneticAlgorithm(); … … 53 54 54 55 //TestMemoryLeak(metaLevelAlgorithm); 56 57 Console.ReadLine(); 58 } 59 60 private static void TestOperators() { 61 IRandom random = new MersenneTwister(); 62 ParameterConfigurationManipulator manip = new ParameterConfigurationManipulator(); 63 64 manip.IntValueManipulatorParameter.ActualValue = new UniformIntValueManipulator(); 65 manip.DoubleValueManipulatorParameter.ActualValue = new NormalDoubleValueManipulator(); 66 67 var doubleRange = new DoubleValueRange(new DoubleValue(0), new DoubleValue(100), new DoubleValue(0.1)); 68 using (var sw = new StreamWriter("out-DoubleValue.txt")) { 69 for (int i = 0; i < 10000; i++) { 70 var val = new DoubleValue(50); 71 NormalDoubleValueManipulator.ApplyStatic(random, val, doubleRange); 72 73 sw.WriteLine(val); 74 } 75 } 76 77 var percentRange = new PercentValueRange(new PercentValue(0), new PercentValue(1), new PercentValue(0.001)); 78 using (var sw = new StreamWriter("out-PercentValue.txt")) { 79 for (int i = 0; i < 10000; i++) { 80 var val = new PercentValue(0.5); 81 NormalDoubleValueManipulator.ApplyStatic(random, val, percentRange.AsDoubleValueRange()); 82 sw.WriteLine(val); 83 } 84 } 85 86 var intRange = new IntValueRange(new IntValue(0), new IntValue(100), new IntValue(1)); 87 using (var sw = new StreamWriter("out-IntValue.txt")) { 88 for (int i = 0; i < 10000; i++) { 89 var val = new IntValue(50); 90 UniformIntValueManipulator.ApplyStatic(random, val, intRange); 91 sw.WriteLine(val); 92 } 93 } 55 94 56 95 Console.ReadLine(); … … 145 184 for (int i = 0; i < 10; i++) { 146 185 IValueConfiguration clonedVc = (IValueConfiguration)algorithmVc.Clone(); 186 GeneticAlgorithm newAlg = (GeneticAlgorithm)baseLevelAlgorithm.Clone(); 147 187 clonedVc.Randomize(rand); 148 clonedVc.Parameterize((GeneticAlgorithm)clonedVc.ActualValue.Value); 149 GeneticAlgorithm newAlg = (GeneticAlgorithm)clonedVc.ActualValue.Value; 188 clonedVc.Parameterize(newAlg); 150 189 Console.WriteLine(string.Format("PopSize: original: {0}, randomized: {1}", baseLevelAlgorithm.PopulationSize, newAlg.PopulationSize)); 151 190 Console.WriteLine(string.Format("MutRate: original: {0}, randomized: {1}", baseLevelAlgorithm.MutationProbability, newAlg.MutationProbability)); 152 191 Console.WriteLine(string.Format("MutOp: original: {0}, randomized: {1}", baseLevelAlgorithm.Mutator, newAlg.Mutator)); 153 192 Console.WriteLine(string.Format("SelOp: original: {0}, randomized: {1}", baseLevelAlgorithm.Selector, newAlg.Selector)); 154 Console.WriteLine(string.Format("GrSi: original: {0}, randomized: {1}", "?", ((TournamentSelector)newAlg.Selector).GroupSizeParameter.Value));193 //Console.WriteLine(string.Format("GrSi: original: {0}, randomized: {1}", "?", ((TournamentSelector)newAlg.Selector).GroupSizeParameter.Value)); 155 194 Console.WriteLine("---"); 156 195 } … … 162 201 for (int i = 0; i < 10; i++) { 163 202 IValueConfiguration clonedVc = (IValueConfiguration)algorithmVc.Clone(); 164 clonedVc.Mutate(rand); 165 clonedVc.Parameterize((GeneticAlgorithm)clonedVc.ActualValue.Value); 166 GeneticAlgorithm newAlg = (GeneticAlgorithm)clonedVc.ActualValue.Value; 203 GeneticAlgorithm newAlg = (GeneticAlgorithm)baseLevelAlgorithm.Clone(); 204 //clonedVc.Mutate(rand); 205 206 //.Apply(rand, clonedVc); todo 207 clonedVc.Parameterize(newAlg); 167 208 Console.WriteLine(string.Format("PopSize: original: {0}, mutated: {1}", baseLevelAlgorithm.PopulationSize, newAlg.PopulationSize)); 168 209 Console.WriteLine(string.Format("MutRate: original: {0}, mutated: {1}", baseLevelAlgorithm.MutationProbability, newAlg.MutationProbability)); 169 210 Console.WriteLine(string.Format("MutOp: original: {0}, mutated: {1}", baseLevelAlgorithm.Mutator, newAlg.Mutator)); 170 211 Console.WriteLine(string.Format("SelOp: original: {0}, mutated: {1}", baseLevelAlgorithm.Selector, newAlg.Selector)); 171 Console.WriteLine(string.Format("GrSi: original: {0}, mutated: {1}", ((TournamentSelector)baseLevelAlgorithm.Selector).GroupSizeParameter.Value, ((TournamentSelector)newAlg.Selector).GroupSizeParameter.Value));212 //Console.WriteLine(string.Format("GrSi: original: {0}, mutated: {1}", ((TournamentSelector)baseLevelAlgorithm.Selector).GroupSizeParameter.Value, ((TournamentSelector)newAlg.Selector).GroupSizeParameter.Value)); 172 213 Console.WriteLine("---"); 173 214 } … … 179 220 IValueConfiguration clonedVc2 = (IValueConfiguration)algorithmVc.Clone(); 180 221 181 GeneticAlgorithm first = (GeneticAlgorithm) clonedVc1.ActualValue.Value.Clone();182 GeneticAlgorithm second = (GeneticAlgorithm) clonedVc2.ActualValue.Value.Clone();222 GeneticAlgorithm first = (GeneticAlgorithm)baseLevelAlgorithm.Clone(); 223 GeneticAlgorithm second = (GeneticAlgorithm)baseLevelAlgorithm.Clone(); 183 224 184 225 clonedVc1.Randomize(rand); … … 192 233 var mutOpBefore = first.Mutator; 193 234 var selOpBefore = first.Selector; 194 var groupSizeBefore = ((TournamentSelector)first.Selector).GroupSizeParameter.Value.Value;195 196 clonedVc1.Cross(clonedVc2, rand);235 //var groupSizeBefore = ((TournamentSelector)first.Selector).GroupSizeParameter.Value.Value; 236 237 //clonedVc1.Cross(clonedVc2, rand); todo 197 238 clonedVc1.Parameterize(first); 198 239 … … 201 242 Console.WriteLine(string.Format("MutOp: first: {0}, second: {1}, crossed: {2}", mutOpBefore, second.Mutator, first.Mutator)); 202 243 Console.WriteLine(string.Format("SelOp: first: {0}, second: {1}, crossed: {2}", selOpBefore, second.Selector, first.Selector)); 203 Console.WriteLine(string.Format("GrSi: first: {0}, second: {1}, crossed: {2}", groupSizeBefore, ((TournamentSelector)second.Selector).GroupSizeParameter.Value, ((TournamentSelector)first.Selector).GroupSizeParameter.Value));244 //Console.WriteLine(string.Format("GrSi: first: {0}, second: {1}, crossed: {2}", groupSizeBefore, ((TournamentSelector)second.Selector).GroupSizeParameter.Value, ((TournamentSelector)first.Selector).GroupSizeParameter.Value)); 204 245 Console.WriteLine("---"); 205 246 } … … 306 347 sb.AppendLine("================================="); 307 348 349 sb.AppendLine(metaLevelAlgorithm.ExecutionState.ToString()); 308 350 foreach (var result in metaLevelAlgorithm.Results) { 309 351 sb.AppendLine(result.ToString());
Note: See TracChangeset
for help on using the changeset viewer.