Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/02/15 13:58:40 (10 years ago)
Author:
bburlacu
Message:

#1772: Micro optimization inside the TraceCalculator and inside the GenealogyGraphNode (Children and Parents properties), resulting in maybe 25% speed gain. Corrected item name for the BeforeCrossoverOperator, very minor refactoring inside the BeforeManipulatorOperator. Updated project file.

Location:
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r11638 r11858  
    326326    <Compile Include="Tracking\SymbolicDataAnalysisExpressionAfterManipulatorOperator.cs" />
    327327    <Compile Include="Tracking\SymbolicDataAnalysisExpressionBeforeManipulatorOperator.cs" />
    328     <Compile Include="Tracking\SymbolicDataAnalysisExpressionTracing.cs" />
    329328    <None Include="HeuristicLab.snk" />
    330329    <None Include="Plugin.cs.frame" />
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/TraceCalculator.cs

    r11855 r11858  
    100100      while (g.Parents.Any()) {
    101101        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;
    104104        if (fragment == null) {
    105105          // TODO: think about what the correct behavior should be here (seems good so far)
    106106          // 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;
    108108          continue;
    109109        }
     
    114114
    115115        #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;
    117119          if (fi == si) {
    118             g = parents[1];
     120            g = parent1;
    119121            si = fragment.Index2;
    120122            continue;
     
    123125            if (fi + fl > si) {
    124126              // fragment contains subtree
    125               g = parents[1];
     127              g = parent1;
    126128              si += fragment.Index2 - fi;
    127129            } else {
    128130              // fragment distinct from subtree
    129               g = parents[0];
     131              g = parent0;
    130132              si += NodeAt(g.Data, fi).GetLength() - fl;
    131133            }
     
    136138              // subtree contains fragment => branching point in the fragment graph
    137139              var n = GetTraceNode(g, si, fi);
    138               TraceRecursive(parents[0], si, n);
    139               TraceRecursive(parents[1], fragment.Index2, n);
     140              TraceRecursive(parent0, si, n);
     141              TraceRecursive(parent1, fragment.Index2, n);
    140142              break;
    141143            } else {
    142144              // subtree and fragment are distinct.
    143               g = parents[0];
     145              g = parent0;
    144146              continue;
    145147            }
     
    150152        // mutation is handled in a simple way: we branch every time there is an overlap between the subtree and the fragment
    151153        // (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;
    153156          Debug.Assert(fragment.Index1 == fragment.Index2);
    154157          // check if the subtree and the fragment overlap => branch out
     
    156159            var n = GetTraceNode(g, si, fi);
    157160            int i = si < fi ? si : fi;
    158             TraceRecursive(parents[0], i, n);
     161            TraceRecursive(parent0, i, n);
    159162            break;
    160163          } else {
    161164            // if they don't overlap, go up
    162             g = parents[0];
     165            g = parent0;
    163166            if (fi < si)
    164167              si += NodeAt(g.Data, fi).GetLength() - fl;
     
    212215    /// <param name="last">The last added node in the trace graph</param>
    213216    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;
    215219      int fi = fragment == null ? 0 : fragment.Index1; // fragment index
    216220      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.