Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/17/11 11:51:09 (13 years ago)
Author:
bburlacu
Message:

#1654: Updated Full-, Grow- and RampedHalfAndHalf tree creators so that the Create call has the exact same signature for all of them (including the probabilistic tree creator); adjusted tests. Added CreateTree interface method and tree creator selection mechanism in the Sample Tree View.

Location:
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4
Files:
6 edited

Legend:

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

    r6944 r7012  
    2727using HeuristicLab.Parameters;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.PluginInfrastructure;
    2930
    3031namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     32  [NonDiscoverableType]
    3133  [StorableClass]
    3234  [Item("FullTreeCreator", "An operator that creates new symbolic expression trees using the 'Full' method")]
     
    6062    public IntValue MaximumSymbolicExpressionTreeDepth {
    6163      get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; }
     64    }
     65   
     66    public IntValue MaximumSymbolicExpressionTreeLength {
     67      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
    6268    }
    6369
     
    97103
    98104    protected override ISymbolicExpressionTree Create(IRandom random) {
    99       return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeDepth.Value);
     105      return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     106    }
     107
     108    public override ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
     109     return Create(random, grammar, maxTreeLength, maxTreeDepth);
    100110    }
    101111
     
    108118    /// <param name="grammar">Available tree grammar</param>
    109119    /// <param name="maxTreeDepth">Maximum tree depth</param>
     120    /// <param name="maxTreeLength">Maximum tree length. This parameter is not used.</param>
    110121    /// <returns></returns>
    111     public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeDepth) {
     122    public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
    112123      var tree = new SymbolicExpressionTree();
    113124      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs

    r6944 r7012  
    2727using HeuristicLab.Parameters;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.PluginInfrastructure;
    2930
    3031namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     32  [NonDiscoverableType]
    3133  [StorableClass]
    3234  [Item("GrowTreeCreator", "An operator that creates new symbolic expression trees using the 'Grow' method")]
     
    6062    public IntValue MaximumSymbolicExpressionTreeDepth {
    6163      get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; }
     64    }
     65
     66    public IntValue MaximumSymbolicExpressionTreeLength {
     67      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
    6268    }
    6369
     
    97103
    98104    protected override ISymbolicExpressionTree Create(IRandom random) {
    99       return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeDepth.Value);
     105      return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     106    }
     107
     108    public override ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
     109      return Create(random, grammar, maxTreeLength, maxTreeDepth);
    100110    }
    101111
     
    107117    /// <param name="grammar">Available tree grammar</param>
    108118    /// <param name="maxTreeDepth">Maximum tree depth</param>
     119    /// <param name="maxTreeLength">Maximum tree length. This parameter is not used.</param>
    109120    /// <returns></returns>
    110     public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeDepth) {
     121    public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
    111122      var tree = new SymbolicExpressionTree();
    112123      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs

    r6911 r7012  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.PluginInfrastructure;
    3031
    3132namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     33  [NonDiscoverableType]
    3234  [StorableClass]
    3335  [Item("ProbabilisticTreeCreator", "An operator that creates new symbolic expression trees with uniformly distributed length")]
     
    101103    }
    102104
    103     public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar,
    104       int maxTreeLength, int maxTreeDepth) {
     105    public override ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
     106      return Create(random, grammar, maxTreeLength, maxTreeDepth);
     107    }
     108
     109    public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
    105110      SymbolicExpressionTree tree = new SymbolicExpressionTree();
    106111      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/RampedHalfAndHalfTreeCreator.cs

    r6887 r7012  
    2929using HeuristicLab.Parameters;
    3030using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     31using HeuristicLab.PluginInfrastructure;
    3132
    3233namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     34  [NonDiscoverableType]
    3335  [StorableClass]
    3436  [Item("RampedHalfAndHalfTreeCreator", "An operator that creates new symbolic expression trees in an alternate way: half the trees are created usign the 'Grow' method while the other half are created using the 'Full' method")]
     
    7274    }
    7375
     76    public IntValue MaximumSymbolicExpressionTreeLength {
     77      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
     78    }
     79
    7480    public ISymbolicExpressionGrammar SymbolicExpressionTreeGrammar {
    7581      get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; }
     
    106112
    107113    protected override ISymbolicExpressionTree Create(IRandom random) {
    108       return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeDepth.Value);
     114      return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeDepth.Value, MaximumSymbolicExpressionTreeLength.Value);
     115    }
     116
     117    public override ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
     118      return Create(random, grammar, maxTreeLength, maxTreeDepth);
    109119    }
    110120
     
    117127    /// <param name="maxTreeDepth">Maximum tree depth</param>
    118128    /// <returns></returns>
    119     public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeDepth) {
     129    public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
    120130      var tree = new SymbolicExpressionTree();
    121131      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/SymbolicExpressionTreeCreator.cs

    r6233 r7012  
    3939    #endregion
    4040
    41     #region Propeties
     41    #region Properties
    4242    public ISymbolicExpressionTree SymbolicExpressionTree {
    4343      get { return SymbolicExpressionTreeParameter.ActualValue; }
     
    6060
    6161    protected abstract ISymbolicExpressionTree Create(IRandom random);
     62    public abstract ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth);
    6263  }
    6364}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeCreator.cs

    r5809 r7012  
    2929  public interface ISymbolicExpressionTreeCreator : ISymbolicExpressionTreeOperator, ISolutionCreator {
    3030    ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
     31    ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth);
    3132  }
    3233}
Note: See TracChangeset for help on using the changeset viewer.