using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Data; using HeuristicLab.Encodings.RealVectorEncoding; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using System.Linq; namespace HeuristicLab.BioBoost.SolutionCreation { [StorableClass] public class ConstantValueRealVectorCreator : RealVectorCreator { public IValueLookupParameter ValueParameter { get { return (IValueLookupParameter) Parameters["Value"]; } } public double Value { get { return ValueParameter.ActualValue.Value; } set { ValueParameter.Value = new DoubleValue(value); } } #region Construction & Cloning [StorableConstructor] protected ConstantValueRealVectorCreator(bool isDeserializing) : base(isDeserializing) {} protected ConstantValueRealVectorCreator(ConstantValueRealVectorCreator orig, Cloner cloner) : base(orig, cloner) {} public ConstantValueRealVectorCreator() { Parameters.Add(new ValueLookupParameter("Value", "The constant value to be replicated.", new DoubleValue(1))); BoundsParameter.Value = new DoubleMatrix(new double[,] {{1, 1}}); } public override IDeepCloneable Clone(Cloner cloner) { return new ConstantValueRealVectorCreator(this, cloner); } #endregion protected override RealVector Create(IRandom random, IntValue length, DoubleMatrix bounds) { return new RealVector(Enumerable.Repeat(Value, length.Value).ToArray()); } } }