using HeuristicLab.Encodings.MoveVectorEncoding.Interfaces; using HeuristicLab.Operators; using HeuristicLab.Optimization; using HeuristicLab.Core; using HeuristicLab.Common; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Data; using HeuristicLab.Parameters; using HeuristicLab.Data.MoveVectorData; using System.Collections.Generic; using HeuristicLab.Data.MoveVectorData.Interfaces; using System; using HeuristicLab.PluginInfrastructure; using System.Linq; namespace HeuristicLab.Encodings.MoveVectorEncoding { [Item("MoveVectorCreator", "A base class for operators creating Move Vectors.")] [StorableClass] public abstract class MoveVectorCreator : InstrumentedOperator, IMoveVectorCreator, IStochasticOperator { #region Parameter Properties public ILookupParameter RandomParameter { get { return (LookupParameter)Parameters["Random"]; } } public ILookupParameter MoveVectorParameter { get { return (ILookupParameter)Parameters["MoveVector"]; } } public IValueLookupParameter LengthParameter { get { return (IValueLookupParameter)Parameters["Length"]; } } public IValueLookupParameter BoundsParameter { get { return (IValueLookupParameter)Parameters["Bounds"]; } } #endregion #region Properties [Storable] private IList moveTypes; public IList MoveTypes { get { if(moveTypes == null) moveTypes = ApplicationManager.Manager.GetTypes(typeof(IMove)).ToList(); return moveTypes; } set { moveTypes = value; } } #endregion #region Cloning [StorableConstructor] protected MoveVectorCreator(bool deserializing) : base(deserializing) { } protected MoveVectorCreator(MoveVectorCreator original, Cloner cloner) : base(original, cloner) { } [StorableHook(HookType.AfterDeserialization)] private void AfterDeserialization() { } #endregion protected MoveVectorCreator(): 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 move vector which should be manipulated.")); Parameters.Add(new ValueLookupParameter("Length", "The length of the vector.")); 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.")); } public override IOperation InstrumentedApply() { MoveVectorParameter.ActualValue = Create(RandomParameter.ActualValue, LengthParameter.ActualValue, BoundsParameter.ActualValue); return base.InstrumentedApply(); } public abstract MoveVector Create(IRandom random, IntValue length, IntMatrix bounds); } }