Changeset 13479 for branches/HeuristicLab.EvolutionTracking
- Timestamp:
- 12/17/15 20:09:28 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/TraceCalculator.cs
r13424 r13479 35 35 public class TraceCalculator : Item { 36 36 private Dictionary<ISymbolicExpressionTree, List<ISymbolicExpressionTreeNode>> nodeListCache; 37 private HashSet<Tuple<IGenealogyGraphNode<ISymbolicExpressionTree>, IGenealogyGraphNode<ISymbolicExpressionTree>, int>> traceCache;37 private HashSet<Tuple<IGenealogyGraphNode<ISymbolicExpressionTree>, int, IGenealogyGraphNode<ISymbolicExpressionTree>, int, int>> traceCache; 38 38 public IGenealogyGraph<ISymbolicExpressionTree> TraceGraph { get; private set; } 39 39 … … 42 42 public bool CacheTraceNodes { get; set; } 43 43 44 public int TraceCacheHits { get; set; } 45 44 46 public TraceCalculator() { 45 47 ResetState(); … … 60 62 TraceGraph = new GenealogyGraph<ISymbolicExpressionTree>(); 61 63 nodeListCache = new Dictionary<ISymbolicExpressionTree, List<ISymbolicExpressionTreeNode>>(); 62 traceCache = new HashSet<Tuple<IGenealogyGraphNode<ISymbolicExpressionTree>, IGenealogyGraphNode<ISymbolicExpressionTree>, int>>();64 traceCache = new HashSet<Tuple<IGenealogyGraphNode<ISymbolicExpressionTree>, int, IGenealogyGraphNode<ISymbolicExpressionTree>, int, int>>(); 63 65 } 64 66 … … 145 147 // subtree contains fragment => branching point in the fragment graph 146 148 var n = AddTraceNode(g); // current node becomes "last" as we restart tracing from the parent 147 var t0 = new Tuple<IGenealogyGraphNode<ISymbolicExpressionTree>, IGenealogyGraphNode<ISymbolicExpressionTree>, int>(parent0, n, si); 148 if (!(CacheTraceNodes && traceCache.Contains(t0))) { 149 if (CacheTraceNodes) { 150 var t0 = new Tuple<IGenealogyGraphNode<ISymbolicExpressionTree>, int, IGenealogyGraphNode<ISymbolicExpressionTree>, int, int>(parent0, si, n, si, fi); 151 var t1 = new Tuple<IGenealogyGraphNode<ISymbolicExpressionTree>, int, IGenealogyGraphNode<ISymbolicExpressionTree>, int, int>(parent1, fragment.Index2, n, si, fi); 152 if (!traceCache.Contains(t0)) { 153 traceCache.Add(t0); 154 TraceRecursive(parent0, si, n, si, fi); 155 } else { 156 TraceCacheHits++; 157 } 158 if (!traceCache.Contains(t1)) { 159 traceCache.Add(t1); 160 TraceRecursive(parent1, fragment.Index2, n, si, fi); 161 } else { 162 TraceCacheHits++; 163 } 164 } else { 149 165 TraceRecursive(parent0, si, n, si, fi); 150 traceCache.Add(t0);151 }152 var t1 = new Tuple<IGenealogyGraphNode<ISymbolicExpressionTree>, IGenealogyGraphNode<ISymbolicExpressionTree>, int>(parent1, n, fragment.Index2);153 if (!(CacheTraceNodes && traceCache.Contains(t1))) {154 166 TraceRecursive(parent1, fragment.Index2, n, si, fi); 155 traceCache.Add(t1);156 167 } 157 168 break; … … 174 185 var n = AddTraceNode(g); // current node becomes "last" as we restart tracing from the parent 175 186 int i = si < fi ? si : fi; 176 var t = new Tuple<IGenealogyGraphNode<ISymbolicExpressionTree>, IGenealogyGraphNode<ISymbolicExpressionTree>, int>(parent0, n,i);187 var t = new Tuple<IGenealogyGraphNode<ISymbolicExpressionTree>, int, IGenealogyGraphNode<ISymbolicExpressionTree>, int, int>(parent0, i, n, si, fi); 177 188 if (!(CacheTraceNodes && traceCache.Contains(t))) { 178 189 TraceRecursive(parent0, i, n, si, fi);
Note: See TracChangeset
for help on using the changeset viewer.