Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/16/16 15:39:03 (9 years ago)
Author:
bburlacu
Message:

#1772: Fixed the way operator improvement is calculated so it also works when a diversification strategy is applied (introducing multiple intermediate vertices between parent and child). Minor code refactoring in the diversification operators. Fixed very small typo in the BeforeManipulatorOperator.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisGeneticOperatorImprovementAnalyzer.cs

    r13495 r13527  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using System.Linq;
    2324using HeuristicLab.Analysis;
     
    103104      var populationSize = population.Length;
    104105
    105       var vertices = population.Select(graph.GetByContent).ToList();
     106      //      var vertices = population.Select(graph.GetByContent).ToList();
     107      var crossoverChildren = new List<IGenealogyGraphNode<ISymbolicExpressionTree>>();
     108      var mutationChildren = new List<IGenealogyGraphNode<ISymbolicExpressionTree>>();
     109      var vertices = graph.Vertices.Where(x => x.Rank > generation - 1);
     110      foreach (var v in vertices) {
     111        if (v.InDegree == 2) {
     112          crossoverChildren.Add(v);
     113        } else {
     114          var parent = v.Parents.First();
     115          // mutation is always preceded by mutation
     116          // so the parent vertex should have an intermediate rank
     117          // otherwise, it is the previos generation elite
     118          if (parent.Rank.IsAlmost(generation - 1) && parent.IsElite)
     119            continue;
     120          mutationChildren.Add(v);
     121        }
     122      }
    106123      DataTable table;
    107124      #region crossover improvement
     
    118135        table = (DataTable)Results["Crossover improvement"].Value;
    119136      }
    120       var crossoverChildren = vertices.Where(x => x.InDegree == 2).ToList();
    121       if (CountIntermediateChildren)
    122         crossoverChildren.AddRange(vertices.Where(x => x.InDegree == 1).Select(v => v.Parents.First()).Where(p => p.Rank.IsAlmost(generation - 0.5))); // add intermediate children
    123137
    124138      var avgCrossoverParentQuality = crossoverChildren.SelectMany(x => x.Parents).Average(x => x.Quality);
     
    148162      }
    149163
    150       var mutationChildren = vertices.Where(x => x.InDegree == 1).ToList();
    151 
    152164      var avgMutationParentQuality = mutationChildren.SelectMany(x => x.Parents).Average(x => x.Quality);
    153165      var avgMutationChildQuality = mutationChildren.Average(x => x.Quality);
Note: See TracChangeset for help on using the changeset viewer.