using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Data; using HeuristicLab.Data.MoveVectorData; using HeuristicLab.Encodings.MoveVectorEncoding.Interfaces; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using System; namespace HeuristicLab.Encodings.MoveVectorEncoding { [Item("BoundedMoveVectorManipulator", "A base class for operators that manipulate bounded move vectors.")] [StorableClass] public abstract class BoundedMoveVectorManipulator : MoveVectorManipulator, IBoundedMoveVectorOperator { public IValueLookupParameter BoundsParameter { get { return (IValueLookupParameter)Parameters["Bounds"]; } } [StorableConstructor] protected BoundedMoveVectorManipulator(bool deserializing) : base(deserializing) { } protected BoundedMoveVectorManipulator(BoundedMoveVectorManipulator original, Cloner cloner) : base(original, cloner) { } protected BoundedMoveVectorManipulator() : base() { Parameters.Add(new ValueLookupParameter("Bounds", "The bounds matrix can contain one row for each dimension with three columns specifying minimum (inclusive), maximum (exclusive), and step size. If less rows are given the matrix is cycled.")); } protected sealed override void Manipulate(IRandom random, MoveVector moveVector) { if (BoundsParameter.ActualValue == null) throw new InvalidOperationException("BoundedIntegerVectorManipulator: Parameter " + BoundsParameter.ActualName + " could not be found."); ManipulateBounded(random, moveVector, BoundsParameter.ActualValue); } protected abstract void ManipulateBounded(IRandom random, MoveVector moveVector, IntMatrix bounds); } }