Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/23/12 16:05:57 (12 years ago)
Author:
mkommend
Message:

#1682: Integrated new gp crossovers into the trunk and corrected the parameter wiring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs

    r7259 r7506  
    125125    }
    126126
     127    public int GetBranchLevel(ISymbolicExpressionTreeNode child) {
     128      return GetBranchLevel(this, child);
     129    }
     130
     131    private static int GetBranchLevel(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode point) {
     132      if (root == point)
     133        return 0;
     134      foreach (var subtree in root.Subtrees) {
     135        int branchLevel = GetBranchLevel(subtree, point);
     136        if (branchLevel < int.MaxValue)
     137          return 1 + branchLevel;
     138      }
     139      return int.MaxValue;
     140    }
     141
    127142    public virtual void ResetLocalParameters(IRandom random) { }
    128143    public virtual void ShakeLocalParameters(IRandom random, double shakingFactor) { }
Note: See TracChangeset for help on using the changeset viewer.