Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/27/14 16:33:17 (10 years ago)
Author:
bburlacu
Message:

#1772: Adjusted namespace in Plugin.cs.frame for HeuristicLab.EvolutionTracking.Views. Simplified DirectedGraph and GenealogyGraph API. Added public events for the Vertex content (so that the graph itself can be notified when the content changes and can adjust it's content-to-vertex map. Adjusted instrumented operators code to reflect api changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers/GenealogyAnalyzer.cs

    r10888 r10897  
    252252        for (int i = 0; i < population.Count; ++i) {
    253253          var individual = population[i];
    254           var vertex = new GenealogyGraphNode<T> { Content = individual, Rank = Generations.Value };
     254          var vertex = new GenealogyGraphNode<T>(individual) { Rank = Generations.Value };
    255255          GenealogyGraph.AddVertex(vertex);
    256256          // save the vertex id in the individual scope (so that we can identify graph indices)
     
    258258        }
    259259      } else {
    260         var elite = population.FirstOrDefault(x => GenealogyGraph.Contains(x));
     260        int index = 0;
     261        T elite = null;
     262        for (int i = 0; i < population.Count; ++i) {
     263          if (GenealogyGraph.Contains(population[i])) {
     264            elite = population[i];
     265            index = i;
     266          }
     267          break;
     268        }
     269
    261270        if (elite != null) {
    262           var prevVertex = (IGenealogyGraphNode<T>)GenealogyGraph[elite];
     271          var prevVertex = (IGenealogyGraphNode<T>)GenealogyGraph.GetVertex(elite);
    263272          prevVertex.IsElite = true; // mark elites in the graph retroactively
    264273
    265274          var clone = (T)elite.Clone();
    266275
    267           var vertex = new GenealogyGraphNode<T> {
    268             Content = prevVertex.Content,
     276          var vertex = new GenealogyGraphNode<T>(prevVertex.Content) {
    269277            Rank = Generations.Value,
    270278            Quality = prevVertex.Quality,
     
    272280          };
    273281
    274           GenealogyGraph.SetContent(prevVertex, clone);
    275           // swap id
    276           var id = prevVertex.Id;
    277           GenealogyGraph.SetId(prevVertex, vertex.Id);
    278 
    279           // add new vertex to the graph
    280           vertex.Id = id;
     282          prevVertex.Content = clone;
     283
     284          ExecutionContext.Scope.SubScopes[index].Variables["Id"].Value = new StringValue(vertex.Id);
     285
    281286          GenealogyGraph.AddVertex(vertex);
    282287
     
    290295      // update qualities
    291296      for (int i = 0; i < population.Count; ++i) {
    292         var vertex = (IGenealogyGraphNode)GenealogyGraph[population[i]];
     297        var vertex = (IGenealogyGraphNode)GenealogyGraph.GetVertex(population[i]);
    293298        vertex.Quality = qualities[i].Value;
    294299      }
Note: See TracChangeset for help on using the changeset viewer.