Changeset 3294 for trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeManipulator.cs
- Timestamp:
- 04/09/10 17:28:32 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeManipulator.cs
r3239 r3294 31 31 /// A base class for operators that manipulate real-valued vectors. 32 32 /// </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.")] 34 34 [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]; } 38 41 } 42 #endregion 39 43 40 public ILookupParameter<IRandom> RandomParameter { 41 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 44 #region Properties 45 public IntValue FailedManipulationEvents { 46 get { return FailedManipulationEventsParameter.Value; } 42 47 } 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 49 49 50 p rotected RealVectorManipulator()50 public SymbolicExpressionTreeManipulator() 51 51 : 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())); 55 53 } 56 54 57 55 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++; 62 62 return base.Apply(); 63 63 } 64 64 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); 66 67 } 67 68 }
Note: See TracChangeset
for help on using the changeset viewer.