Changeset 12422 for trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/RampedHalfAndHalfTreeCreator.cs
- Timestamp:
- 06/10/15 11:29:34 (9 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/RampedHalfAndHalfTreeCreator.cs
r12012 r12422 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data;25 using HeuristicLab.Parameters;26 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 25 using HeuristicLab.PluginInfrastructure; … … 31 29 [StorableClass] 32 30 [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 { 59 32 [StorableConstructor] 60 33 protected RampedHalfAndHalfTreeCreator(bool deserializing) : base(deserializing) { } 61 34 protected RampedHalfAndHalfTreeCreator(RampedHalfAndHalfTreeCreator original, Cloner cloner) : base(original, cloner) { } 62 35 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() { } 70 37 71 38 public override IDeepCloneable Clone(Cloner cloner) { … … 74 41 75 42 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); 77 45 } 78 46
Note: See TracChangeset
for help on using the changeset viewer.