Changeset 11858 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking
- Timestamp:
- 02/02/15 13:58:40 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/TraceCalculator.cs
r11855 r11858 100 100 while (g.Parents.Any()) { 101 101 Debug.Assert(si < g.Data.Length); 102 var parents = g.Parents.ToList();103 var fragment = (IFragment<ISymbolicExpressionTreeNode>) g.InArcs.Last().Data;102 var inArcs = (List<IArc>)((IVertex)g).InArcs; 103 var fragment = (IFragment<ISymbolicExpressionTreeNode>)inArcs.Last().Data; 104 104 if (fragment == null) { 105 105 // TODO: think about what the correct behavior should be here (seems good so far) 106 106 // the node is either an elite node or (in rare cases) no fragment was transferred 107 g = parents[0];107 g = (IGenealogyGraphNode<ISymbolicExpressionTree>)inArcs[0].Source; 108 108 continue; 109 109 } … … 114 114 115 115 #region trace crossover 116 if (parents.Count == 2) { 116 if (inArcs.Count == 2) { 117 var parent0 = (IGenealogyGraphNode<ISymbolicExpressionTree>)inArcs[0].Source; 118 var parent1 = (IGenealogyGraphNode<ISymbolicExpressionTree>)inArcs[1].Source; 117 119 if (fi == si) { 118 g = parent s[1];120 g = parent1; 119 121 si = fragment.Index2; 120 122 continue; … … 123 125 if (fi + fl > si) { 124 126 // fragment contains subtree 125 g = parent s[1];127 g = parent1; 126 128 si += fragment.Index2 - fi; 127 129 } else { 128 130 // fragment distinct from subtree 129 g = parent s[0];131 g = parent0; 130 132 si += NodeAt(g.Data, fi).GetLength() - fl; 131 133 } … … 136 138 // subtree contains fragment => branching point in the fragment graph 137 139 var n = GetTraceNode(g, si, fi); 138 TraceRecursive(parent s[0], si, n);139 TraceRecursive(parent s[1], fragment.Index2, n);140 TraceRecursive(parent0, si, n); 141 TraceRecursive(parent1, fragment.Index2, n); 140 142 break; 141 143 } else { 142 144 // subtree and fragment are distinct. 143 g = parent s[0];145 g = parent0; 144 146 continue; 145 147 } … … 150 152 // mutation is handled in a simple way: we branch every time there is an overlap between the subtree and the fragment 151 153 // (since mutation effects can be quite unpredictable: replace branch, change node, shake tree, etc) 152 if (parents.Count == 1) { 154 if (inArcs.Count == 1) { 155 var parent0 = (IGenealogyGraphNode<ISymbolicExpressionTree>)inArcs[0].Source; 153 156 Debug.Assert(fragment.Index1 == fragment.Index2); 154 157 // check if the subtree and the fragment overlap => branch out … … 156 159 var n = GetTraceNode(g, si, fi); 157 160 int i = si < fi ? si : fi; 158 TraceRecursive(parent s[0], i, n);161 TraceRecursive(parent0, i, n); 159 162 break; 160 163 } else { 161 164 // if they don't overlap, go up 162 g = parent s[0];165 g = parent0; 163 166 if (fi < si) 164 167 si += NodeAt(g.Data, fi).GetLength() - fl; … … 212 215 /// <param name="last">The last added node in the trace graph</param> 213 216 private void ConnectLast(IGenealogyGraphNode<ISymbolicExpressionTree> g, int si, IGenealogyGraphNode<ISymbolicExpressionTree> last) { 214 IFragment<ISymbolicExpressionTreeNode> fragment = g.Parents.Any() ? (IFragment<ISymbolicExpressionTreeNode>)g.InArcs.Last().Data : null; 217 var inArcs = (List<IArc>)((IVertex)g).InArcs; 218 var fragment = g.Parents.Any() ? (IFragment<ISymbolicExpressionTreeNode>)inArcs.Last().Data : null; 215 219 int fi = fragment == null ? 0 : fragment.Index1; // fragment index 216 220 var n = GetTraceNode(g, si, fi); // will append n to the trace graph if it does not exist
Note: See TracChangeset
for help on using the changeset viewer.