- Timestamp:
- 08/29/17 18:05:17 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/Push.Thesis/Program.cs
r15341 r15344 9 9 10 10 using HeuristicLab.Algorithms.GeneticAlgorithm; 11 using HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm; 11 12 using HeuristicLab.BenchmarkSuite; 12 13 using HeuristicLab.Clients.Hive; … … 29 30 static void Main(string[] args) { 30 31 //BuildListOfInstructions(); 31 GenerateRuns(); 32 GetProblemNames(); 33 34 //GenerateRuns(); 32 35 //GenerateExperiments(false); 36 //GenerateOffspringRuns(); 37 //GenerateOffspringExperiments(false); 38 33 39 //GenerateHiveHJobs(); 34 40 //GenerateExperimentWithAllProblems(); … … 45 51 } 46 52 53 private static void GetProblemNames() { 54 var provider = new BenchmarkSuiteInstanceProvider(); 55 var descriptors = provider.GetDataDescriptors(); 56 57 var names = descriptors.Select(d => d.Name).OrderBy(x => x).ToList(); 58 var maxLength = names.Max(n => n.Length); 59 names = names.Select(n => n.PadRight(maxLength)).ToList(); 60 61 var result = string.Join(" & & & & \n", names); 62 } 63 47 64 private static void GenerateExperimentWithAllProblems() { 48 65 var provider = new BenchmarkSuiteInstanceProvider(); … … 82 99 83 100 XmlGenerator.Serialize(experiment, $@"C:\tmp\Plush - GA\Experiments\Experiment_{descriptor.Name}.hl"); 101 }); 102 } 103 104 static void GenerateOffspringRuns() { 105 var provider = new BenchmarkSuiteInstanceProvider(); 106 var descriptors = provider.GetDataDescriptors(); 107 108 Parallel.ForEach(descriptors, descriptor => { 109 var benchmarkSuiteProblemDescriptor = (BenchmarkSuiteDataDescriptor)descriptor; 110 var alg = GetOffspringGA(benchmarkSuiteProblemDescriptor); 111 112 XmlGenerator.Serialize(alg, $@"C:\tmp\Plush - Offspring\Runs\{descriptor.Name}.hl"); 113 }); 114 } 115 116 static void GenerateOffspringExperiments(bool parallel = true) { 117 var provider = new BenchmarkSuiteInstanceProvider(); 118 var descriptors = provider.GetDataDescriptors(); 119 120 Parallel.ForEach(descriptors, descriptor => { 121 var benchmarkSuiteProblemDescriptor = (BenchmarkSuiteDataDescriptor)descriptor; 122 var alg = GetOffspringGA(benchmarkSuiteProblemDescriptor, parallel); 123 var experiment = GetExperiment(alg, 50); 124 125 XmlGenerator.Serialize(experiment, $@"C:\tmp\Plush - Offspring\Experiments\Experiment_{descriptor.Name}.hl"); 84 126 }); 85 127 } … … 116 158 Job = 117 159 { 118 Name = "[SFL] [pkimmesw] -" + optimizer.Name,160 Name = "[SFL] " + optimizer.Name, 119 161 ResourceNames = "HEAL;Labs" 120 162 } … … 127 169 128 170 static Experiment GetExperiment(IAlgorithm alg, int repeats) { 129 var experiment = new Experiment( alg.Problem.Name);171 var experiment = new Experiment("[SFL]" + alg.Name); 130 172 experiment.Optimizers.Add(new BatchRun { 131 173 Optimizer = alg, … … 143 185 144 186 pushProblem.Load(problemData); 145 ga.Name = " GA" + pushProblem.Name;187 ga.Name = "[GA]" + pushProblem.Name; 146 188 147 189 ga.Problem = pushProblem; … … 194 236 } 195 237 238 239 static IAlgorithm GetOffspringGA(IBenchmarkSuiteDataDescriptor descriptor, bool parallel = true) { 240 var ga = new OffspringSelectionGeneticAlgorithm(); 241 242 var problemData = descriptor.CreateProblemData(); 243 var pushProblem = new PlushPushBenchmarkSuiteProblem(); 244 245 pushProblem.Load(problemData); 246 ga.Name = "[Offspring GA]" + pushProblem.Name; 247 248 ga.Problem = pushProblem; 249 250 var crossover = ga.CrossoverParameter.ValidValues.OfType<AlternationCrossover>().First(); 251 252 switch (problemData.ProblemType) { 253 case ProblemType.NumberIO: 254 case ProblemType.SmallOrLarge: 255 case ProblemType.Median: 256 case ProblemType.Smallest: 257 crossover.AlignmentDeviation = 5; 258 break; 259 260 default: 261 crossover.AlignmentDeviation = 10; 262 break; 263 } 264 265 crossover.AlternationRate = 0.01; 266 ga.Crossover = crossover; 267 268 ga.Selector = ga.SelectorParameter.ValidValues.OfType<LexicaseSelector>().First(); 269 270 var mutator = ga.MutatorParameter.ValidValues.OfType<UniformMutation>().First(); 271 mutator.InstructionMutationProbability = 0.875; 272 mutator.CloseMutationProbability = 0.125; 273 mutator.CloseIncrementRate = 0.1; 274 ga.Mutator = mutator; 275 276 ga.MutationProbability.Value = 0.8; 277 ga.SetSeedRandomly.Value = true; 278 ga.PopulationSize.Value = 1000; 279 280 ga.MaximumGenerations.Value = problemData.ProgramExecutionBudget / problemData.TrainingCount / 1000; 281 282 var zeroErrorAnalyzer = pushProblem.OperatorsParameter.Value 283 .OfType<IndividualZeroErrorAnalyzer>().SingleOrDefault(); 284 285 if (zeroErrorAnalyzer != null) { 286 zeroErrorAnalyzer.StoreHistoryParameter.Value.Value = true; 287 zeroErrorAnalyzer.UpdateIntervalParameter.Value.Value = 5; 288 } 289 290 ga.ComparisonFactorUpperBound.Value = 0.5; 291 ga.ComparisonFactorLowerBound.Value = 0.5; 292 ga.MaximumSelectionPressure.Value = 100; 293 ga.SuccessRatio.Value = 0.75; 294 295 ga.Engine = parallel 296 ? (IEngine)new ParallelEngine() 297 : (IEngine)new SequentialEngine(); 298 299 return ga; 300 } 301 196 302 static void BuildListOfInstructions() { 197 303 var sb = new StringBuilder();
Note: See TracChangeset
for help on using the changeset viewer.