Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7817


Ignore:
Timestamp:
05/15/12 00:21:10 (13 years ago)
Author:
bburlacu
Message:

#1772: Fixed a small bug in the TracingSymbolicExpressionTreeCrossover. Fixed bug in fragment matching code.

Location:
branches/HeuristicLab.EvolutionaryTracking
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/TracingSymbolicExpressionTreeCrossover.cs

    r7792 r7817  
    127127      // compare the two nodes lists and check the difference (comparing node references so we avoid false functional identity).
    128128      // if no difference is found, then it is assumed that the whole tree was swapped with itself (it can happen), so the index is 0
    129       int i, min = Math.Max(nodes0.Count, nodes1.Count);
    130       for (i = 0; i != min; ++i)
     129      int i = 0, min = Math.Min(nodes0.Count, nodes1.Count);
     130      for (; i != min; ++i)
    131131        if (nodes0[i] != nodes1[i]) break;
    132132      if (i == min) i = 0;
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Plugin.cs

    r7800 r7817  
    2626
    2727namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    28   [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.2.7799")]
     28  [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.2.7800")]
    2929  [PluginFile("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Analysis", "3.3")]
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeMatching.cs

    r7792 r7817  
    7070
    7171    public static bool ContainsFragment(this ISymbolicExpressionTree tree, ISymbolicExpressionTreeNode fragment, int mode) {
    72       var nodes = tree.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;
    73       var fragments = fragment.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;
     72      var nodes = tree.IterateNodesPostfix() as List<ISymbolicExpressionTreeNode>;
     73      var fragments = fragment.IterateNodesPostfix() as List<ISymbolicExpressionTreeNode>;
    7474      return FindMatch(nodes, fragments, mode) != -1;
    7575    }
     
    7777    // convenience methods for less typing :)
    7878    private static IEnumerator<ISymbolicExpressionTreeNode> Enumerator(this ISymbolicExpressionTree tree) {
    79       return tree.IterateNodesBreadth().GetEnumerator();
     79      return tree.IterateNodesPostfix().GetEnumerator();
    8080    }
    8181    private static IEnumerator<ISymbolicExpressionTreeNode> Enumerator(this ISymbolicExpressionTreeNode tree) {
    82       return tree.IterateNodesBreadth().GetEnumerator();
     82      return tree.IterateNodesPostfix().GetEnumerator();
    8383    }
    8484    public static int FindMatch(ISymbolicExpressionTree a, ISymbolicExpressionTree b, int mode) {
    85       var nodesA = a.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;
    86       var nodesB = b.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;
     85      var nodesA = a.IterateNodesPostfix() as List<ISymbolicExpressionTreeNode>;
     86      var nodesB = b.IterateNodesPostfix() as List<ISymbolicExpressionTreeNode>;
    8787      return FindMatch(nodesA, nodesB, mode);
    8888    }
    8989    public static int FindMatch(ISymbolicExpressionTreeNode a, ISymbolicExpressionTreeNode b, int mode) {
    90       var nodesA = a.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;
    91       var nodesB = b.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;
     90      var nodesA = a.IterateNodesPostfix() as List<ISymbolicExpressionTreeNode>;
     91      var nodesB = b.IterateNodesPostfix() as List<ISymbolicExpressionTreeNode>;
    9292      return FindMatch(nodesA, nodesB, mode);
    9393    }
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphChart.cs

    r7792 r7817  
    160160          // color selected node and its genealogy
    161161          if (_selectedGenealogyGraphNode == null) return;
    162           var gNode = _selectedGenealogyGraphNode.Data; // genealogy graph node (representing an individual in the population)
    163           double rank = gNode.Rank;
    164           var ancestors = gNode.Ancestors().Where(a => a.Rank < rank).ToList();
    165           ancestors.Add(gNode);
    166162          // use special highlighting for the currently selected genealogy graph node
    167163          var center = _selectedGenealogyGraphNode.Center;
     
    174170            Chart.Group.Add(_targetRectangle);
    175171          }
     172          var gNode = _selectedGenealogyGraphNode.Data; // genealogy graph node (representing an individual in the population)
     173          double rank = gNode.Rank;
     174          var ancestors = gNode.Ancestors().Where(a => a.Rank < rank).ToList();
     175          ancestors.Add(gNode);
    176176          // highlight selected node and its ancestry
    177177          foreach (var node in ancestors.SelectMany(n => _visualNodeMap[n])) {
     
    206206        if (_selectedGenealogyGraphNode != null)
    207207          /* emit clicked event */
    208           OnGenealogyGraphNodeClicked(_selectedGenealogyGraphNode, e);
     208          GenealogyGraphNodeClicked(_selectedGenealogyGraphNode, e);
    209209      }
    210210    }
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphView.cs

    r7800 r7817  
    9797        int index = SymbolicExpressionTreeMatching.FindMatch(nodes, fragments, similarityModeSelector.SelectedIndex);
    9898        if (index != -1) {
    99           _selectedVisualSymbolicExpressionTreeNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(nodes[index + fragments.Count - 1]);
     99          _selectedVisualSymbolicExpressionTreeNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(nodes[index]);
    100100          var subtree = _selectedVisualSymbolicExpressionTreeNode.SymbolicExpressionTreeNode;
    101101          foreach (var visualNode in subtree.IterateNodesBreadth().Select(node => symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node))) {
     
    111111        if (arc != null) {
    112112          var fragment = arc.Data as ISymbolicExpressionTreeNode;
    113           //var fragmentNodes = fragment.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;
    114           //var treeNodes = tree.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;
    115           //var idx = SymbolicExpressionTreeMatching.FindMatch(treeNodes, fragmentNodes, (int)SymbolicExpressionTreeMatching.SimilarityLevel.Exact);
    116113          foreach (var node in fragment.IterateNodesBreadth()) {
    117114            var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
     
    121118        }
    122119      }
    123       // what's left to be done here is to:
    124       // - get the symbolic expression tree
    125       // - get the corresponding fragment
    126       // - for all symbolic expression tree nodes in the fragment, colorize the corresponding visual nodes
    127       // - repaint the tree
    128120    }
    129121
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking/3.4/SymbolicExpressionTreeGenealogyGraph.cs

    r7785 r7817  
    1616    #region Fragment tracing
    1717    public IEnumerable<ISymbolicExpressionTree> TraceFragment(ISymbolicExpressionTreeNode fragment, int mode = 0) {
    18       //return Keys.Where(tree => ContainsFragment(tree, fragment, mode) != -1);
    1918      return Keys.Where(tree => tree.ContainsFragment(fragment, mode));
    2019    }
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Selection/3.3/Plugin.cs

    r7800 r7817  
    2626  /// Plugin class for HeuristicLab.Selection plugin.
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Selection", "3.3.6.7799")]
     28  [Plugin("HeuristicLab.Selection", "3.3.6.7800")]
    2929  [PluginFile("HeuristicLab.Selection-3.3.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Collections", "3.3")]
Note: See TracChangeset for help on using the changeset viewer.