using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Data.MoveVectorData; using HeuristicLab.Encodings.MoveVectorEncoding.Interfaces; using HeuristicLab.Optimization; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Encodings.MoveVectorEncoding { [Item("MoveVectorManipulator", "A base class for operators that manipulate move vectors.")] [StorableClass] public abstract class MoveVectorManipulator : MoveVectorOperator, IMoveVectorManipulator, IStochasticOperator { public override bool CanChangeName { get { return false; } } public ILookupParameter RandomParameter { get { return (LookupParameter)Parameters["Random"]; } } public ILookupParameter MoveVectorParameter { get { return (ILookupParameter)Parameters["MoveVector"]; } } [StorableConstructor] protected MoveVectorManipulator(bool deserializing) : base(deserializing) { } protected MoveVectorManipulator(MoveVectorManipulator original, Cloner cloner) : base(original, cloner) { } protected MoveVectorManipulator() : base() { Parameters.Add(new LookupParameter("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); Parameters.Add(new LookupParameter("MoveVector", "The vector which should be manipulated.")); } public sealed override IOperation InstrumentedApply() { Manipulate(RandomParameter.ActualValue, MoveVectorParameter.ActualValue); return base.InstrumentedApply(); } protected abstract void Manipulate(IRandom random, MoveVector moveVector); } }