- Timestamp:
- 05/22/14 13:49:35 (11 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/HeuristicLab.EvolutionTracking.Views-3.4.csproj
r10884 r10886 97 97 <DependentUpon>FrequentFragmentsDialog.cs</DependentUpon> 98 98 </Compile> 99 <Compile Include="GenealogyGraphChart.cs" /> 99 <Compile Include="GenealogyGraphChart.cs"> 100 <SubType>UserControl</SubType> 101 </Compile> 100 102 <Compile Include="GenealogyGraphChart.Designer.cs"> 101 103 <DependentUpon>GenealogyGraphChart.cs</DependentUpon> -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers/GenealogyAnalyzer.cs
r10884 r10886 54 54 private const string EnableSolutionCreatorTrackingParameterName = "EnableSolutionCreatorTracking"; // should always be enabled. maybe superfluous 55 55 56 public string CrossoverParentsParameterName { get; set; } 57 public string CrossoverChildParameterName { get; set; } 58 public string ManipulatorChildParameterName { get; set; } 59 56 #region parameter properties 60 57 public IScopeTreeLookupParameter<DoubleValue> QualityParameter { 61 58 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters[QualityParameterName]; } 62 59 } 63 64 60 public IScopeTreeLookupParameter<T> PopulationParameter { 65 61 get { return (IScopeTreeLookupParameter<T>)Parameters[PopulationParameterName]; } 66 62 } 67 68 63 public IValueParameter<ICrossoverOperator<T>> BeforeCrossoverOperatorParameter { 69 64 get { return (IValueParameter<ICrossoverOperator<T>>)Parameters[BeforeCrossoverOperatorParameterName]; } … … 78 73 get { return (IValueParameter<IManipulatorOperator<T>>)Parameters[AfterManipulatorOperatorParameterName]; } 79 74 } 80 81 #region parameter properties82 75 public ILookupParameter<ResultCollection> ResultsParameter { 83 76 get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; } … … 265 258 } 266 259 } else { 260 // TODO: eliminate from the graph extra vertices added by the recombination operators when filling the pool of offspring with offspring selection 261 267 262 var elite = population.FirstOrDefault(x => GenealogyGraph.Contains(x)); 268 263 if (elite != null) { … … 282 277 GenealogyGraph[vertex.Content] = vertex; 283 278 GenealogyGraph[previousVertex.Content] = previousVertex; 284 // connect current elite with previous elite 285 previousVertex.AddForwardArc(vertex); 286 vertex.AddReverseArc(previousVertex); 279 GenealogyGraph.AddArc(previousVertex, vertex); // connect current elite with previous elite 287 280 vertex.Id = previousVertex.Id; // another way would be to introduce the vertex.Id into the scope of the elite 288 281 vertex.Quality = previousVertex.Quality; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/DirectedGraph/Interfaces/IVertex.cs
r10677 r10886 36 36 double Weight { get; set; } 37 37 38 void AddForwardArc(IVertex target, double weight = 0.0, object content = null);39 38 void AddForwardArc(IArc arc); 40 void AddReverseArc(IVertex target, double weight = 0.0, object content = null);41 39 void AddReverseArc(IArc arc); 42 40 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/DirectedGraph/Vertex.cs
r10834 r10886 87 87 // (they do not appear in the nodes Dictionary). It is the programmers responsibility to 88 88 // enforce the correct and desired behavior. 89 public void AddForwardArc(IVertex target, double w = 0.0, object data = null) {90 var arc = new Arc { Source = this, Target = target, Data = data, Weight = w };91 if (outArcs == null) outArcs = new List<IArc> { arc };92 else outArcs.Add(arc);93 }94 89 public void AddForwardArc(IArc arc) { 95 if (arc.Source == null) { arc.Source = this; }96 90 if (arc.Source != this) { throw new Exception("AddForwardArc: Source should be equal to this."); } 97 if (outArcs == null) { outArcs = new List<IArc> { arc }; } else { outArcs.Add(arc); } 98 } 99 public void AddReverseArc(IVertex source, double w = 0.0, object data = null) { 100 var arc = new Arc { Source = source, Target = this, Data = data, Weight = w }; 101 if (inArcs == null) inArcs = new List<IArc> { arc }; 102 else inArcs.Add(arc); 91 if (outArcs == null) 92 outArcs = new List<IArc>(); 93 outArcs.Add(arc); 103 94 } 104 95 public void AddReverseArc(IArc arc) { 105 if (arc.Target == null) { arc.Target = this; }106 96 if (arc.Target != this) { throw new Exception("AddReverseArc: Target should be equal to this."); }; 107 if (inArcs == null) { inArcs = new List<IArc> { arc }; } else { inArcs.Add(arc); } 97 if (inArcs == null) 98 inArcs = new List<IArc>(); 99 inArcs.Add(arc); 108 100 } 109 110 101 public int InDegree { get { return InArcs.Count(); } } 111 102 public int OutDegree { get { return OutArcs.Count(); } } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraph.cs
r10833 r10886 40 40 get { return from n in base.Nodes select (IGenealogyGraphNode)n; } 41 41 } 42 43 public IGenealogyGraphArc AddArc(IGenealogyGraphNode source, IGenealogyGraphNode target) { 44 var arc = new GenealogyGraphArc(source, target); 45 source.AddForwardArc(arc); 46 target.AddReverseArc(arc); 47 return arc; 48 } 49 42 50 protected GenealogyGraph(GenealogyGraph original, Cloner cloner) 43 51 : base(original, cloner) { … … 98 106 get { return from n in base.Nodes select (IGenealogyGraphNode<T>)n; } 99 107 } 108 109 public IGenealogyGraphArc AddArc(IGenealogyGraphNode source, IGenealogyGraphNode target) { 110 var arc = new GenealogyGraphArc(source, target); 111 source.AddForwardArc(arc); 112 target.AddReverseArc(arc); 113 return arc; 114 } 115 100 116 // contructors 101 117 protected GenealogyGraph(GenealogyGraph<T> original, Cloner cloner) -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraphArc.cs
r10293 r10886 32 32 protected GenealogyGraphArc(GenealogyGraphArc original, Cloner cloner) 33 33 : base(original, cloner) { 34 this.Target = original.Target; 35 this.Source = original.Source; 36 this.Label = original.Label; 37 this.Weight = original.Weight; 38 this.Data = original.Data; 34 39 } 35 40 36 public GenealogyGraphArc() { } 41 protected GenealogyGraphArc() { } 42 43 public GenealogyGraphArc(IGenealogyGraphNode source, IGenealogyGraphNode target, object data = null) { 44 Source = source; 45 Target = target; 46 Data = data; 47 } 37 48 38 49 public override IDeepCloneable Clone(Cloner cloner) { … … 60 71 Data = (T)original.Data.Clone(); 61 72 } 62 public GenealogyGraphArc() { }63 73 64 74 public override IDeepCloneable Clone(Cloner cloner) { -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraphNode.cs
r10685 r10886 107 107 return Quality.CompareTo(other.Quality); 108 108 } 109 public new void AddForwardArc(IVertex target, double w = 0.0, object data = null) {110 var arc = new GenealogyGraphArc { Source = this, Target = (IGenealogyGraphNode)target, Data = data, Weight = w };111 base.AddForwardArc(arc);112 }113 public new void AddReverseArc(IVertex source, double w = 0.0, object data = null) {114 var arc = new GenealogyGraphArc { Source = (IGenealogyGraphNode)source, Target = this, Data = data, Weight = w };115 base.AddReverseArc(arc);116 }117 109 public IEnumerable<IGenealogyGraphNode> Parents { 118 110 get { return InArcs.Select(a => a.Source); } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/Interfaces/IGenealogyGraph.cs
r10830 r10886 27 27 Dictionary<double, List<IGenealogyGraphNode>> Ranks { get; } 28 28 new IEnumerable<IGenealogyGraphNode> Nodes { get; } 29 IGenealogyGraphArc AddArc(IGenealogyGraphNode source, IGenealogyGraphNode target); 29 30 } 30 31 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/BeforeCrossoverOperator.cs
r10884 r10886 78 78 }; 79 79 GenealogyGraph.AddVertex(childVertex); 80 foreach (var v in parentVertices) { 81 childVertex.AddReverseArc(v); 82 v.AddForwardArc(childVertex); 80 foreach (var parentVertex in parentVertices) { 81 GenealogyGraph.AddArc(parentVertex, childVertex); 83 82 } 84 83 ExecutionContext.Scope.Variables.Add(new Variable("Id", new StringValue(childVertex.Id))); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/BeforeManipulatorOperator.cs
r10837 r10886 60 60 var parents = vChild.Parents; // parents of child become parents of clone 61 61 foreach (var p in parents) { 62 foreach (var a in p.OutArcs.Where(a => a.Target == vChild)) { 63 a.Target = vClone; 64 } 65 vClone.AddReverseArc(p); 62 var arc = p.OutArcs.First(a => a.Target == vChild); 63 arc.Target = vClone; 64 vClone.AddReverseArc(arc); 66 65 } 67 66 68 67 vClone.InArcs.Last().Data = vChild.InArcs.Last().Data; // fragment of child becomes fragment of clone 69 68 vChild.InArcs = new List<IGenealogyGraphArc>(); // child will be connected to clone 70 vChild.AddReverseArc(vClone); 71 vClone.AddForwardArc(vChild); 69 GenealogyGraph.AddArc(vClone, vChild); 72 70 73 71 // the following step in necessary because some mutation operators change values while the reference stays the same -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolGraph/FPGraph.cs
r10347 r10886 56 56 return node; 57 57 } 58 59 void AddArc(SymbolNode source, SymbolNode target, double weight, object data = null) {60 source.AddForwardArc(target, weight, data);61 }62 58 } 63 59 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolGraph/SymbolGraph.cs
r10347 r10886 49 49 return node; 50 50 } 51 52 void AddArc(SymbolNode source, SymbolNode target, double weight, object data = null) {53 source.AddForwardArc(target, weight, data);54 }55 51 } 56 52 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionTracing.cs
r10884 r10886 58 58 }; 59 59 if (parent != null) { 60 var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode };60 var arc = new GenealogyGraphArc(parent, fragmentNode); 61 61 parent.AddForwardArc(arc); 62 fragmentNode.AddReverseArc( parent);62 fragmentNode.AddReverseArc(arc); 63 63 } 64 64 yield return fragmentNode; // no tracing if there are no parents … … 91 91 }; 92 92 if (parent != null) { 93 var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode };93 var arc = new GenealogyGraphArc(parent, fragmentNode); 94 94 parent.AddForwardArc(arc); 95 fragmentNode.AddReverseArc( parent);95 fragmentNode.AddReverseArc(arc); 96 96 } 97 97 yield return fragmentNode; … … 134 134 }; 135 135 if (parent != null) { 136 var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode };136 var arc = new GenealogyGraphArc(parent, fragmentNode); 137 137 parent.AddForwardArc(arc); 138 fragmentNode.AddReverseArc( parent);138 fragmentNode.AddReverseArc(arc); 139 139 } 140 140 // fragmentNode.Content.Index1 = fragment.Index1 - index; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
r10830 r10886 388 388 if (TSPCrossover != null) { 389 389 TSPGenealogyAnalyzer.BeforeCrossoverOperatorParameter.ActualValue = new BeforeCrossoverOperator<Permutation>(); 390 TSPGenealogyAnalyzer.BeforeCrossoverOperator.ParentsParameter.ActualName = TSPCrossover.ParentsParameter.Name; 391 TSPGenealogyAnalyzer.BeforeCrossoverOperator.ChildParameter.ActualName = TSPCrossover.ChildParameter.Name; 390 392 TSPGenealogyAnalyzer.AfterCrossoverOperatorParameter.ActualValue = new AfterCrossoverOperator<Permutation>(); 391 TSPGenealogyAnalyzer. CrossoverParentsParameterName = TSPCrossover.ParentsParameter.Name;392 TSPGenealogyAnalyzer. CrossoverChildParameterName = TSPCrossover.ChildParameter.Name;393 TSPGenealogyAnalyzer.AfterCrossoverOperator.ParentsParameter.ActualName = TSPCrossover.ParentsParameter.Name; 394 TSPGenealogyAnalyzer.AfterCrossoverOperator.ChildParameter.ActualName = TSPCrossover.ChildParameter.Name; 393 395 } 394 396 if (TSPManipulator != null) { 395 397 TSPGenealogyAnalyzer.BeforeManipulatorOperatorParameter.ActualValue = new BeforeManipulatorOperator<Permutation>(); 398 TSPGenealogyAnalyzer.BeforeManipulatorOperator.ChildParameter.ActualName = TSPManipulator.PermutationParameter.Name; 396 399 TSPGenealogyAnalyzer.AfterManipulatorOperatorParameter.ActualValue = new AfterManipulatorOperator<Permutation>(); 397 TSPGenealogyAnalyzer. ManipulatorChildParameterName = TSPManipulator.PermutationParameter.Name;400 TSPGenealogyAnalyzer.AfterManipulatorOperator.ChildParameter.ActualName = TSPManipulator.PermutationParameter.Name; 398 401 } 399 402 TSPGenealogyAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
Note: See TracChangeset
for help on using the changeset viewer.