using System; using System.Collections.Generic; using System.Linq; using System.Text; using HeuristicLab.Core; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Common; namespace HeuristicLab.Problems.NK.WeightInitializers { [Item("ReverseExponentialWeightsInitializer", "Assigned exponentially decreasing weights.")] public class ReverseExponentialWeightsInitializer : NamedItem, IWeightsInitializer { public override bool CanChangeName { get { return false; } } public override bool CanChangeDescription { get { return false; } } [StorableConstructor] protected ReverseExponentialWeightsInitializer(bool deserializing) : base(deserializing) { } protected ReverseExponentialWeightsInitializer(ReverseExponentialWeightsInitializer original, Cloner cloner) : base(original, cloner) { } public ReverseExponentialWeightsInitializer() { name = ItemName; description = ItemDescription; } public override IDeepCloneable Clone(Cloner cloner) { return new ReverseExponentialWeightsInitializer(this, cloner); } #region IWeightsInitializer Members public IEnumerable GetWeights(int nComponents) { for (int i = nComponents-1; i>=0; i--) yield return Math.Pow(2, i); } #endregion } }