namespace HeuristicLab.Problems.ProgramSynthesis { 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 VectorConstantsErc : WeightedErcItem> where T : struct where TValue : ValueTypeArray { private const string ConstantsParameterName = "Constants"; protected VectorConstantsErc(params TValue[] arrays) : this(true, 1d, arrays) { } protected VectorConstantsErc(bool isEnabled, double weight = 1d, params TValue[] arrays) : base(isEnabled, weight) { IsEnabled = isEnabled; Parameters.Add(new ValueParameter>(ConstantsParameterName, new ItemCollection(arrays))); } [StorableConstructor] private VectorConstantsErc(bool deserializing) : base(deserializing) { } protected VectorConstantsErc(VectorConstantsErc 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(); } } }