Changeset 10833
- Timestamp:
- 05/11/14 00:03:36 (11 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeTile.cs
r10827 r10833 40 40 public int PreferredNodeHeight { get; set; } 41 41 42 private const int labelHeight = 30;42 private const int labelHeight = 60; 43 43 44 44 private readonly SolidBrush defaultBrush; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.cs
r10830 r10833 132 132 if (!node.InArcs.Any()) continue; 133 133 var visualNode = GetMappedNode(node); 134 134 135 if (visualNode == null) continue; 135 136 foreach (var arc in node.InArcs) { … … 139 140 var pen = Pens.Transparent; 140 141 var visualArc = AddArc(Chart, visualParent, visualNode, pen); 142 visualArc.OneLayerDown(); // send it behind the visual nodes 141 143 if (!arcMap.ContainsKey(Tuple.Create(visualParent, visualNode))) { 142 144 arcMap.Add(Tuple.Create(visualParent, visualNode), visualArc); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers/GenealogyAnalyzer.cs
r10830 r10833 205 205 if (EnableCrossoverTracking.Value) { 206 206 if (BeforeCrossoverOperator != null) { 207 // BeforeCrossoverOperator.ParentsParameter.ActualName = CrossoverParentsParameterName;208 // BeforeCrossoverOperator.ChildParameter.ActualName = CrossoverChildParameterName;209 207 instrumentedCrossover.BeforeExecutionOperators.Add(BeforeCrossoverOperator); 210 208 } 211 209 if (AfterCrossoverOperator != null) { 212 // AfterCrossoverOperator.ParentsParameter.ActualName = CrossoverParentsParameterName;213 // AfterCrossoverOperator.ChildParameter.ActualName = CrossoverChildParameterName;214 210 instrumentedCrossover.AfterExecutionOperators.Add(AfterCrossoverOperator); 215 211 } … … 224 220 if (EnableManipulatorTracking.Value) { 225 221 if (BeforeManipulatorOperator != null) { 226 // BeforeManipulatorOperator.ChildParameter.ActualName = ManipulatorChildParameterName;227 222 instrumentedManipulator.BeforeExecutionOperators.Add(BeforeManipulatorOperator); 228 223 } 229 224 if (AfterManipulatorOperator != null) { 230 // AfterManipulatorOperator.ChildParameter.ActualName = ManipulatorChildParameterName;231 225 instrumentedManipulator.AfterExecutionOperators.Add(AfterManipulatorOperator); 232 226 } … … 257 251 IsElite = true 258 252 }; 253 // add new vertex to the graph 254 GenealogyGraph.AddVertex(vertex); 255 // swap content between current vertex and previous vertex 259 256 var previousVertex = (IGenealogyGraphNode<T>)GenealogyGraph[elite]; 260 GenealogyGraph.AddVertex(vertex); 257 var tmp = vertex.Content; 258 vertex.Content = previousVertex.Content; 259 previousVertex.Content = tmp; 260 // adjust graph content map 261 GenealogyGraph[vertex.Content] = vertex; 262 GenealogyGraph[previousVertex.Content] = previousVertex; 263 // connect current elite with previous elite 261 264 previousVertex.AddForwardArc(vertex); 262 265 vertex.AddReverseArc(previousVertex); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/DirectedGraph/DirectedGraph.cs
r10755 r10833 68 68 return result; 69 69 } 70 set { 71 contentMap[key] = value; 72 } 70 73 } 71 74 public virtual bool Any(Func<IVertex, bool> predicate) { -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/DirectedGraph/Interfaces/IDirectedGraph.cs
r10755 r10833 32 32 void RemoveVertex(IVertex vertex); 33 33 List<IVertex> Nodes { get; } 34 IVertex this[object content] { get; }34 IVertex this[object content] { get; set; } 35 35 bool Contains(object content); 36 36 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraph.cs
r10830 r10833 76 76 return result == null ? null : (IGenealogyGraphNode)result; 77 77 } 78 set { base[content] = value; } 78 79 } 79 80 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/FragmentGraphView.cs
r10827 r10833 1 using System.Collections.Generic; 1 using System; 2 using System.Collections.Generic; 2 3 using System.Drawing; 3 4 using System.Linq; … … 50 51 var tile = new SymbolicExpressionTreeTile(chart); 51 52 tile.LayoutEngine = symbolicExpressionEngine; 52 tile.Label = "Generation " + node.Rank; 53 tile.Label = "Generation " + node.Rank + Environment.NewLine + 54 "Quality " + String.Format("{0:0.000}", node.Quality); 53 55 tile.Root = node.Content.Root; 54 56 var tileNode = new TileLayoutNode { Tile = tile }; … … 131 133 } 132 134 } 135 // center display on the root of the fragment graph 136 symbolicExpressionChartControl.Chart.Move(tileDictionary[root].Tile.Position.X, tileDictionary[root].Tile.Position.Y); 133 137 symbolicExpressionChartControl.UpdateEnabled = true; 134 138 symbolicExpressionChartControl.EnforceUpdate(); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymboldDataAnalysisGenealogyView.Designer.cs
r10746 r10833 19 19 */ 20 20 #endregion 21 22 using System.Drawing; 21 23 22 24 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { … … 100 102 this.symbolicExpressionTreeChart.SuspendRepaint = false; 101 103 this.symbolicExpressionTreeChart.TabIndex = 0; 102 this.symbolicExpressionTreeChart.TextFont = new System.Drawing.Font( "Microsoft Sans Serif", 12F);104 this.symbolicExpressionTreeChart.TextFont = new System.Drawing.Font(FontFamily.GenericSansSerif, 10); 103 105 this.symbolicExpressionTreeChart.Tree = null; 104 106 // -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Matching/SymbolicExpressionTreeMaxCommonSequenceCalculator.cs
r10650 r10833 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 using System.Collections.Generic; 3 24 4 25 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Matching { 5 public class MaxCommonSequenceCalculator<T, U>26 public class MaxCommonSequenceCalculator<T, TComp> 6 27 where T : class 7 where U: IEqualityComparer<T> {28 where TComp : IEqualityComparer<T> { 8 29 9 public U Comparer { get; set; } 30 private TComp comparer; 31 public TComp Comparer { 32 get { return comparer; } 33 set { comparer = value; } 34 } 35 10 36 private int[,] matrix; 11 37 private List<T> sequence; 12 38 39 public MaxCommonSequenceCalculator(TComp comparer) { 40 this.comparer = comparer; 41 } 42 13 43 /// <summary> 14 /// Calculate the maximal common subsequence between arrays a and b and return it 44 /// Calculate the maximal common subsequence between arrays a and b and return it. 45 /// THIS DOES NOT WORK FOR TREES 15 46 /// </summary> 16 47 /// <param name="a"></param> … … 27 58 for (int i = 0; i <= m; ++i) { 28 59 for (int j = 0; j <= n; ++j) { 29 if (i == 0 || j == 0) { 30 matrix[i, j] = 0; 31 } else if (Comparer.Equals(a[i - 1], b[j - 1])) { 60 if (comparer.Equals(a[i - 1], b[j - 1])) { 32 61 matrix[i, j] = matrix[i - 1, j - 1] + 1; 33 62 } else { … … 36 65 } 37 66 } 38 recon(a, b, n, m);67 Recon(a, b, n, m); // build the common subsequence 39 68 return sequence; 40 69 } 41 70 42 private void recon(T[] a, T[] b, int i, int j) { 43 while (true) { 44 if (i == 0 || j == 0) return; 45 if (Comparer.Equals(a[i - 1], b[j - 1])) { 46 recon(a, b, i - 1, j - 1); 71 private void Recon(T[] a, T[] b, int i, int j) { 72 while (i > 0 && j > 0) { 73 if (comparer.Equals(a[i - 1], b[j - 1])) { 74 Recon(a, b, i - 1, j - 1); 47 75 sequence.Add(a[i - 1]); 48 76 } else if (matrix[i - 1, j] > matrix[i, j - 1]) { -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionAfterCrossoverOperator.cs
r10827 r10833 46 46 break; 47 47 } 48 //49 // if (fragment == null) {50 // throw new Exception("SymbolicDataAnalysisExpressionAfterCrossoverOperator: Could not identify fragment");51 // }52 48 53 49 arcs[0].Data = null; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionAfterManipulatorOperator.cs
r10827 r10833 57 57 } 58 58 59 // if (fragment == null) {60 // throw new Exception("SymbolicDataAnalysisExpressionAfterManipulatorOperator: Could not identify fragment");61 // }62 63 59 vChild.InArcs.First().Data = fragment; 64 60 return base.Apply(); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionBeforeCrossoverOperator.cs
r10755 r10833 20 20 #endregion 21 21 22 using System;23 22 using System.Linq; 24 23 using HeuristicLab.Core; … … 35 34 36 35 for (int i = 0; i < parents.Count; ++i) { 37 var nodes = parents[i].IterateNodesPrefix().ToList(); 38 arcs[i].Data = nodes; 36 arcs[i].Data = parents[i].IterateNodesPrefix().ToList(); 39 37 } 40 var parentVertices = childVertex.Parents.ToList(); 41 if (parents[0].Length != parentVertices[0].Content.Length || parents[1].Length != parentVertices[1].Content.Length) { 42 throw new Exception("Inconsistency detected in GenealogyGraph."); 43 } 38 39 // var parentVertices = childVertex.Parents.ToList(); 40 // 41 // if (parents[0].Length != parentVertices[0].Content.Length || parents[1].Length != parentVertices[1].Content.Length) { 42 // throw new Exception("Inconsistency detected in GenealogyGraph."); 43 // } 44 44 45 45 return result; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionBeforeManipulatorOperator.cs
r10827 r10833 33 33 vChild.InArcs.First().Data = vChild.Content.IterateNodesPrefix().ToList(); 34 34 35 var vClone = (IGenealogyGraphNode<ISymbolicExpressionTree>)vChild.InArcs.Last().Source; 36 var fragment = (IFragment<ISymbolicExpressionTreeNode>)vClone.InArcs.Last().Data; 37 if (fragment != null) { 38 // this step must be performed because the fragment root actually references the original child (not the clone). 39 // then, a mutation operation (acting on the original child), could disrupt it 40 fragment.Root = vClone.Content.IterateNodesPrefix().ElementAt(fragment.Index1); 41 } 42 35 43 return result; 36 44 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionTracing.cs
r10827 r10833 30 30 var fragmentNode = new FragmentNode { 31 31 Content = new Fragment<ISymbolicExpressionTreeNode> { Root = node.Content.NodeAt(index) }, 32 Rank = node.Rank 32 Rank = node.Rank, 33 Quality = node.Quality 33 34 }; 34 35 if (parent != null) { … … 98 99 var fragmentNode = new FragmentNode { 99 100 Content = new Fragment<ISymbolicExpressionTreeNode> { Root = subtree }, 100 Rank = node.Rank 101 Rank = node.Rank, 102 Quality = node.Quality 101 103 }; 102 104 if (parent != null) { -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Tracking.sln
r10746 r10833 2 2 Microsoft Visual Studio Solution File, Format Version 12.00 3 3 # Visual Studio 2013 4 VisualStudioVersion = 12.0. 30110.04 VisualStudioVersion = 12.0.21005.1 5 5 MinimumVisualStudioVersion = 10.0.40219.1 6 6 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C80F4C35-CB87-4695-8A53-6F2D08275253}" … … 170 170 HideSolutionNode = FALSE 171 171 EndGlobalSection 172 GlobalSection(Performance) = preSolution173 HasPerformanceSessions = true174 EndGlobalSection175 172 GlobalSection(TestCaseManagementSettings) = postSolution 176 173 CategoryFile = HeuristicLab.Tracking.vsmdi
Note: See TracChangeset
for help on using the changeset viewer.