Changeset 12017
- Timestamp:
- 02/16/15 16:52:52 (10 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj
r11925 r12017 367 367 <SubType>Designer</SubType> 368 368 </EmbeddedResource> 369 <EmbeddedResource Include="Tracking\SymbolicDataAnalysisGenealogyGraphView.resx"> 370 <DependentUpon>SymbolicDataAnalysisGenealogyGraphView.cs</DependentUpon> 371 </EmbeddedResource> 369 372 </ItemGroup> 370 373 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymbolicDataAnalysisGenealogyGraphView.Designer.cs
r11864 r12017 63 63 // splitContainer 64 64 // 65 this.splitContainer.Size = new System.Drawing.Size(1241, 700); 66 this.splitContainer.SplitterDistance = 617; 67 // 68 // viewHost 69 // 70 this.viewHost.Size = new System.Drawing.Size(617, 697); 65 71 // 66 72 // genealogyGraphChart 67 73 // 68 this.genealogyGraphChart.Size = new System.Drawing.Size(6 92, 697);74 this.genealogyGraphChart.Size = new System.Drawing.Size(614, 697); 69 75 // 70 76 // groupBox1 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymbolicDataAnalysisGenealogyGraphView.cs
r11927 r12017 39 39 private readonly ISymbolicExpressionTreeNodeEqualityComparer comparer; 40 40 41 private ISymbolicExpressionTreeNode selectedSubtree; 42 private ISymbolicExpressionTreeNode SelectedSubtree { 43 get { 44 return selectedSubtree; 45 } 46 set { 47 if (selectedSubtree == value) return; 48 selectedSubtree = value; 49 ClonedSubtree = (ISymbolicExpressionTreeNode)selectedSubtree.Clone(); 50 } 51 } 52 53 private ISymbolicExpressionTreeNode ClonedSubtree { get; set; } 54 41 55 public SymbolicDataAnalysisGenealogyGraphView() { 42 56 InitializeComponent(); … … 100 114 var nodes = graphNode.Data.IterateNodesPrefix().ToList(); 101 115 treeChart_HighlightSubtree(nodes[td.LastSubtreeIndex], Color.Orange); 102 treeChart_HighlightSubtree(nodes[td.LastFragmentIndex], Color.DodgerBlue);116 treeChart_HighlightSubtree(nodes[td.LastFragmentIndex], null, Color.PowderBlue); 103 117 } 104 118 } … … 114 128 bool trace = genealogyGraphChart.TraceFragments; // check whether we are in 'trace' or 'match' mode 115 129 116 if (trace) { 117 // perform fragment tracing 118 var graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)genealogyGraphChart.SelectedGraphNode; 119 var subtreeIndex = graphNode.Data.IterateNodesPrefix().ToList().IndexOf(subtree); 120 var traceGraph = TraceCalculator.TraceSubtree(graphNode, subtreeIndex); 121 if (traceGraph.Vertices.Any()) { 122 genealogyGraphChart.UpdateEnabled = false; 123 genealogyGraphChart.ClearArcs(); 124 var genealogyNodes = traceGraph.Vertices.Select(v => Content.GetByContent(v.Data)); 125 genealogyGraphChart.HighlightNodes(genealogyNodes, Color.Black, false); 126 genealogyGraphChart.UpdateEnabled = true; 127 genealogyGraphChart.EnforceUpdate(); 128 MainFormManager.MainForm.ShowContent(traceGraph); // display the fragment graph on the screen 129 } 130 } else { 131 // perform matching like it was done before 132 // currently there is no possibility to specify the subtree matching criteria 133 var trees = Content.Vertices.Select(x => x.Data); 134 var matchingTrees = trees.Where(x => x.Root.ContainsSubtree(subtree, comparer)); 135 136 var matchingVertices = matchingTrees.Select(x => Content.GetByContent(x)); 137 graphChart_HighlightMatchingVertices(matchingVertices); 130 switch (args.Button) { 131 case MouseButtons.Left: 132 SelectedSubtree = subtree; 133 if (trace) { 134 // perform fragment tracing 135 var graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)genealogyGraphChart.SelectedGraphNode; 136 var subtreeIndex = graphNode.Data.IterateNodesPrefix().ToList().IndexOf(subtree); 137 var traceGraph = TraceCalculator.TraceSubtree(graphNode, subtreeIndex); 138 if (traceGraph.Vertices.Any()) { 139 genealogyGraphChart.UpdateEnabled = false; 140 genealogyGraphChart.ClearArcs(); 141 var genealogyNodes = traceGraph.Vertices.Select(v => Content.GetByContent(v.Data)); 142 genealogyGraphChart.HighlightNodes(genealogyNodes, Color.Black, false); 143 genealogyGraphChart.UpdateEnabled = true; 144 genealogyGraphChart.EnforceUpdate(); 145 MainFormManager.MainForm.ShowContent(traceGraph); // display the fragment graph on the screen 146 } 147 } else { 148 // perform matching like it was done before 149 // currently there is no possibility to specify the subtree matching criteria 150 var trees = Content.Vertices.Select(x => x.Data); 151 var matchingTrees = trees.Where(x => x.Root.ContainsSubtree(subtree, comparer)); 152 153 var matchingVertices = matchingTrees.Select(x => Content.GetByContent(x)); 154 graphChart_HighlightMatchingVertices(matchingVertices); 155 } 156 break; 157 case MouseButtons.Middle: 158 var index = SelectedSubtree.IterateNodesPrefix().ToList().IndexOf(subtree); 159 if (index > 0) { 160 var s = ClonedSubtree.NodeAt(index); 161 s.Parent.RemoveSubtree(s.Parent.IndexOfSubtree(s)); 162 163 var trees = Content.Vertices.Select(x => x.Data); 164 var matchingTrees = trees.Where(x => x.Root.ContainsSubtree(ClonedSubtree, comparer)); 165 166 var matchingVertices = matchingTrees.Select(x => Content.GetByContent(x)); 167 treeChart_HighlightSubtree(subtree, Color.Black, Color.White); 168 graphChart_HighlightMatchingVertices(matchingVertices); 169 } 170 break; 138 171 } 139 172 } … … 158 191 } 159 192 160 private void treeChart_HighlightSubtree(ISymbolicExpressionTreeNode subtree, Color? color = null) { 161 Color myColor = color ?? Color.RoyalBlue; 193 private void treeChart_HighlightSubtree(ISymbolicExpressionTreeNode subtree, Color? lineColor = null, Color? fillColor = null) { 194 var lc = lineColor ?? Color.RoyalBlue; 195 var fc = fillColor ?? Color.White; 162 196 foreach (var s in subtree.IterateNodesPrefix()) { 163 197 var visualNode = SymbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(s); 164 visualNode.LineColor = myColor; 198 visualNode.LineColor = lc; 199 visualNode.FillColor = fc; 165 200 166 201 foreach (var c in s.Subtrees) { 167 202 var visualArc = SymbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNodeConnection(s, c); 168 visualArc.LineColor = myColor;203 visualArc.LineColor = lc; 169 204 } 170 205 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisBottomUpDiversityAnalyzer.cs
r11965 r12017 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 21 21 22 22 using HeuristicLab.Analysis; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 26 26 27 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Analyzers { 27 [Item("SymbolicDataAnalysisBottomUpDiversityAnalyzer", "A diversity analyzer based on the bottom-up similaritybetween trees.")]28 [Item("SymbolicDataAnalysisBottomUpDiversityAnalyzer", "A diversity analyzer based on the bottom-up distance between trees.")] 28 29 [StorableClass] 29 30 public class SymbolicDataAnalysisBottomUpDiversityAnalyzer : SingleObjectivePopulationDiversityAnalyzer { … … 31 32 protected SymbolicDataAnalysisBottomUpDiversityAnalyzer(bool deserializing) : base(deserializing) { } 32 33 33 [StorableHook(HookType.AfterDeserialization)] 34 private void AfterDeserialization() { 34 private SymbolicDataAnalysisBottomUpDiversityAnalyzer(SymbolicDataAnalysisBottomUpDiversityAnalyzer original, Cloner cloner) 35 : base(original, cloner) { 36 } 37 38 public override IDeepCloneable Clone(Cloner cloner) { 39 return new SymbolicDataAnalysisBottomUpDiversityAnalyzer(this, cloner); 35 40 } 36 41 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisPhenotypicDiversityAnalyzer.cs
r11291 r12017 22 22 using System.Linq; 23 23 using HeuristicLab.Analysis; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Data; … … 29 30 30 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Analyzers { 31 [Item("SymbolicDataAnalysisPhenotypicDiversityAnalyzer", "An analyzer which calculates diversity based on the phenotypic similaritybetween trees")]32 [Item("SymbolicDataAnalysisPhenotypicDiversityAnalyzer", "An analyzer which calculates diversity based on the phenotypic distance between trees")] 32 33 [StorableClass] 33 34 public class SymbolicDataAnalysisPhenotypicDiversityAnalyzer : SingleObjectivePopulationDiversityAnalyzer { 35 #region parameter names 34 36 private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree"; 35 37 private const string EvaluatedValuesParameterName = "EstimatedValues"; … … 37 39 private const string ProblemDataParameterName = "ProblemData"; 38 40 private const string EstimationLimitsParameterName = "EstimationLimits"; 41 #endregion 39 42 43 #region parameter properties 40 44 public IScopeTreeLookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { 41 45 get { return (IScopeTreeLookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; } … … 56 60 get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; } 57 61 } 62 #endregion 58 63 59 64 public SymbolicDataAnalysisPhenotypicDiversityAnalyzer() { 60 65 SimilarityCalculator = new PhenotypicSimilarityCalculator { SolutionVariableName = "SymbolicExpressionTree" }; 61 66 #region add parameters 62 67 Parameters.Add(new ScopeTreeLookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees.")); 63 68 Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>(EvaluatedValuesParameterName, "Intermediate estimated values to be saved in the scopes.")); … … 65 70 Parameters.Add(new ValueLookupParameter<IDataAnalysisProblemData>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated.")); 66 71 Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The upper and lower limit that should be used as cut off value for the output values of symbolic data analysis trees.")); 72 #endregion 73 } 74 75 [StorableConstructor] 76 protected SymbolicDataAnalysisPhenotypicDiversityAnalyzer(bool deserializing) 77 : base(deserializing) { 78 } 79 80 public override IDeepCloneable Clone(Cloner cloner) { 81 return new SymbolicDataAnalysisPhenotypicDiversityAnalyzer(this, cloner); 82 } 83 84 private SymbolicDataAnalysisPhenotypicDiversityAnalyzer(SymbolicDataAnalysisPhenotypicDiversityAnalyzer original, Cloner cloner) 85 : base(original, cloner) { 67 86 } 68 87 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeBottomUpSimilarityCalculator.cs
r11965 r12017 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 81 81 82 82 // visit nodes in order of decreasing height to ensure correct mapping 83 var nodes1 = n1.IterateNodesPrefix(). ToList();83 var nodes1 = n1.IterateNodesPrefix().OrderByDescending(x => x.GetDepth()).ToList(); 84 84 var nodes2 = n2.IterateNodesPrefix().ToList(); 85 85 for (int i = 0; i < nodes1.Count; ++i) { … … 98 98 if (w == null) continue; 99 99 100 // at this point we know that v and w are isomorphic, however, the mapping cannot be done directly (as in the paper) because the trees are unordered (subtree order might differ) 101 // the solution is to sort subtrees by label using IterateBreadthOrdered (this will work because the subtrees are isomorphic!) and simultaneously iterate over the two subtrees 100 // at this point we know that v and w are isomorphic, however, the mapping cannot be done directly 101 // (as in the paper) because the trees are unordered (subtree order might differ). the solution is 102 // to sort subtrees from under commutative labels (this will work because the subtrees are isomorphic!) 103 // while iterating over the two subtrees 102 104 var vv = IterateBreadthOrdered(v, comparer).ToList(); 103 105 var ww = IterateBreadthOrdered(w, comparer).ToList(); … … 133 135 foreach (var n in nodes) { 134 136 if (n.SubtreeCount == 0) { 135 var label = Label(n);137 var label = GetLabel(n); 136 138 if (!labelMap.ContainsKey(label)) { 137 139 var z = new GraphNode { SymbolicExpressionTreeNode = n, Label = label }; … … 209 211 } 210 212 211 private static string Label(ISymbolicExpressionTreeNode node) {213 private static string GetLabel(ISymbolicExpressionTreeNode node) { 212 214 if (node.SubtreeCount > 0) 213 215 return node.Symbol.Name; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreePhenotypicSimilarityCalculator.cs
r11927 r12017 34 34 public ISymbolicDataAnalysisExpressionTreeInterpreter Interpreter { get; set; } 35 35 36 [StorableConstructor] 37 protected PhenotypicSimilarityCalculator(bool deserializing) : base(deserializing) { } 38 36 39 public PhenotypicSimilarityCalculator(PhenotypicSimilarityCalculator original, Cloner cloner) 37 40 : base(original, cloner) { 41 this.ProblemData = original.ProblemData; 42 this.Interpreter = original.Interpreter; 38 43 } 39 40 public PhenotypicSimilarityCalculator() { }41 42 [StorableConstructor]43 protected PhenotypicSimilarityCalculator(bool deserializing) : base(deserializing) { }44 44 45 45 public override IDeepCloneable Clone(Cloner cloner) { 46 46 return new PhenotypicSimilarityCalculator(this, cloner); 47 47 } 48 49 public PhenotypicSimilarityCalculator() { } 48 50 49 51 public double CalculateSimilarity(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2) { -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Tracking.sln
r11968 r12017 10 10 Local.testsettings = Local.testsettings 11 11 Performance1.psess = Performance1.psess 12 Performance2.psess = Performance2.psess 12 13 Performance3.psess = Performance3.psess 13 14 PreBuildEvent.cmd = PreBuildEvent.cmd
Note: See TracChangeset
for help on using the changeset viewer.