Changeset 11925
- Timestamp:
- 02/05/15 19:35:34 (10 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 2 added
- 5 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraph.cs
r11852 r11925 37 37 private Dictionary<string, IGenealogyGraphNode> idMap; 38 38 39 private readonly Comparison<IArc > compareArcs = (a, b) => {39 private readonly Comparison<IArc<IDeepCloneable>> compareArcs = (a, b) => { 40 40 if (a.Data == b.Data) 41 41 return 0; … … 56 56 RebuildDictionaries(); 57 57 58 foreach (var arcs in Vertices.Select(v => (List<IArc>)((IVertex)v).InArcs)) { arcs.Sort(compareArcs); }58 foreach (var arcs in Vertices.Select(v => v.InArcs.ToList())) { arcs.Sort(compareArcs); } 59 59 } 60 60 public override IDeepCloneable Clone(Cloner cloner) { … … 69 69 private void AfterDeserialization() { 70 70 RebuildDictionaries(); 71 foreach (var arcs in Vertices.Select(v => (List<IArc>)((Vertex)v).InArcs)) { arcs.Sort(compareArcs); }71 foreach (var arcs in Vertices.Select(v => v.InArcs.ToList())) { arcs.Sort(compareArcs); } 72 72 } 73 73 public GenealogyGraph() { … … 169 169 return ColorGradient.Colors[colorIndex]; 170 170 } 171 172 public override void AddVertices(IEnumerable<IVertex> vertexList) {173 base.AddVertices(vertexList);174 RebuildDictionaries();175 }176 171 } 177 172 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraphArc.cs
r11502 r11925 27 27 [StorableClass] 28 28 [Item("GenealogyGraphArc", "A graph arc connecting two GenealogyGraphNodes and holding some data.")] 29 public class GenealogyGraphArc : Arc , IGenealogyGraphArc {29 public class GenealogyGraphArc : Arc<IDeepCloneable>, IGenealogyGraphArc { 30 30 [StorableConstructor] 31 31 protected GenealogyGraphArc(bool deserializing) : base(deserializing) { } … … 55 55 [StorableConstructor] 56 56 protected GenealogyGraphArc(bool deserializing) : base(deserializing) { } 57 57 58 protected GenealogyGraphArc(GenealogyGraphArc original, Cloner cloner) 58 59 : base(original, cloner) { … … 62 63 return new GenealogyGraphArc<T>(this, cloner); 63 64 } 65 64 66 public new T Data { 65 67 get { return (T)base.Data; } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraphNode.cs
r11858 r11925 30 30 [StorableClass] 31 31 [Item("GenealogGraphNode", "A class representing a node in the GenealogyGraph")] 32 public class GenealogyGraphNode : Vertex , IGenealogyGraphNode {32 public class GenealogyGraphNode : Vertex<IDeepCloneable>, IGenealogyGraphNode { 33 33 [StorableConstructor] 34 34 protected GenealogyGraphNode(bool deserializing) : base(deserializing) { } … … 46 46 } 47 47 48 public GenealogyGraphNode() { 49 Id = Guid.NewGuid().ToString(); 50 } 51 48 52 public GenealogyGraphNode(IDeepCloneable data) 49 : base(data) {50 Id = Guid.NewGuid().ToString();53 : this() { 54 Data = data; 51 55 } 52 56 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/Interfaces/IGenealogyGraphArc.cs
r11253 r11925 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 24 25 namespace HeuristicLab.EvolutionTracking { 25 public interface IGenealogyGraphArc : IArc {26 public interface IGenealogyGraphArc : IArc<IDeepCloneable> { 26 27 new IGenealogyGraphNode Source { get; } 27 28 new IGenealogyGraphNode Target { get; } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/Interfaces/IGenealogyGraphNode.cs
r11253 r11925 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 26 27 namespace HeuristicLab.EvolutionTracking { 27 public interface IGenealogyGraphNode : IVertex , IComparable<IGenealogyGraphNode> {28 public interface IGenealogyGraphNode : IVertex<IDeepCloneable>, IComparable<IGenealogyGraphNode> { 28 29 double Rank { get; set; } 29 30 double Quality { get; set; } … … 39 40 } 40 41 41 public interface IGenealogyGraphNode<T> : IGenealogyGraphNode , IVertex<T>where T : class {42 public interface IGenealogyGraphNode<T> : IGenealogyGraphNode where T : class { 42 43 new IEnumerable<IGenealogyGraphNode<T>> Parents { get; } 43 44 new IEnumerable<IGenealogyGraphNode<T>> Children { get; } 44 45 45 new IEnumerable<IGenealogyGraphNode<T>> Ancestors { get; } 46 46 new IEnumerable<IGenealogyGraphNode<T>> Descendants { get; } 47 48 new T Data { get; set; } 47 49 } 48 50 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/HeuristicLab.EvolutionTracking-3.4.csproj
r11639 r11925 110 110 <ItemGroup> 111 111 <Compile Include="Analyzers\GenealogyAnalyzer.cs" /> 112 <Compile Include="Collections\CloneableCollection.cs" /> 112 113 <Compile Include="Fragment.cs" /> 113 114 <Compile Include="Interfaces\IFragment.cs" /> -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj
r11864 r11925 278 278 <DependentUpon>VariableView.cs</DependentUpon> 279 279 </Compile> 280 <Compile Include="Tracking\FragmentGraphView.cs">281 <SubType>UserControl</SubType>282 </Compile>283 <Compile Include="Tracking\FragmentGraphView.Designer.cs">284 <DependentUpon>FragmentGraphView.cs</DependentUpon>285 </Compile>286 280 <Compile Include="Tracking\SymbolicDataAnalysisGenealogyGraphView.cs"> 287 281 <SubType>UserControl</SubType> … … 289 283 <Compile Include="Tracking\SymbolicDataAnalysisGenealogyGraphView.Designer.cs"> 290 284 <DependentUpon>SymbolicDataAnalysisGenealogyGraphView.cs</DependentUpon> 291 </Compile>292 <Compile Include="Tracking\SymbolicDataAnalysisExpressionLineageExplorerView.cs">293 <SubType>UserControl</SubType>294 </Compile>295 <Compile Include="Tracking\SymbolicDataAnalysisExpressionLineageExplorerView.Designer.cs">296 <DependentUpon>SymbolicDataAnalysisExpressionLineageExplorerView.cs</DependentUpon>297 </Compile>298 <Compile Include="Tracking\SymbolicExpressionChartControl.cs">299 <SubType>UserControl</SubType>300 </Compile>301 <Compile Include="Tracking\SymbolicExpressionChartControl.Designer.cs">302 <DependentUpon>SymbolicExpressionChartControl.cs</DependentUpon>303 285 </Compile> 304 286 <Compile Include="TreeEditDialogs\SymbolicExpressionTreeConstantNodeEditDialog.cs"> … … 384 366 <LastGenOutput>Resources.Designer.cs</LastGenOutput> 385 367 <SubType>Designer</SubType> 386 </EmbeddedResource>387 <EmbeddedResource Include="Tracking\SymbolicDataAnalysisGenealogyGraphView.resx">388 <DependentUpon>SymbolicDataAnalysisGenealogyGraphView.cs</DependentUpon>389 368 </EmbeddedResource> 390 369 </ItemGroup> -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymbolicDataAnalysisGenealogyGraphView.cs
r11881 r11925 85 85 // that will include just the individual and its ancestors 86 86 var graph = new GenealogyGraph<ISymbolicExpressionTree>(); 87 var ancestors = new[] { graphNode }.Concat(graphNode.Ancestors); 88 var cloned = ancestors.ToDictionary(x => x, x => cloner.Clone(x)); 89 graph.AddVertices(cloned.Values); 90 foreach (var arc in cloned.Keys.SelectMany(x => x.InArcs)) { 91 graph.AddArc(cloner.Clone(arc)); 92 } 87 var ancestors = new[] { graphNode }.Concat(graphNode.Ancestors).ToList(); 88 graph.AddVertices(ancestors.Select(cloner.Clone)); 89 graph.AddArcs(ancestors.SelectMany(x => x.InArcs).Select(cloner.Clone)); 93 90 MainFormManager.MainForm.ShowContent(graph); 94 91 } … … 185 182 private void navigateRightButton_Click(object sender, EventArgs e) { 186 183 var graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)genealogyGraphChart.SelectedGraphNode; 187 var inArcs = (List<IArc>)((IVertex)graphNode).InArcs;184 var inArcs = graphNode.InArcs.ToList(); 188 185 if (inArcs.Count > 0) { 189 186 var data = inArcs.Last().Data; … … 205 202 for (int i = 1; i < inArcs.Count; ++i) { 206 203 td = (TraceData)inArcs[i].Data; 207 var f2 = ((I SymbolicExpressionTree)inArcs[i].Source.Data).NodeAt(td.SubtreeIndex);204 var f2 = ((IGenealogyGraphNode<ISymbolicExpressionTree>)inArcs[i].Source).Data.NodeAt(td.SubtreeIndex); 208 205 // if the subtrees are the same we have found a match 209 206 // note: this is not necessarily 100% correct if in the trace graph we have identical fragments on different arcs … … 218 215 } 219 216 } 220 221 217 public class SymbolicDataAnalysisGenealogyGraphViewDesignable : GenealogyGraphView<ISymbolicExpressionTree> { } 218 219 internal static class Util { 220 internal static ISymbolicExpressionTreeNode NodeAt(this ISymbolicExpressionTree tree, int position) { 221 return NodeAt(tree.Root, position); 222 } 223 internal static ISymbolicExpressionTreeNode NodeAt(this ISymbolicExpressionTreeNode root, int position) { 224 return root.IterateNodesPrefix().ElementAt(position); 225 } 226 } 222 227 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r11858 r11925 321 321 <Compile Include="Tracking\TraceCalculator.cs" /> 322 322 <Compile Include="TransformationToSymbolicTreeMapper.cs" /> 323 <Compile Include="Tracking\FragmentGraph\FragmentGraph.cs" />324 323 <Compile Include="Tracking\SymbolicDataAnalysisExpressionAfterCrossoverOperator.cs" /> 325 324 <Compile Include="Tracking\SymbolicDataAnalysisExpressionBeforeCrossoverOperator.cs" /> -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionBeforeCrossoverOperator.cs
r11852 r11925 49 49 50 50 for (int i = 0; i < parents.Count; ++i) { 51 arcs[i].Data = parents[i].IterateNodesPrefix().To List();51 arcs[i].Data = parents[i].IterateNodesPrefix().ToCloneableCollection(); 52 52 } 53 53 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/TraceCalculator.cs
r11881 r11925 95 95 Debug.Assert(si < g.Data.Length); 96 96 var inArcs = (List<IArc>)((IVertex)g).InArcs; 97 var fragment = (IFragment<ISymbolicExpressionTreeNode>) inArcs.Last().Data;97 var fragment = (IFragment<ISymbolicExpressionTreeNode>)((IGenealogyGraphArc)inArcs.Last()).Data; 98 98 if (fragment == null) { 99 99 // TODO: think about what the correct behavior should be here (seems good so far) … … 225 225 } 226 226 // this class is here to help clarify the semantics 227 public class TraceData : Tuple<int, int, int, int> {227 public class TraceData : Tuple<int, int, int, int>, IDeepCloneable { 228 228 public TraceData(int currentSubtreeIndex, int currentFragmentIndex, int lastSubtreeIndex, int lastFragmentIndex) 229 229 : base(currentSubtreeIndex, currentFragmentIndex, lastSubtreeIndex, lastFragmentIndex) { … … 234 234 public int LastSubtreeIndex { get { return Item3; } } 235 235 public int LastFragmentIndex { get { return Item4; } } 236 public object Clone() { 237 return new TraceData(SubtreeIndex, FragmentIndex, LastSubtreeIndex, LastFragmentIndex); 238 } 239 240 public IDeepCloneable Clone(Cloner cloner) { 241 return cloner.Clone(this); 242 } 236 243 } 237 244
Note: See TracChangeset
for help on using the changeset viewer.