Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8237


Ignore:
Timestamp:
07/05/12 16:21:23 (12 years ago)
Author:
ascheibe
Message:

#1886 added ranks list to nodes in graph

Location:
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/AlgorithmBehaviorHelpers.cs

    r8229 r8237  
    6363      if (filteredDescendants.Any()) {
    6464        foreach (var descendant in filteredDescendants) {
    65           generations.Add((int)descendant.Rank);
     65          foreach (var rank in descendant.Rank) {
     66            generations.Add((int)rank);
     67          }
    6668        }
    6769      }
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/BestIndividualQualityAnalyzer.cs

    r8234 r8237  
    129129      SchemaEqualityComparer comparer = new SchemaEqualityComparer();
    130130
    131       var lastGen = graph.Values.Where(x => x.Rank == GenerationsParameter.ActualValue.Value);
     131      var lastGen = graph.Values.Where(x => x.Rank.Contains(GenerationsParameter.ActualValue.Value));
    132132      var parents = lastGen.Where(x => comparer.Equals((IntArray)x.Data, parent));
    133133      var ancestors = parents.First().Ancestors().Where(x => AlgorithmBehaviorHelpers.IsSubtour(schema, (Permutation)x.Data));
    134134
    135135      StringBuilder sb = new StringBuilder();
     136      double curGen = GenerationsParameter.ActualValue.Value;
    136137      foreach (var a in ancestors) {
    137         sb.Append(a.Rank + ", ");
     138        if (a.Rank.Contains(curGen))
     139          sb.Append(curGen + ", ");
     140        else {
     141          for (int i = 0; i < GenerationsParameter.ActualValue.Value; i++) {
     142            if (a.Rank.Contains(curGen - i)) {
     143              curGen = curGen - i;
     144              break;
     145            } else if (a.Rank.Contains(curGen - i + 0.5)) {
     146              curGen = curGen - i + 0.5;
     147              break;
     148            }
     149          }
     150          sb.Append(curGen + ", ");
     151        }
    138152      }
    139153      return sb.ToString();
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/BrokenInheritanceWildcardAnalyzer.cs

    r8227 r8237  
    7777      var graph = (GenealogyGraph<Permutation>)Results[PopulationGraphResultName].Value;
    7878      var wildcards = (ItemArray<IntArray>)Results[WildcardsResultName].Value;
    79       var generationZero = graph.Values.Where(x => x.Rank == 0);
     79      var generationZero = graph.Values.Where(x => x.Rank.Contains(0));
    8080
    8181      var buildingBlockMatrix = new StringMatrix(wildcards.Count(), generationZero.Count());
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/BrokenInteritanceSchemaAnalyzer.cs

    r8227 r8237  
    7777      var graph = (GenealogyGraph<Permutation>)Results[PopulationGraphResultName].Value;
    7878      var schemata = (ItemArray<IntArray>)Results[SchemataResultName].Value;
    79       var generationZero = graph.Values.Where(x => x.Rank == 0);
     79      var generationZero = graph.Values.Where(x => x.Rank.Contains(0));
    8080
    8181      var brokenInteritanceSchemaOccurrenceMatrix = new StringMatrix(schemata.Count(), generationZero.Count());
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/GenealogyAnalyzer.cs

    r8216 r8237  
    3232
    3333namespace HeuristicLab.Analysis.AlgorithmBehavior {
     34  using System.Collections.Generic;
    3435  using CloneMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Core.IItem, HeuristicLab.Core.IItem>;
    3536  using TraceMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Core.IItem, HeuristicLab.Core.IItemList<HeuristicLab.Core.IItem>>;
     
    182183          for (int i = 0; i < population.Count; i++) {
    183184            var solutionEntry = population.ElementAt(i);
    184             var node = new GenealogyGraphNode(solutionEntry.Key) { Quality = solutionEntry.Value, Label = label, Rank = generation, IsElite = i < Elites.Value };
     185            var rank = new List<double>();
     186            rank.Add(generation);
     187            var node = new GenealogyGraphNode(solutionEntry.Key) { Quality = solutionEntry.Value, Label = label, Rank = rank, IsElite = i < Elites.Value };
    185188            graph.AddNode(node);
    186189          }
     
    192195          var solutionEntry = population.ElementAt(i);
    193196          if (!graph.HasNode(solutionEntry.Key)) {
    194             var node = new GenealogyGraphNode(solutionEntry.Key) { Quality = solutionEntry.Value, Label = label, Rank = generation, IsElite = i < Elites.Value };
     197            var rank = new List<double>();
     198            rank.Add(generation);
     199            var node = new GenealogyGraphNode(solutionEntry.Key) { Quality = solutionEntry.Value, Label = label, Rank = rank, IsElite = i < Elites.Value };
    195200            graph.AddNode(node);
    196201          }
     
    204209              // handle mutation
    205210              double quality = Evaluate(parent);
    206               var node = new GenealogyGraphNode(parent) { Quality = quality, Label = label, Rank = generation - 0.5 };
     211              var rank = new List<double>();
     212              rank.Add(generation - 0.5);
     213              var node = new GenealogyGraphNode(parent) { Quality = quality, Label = label, Rank = rank };
    207214              graph.AddNode(node);
    208215              var parentParents = GlobalTraceMap[parent].Cast<Permutation>().ToArray();
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/SchemaOccurenceInGenerationsAnalyzer.cs

    r8227 r8237  
    126126      foreach (var individual in graph.Values) {
    127127        if (AlgorithmBehaviorHelpers.IsSubtour(schema, (Permutation)individual.Data)) {
    128           occurences[(int)individual.Rank]++;
     128          foreach (var rank in individual.Rank) {
     129            occurences[(int)rank]++;
     130          }
    129131        }
    130132      }
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/SchemaQualityAnalyzer.cs

    r8227 r8237  
    136136      foreach (var individual in graph.Values) {
    137137        if (AlgorithmBehaviorHelpers.IsSubtour(schema, (Permutation)individual.Data)) {
    138           occurences[(int)individual.Rank]++;
     138          foreach (var rank in individual.Rank) {
     139            occurences[(int)rank]++;
     140          }
    139141        }
    140142      }
     
    166168          double pQuality = TSPDistanceMatrixEvaluator.Apply(DistanceMatrix, p);
    167169
    168           if (Qualities.Rows["CurrentAverageQuality"].Values[(int)individual.Rank] > pQuality) {
     170          //TODO: fix that
     171          /*if (Qualities.Rows["CurrentAverageQuality"].Values[(int)individual.Rank] > pQuality) {
    169172            qualityPoint += 1;
    170173          } else {
    171174            worstQualityPoint += 1;
    172           }
     175          } */
    173176        }
    174177      }
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Creators/SchemataCreator.cs

    r8229 r8237  
    8585    public override IOperation Apply() {
    8686      var graph = (GenealogyGraph<Permutation>)Results[PopulationGraphResultParameterName].Value;
    87       var generationZero = graph.Values.Where(x => x.Rank == 0);
     87      var generationZero = graph.Values.Where(x => x.Rank.Contains(0));
    8888
    8989      // extract all subtours for each individual in generation zero
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/GenealogyGraph.cs

    r8234 r8237  
    7373    public void AddNode(T t) {
    7474      if (HasNode(t)) return;
    75       _nodes[t] = new GenealogyGraphNode(t) { Quality = 0.0, Label = "", IsElite = false, Rank = 0.0 };
     75      _nodes[t] = new GenealogyGraphNode(t) { Quality = 0.0, Label = "", IsElite = false, Rank = new List<double>() };
    7676    }
    7777
     
    166166    public bool IsElite { get; set; }
    167167    public double Quality { get; set; }
    168     public double Rank { get; set; }
     168    public List<double> Rank { get; set; }
    169169    public List<GenealogyGraphArc> InEdges { get; set; }
    170170    public List<GenealogyGraphArc> OutEdges { get; set; }
     
    193193    public GenealogyGraphNode(GenealogyGraphNode node) {
    194194      Id = Guid.NewGuid().ToString();
    195       Rank = node.Rank;
     195      Rank = new List<double>(node.Rank);
    196196      Quality = node.Quality;
    197197      IsElite = node.IsElite;
Note: See TracChangeset for help on using the changeset viewer.