Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/09/10 17:28:32 (14 years ago)
Author:
gkronber
Message:

Added first version of architecture altering operators for ADFs. #290 (Implement ADFs)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeManipulator.cs

    r3239 r3294  
    3131  /// A base class for operators that manipulate real-valued vectors.
    3232  /// </summary>
    33   [Item("RealVectorManipulator", "A base class for operators that manipulate real-valued vectors.")]
     33  [Item("SymbolicExpressionTreeManipulator", "A base class for operators that manipulate symbolic expression trees.")]
    3434  [StorableClass]
    35   public abstract class RealVectorManipulator : SingleSuccessorOperator, IRealVectorManipulator, IStochasticOperator, ISymbolicExpressionTreeOperator {
    36     public override bool CanChangeName {
    37       get { return false; }
     35  public abstract class SymbolicExpressionTreeManipulator : SymbolicExpressionTreeOperator, IManipulator {
     36    private const string FailedManipulationEventsParameterName = "FailedManipulationEvents";
     37
     38    #region Parameter Properties
     39    public IValueParameter<IntValue> FailedManipulationEventsParameter {
     40      get { return (IValueParameter<IntValue>)Parameters[FailedManipulationEventsParameterName]; }
    3841    }
     42    #endregion
    3943
    40     public ILookupParameter<IRandom> RandomParameter {
    41       get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     44    #region Properties
     45    public IntValue FailedManipulationEvents {
     46      get { return FailedManipulationEventsParameter.Value; }
    4247    }
    43     public ILookupParameter<RealVector> RealVectorParameter {
    44       get { return (ILookupParameter<RealVector>)Parameters["RealVector"]; }
    45     }
    46     public IValueLookupParameter<DoubleMatrix> BoundsParameter {
    47       get { return (IValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
    48     }
     48    #endregion
    4949
    50     protected RealVectorManipulator()
     50    public SymbolicExpressionTreeManipulator()
    5151      : base() {
    52       Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    53       Parameters.Add(new LookupParameter<RealVector>("RealVector", "The vector which should be manipulated."));
    54       Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds of the real vector."));
     52      Parameters.Add(new ValueParameter<IntValue>(FailedManipulationEventsParameterName, "The number of failed manipulation events.", new IntValue()));
    5553    }
    5654
    5755    public sealed override IOperation Apply() {
    58       RealVector vector = RealVectorParameter.ActualValue;
    59       Manipulate(RandomParameter.ActualValue, vector);
    60       DoubleMatrix bounds = BoundsParameter.ActualValue;
    61       if (bounds != null) BoundsChecker.Apply(vector, bounds);
     56      SymbolicExpressionTree tree = SymbolicExpressionTreeParameter.ActualValue;
     57      bool success;
     58      Manipulate(RandomParameter.ActualValue, tree, SymbolicExpressionGrammarParameter.ActualValue,
     59        MaxTreeSizeParameter.ActualValue, MaxTreeHeightParameter.ActualValue, out success);
     60
     61      if (!success) FailedManipulationEvents.Value++;
    6262      return base.Apply();
    6363    }
    6464
    65     protected abstract void Manipulate(IRandom random, RealVector realVector);
     65    protected abstract void Manipulate(IRandom random, SymbolicExpressionTree symbolicExpressionTree, ISymbolicExpressionGrammar grammar,
     66      IntValue maxTreeSize, IntValue maxTreeHeight, out bool success);
    6667  }
    6768}
Note: See TracChangeset for help on using the changeset viewer.