Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11852


Ignore:
Timestamp:
02/01/15 23:17:56 (10 years ago)
Author:
bburlacu
Message:

#1772: Added some useful functionality to the GenealogyGraphView.

Location:
branches/HeuristicLab.EvolutionTracking
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Tests/GenealogyOperationsPerformanceTests.cs

    r11694 r11852  
    4848      //      var trace = tc.Trace(bestIndividual, 2);
    4949      sw.Stop();
    50       Console.WriteLine("Avg trace size: {0}", s / graph.Ranks.Last().Value.Count);
     50      Console.WriteLine("Avg trace size: {0}", s / graph.Ranks.Last().Value.Count());
    5151      //      var ancestry = bestIndividual.Ancestors;
    5252      //      Console.WriteLine("Ancestry size: {0}", ancestry.Count());
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.cs

    r11817 r11852  
    4040    private readonly Pen defaultPen;
    4141
     42    private Dictionary<IGenealogyGraphNode, VisualGenealogyGraphNode> nodeMap;
     43    private Dictionary<Tuple<VisualGenealogyGraphNode, VisualGenealogyGraphNode>, VisualGenealogyGraphArc> arcMap;
     44
    4245    public IGenealogyGraph GenealogyGraph {
    4346      get { return genealogyGraph; }
     
    6366    }
    6467
    65     private Dictionary<IGenealogyGraphNode, VisualGenealogyGraphNode> nodeMap;
    66     private Dictionary<Tuple<VisualGenealogyGraphNode, VisualGenealogyGraphNode>, VisualGenealogyGraphArc> arcMap;
     68    public bool UpdateEnabled {
     69      get { return Chart.UpdateEnabled; }
     70      set { Chart.UpdateEnabled = value; }
     71    }
     72
     73    public void EnforceUpdate() {
     74      Chart.EnforceUpdate();
     75    }
    6776
    6877    #region chart modes
     
    225234
    226235      // update
    227       Chart.UpdateEnabled = true;
    228       Chart.EnforceUpdate();
     236      UpdateEnabled = true;
     237      EnforceUpdate();
    229238
    230239      if (SelectedVisualNode != null)
    231         /* emit clicked event */
    232         OnGenealogyGraphNodeClicked(SelectedVisualNode, e);
     240        OnGenealogyGraphNodeClicked(SelectedVisualNode, e); // emit clicked event
    233241
    234242      base.pictureBox_MouseUp(sender, e);
     
    306314    }
    307315
     316    public void ClearArcs() {
     317      foreach (var primitive in Chart.Group.Primitives.OfType<VisualGenealogyGraphArc>()) {
     318        primitive.Pen = Pens.Transparent;
     319      }
     320    }
     321
     322    public void ClearNodes() {
     323      foreach (var primitive in Chart.Group.Primitives.OfType<VisualGenealogyGraphNode>()) {
     324        primitive.Brush = new SolidBrush(Color.Transparent);
     325        primitive.Pen = new Pen(Color.LightGray);
     326      }
     327    }
     328
    308329    public virtual void ClearPrimitives() {
    309330      foreach (var primitive in Chart.Group.Primitives) {
     
    313334          primitive.Brush = new SolidBrush(Color.Transparent);
    314335          primitive.Pen = new Pen(Color.DarkGray);
    315         }
    316       }
    317     }
    318 
    319     public void HighlightNodes(IEnumerable<IGenealogyGraphNode> nodes) {
    320       Chart.UpdateEnabled = false;
    321       ClearPrimitives();
     336          //          primitive.Pen = Pens.Transparent; // remove the node contour
     337        }
     338      }
     339    }
     340
     341    public void HighlightNodes(IEnumerable<IGenealogyGraphNode> nodes, bool clearPrimitives = true) {
     342      if (clearPrimitives)
     343        ClearPrimitives();
     344
    322345      foreach (var node in nodes) {
    323346        var graphNode = GetMappedNode(node);
    324347        graphNode.Brush = new SolidBrush(node.GetColor());
    325348      }
    326       Chart.UpdateEnabled = true;
    327       Chart.EnforceUpdate();
     349    }
     350
     351    public void HighlightNodes(IEnumerable<IGenealogyGraphNode> nodes, Color color, bool clearPrimitives = true) {
     352      if (clearPrimitives)
     353        ClearPrimitives();
     354
     355      foreach (var node in nodes.Select(GetMappedNode)) {
     356        node.Brush = new SolidBrush(color);
     357      }
    328358    }
    329359
    330360    public void HighlightAll() {
    331       Chart.UpdateEnabled = false;
    332361      foreach (var visualNode in nodeMap.Values) {
    333362        visualNode.Brush = new SolidBrush(visualNode.Data.GetColor());
     
    340369        arc.Pen.Brush = new LinearGradientBrush(start, end, source.GetColor(), target.GetColor());
    341370      }
    342       Chart.UpdateEnabled = true;
    343       Chart.EnforceUpdate();
    344371    }
    345372
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphView.Designer.cs

    r11817 r11852  
    2626    private void InitializeComponent() {
    2727      this.splitContainer = new System.Windows.Forms.SplitContainer();
     28      this.genealogyGraphChart = new HeuristicLab.EvolutionTracking.Views.GenealogyGraphChart();
    2829      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    2930      this.groupBox = new System.Windows.Forms.GroupBox();
     
    3132      this.simpleLineages_checkBox = new System.Windows.Forms.CheckBox();
    3233      this.trace_checkBox = new System.Windows.Forms.CheckBox();
    33       this.genealogyGraphChart = new HeuristicLab.EvolutionTracking.Views.GenealogyGraphChart();
     34      this.openNew_CheckBox = new System.Windows.Forms.CheckBox();
    3435      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    3536      this.splitContainer.Panel1.SuspendLayout();
     
    5859      this.splitContainer.TabIndex = 0;
    5960      //
     61      // genealogyGraphChart
     62      //
     63      this.genealogyGraphChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     64            | System.Windows.Forms.AnchorStyles.Left)
     65            | System.Windows.Forms.AnchorStyles.Right)));
     66      this.genealogyGraphChart.BackColor = System.Drawing.SystemColors.Control;
     67      this.genealogyGraphChart.GenealogyGraph = null;
     68      this.genealogyGraphChart.Location = new System.Drawing.Point(0, 0);
     69      this.genealogyGraphChart.LockGenealogy = false;
     70      this.genealogyGraphChart.Name = "genealogyGraphChart";
     71      this.genealogyGraphChart.ScaleOnResize = true;
     72      this.genealogyGraphChart.SimpleLineages = false;
     73      this.genealogyGraphChart.Size = new System.Drawing.Size(689, 738);
     74      this.genealogyGraphChart.TabIndex = 0;
     75      this.genealogyGraphChart.TraceFragments = false;
     76      this.genealogyGraphChart.UpdateEnabled = true;
     77      //
    6078      // viewHost
    6179      //
     
    7795      // groupBox
    7896      //
     97      this.groupBox.Controls.Add(this.openNew_CheckBox);
    7998      this.groupBox.Controls.Add(this.lockGraph_checkBox);
    8099      this.groupBox.Controls.Add(this.simpleLineages_checkBox);
     
    123142      this.trace_checkBox.CheckedChanged += new System.EventHandler(this.trace_checkBox_CheckedChanged);
    124143      //
    125       // genealogyGraphChart
     144      // openNew_CheckBox
    126145      //
    127       this.genealogyGraphChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    128             | System.Windows.Forms.AnchorStyles.Left)
    129             | System.Windows.Forms.AnchorStyles.Right)));
    130       this.genealogyGraphChart.BackColor = System.Drawing.SystemColors.Control;
    131       this.genealogyGraphChart.GenealogyGraph = null;
    132       this.genealogyGraphChart.Location = new System.Drawing.Point(0, 0);
    133       this.genealogyGraphChart.LockGenealogy = false;
    134       this.genealogyGraphChart.Name = "genealogyGraphChart";
    135       this.genealogyGraphChart.ScaleOnResize = true;
    136       this.genealogyGraphChart.SimpleLineages = false;
    137       this.genealogyGraphChart.Size = new System.Drawing.Size(689, 738);
    138       this.genealogyGraphChart.TabIndex = 0;
    139       this.genealogyGraphChart.TraceFragments = false;
     146      this.openNew_CheckBox.AutoSize = true;
     147      this.openNew_CheckBox.Location = new System.Drawing.Point(237, 20);
     148      this.openNew_CheckBox.Name = "openNew_CheckBox";
     149      this.openNew_CheckBox.Size = new System.Drawing.Size(111, 17);
     150      this.openNew_CheckBox.TabIndex = 1;
     151      this.openNew_CheckBox.Text = "Open in new view";
     152      this.openNew_CheckBox.UseVisualStyleBackColor = true;
    140153      //
    141154      // GenealogyGraphView
     
    166179    protected System.Windows.Forms.CheckBox simpleLineages_checkBox;
    167180    protected System.Windows.Forms.CheckBox lockGraph_checkBox;
     181    protected System.Windows.Forms.CheckBox openNew_CheckBox;
    168182
    169183  }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/HeuristicLab.EvolutionTracking.Views-3.4.csproj

    r11639 r11852  
    129129    <None Include="HeuristicLab.snk" />
    130130  </ItemGroup>
     131  <ItemGroup>
     132    <EmbeddedResource Include="GenealogyGraphView.resx">
     133      <DependentUpon>GenealogyGraphView.cs</DependentUpon>
     134    </EmbeddedResource>
     135  </ItemGroup>
    131136  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    132137  <PropertyGroup>
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Fragment.cs

    r10830 r11852  
    1919      set { root = value; }
    2020    }
    21 
    2221    [StorableConstructor]
    2322    protected Fragment(bool deserializable) : base(deserializable) { }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraph.cs

    r11752 r11852  
    154154      sb.AppendLine("graph fragmentgraph {");
    155155      foreach (var v in Vertices) {
    156         sb.AppendLine("\"" + v.Id + "\"[shape=circle, style = filled, width = " + v.Degree / 2.0 + ", label = " + v.Rank + ", fillcolor = \"" + ColorTranslator.ToHtml(GetColor(v)) + "\"]");
     156        double width = Math.Max(0.5, v.Degree);
     157        sb.AppendLine("\"" + v.Id + "\"[shape=circle, style = filled, width = " + width + ", label = " + v.Rank + "\n" + String.Format("{0:00}", v.Quality) + ", fillcolor = \"" + ColorTranslator.ToHtml(GetColor(v)) + "\"]");
    157158      }
    158159      foreach (var a in Arcs) {
     
    167168      if (colorIndex >= ColorGradient.Colors.Count) return ColorGradient.Colors.Last();
    168169      return ColorGradient.Colors[colorIndex];
     170    }
     171
     172    public override void AddVertices(IEnumerable<IVertex> vertexList) {
     173      base.AddVertices(vertexList);
     174      RebuildDictionaries();
    169175    }
    170176  }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraphNode.cs

    r11750 r11852  
    6262      get { return InArcs.Select(a => a.Source); }
    6363    }
     64
    6465    public IEnumerable<IGenealogyGraphNode> Children {
    6566      get { return OutArcs.Select(a => a.Target); }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views

  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/VariableView.cs

    r11638 r11852  
    132132        Content.Fixed = true;
    133133        DeregisterContentEvents();
    134         Content.VariableNames = variableNamesView.Content.CheckedItems.Select(x => x.Value).ToList();
     134        Content.VariableNames = variableNamesView.Content.CheckedItems.Select(x => x.Value);
     135        Content.AllVariableNames = variableNamesView.Content.Select(x => x.Value);
    135136        RegisterContentEvents();
    136137      }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymbolicDataAnalysisGenealogyGraphView.cs

    r11817 r11852  
    2525using System.Linq;
    2626using System.Windows.Forms;
     27using HeuristicLab.Common;
    2728using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2829using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
     
    7273      var visualNode = (VisualGenealogyGraphNode)sender;
    7374      var graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)visualNode.Data;
     75
     76      if (openNew_CheckBox.Checked) {
     77        // get the ancestors into a new view
     78        var cloner = new Cloner();
     79
     80        var graph = new GenealogyGraph<ISymbolicExpressionTree>();
     81        var ancestors = new[] { graphNode }.Concat(graphNode.Ancestors);
     82        var cloned = ancestors.ToDictionary(x => x, x => cloner.Clone(x));
     83        graph.AddVertices(cloned.Values);
     84        foreach (var arc in cloned.Keys.SelectMany(x => x.InArcs)) {
     85          graph.AddArc(cloner.Clone(arc));
     86        }
     87        //        graph.AddVertices(graphNode.Ancestors);
     88        MainFormManager.MainForm.ShowContent(graph);
     89      }
     90
    7491      if (graphNode.InArcs.Any()) {
    7592        var fragment = graphNode.InArcs.Last().Data as IFragment<ISymbolicExpressionTreeNode>;
     
    92109      var visualNode = (VisualTreeNode<ISymbolicExpressionTreeNode>)sender;
    93110      var subtree = visualNode.Content;
    94 
    95111      // highlight the selected subtree inside the displayed tree on the right hand side
    96112      treeChart_ClearColors();
     
    103119        var graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)genealogyGraphChart.SelectedGraphNode;
    104120        var subtreeIndex = graphNode.Data.IterateNodesPrefix().ToList().IndexOf(subtree);
    105         //        var fragmentGraph = SymbolicDataAnalysisExpressionTracing.TraceSubtree(graphNode, subtreeIndex);
    106121        var traceGraph = TraceCalculator.TraceSubtree(graphNode, subtreeIndex);
    107 
    108122        if (traceGraph.Vertices.Any()) {
     123          genealogyGraphChart.UpdateEnabled = false;
     124          genealogyGraphChart.ClearArcs();
     125          //          genealogyGraphChart.ClearPrimitives();
    109126          var genealogyNodes = traceGraph.Vertices.Select(v => Content.GetByContent(v.Data));
    110           genealogyGraphChart.HighlightNodes(genealogyNodes);
    111           foreach (var a in traceGraph.Arcs) {
    112             genealogyGraphChart.HighlightArc(Content.GetByContent(a.Target.Data), Content.GetByContent(a.Source.Data));
    113           }
     127          //          genealogyGraphChart.HighlightNodes(graphNode.Ancestors, Color.Gray, false);
     128          genealogyGraphChart.HighlightNodes(genealogyNodes, Color.Black, false);
     129          //          foreach (var a in traceGraph.Arcs) {
     130          //            genealogyGraphChart.HighlightArc(Content.GetByContent(a.Target.Data), Content.GetByContent(a.Source.Data));
     131          //          }
     132          genealogyGraphChart.UpdateEnabled = true;
     133          genealogyGraphChart.EnforceUpdate();
    114134          MainFormManager.MainForm.ShowContent(traceGraph); // display the fragment graph on the screen
    115135        }
     
    121141
    122142        var matchingVertices = matchingTrees.Select(x => Content.GetByContent(x));
    123         graphChart_highlightMatchingVertices(matchingVertices);
     143        graphChart_HighlightMatchingVertices(matchingVertices);
    124144      }
    125145    }
    126146
    127     private void graphChart_highlightMatchingVertices(IEnumerable<IGenealogyGraphNode> vertices) {
     147    private void graphChart_HighlightMatchingVertices(IEnumerable<IGenealogyGraphNode> vertices) {
    128148      genealogyGraphChart.Chart.UpdateEnabled = false;
    129149      genealogyGraphChart.ClearPrimitives();
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationAnalyzer.cs

    r11208 r11852  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Data;
     28using HeuristicLab.Optimization;
    2829using HeuristicLab.Parameters;
    2930using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3637  [StorableClass]
    3738  public abstract class SymbolicDataAnalysisSingleObjectiveValidationAnalyzer<T, U> : SymbolicDataAnalysisSingleObjectiveAnalyzer,
    38     ISymbolicDataAnalysisValidationAnalyzer<T, U>
     39    ISymbolicDataAnalysisValidationAnalyzer<T, U>, IStochasticOperator
    3940    where T : class, ISymbolicDataAnalysisSingleObjectiveEvaluator<U>
    4041    where U : class, IDataAnalysisProblemData {
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionBeforeCrossoverOperator.cs

    r11694 r11852  
    4545      var result = base.Apply(); // the base operator will add the child to the graph before the actual crossover operation takes place
    4646      var parents = ParentsParameter.ActualValue.ToList();
    47       var childVertex = (IGenealogyGraphNode<ISymbolicExpressionTree>)GenealogyGraph.GetByContent(parents[0]); // use the parent since it is actually the child before crossover (and the ChildParameter doesn't have a value yet)
     47      var childVertex = GenealogyGraph.GetByContent(parents[0]); // use the parent since it is actually the child before crossover (and the ChildParameter doesn't have a value yet)
    4848      var arcs = childVertex.InArcs.ToList();
    4949
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/TraceCalculator.cs

    r11751 r11852  
    204204        return;
    205205      var lastTraceData = traceMap[last];
    206       int lastSi = lastTraceData.Item1; // last subtree index
    207       int lastFi = lastTraceData.Item2; // last fragment index
     206      int lastSi = lastTraceData.Item1; // last subtree index (index of the traced subtree in the parent)
     207      int lastFi = lastTraceData.Item2; // last fragment index (index of the fragment in the parent)
    208208      var td = new Tuple<int, int, int, int>(si, fi, lastSi, lastFi); // trace data
    209209      var arc = n.InArcs.SingleOrDefault(a => a.Source == last && a.Data.Equals(td));
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.TravelingSalesman

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.TravelingSalesman.Views

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Tracking.sln

    r11694 r11852  
    184184    HideSolutionNode = FALSE
    185185  EndGlobalSection
    186   GlobalSection(Performance) = preSolution
    187     HasPerformanceSessions = true
    188   EndGlobalSection
    189186  GlobalSection(TestCaseManagementSettings) = postSolution
    190187    CategoryFile = HeuristicLab.Tracking.vsmdi
Note: See TracChangeset for help on using the changeset viewer.