- Timestamp:
- 08/04/14 14:50:52 (10 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers/GenealogyAnalyzer.cs
r11257 r11262 272 272 var prevVertex = (IGenealogyGraphNode<T>)GenealogyGraph.GetByContent(elite); 273 273 prevVertex.IsElite = true; // mark elites in the graph retroactively 274 var w = new GenealogyGraphNode<T>(prevVertex); //shallow copy, arcs are not copied274 var w = (IGenealogyGraphNode<T>)prevVertex.Clone(); 275 275 var v = new GenealogyGraphNode<T>(prevVertex.Data) { 276 276 Rank = generation, … … 321 321 int generation = GenerationsParameter.ActualValue.Value; 322 322 var population = PopulationParameter.ActualValue; 323 var discardedOffspring = GenealogyGraph.Ranks[generation].Select(x => (T)x.Data).Except(population) ;323 var discardedOffspring = GenealogyGraph.Ranks[generation].Select(x => (T)x.Data).Except(population).ToList(); 324 324 foreach (var vertex in discardedOffspring.Select(individual => GenealogyGraph.GetByContent(individual))) { 325 325 if (vertex.InDegree == 1) { 326 326 var p = vertex.Parents.First(); 327 if ( p.Rank.Equals(generation - 1))327 if (!p.Rank.Equals(generation - 0.5)) 328 328 throw new InvalidOperationException("Parent must be an intermediate vertex"); 329 329 GenealogyGraph.RemoveVertex(p); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraphNode.cs
r11253 r11262 36 36 public override IDeepCloneable Clone(Cloner cloner) { 37 37 return new GenealogyGraphNode(this, cloner); 38 }39 40 // this constructor emulates the behavior of a copy constructor41 // it returns a shallow copy in which the arcs are not cloned42 protected GenealogyGraphNode(IGenealogyGraphNode original)43 : base((IDeepCloneable)original.Data.Clone()) {44 Quality = original.Quality;45 Rank = original.Rank;46 IsElite = original.IsElite;47 Id = Guid.NewGuid().ToString();48 38 } 49 39 … … 146 136 } 147 137 148 public GenealogyGraphNode(IGenealogyGraphNode<T> original) : base(original) { } 138 [StorableConstructor] 139 protected GenealogyGraphNode(bool deserializing) : base(deserializing) { } 149 140 150 141 public GenealogyGraphNode(IDeepCloneable content) : base(content) { }
Note: See TracChangeset
for help on using the changeset viewer.