Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/29/17 18:05:17 (7 years ago)
Author:
pkimmesw
Message:

#2665 Fixed Integer Overflow Exceptions, Adjusted Offspring Selection Experiments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/Push.Thesis/Program.cs

    r15341 r15344  
    99
    1010  using HeuristicLab.Algorithms.GeneticAlgorithm;
     11  using HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm;
    1112  using HeuristicLab.BenchmarkSuite;
    1213  using HeuristicLab.Clients.Hive;
     
    2930    static void Main(string[] args) {
    3031      //BuildListOfInstructions();
    31       GenerateRuns();
     32      GetProblemNames();
     33
     34      //GenerateRuns();
    3235      //GenerateExperiments(false);
     36      //GenerateOffspringRuns();
     37      //GenerateOffspringExperiments(false);
     38
    3339      //GenerateHiveHJobs();
    3440      //GenerateExperimentWithAllProblems();
     
    4551    }
    4652
     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
    4764    private static void GenerateExperimentWithAllProblems() {
    4865      var provider = new BenchmarkSuiteInstanceProvider();
     
    8299
    83100        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");
    84126      });
    85127    }
     
    116158        Job =
    117159          {
    118             Name = "[SFL][pkimmesw] - " + optimizer.Name,
     160            Name = "[SFL] " + optimizer.Name,
    119161            ResourceNames = "HEAL;Labs"
    120162          }
     
    127169
    128170    static Experiment GetExperiment(IAlgorithm alg, int repeats) {
    129       var experiment = new Experiment(alg.Problem.Name);
     171      var experiment = new Experiment("[SFL]" + alg.Name);
    130172      experiment.Optimizers.Add(new BatchRun {
    131173        Optimizer = alg,
     
    143185
    144186      pushProblem.Load(problemData);
    145       ga.Name = "GA " + pushProblem.Name;
     187      ga.Name = "[GA]" + pushProblem.Name;
    146188
    147189      ga.Problem = pushProblem;
     
    194236    }
    195237
     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
    196302    static void BuildListOfInstructions() {
    197303      var sb = new StringBuilder();
Note: See TracChangeset for help on using the changeset viewer.