Changeset 7972


Ignore:
Timestamp:
06/06/12 09:46:34 (9 years ago)
Author:
gkronber
Message:

#1722 added static methods in OnePointShaker and SymbolicDataAnalysisAlleleFrequencyAnalyzer

Location:
trunk/sources
Files:
2 edited

Legend:

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

    r7259 r7972  
    5757
    5858    protected override void Manipulate(IRandom random, ISymbolicExpressionTree tree) {
     59      OnePointShaker.Shake(random, tree, ShakingFactor);
     60    }
     61
     62    public static void Shake(IRandom random, ISymbolicExpressionTree tree, double shakingFactor) {
    5963      List<ISymbolicExpressionTreeNode> parametricNodes = new List<ISymbolicExpressionTreeNode>();
    6064      tree.Root.ForEachNodePostfix(n => {
     
    6367      if (parametricNodes.Count > 0) {
    6468        var selectedPoint = parametricNodes.SelectRandom(random);
    65         selectedPoint.ShakeLocalParameters(random, ShakingFactor);
     69        selectedPoint.ShakeLocalParameters(random, shakingFactor);
    6670      }
    6771    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAlleleFrequencyAnalyzer.cs

    r7305 r7972  
    7070
    7171    protected override Allele[] CalculateAlleles(ISymbolicExpressionTree solution) {
    72       return GetAllSubtreesOfDepth(solution, AlleleTreeDepth)
     72      return CalculateAlleles(solution, AlleleTreeDepth);
     73    }
     74
     75    public static Allele[] CalculateAlleles(ISymbolicExpressionTree solution, int alleleTreedepth) {
     76      return GetAllSubtreesOfDepth(solution, alleleTreedepth)
    7377        .AsParallel()
    74         .Select(t => GetAlleleFromSubtreeOfDepth(t, AlleleTreeDepth))
     78        .Select(t => GetAlleleFromSubtreeOfDepth(t, alleleTreedepth))
    7579        .ToArray();
    7680    }
    7781
    78     private Allele GetAlleleFromSubtreeOfDepth(ISymbolicExpressionTreeNode tree, int d) {
     82    private static Allele GetAlleleFromSubtreeOfDepth(ISymbolicExpressionTreeNode tree, int d) {
    7983      string textualRepresentation = GetTextualRepresentationFromSubtreeOfDepth(tree, d);
    8084      return new Allele(textualRepresentation);
    8185    }
    8286
    83     private string GetTextualRepresentationFromSubtreeOfDepth(ISymbolicExpressionTreeNode tree, int d) {
     87    private static string GetTextualRepresentationFromSubtreeOfDepth(ISymbolicExpressionTreeNode tree, int d) {
    8488      if (d == 0) return "";
    8589      StringBuilder builder = new StringBuilder();
     
    100104    }
    101105
    102     private IEnumerable<ISymbolicExpressionTreeNode> GetAllSubtreesOfDepth(ISymbolicExpressionTree solution, int d) {
     106    private static IEnumerable<ISymbolicExpressionTreeNode> GetAllSubtreesOfDepth(ISymbolicExpressionTree solution, int d) {
    103107      return from node in solution.IterateNodesPostfix()
    104108             where node.GetDepth() >= d
Note: See TracChangeset for help on using the changeset viewer.