Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10833


Ignore:
Timestamp:
05/11/14 00:03:36 (10 years ago)
Author:
bburlacu
Message:

#1772: Fixed another minor display bug concerning elite individuals. Fixed bug when saving fragments from mutation. Displayed quality as well in the SymbolicExpressionTreeTile.

Location:
branches/HeuristicLab.EvolutionTracking
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeTile.cs

    r10827 r10833  
    4040    public int PreferredNodeHeight { get; set; }
    4141
    42     private const int labelHeight = 30;
     42    private const int labelHeight = 60;
    4343
    4444    private readonly SolidBrush defaultBrush;
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.cs

    r10830 r10833  
    132132        if (!node.InArcs.Any()) continue;
    133133        var visualNode = GetMappedNode(node);
     134
    134135        if (visualNode == null) continue;
    135136        foreach (var arc in node.InArcs) {
     
    139140          var pen = Pens.Transparent;
    140141          var visualArc = AddArc(Chart, visualParent, visualNode, pen);
     142          visualArc.OneLayerDown(); // send it behind the visual nodes
    141143          if (!arcMap.ContainsKey(Tuple.Create(visualParent, visualNode))) {
    142144            arcMap.Add(Tuple.Create(visualParent, visualNode), visualArc);
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers/GenealogyAnalyzer.cs

    r10830 r10833  
    205205        if (EnableCrossoverTracking.Value) {
    206206          if (BeforeCrossoverOperator != null) {
    207             //            BeforeCrossoverOperator.ParentsParameter.ActualName = CrossoverParentsParameterName;
    208             //            BeforeCrossoverOperator.ChildParameter.ActualName = CrossoverChildParameterName;
    209207            instrumentedCrossover.BeforeExecutionOperators.Add(BeforeCrossoverOperator);
    210208          }
    211209          if (AfterCrossoverOperator != null) {
    212             //            AfterCrossoverOperator.ParentsParameter.ActualName = CrossoverParentsParameterName;
    213             //            AfterCrossoverOperator.ChildParameter.ActualName = CrossoverChildParameterName;
    214210            instrumentedCrossover.AfterExecutionOperators.Add(AfterCrossoverOperator);
    215211          }
     
    224220        if (EnableManipulatorTracking.Value) {
    225221          if (BeforeManipulatorOperator != null) {
    226             //            BeforeManipulatorOperator.ChildParameter.ActualName = ManipulatorChildParameterName;
    227222            instrumentedManipulator.BeforeExecutionOperators.Add(BeforeManipulatorOperator);
    228223          }
    229224          if (AfterManipulatorOperator != null) {
    230             //            AfterManipulatorOperator.ChildParameter.ActualName = ManipulatorChildParameterName;
    231225            instrumentedManipulator.AfterExecutionOperators.Add(AfterManipulatorOperator);
    232226          }
     
    257251            IsElite = true
    258252          };
     253          // add new vertex to the graph
     254          GenealogyGraph.AddVertex(vertex);
     255          // swap content between current vertex and previous vertex
    259256          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
    261264          previousVertex.AddForwardArc(vertex);
    262265          vertex.AddReverseArc(previousVertex);
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/DirectedGraph/DirectedGraph.cs

    r10755 r10833  
    6868        return result;
    6969      }
     70      set {
     71        contentMap[key] = value;
     72      }
    7073    }
    7174    public virtual bool Any(Func<IVertex, bool> predicate) {
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/DirectedGraph/Interfaces/IDirectedGraph.cs

    r10755 r10833  
    3232    void RemoveVertex(IVertex vertex);
    3333    List<IVertex> Nodes { get; }
    34     IVertex this[object content] { get; }
     34    IVertex this[object content] { get; set; }
    3535    bool Contains(object content);
    3636  }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraph.cs

    r10830 r10833  
    7676        return result == null ? null : (IGenealogyGraphNode)result;
    7777      }
     78      set { base[content] = value; }
    7879    }
    7980
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/FragmentGraphView.cs

    r10827 r10833  
    1 using System.Collections.Generic;
     1using System;
     2using System.Collections.Generic;
    23using System.Drawing;
    34using System.Linq;
     
    5051        var tile = new SymbolicExpressionTreeTile(chart);
    5152        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);
    5355        tile.Root = node.Content.Root;
    5456        var tileNode = new TileLayoutNode { Tile = tile };
     
    131133        }
    132134      }
     135      // center display on the root of the fragment graph
     136      symbolicExpressionChartControl.Chart.Move(tileDictionary[root].Tile.Position.X, tileDictionary[root].Tile.Position.Y);
    133137      symbolicExpressionChartControl.UpdateEnabled = true;
    134138      symbolicExpressionChartControl.EnforceUpdate();
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymboldDataAnalysisGenealogyView.Designer.cs

    r10746 r10833  
    1919 */
    2020#endregion
     21
     22using System.Drawing;
    2123
    2224namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
     
    100102      this.symbolicExpressionTreeChart.SuspendRepaint = false;
    101103      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);
    103105      this.symbolicExpressionTreeChart.Tree = null;
    104106      //
  • 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
     22using System;
    223using System.Collections.Generic;
    324
    425namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Matching {
    5   public class MaxCommonSequenceCalculator<T, U>
     26  public class MaxCommonSequenceCalculator<T, TComp>
    627    where T : class
    7     where U : IEqualityComparer<T> {
     28    where TComp : IEqualityComparer<T> {
    829
    9     public U Comparer { get; set; }
     30    private TComp comparer;
     31    public TComp Comparer {
     32      get { return comparer; }
     33      set { comparer = value; }
     34    }
     35
    1036    private int[,] matrix;
    1137    private List<T> sequence;
    1238
     39    public MaxCommonSequenceCalculator(TComp comparer) {
     40      this.comparer = comparer;
     41    }
     42
    1343    /// <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
    1546    /// </summary>
    1647    /// <param name="a"></param>
     
    2758      for (int i = 0; i <= m; ++i) {
    2859        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])) {
    3261            matrix[i, j] = matrix[i - 1, j - 1] + 1;
    3362          } else {
     
    3665        }
    3766      }
    38       recon(a, b, n, m);
     67      Recon(a, b, n, m); // build the common subsequence
    3968      return sequence;
    4069    }
    4170
    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);
    4775          sequence.Add(a[i - 1]);
    4876        } else if (matrix[i - 1, j] > matrix[i, j - 1]) {
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionAfterCrossoverOperator.cs

    r10827 r10833  
    4646        break;
    4747      }
    48       //
    49       //      if (fragment == null) {
    50       //        throw new Exception("SymbolicDataAnalysisExpressionAfterCrossoverOperator: Could not identify fragment");
    51       //      }
    5248
    5349      arcs[0].Data = null;
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionAfterManipulatorOperator.cs

    r10827 r10833  
    5757      }
    5858
    59       //      if (fragment == null) {
    60       //        throw new Exception("SymbolicDataAnalysisExpressionAfterManipulatorOperator: Could not identify fragment");
    61       //      }
    62 
    6359      vChild.InArcs.First().Data = fragment;
    6460      return base.Apply();
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionBeforeCrossoverOperator.cs

    r10755 r10833  
    2020#endregion
    2121
    22 using System;
    2322using System.Linq;
    2423using HeuristicLab.Core;
     
    3534
    3635      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();
    3937      }
    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      //      }
    4444
    4545      return result;
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionBeforeManipulatorOperator.cs

    r10827 r10833  
    3333      vChild.InArcs.First().Data = vChild.Content.IterateNodesPrefix().ToList();
    3434
     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
    3543      return result;
    3644    }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionTracing.cs

    r10827 r10833  
    3030          var fragmentNode = new FragmentNode {
    3131            Content = new Fragment<ISymbolicExpressionTreeNode> { Root = node.Content.NodeAt(index) },
    32             Rank = node.Rank
     32            Rank = node.Rank,
     33            Quality = node.Quality
    3334          };
    3435          if (parent != null) {
     
    9899              var fragmentNode = new FragmentNode {
    99100                Content = new Fragment<ISymbolicExpressionTreeNode> { Root = subtree },
    100                 Rank = node.Rank
     101                Rank = node.Rank,
     102                Quality = node.Quality
    101103              };
    102104              if (parent != null) {
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Tracking.sln

    r10746 r10833  
    22Microsoft Visual Studio Solution File, Format Version 12.00
    33# Visual Studio 2013
    4 VisualStudioVersion = 12.0.30110.0
     4VisualStudioVersion = 12.0.21005.1
    55MinimumVisualStudioVersion = 10.0.40219.1
    66Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C80F4C35-CB87-4695-8A53-6F2D08275253}"
     
    170170    HideSolutionNode = FALSE
    171171  EndGlobalSection
    172   GlobalSection(Performance) = preSolution
    173     HasPerformanceSessions = true
    174   EndGlobalSection
    175172  GlobalSection(TestCaseManagementSettings) = postSolution
    176173    CategoryFile = HeuristicLab.Tracking.vsmdi
Note: See TracChangeset for help on using the changeset viewer.