namespace HeuristicLab.Problems.ProgramSynthesis.Base.Erc { using System.Collections.Generic; using System.Linq; using Common; using Core; using Data; using Parameters; using Persistence.Default.CompositeSerializers.Storable; using Random; [StorableClass] public abstract class VectorConstantsErcValue : WeightedErcValueItem> where T : struct where TValue : ValueTypeArray { private const string ConstantsParameterName = "Constants"; protected VectorConstantsErcValue(params TValue[] arrays) : this(true, 1d, arrays) { } protected VectorConstantsErcValue(bool isEnabled, double weight = 1d, params TValue[] arrays) : base(isEnabled, weight) { IsEnabled = isEnabled; Parameters.Add(new ValueParameter>(ConstantsParameterName, new ItemCollection(arrays))); } [StorableConstructor] private VectorConstantsErcValue(bool deserializing) : base(deserializing) { } protected VectorConstantsErcValue(VectorConstantsErcValue origin, Cloner cloner) : base(origin, cloner) { } public IValueParameter> ConstantsParameter { get { return (IValueParameter>)Parameters[ConstantsParameterName]; } } public IEnumerable Constants { get { return ConstantsParameter.Value; } } public override IReadOnlyList GetErcValue(IRandom random) { // TODO: remove ToList when ValueTypeArray implements IReadOnlyList return Constants.SampleRandom(random).ToArray(); } } }