Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/03/12 11:22:21 (13 years ago)
Author:
gkronber
Message:

#1081: merged r7214:7266 from trunk into time series branch.

Location:
branches/HeuristicLab.TimeSeries
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries

  • branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/RampedHalfAndHalfTreeCreator.cs

    r7034 r7268  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.ComponentModel;
    25 using System.Linq;
    2622using HeuristicLab.Common;
    2723using HeuristicLab.Core;
     
    5450    public IValueLookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter {
    5551      get {
    56         return
    57             (IValueLookupParameter<ISymbolicExpressionGrammar>)
    58             Parameters[SymbolicExpressionTreeGrammarParameterName];
     52        return (IValueLookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName];
    5953      }
    6054    }
     
    6256    public ILookupParameter<ISymbolicExpressionGrammar> ClonedSymbolicExpressionTreeGrammarParameter {
    6357      get {
    64         return
    65             (ILookupParameter<ISymbolicExpressionGrammar>)
    66             Parameters[ClonedSymbolicExpressionTreeGrammarParameterName];
     58        return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[ClonedSymbolicExpressionTreeGrammarParameterName];
    6759      }
    6860    }
     
    7870    }
    7971
    80     public ISymbolicExpressionGrammar SymbolicExpressionTreeGrammar {
     72    public ISymbolicExpressionGrammar ClonedSymbolicExpressionTreeGrammar {
    8173      get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; }
    8274    }
     
    8981    public RampedHalfAndHalfTreeCreator()
    9082      : base() {
    91       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree."));
    92       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    93       Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
    94       Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName, "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
     83      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName,
     84        "The maximal length (number of nodes) of the symbolic expression tree (this parameter is ignored)."));
     85      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName,
     86        "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
     87      Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName,
     88        "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
     89      Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName,
     90        "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
    9591    }
    9692
     
    106102          globalScope = globalScope.Parent;
    107103
    108         globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName, (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
     104        globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName,
     105          (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
    109106      }
    110107      return base.Apply();
     
    112109
    113110    protected override ISymbolicExpressionTree Create(IRandom random) {
    114       return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     111      return Create(random, ClonedSymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
    115112    }
    116113
     
    125122    /// <param name="random">Random generator</param>
    126123    /// <param name="grammar">Available tree grammar</param>
     124    /// <param name="maxTreeLength">Maximum tree length (this parameter is ignored)</param>
    127125    /// <param name="maxTreeDepth">Maximum tree depth</param>
    128126    /// <returns></returns>
     
    134132
    135133      var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode();
     134      if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
    136135      startNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
    137       if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
    138136
    139137      rootNode.AddSubtree(startNode);
     
    142140
    143141      if (p < 0.5)
    144         GrowTreeCreator.Grow(random, startNode, maxTreeDepth - 2);
     142        GrowTreeCreator.Create(random, startNode, maxTreeDepth - 2);
    145143      else
    146         FullTreeCreator.Grow(random, startNode, maxTreeDepth - 2);
     144        FullTreeCreator.Create(random, startNode, maxTreeDepth - 2);
    147145
    148146      tree.Root = rootNode;
Note: See TracChangeset for help on using the changeset viewer.