Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/13/17 18:18:37 (7 years ago)
Author:
abeham
Message:

#2701:

  • Tagged unbiased models with property
  • Changed default configuration
  • Added solution distance to breeding, relinking and delinking performance models
  • Changed sampling model to base prediction on average distance in genotype space
  • Changed target for hillclimber and relinking to relative (quality improvement)
  • changed breeding to count cache hits per crossover
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/LinearLinkage/LinearLinkageMemPR.cs

    r14556 r14563  
    3232using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3333using HeuristicLab.PluginInfrastructure;
     34using HeuristicLab.Random;
    3435
    3536namespace HeuristicLab.Algorithms.MemPR.Grouping {
     
    4445      foreach (var trainer in ApplicationManager.Manager.GetInstances<ISolutionModelTrainer<LinearLinkageMemPRPopulationContext>>())
    4546        SolutionModelTrainerParameter.ValidValues.Add(trainer);
    46      
     47
     48      if (SolutionModelTrainerParameter.ValidValues.Count > 0) {
     49        var unbiased = SolutionModelTrainerParameter.ValidValues.FirstOrDefault(x => !x.Bias);
     50        if (unbiased != null) SolutionModelTrainerParameter.Value = unbiased;
     51      }
     52
    4753      foreach (var localSearch in ApplicationManager.Manager.GetInstances<ILocalSearch<LinearLinkageMemPRSolutionContext>>()) {
    4854        LocalSearchParameter.ValidValues.Add(localSearch);
     
    245251      cache.Add(p2.Solution);
    246252
    247       var cachehits = 0;
     253      var cacheHits = new Dictionary<int, int>() { { 0, 0 }, { 1, 0 } };
    248254      var evaluations = 0;
    249255      var probe = Context.ToScope((LinearLinkage)p1.Solution.Clone());
     
    251257      while (evaluations < p1.Solution.Length) {
    252258        LinearLinkage c = null;
    253         if (Context.Random.NextDouble() < 0.8)
    254           c = GroupCrossover.Apply(Context.Random, p1.Solution, p2.Solution);
    255         else c = SinglePointCrossover.Apply(Context.Random, p1.Solution, p2.Solution);
    256        
     259        var xochoice = cacheHits.SampleRandom(Context.Random).Key;
     260        switch (xochoice) {
     261          case 0: c = GroupCrossover.Apply(Context.Random, p1.Solution, p2.Solution); break;
     262          case 1: c = SinglePointCrossover.Apply(Context.Random, p1.Solution, p2.Solution); break;
     263        }
    257264        if (cache.Contains(c)) {
    258           cachehits++;
    259           if (cachehits > 10) break;
     265          cacheHits[xochoice]++;
     266          if (cacheHits[xochoice] > 10) {
     267            cacheHits.Remove(xochoice);
     268            if (cacheHits.Count == 0) break;
     269          }
    260270          continue;
    261271        }
Note: See TracChangeset for help on using the changeset viewer.