Changeset 10890
- Timestamp:
- 05/26/14 16:28:09 (10 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/DirectedGraph/Vertex.cs
r10888 r10890 46 46 public IEnumerable<IArc> InArcs { 47 47 get { return inArcs ?? Enumerable.Empty<IArc>(); } 48 set { inArcs = value.ToList(); } 48 49 } 49 50 [Storable] … … 51 52 public IEnumerable<IArc> OutArcs { 52 53 get { return outArcs ?? Enumerable.Empty<IArc>(); } 54 set { outArcs = value.ToList(); } 53 55 } 54 56 [Storable] -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraphNode.cs
r10888 r10890 43 43 public new IEnumerable<IGenealogyGraphArc> InArcs { 44 44 get { return base.InArcs.Cast<IGenealogyGraphArc>(); } 45 set { base.InArcs = value; } 45 46 } 46 47 public new IEnumerable<IGenealogyGraphArc> OutArcs { 47 48 get { return base.OutArcs.Cast<IGenealogyGraphArc>(); } 49 set { base.OutArcs = value; } 48 50 } 49 51 public IEnumerable<IGenealogyGraphNode> Ancestors { -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/Interfaces/IGenealogyGraphNode.cs
r10888 r10890 33 33 IEnumerable<IGenealogyGraphNode> Ancestors { get; } 34 34 IEnumerable<IGenealogyGraphNode> Descendants { get; } 35 new IEnumerable<IGenealogyGraphArc> InArcs { get; }36 new IEnumerable<IGenealogyGraphArc> OutArcs { get; }35 new IEnumerable<IGenealogyGraphArc> InArcs { get; set; } 36 new IEnumerable<IGenealogyGraphArc> OutArcs { get; set; } 37 37 } 38 38 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/BeforeCrossoverOperator.cs
r10888 r10890 81 81 // but the first parent is actually the future child so we use this 82 82 Content = parents[0], 83 // Rank = Generations.Value + 184 83 Rank = parentVertices[0].Rank + 1 85 84 }; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/BeforeManipulatorOperator.cs
r10888 r10890 20 20 #endregion 21 21 22 using System; 22 23 using System.Linq; 23 24 using HeuristicLab.Common; … … 49 50 50 51 public override IOperation Apply() { 51 var vChild = (IGenealogyGraphNode<T>)GenealogyGraph[ChildParameter.ActualValue]; 52 if (vChild.Rank.IsAlmost(Generations.Value + 1)) { 53 // if the graph already contains a vertex representing the child, it means that the child is a product of crossover 54 // when mutation follows after crossover, some changes need to be made to the graph to maintain consistency 55 var vClone = new GenealogyGraphNode<T> { 56 Content = (T)ChildParameter.ActualValue.Clone(), 57 Rank = vChild.Parents.Last().Rank + 0.5 58 }; 59 GenealogyGraph.AddVertex(vClone); 52 // since mutation always takes place after crossover, the vertex for the current child is already in the tree 53 var v = (IGenealogyGraphNode<T>)GenealogyGraph[ChildParameter.ActualValue]; 60 54 61 foreach (var arc in vChild.InArcs) {62 arc.Target = vClone;63 vClone.AddReverseArc(arc);64 }55 if (!v.Rank.IsAlmost(Generations.Value + 1)) { 56 throw new Exception("Child rank should be generations.value + 1"); 57 } 58 var clone = (T)ChildParameter.ActualValue.Clone(); 65 59 66 vClone.InArcs.Last().Data = vChild.InArcs.Last().Data; // fragment of child becomes fragment of clone 67 GenealogyGraph.AddArc(vClone, vChild); 60 var c = new GenealogyGraphNode<T> { 61 Rank = v.Rank - 0.5, 62 Content = clone 63 }; 68 64 69 // the following step in necessary because some mutation operators change values while the reference stays the same 70 // so we clone in order to prevent mutations to be "shadowed" in the parent 71 var parent = vClone.Parents.First(); 72 parent.Content = (T)parent.Content.Clone(); 73 GenealogyGraph[parent.Content] = parent; 65 foreach (var a in v.InArcs) { 66 a.Target = c; 67 c.AddReverseArc(a); 68 } 74 69 75 } else if (vChild.Rank.IsAlmost(Generations.Value)) { 76 var clone = (T)ChildParameter.ActualValue.Clone(); 77 GenealogyGraph.SetContent(vChild, clone); 78 var xx = new GenealogyGraphNode<T> { Content = ChildParameter.ActualValue, Rank = Generations.Value + 1 }; 79 GenealogyGraph.AddVertex(xx); 80 GenealogyGraph.AddArc(vChild, xx); 81 } 70 v.InArcs = Enumerable.Empty<IGenealogyGraphArc>(); 71 72 GenealogyGraph.AddVertex(c); 73 GenealogyGraph.AddArc(c, v); 74 82 75 return base.Apply(); 83 76 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionAfterCrossoverOperator.cs
r10833 r10890 30 30 public class SymbolicDataAnalysisExpressionAfterCrossoverOperator : AfterCrossoverOperator<ISymbolicExpressionTree> { 31 31 public override IOperation Apply() { 32 var child = ChildParameter.ActualValue; 33 var childVertex = (IGenealogyGraphNode)GenealogyGraph[child]; 32 var childVertex = (IGenealogyGraphNode<ISymbolicExpressionTree>)GenealogyGraph[ChildParameter.ActualValue]; 34 33 var arcs = childVertex.InArcs.ToList(); 35 34 var nodes0 = (List<ISymbolicExpressionTreeNode>)arcs[0].Data; 36 35 var nodes1 = (List<ISymbolicExpressionTreeNode>)arcs[1].Data; 37 var childNodes = child .IterateNodesPrefix().ToList();36 var childNodes = childVertex.Content.IterateNodesPrefix().ToList(); 38 37 IFragment<ISymbolicExpressionTreeNode> fragment = null; 39 38 for (int i = 0; i < Math.Min(nodes0.Count, childNodes.Count); ++i) {
Note: See TracChangeset
for help on using the changeset viewer.