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/Permutation/PermutationMemPR.cs

    r14556 r14563  
    5252      foreach (var trainer in ApplicationManager.Manager.GetInstances<ISolutionModelTrainer<PermutationMemPRPopulationContext>>())
    5353        SolutionModelTrainerParameter.ValidValues.Add(trainer);
    54      
     54
     55      if (SolutionModelTrainerParameter.ValidValues.Count > 0) {
     56        var unbiased = SolutionModelTrainerParameter.ValidValues.FirstOrDefault(x => !x.Bias);
     57        if (unbiased != null) SolutionModelTrainerParameter.Value = unbiased;
     58      }
     59
    5560      foreach (var localSearch in ApplicationManager.Manager.GetInstances<ILocalSearch<PermutationMemPRSolutionContext>>()) {
    5661        LocalSearchParameter.ValidValues.Add(localSearch);
     
    290295        InversionMove bestOfTheRest = null;
    291296        var improved = false;
    292 
     297       
    293298        foreach (var opt in ExhaustiveInversionMoveGenerator.Generate(current).Shuffle(random)) {
    294299          var prev = opt.Index1 - 1;
     
    395400      cache.Add(p2.Solution);
    396401
    397       var cacheHits = 0;
     402      var cacheHits = new Dictionary<int, int>() { { 0, 0 }, { 1, 0 }, { 2, 0 } };
    398403      var evaluations = 0;
    399404      ISingleObjectiveSolutionScope<Encodings.PermutationEncoding.Permutation> offspring = null;
     
    401406      while (evaluations < p1.Solution.Length) {
    402407        Encodings.PermutationEncoding.Permutation c = null;
    403         var xochoice = Context.Random.Next(3);
     408        var xochoice = cacheHits.SampleRandom(Context.Random).Key;
    404409        switch (xochoice) {
    405410          case 0: c = CyclicCrossover2.Apply(Context.Random, p1.Solution, p2.Solution); break;
     
    408413        }
    409414        if (cache.Contains(c)) {
    410           cacheHits++;
    411           if (cacheHits > 10) break;
     415          cacheHits[xochoice]++;
     416          if (cacheHits[xochoice] > 10) {
     417            cacheHits.Remove(xochoice);
     418            if (cacheHits.Count == 0) break;
     419          }
    412420          continue;
    413421        }
     
    431439      cache.Add(p2.Solution);
    432440
    433       var cacheHits = 0;
     441      var cacheHits = new Dictionary<int, int>() { { 0, 0 }, { 1, 0 }, { 2, 0 } };
    434442      var evaluations = 0;
    435443      ISingleObjectiveSolutionScope<Encodings.PermutationEncoding.Permutation> offspring = null;
     
    437445      while (evaluations < p1.Solution.Length) {
    438446        Encodings.PermutationEncoding.Permutation c = null;
    439         var xochoice = Context.Random.Next(3);
     447        var xochoice = cacheHits.SampleRandom(Context.Random).Key;
    440448        switch (xochoice) {
    441449          case 0: c = OrderCrossover2.Apply(Context.Random, p1.Solution, p2.Solution); break;
     
    444452        }
    445453        if (cache.Contains(c)) {
    446           cacheHits++;
    447           if (cacheHits > 10) break;
     454          cacheHits[xochoice]++;
     455          if (cacheHits[xochoice] > 10) {
     456            cacheHits.Remove(xochoice);
     457            if (cacheHits.Count == 0) break;
     458          }
    448459          continue;
    449460        }
     
    467478      cache.Add(p2.Solution);
    468479
    469       var cacheHits = 0;
     480      var cacheHits = new Dictionary<int, int>() { { 0, 0 }, { 1, 0 }, { 2, 0 } };
    470481      var evaluations = 0;
    471482      ISingleObjectiveSolutionScope<Encodings.PermutationEncoding.Permutation> offspring = null;
     
    473484      while (evaluations <= p1.Solution.Length) {
    474485        Encodings.PermutationEncoding.Permutation c = null;
    475         var xochoice = Context.Random.Next(3);
     486        var xochoice = cacheHits.SampleRandom(Context.Random).Key;
    476487        switch (xochoice) {
    477488          case 0: c = OrderCrossover2.Apply(Context.Random, p1.Solution, p2.Solution); break;
     
    480491        }
    481492        if (cache.Contains(c)) {
    482           cacheHits++;
    483           if (cacheHits > 10) break;
     493          cacheHits[xochoice]++;
     494          if (cacheHits[xochoice] > 10) {
     495            cacheHits.Remove(xochoice);
     496            if (cacheHits.Count == 0) break;
     497          }
    484498          continue;
    485499        }
Note: See TracChangeset for help on using the changeset viewer.