Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/06/12 11:24:34 (12 years ago)
Author:
bburlacu
Message:

#1772: Separated instance-specific attributes of graph node objects from the generic genealogy graph, into metadata objects kept by the specific graph class which corresponds to the specific problem instance (so for instance the SymbolicExpressionTreeGenealogyGraph will keep info about node ranks and qualities etc because that info is specific to symbolic data analysis problems).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking/3.4/SymbolicExpressionTreeGenealogyGraph.cs

    r8236 r8248  
    1111  [StorableClass]
    1212  public class SymbolicExpressionTreeGenealogyGraph : GenealogyGraph<ISymbolicExpressionTree> {
     13
     14    [Storable]
     15    private readonly Dictionary<GenealogyGraphNode, NodeMetadata> _nodeInfo = new Dictionary<GenealogyGraphNode, NodeMetadata>();
     16
    1317    public SymbolicExpressionTreeGenealogyGraph() {
    1418    }
     
    2731    }
    2832
     33    public override void AddNode(ISymbolicExpressionTree tree) {
     34      if (HasNode(tree)) return;
     35      var node = new GenealogyGraphNode(tree);
     36      _nodeInfo[node] = new NodeMetadata();
     37      base.AddNode(node);
     38    }
     39
     40    public override void AddNode(GenealogyGraphNode node) {
     41      var tree = (ISymbolicExpressionTree)node.Data;
     42      if (HasNode(tree)) return;
     43      _nodeInfo[node] = new NodeMetadata();
     44      base.AddNode(node);
     45    }
     46
     47    public NodeMetadata this[GenealogyGraphNode node] {
     48      get {
     49        NodeMetadata value;
     50        _nodeInfo.TryGetValue(node, out value);
     51        return value;
     52      }
     53      set {
     54        _nodeInfo[node] = value;
     55      }
     56    }
     57
    2958    #region Fragment tracing
    3059    public IEnumerable<ISymbolicExpressionTree> TraceFragment(ISymbolicExpressionTreeNode fragment, int mode = 0) {
     
    3362    #endregion
    3463  }
     64
     65  public class NodeMetadata {
     66    public double Quality { get; set; }
     67    public List<double> Ranks { get; set; }
     68    public bool IsElite { get; set; }
     69
     70    public NodeMetadata() {
     71      Ranks = new List<double>();
     72    }
     73  }
    3574}
Note: See TracChangeset for help on using the changeset viewer.