Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12313


Ignore:
Timestamp:
04/14/15 15:17:23 (9 years ago)
Author:
mkommend
Message:

#2320: Simplified TreeCreators.

Location:
branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4
Files:
6 edited

Legend:

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

    r12012 r12313  
    3636                                 ISymbolicExpressionTreeSizeConstraintOperator,
    3737                                 ISymbolicExpressionTreeGrammarBasedOperator {
    38     private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
    39     private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
    40 
    41     #region Parameter Properties
    42     public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
    43       get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
    44     }
    45 
    46     public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
    47       get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
    48     }
    49     #endregion
    50     #region Properties
    51     public IntValue MaximumSymbolicExpressionTreeDepth {
    52       get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; }
    53     }
    54 
    55     public IntValue MaximumSymbolicExpressionTreeLength {
    56       get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
    57     }
    58 
    59     #endregion
    6038
    6139    [StorableConstructor]
     
    6341    protected FullTreeCreator(FullTreeCreator original, Cloner cloner) : base(original, cloner) { }
    6442
    65     public FullTreeCreator()
    66       : base() {
    67       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName,
    68         "The maximal length (number of nodes) of the symbolic expression tree (this parameter is ignored)."));
    69       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName,
    70         "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    71     }
     43    public FullTreeCreator() : base() { }
    7244
    7345    public override IDeepCloneable Clone(Cloner cloner) {
     
    7749
    7850    protected override ISymbolicExpressionTree Create(IRandom random) {
    79       return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     51      return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue,
     52          MaximumSymbolicExpressionTreeLengthParameter.ActualValue.Value, MaximumSymbolicExpressionTreeDepthParameter.ActualValue.Value);
    8053    }
    8154
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs

    r12012 r12313  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
    26 using HeuristicLab.Data;
    27 using HeuristicLab.Parameters;
    2826using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2927using HeuristicLab.PluginInfrastructure;
     
    3331  [StorableClass]
    3432  [Item("GrowTreeCreator", "An operator that creates new symbolic expression trees using the 'Grow' method")]
    35   public class GrowTreeCreator : SymbolicExpressionTreeCreator,
    36                                  ISymbolicExpressionTreeSizeConstraintOperator,
    37                                  ISymbolicExpressionTreeGrammarBasedOperator {
    38     private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
    39     private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
    40 
    41     #region Parameter Properties
    42     public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
    43       get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
    44     }
    45 
    46     public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
    47       get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
    48     }
    49 
    50     #endregion
    51     #region Properties
    52     public IntValue MaximumSymbolicExpressionTreeDepth {
    53       get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; }
    54     }
    55 
    56     public IntValue MaximumSymbolicExpressionTreeLength {
    57       get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
    58     }
    59     #endregion
    60 
     33  public class GrowTreeCreator : SymbolicExpressionTreeCreator {
    6134    [StorableConstructor]
    6235    protected GrowTreeCreator(bool deserializing) : base(deserializing) { }
    6336    protected GrowTreeCreator(GrowTreeCreator original, Cloner cloner) : base(original, cloner) { }
    6437
    65     public GrowTreeCreator()
    66       : base() {
    67       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName,
    68         "The maximal length (number of nodes) of the symbolic expression tree (this parameter is ignored)."));
    69       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName,
    70         "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    71     }
     38    public GrowTreeCreator() : base() { }
    7239
    7340    public override IDeepCloneable Clone(Cloner cloner) {
     
    7845    protected override ISymbolicExpressionTree Create(IRandom random) {
    7946      return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue,
    80         MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     47        MaximumSymbolicExpressionTreeLengthParameter.ActualValue.Value, MaximumSymbolicExpressionTreeDepthParameter.ActualValue.Value);
    8148    }
    8249
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs

    r12012 r12313  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.Data;
    28 using HeuristicLab.Parameters;
    2927using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3028using HeuristicLab.PluginInfrastructure;
     
    3735    ISymbolicExpressionTreeSizeConstraintOperator, ISymbolicExpressionTreeGrammarBasedOperator {
    3836    private const int MAX_TRIES = 100;
    39     private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
    40     private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
    41     #region Parameter Properties
    42     public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
    43       get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
    44     }
    45     public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
    46       get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
    47     }
    48     #endregion
    49     #region Properties
    50     public IntValue MaximumSymbolicExpressionTreeLength {
    51       get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
    52     }
    53     public IntValue MaximumSymbolicExpressionTreeDepth {
    54       get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; }
    55     }
    56     #endregion
    5737
    5838    [StorableConstructor]
     
    6141    public ProbabilisticTreeCreator()
    6242      : base() {
    63       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree."));
    64       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
     43
    6544    }
    6645
     
    7150
    7251    protected override ISymbolicExpressionTree Create(IRandom random) {
    73       return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     52      return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue,
     53        MaximumSymbolicExpressionTreeLengthParameter.ActualValue.Value, MaximumSymbolicExpressionTreeDepthParameter.ActualValue.Value);
    7454    }
    7555
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/RampedHalfAndHalfTreeCreator.cs

    r12012 r12313  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Data;
    25 using HeuristicLab.Parameters;
    2624using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2725using HeuristicLab.PluginInfrastructure;
     
    3129  [StorableClass]
    3230  [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")]
    33   public class RampedHalfAndHalfTreeCreator : SymbolicExpressionTreeCreator,
    34                                  ISymbolicExpressionTreeSizeConstraintOperator,
    35                                  ISymbolicExpressionTreeGrammarBasedOperator {
    36     private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
    37     private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
    38 
    39     #region Parameter Properties
    40     public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
    41       get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
    42     }
    43 
    44     public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
    45       get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
    46     }
    47 
    48     #endregion
    49     #region Properties
    50     public IntValue MaximumSymbolicExpressionTreeDepth {
    51       get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; }
    52     }
    53 
    54     public IntValue MaximumSymbolicExpressionTreeLength {
    55       get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
    56     }
    57     #endregion
    58 
     31  public class RampedHalfAndHalfTreeCreator : SymbolicExpressionTreeCreator {
    5932    [StorableConstructor]
    6033    protected RampedHalfAndHalfTreeCreator(bool deserializing) : base(deserializing) { }
    6134    protected RampedHalfAndHalfTreeCreator(RampedHalfAndHalfTreeCreator original, Cloner cloner) : base(original, cloner) { }
    6235
    63     public RampedHalfAndHalfTreeCreator()
    64       : base() {
    65       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName,
    66         "The maximal length (number of nodes) of the symbolic expression tree (this parameter is ignored)."));
    67       Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName,
    68         "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    69     }
     36    public RampedHalfAndHalfTreeCreator() : base() { }
    7037
    7138    public override IDeepCloneable Clone(Cloner cloner) {
     
    7441
    7542    protected override ISymbolicExpressionTree Create(IRandom random) {
    76       return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     43      return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue,
     44        MaximumSymbolicExpressionTreeLengthParameter.ActualValue.Value, MaximumSymbolicExpressionTreeDepthParameter.ActualValue.Value);
    7745    }
    7846
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/SymbolicExpressionTreeCreator.cs

    r12012 r12313  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
     24using HeuristicLab.Data;
    2425using HeuristicLab.Parameters;
    2526using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3233  [StorableClass]
    3334  public abstract class SymbolicExpressionTreeCreator : SymbolicExpressionTreeOperator, ISymbolicExpressionTreeCreator {
     35    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
     36    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
     37
    3438    private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
    3539    private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
     
    3741
    3842    #region Parameter Properties
     43    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
     44      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
     45    }
     46    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
     47      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
     48    }
     49
    3950    public ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {
    4051      get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
     
    5566    protected SymbolicExpressionTreeCreator()
    5667      : base() {
     68      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree."));
     69      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
     70
    5771      Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree that should be created."));
    5872      Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName,
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeCreator.cs

    r12012 r12313  
    2727  /// Interface for operators that create symbolic expression trees.
    2828  /// </summary>
    29   public interface ISymbolicExpressionTreeCreator : ISymbolicExpressionTreeOperator, ISolutionCreator {
     29  public interface ISymbolicExpressionTreeCreator : ISolutionCreator, ISymbolicExpressionTreeSizeConstraintOperator, ISymbolicExpressionTreeGrammarBasedOperator {
    3030    ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
    3131    ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth);
Note: See TracChangeset for help on using the changeset viewer.