using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.PluginInfrastructure; using HeuristicLab.Data; using HeuristicLab.Data.MoveVectorData; using HeuristicLab.Data.MoveVectorData.Interfaces; using System.Linq; using System; using System.Collections.Generic; namespace HeuristicLab.Encodings.MoveVectorEncoding.Creators { [NonDiscoverableType] [StorableClass] [Item("RandomMoveVectorCreator", "An operator that creates new MoveVectors using random methods")] public class RandomMoveVectorCreator : MoveVectorCreator { #region Cloning [StorableConstructor] protected RandomMoveVectorCreator(bool deserializing) : base(deserializing) { } protected RandomMoveVectorCreator(RandomMoveVectorCreator original, Cloner cloner) : base(original, cloner) { } public override IDeepCloneable Clone(Cloner cloner) { var ret = new RandomMoveVectorCreator(this, cloner); ret.MoveTypes = this.MoveTypes; return ret; } #endregion public RandomMoveVectorCreator() : base() { } public static MoveVector Apply(IRandom random, IList moveTypes, int length, IntMatrix bounds) { var result = new MoveVector(length, moveTypes); result.Randomize(random, bounds); return result; } public override MoveVector Create(IRandom random, IntValue length, IntMatrix bounds) { return Apply(random, MoveTypes, length.Value, bounds); } } }