Changeset 10897 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers
- Timestamp:
- 05/27/14 16:33:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers/GenealogyAnalyzer.cs
r10888 r10897 252 252 for (int i = 0; i < population.Count; ++i) { 253 253 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 }; 255 255 GenealogyGraph.AddVertex(vertex); 256 256 // save the vertex id in the individual scope (so that we can identify graph indices) … … 258 258 } 259 259 } 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 261 270 if (elite != null) { 262 var prevVertex = (IGenealogyGraphNode<T>)GenealogyGraph [elite];271 var prevVertex = (IGenealogyGraphNode<T>)GenealogyGraph.GetVertex(elite); 263 272 prevVertex.IsElite = true; // mark elites in the graph retroactively 264 273 265 274 var clone = (T)elite.Clone(); 266 275 267 var vertex = new GenealogyGraphNode<T> { 268 Content = prevVertex.Content, 276 var vertex = new GenealogyGraphNode<T>(prevVertex.Content) { 269 277 Rank = Generations.Value, 270 278 Quality = prevVertex.Quality, … … 272 280 }; 273 281 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 281 286 GenealogyGraph.AddVertex(vertex); 282 287 … … 290 295 // update qualities 291 296 for (int i = 0; i < population.Count; ++i) { 292 var vertex = (IGenealogyGraphNode)GenealogyGraph [population[i]];297 var vertex = (IGenealogyGraphNode)GenealogyGraph.GetVertex(population[i]); 293 298 vertex.Quality = qualities[i].Value; 294 299 }
Note: See TracChangeset
for help on using the changeset viewer.