Changeset 12582


Ignore:
Timestamp:
07/03/15 14:54:28 (4 years ago)
Author:
ascheibe
Message:

#2306 made comparers and initializers consistent

Location:
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK
Files:
1 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/BinaryVectorComparers/AverageBitBinaryVectorComparer.cs

    r12566 r12582  
    2727
    2828namespace HeuristicLab.Problems.NK {
    29 
    3029  [Item("Average Bit Binary Vector Comparer", "Compares two binary vectors by their average positive bit location")]
    3130  [StorableClass]
    32   public sealed class AverageBitBinaryVectorComparer : BinaryVectorComparer {
    33 
     31  public sealed class AverageBitBinaryVectorComparer : Item, IBinaryVectorComparer {
    3432    [StorableConstructor]
    3533    private AverageBitBinaryVectorComparer(bool deserializing) : base(deserializing) { }
    3634    private AverageBitBinaryVectorComparer(AverageBitBinaryVectorComparer original, Cloner cloner)
    37       : base(original, cloner) {
    38     }
     35      : base(original, cloner) { }
    3936    public AverageBitBinaryVectorComparer() { }
    4037    public override IDeepCloneable Clone(Cloner cloner) {
     
    4239    }
    4340
    44     public static double AverageBit(BinaryVector x) {
     41    private static double AverageBit(BinaryVector x) {
    4542      return x.Select((b, i) => new { b, i }).Where(v => v.b).Average(v => v.i);
    4643    }
    4744
    48     public override int Compare(BinaryVector x, BinaryVector y) {
     45    public int Compare(BinaryVector x, BinaryVector y) {
    4946      return (AverageBit(x) - AverageBit(y)).CompareTo(0);
    5047    }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/BinaryVectorComparers/IBinaryVectorComparer.cs

    r12569 r12582  
    2525
    2626namespace HeuristicLab.Problems.NK {
    27   public interface IBinaryVectorComparer : INamedItem, IComparer<BinaryVector> { }
     27  public interface IBinaryVectorComparer : IItem, IComparer<BinaryVector> { }
    2828}
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/BinaryVectorComparers/LexicographicBinaryVectorComparer.cs

    r12566 r12582  
    2727
    2828namespace HeuristicLab.Problems.NK {
    29 
    3029  [Item("Lexicographic Binary Vector Comparer", "Compares two binary vectors lexicographically")]
    3130  [StorableClass]
    32   public sealed class LexicographicBinaryVectorComparer : BinaryVectorComparer {
    33 
     31  public sealed class LexicographicBinaryVectorComparer : Item, IBinaryVectorComparer {
    3432    [StorableConstructor]
    3533    private LexicographicBinaryVectorComparer(bool deserializing) : base(deserializing) { }
    3634    private LexicographicBinaryVectorComparer(LexicographicBinaryVectorComparer original, Cloner cloner)
    37       : base(original, cloner) {
    38     }
     35      : base(original, cloner) { }
    3936    public LexicographicBinaryVectorComparer() { }
    4037    public override IDeepCloneable Clone(Cloner cloner) {
     
    4239    }
    4340
    44     public override int Compare(BinaryVector x, BinaryVector y) {
     41    public int Compare(BinaryVector x, BinaryVector y) {
    4542      for (int i = 0; i < Math.Min(x.Length, y.Length); i++) {
    4643        if (!x[i] && y[i])
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/BinaryVectorComparers/MedianBitBinaryVectorComparer.cs

    r12566 r12582  
    2727
    2828namespace HeuristicLab.Problems.NK {
    29 
    3029  [Item("Median Bit Binary Vector Comparer", "Compares two binary vectors by the median positive bit location")]
    3130  [StorableClass]
    32   public sealed class MedianBitBinaryVectorComparer : BinaryVectorComparer {
    33 
     31  public sealed class MedianBitBinaryVectorComparer : Item, IBinaryVectorComparer {
    3432    [StorableConstructor]
    3533    private MedianBitBinaryVectorComparer(bool deserializing) : base(deserializing) { }
    3634    private MedianBitBinaryVectorComparer(MedianBitBinaryVectorComparer original, Cloner cloner)
    37       : base(original, cloner) {
    38     }
     35      : base(original, cloner) { }
    3936    public MedianBitBinaryVectorComparer() { }
    4037    public override IDeepCloneable Clone(Cloner cloner) {
     
    4239    }
    4340
    44     public static int MedianBit(BinaryVector x) {
     41    private static int MedianBit(BinaryVector x) {
    4542      var activeIndices = x.Select((b, i) => new { b, i }).Where(v => v.b).ToList();
    4643      if (activeIndices.Count > 0)
     
    4946        return 0;
    5047    }
    51     public override int Compare(BinaryVector x, BinaryVector y) {
     48
     49    public int Compare(BinaryVector x, BinaryVector y) {
    5250      return MedianBit(x) - MedianBit(y);
    5351    }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/HeuristicLab.Problems.NK.csproj

    r12569 r12582  
    157157  </ItemGroup>
    158158  <ItemGroup>
    159     <Compile Include="BinaryVectorComparers\BinaryVectorComparer.cs" />
    160159    <Compile Include="BinaryVectorComparers\IBinaryVectorComparer.cs" />
    161160    <Compile Include="BinaryVectorComparers\LexicographicBinaryVectorComparer.cs" />
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/IInteractionInitializer.cs

    r12566 r12582  
    2424
    2525namespace HeuristicLab.Problems.NK {
    26   public interface IInteractionInitializer : INamedItem {
     26  public interface IInteractionInitializer : IItem {
    2727    BoolMatrix InitializeInterations(int length, int nComponents, int nInteractions, IRandom random);
    2828  }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/IncreasingBlockSizeInteractionsInitializer.cs

    r12566 r12582  
    2929
    3030namespace HeuristicLab.Problems.NK {
    31 
    3231  [Item("IncreasingBlockSizeInteractionsInitializer", "Randomly assignes interactions across all bits but makes sure that different numbers of ineractions are applied to different bits.")]
    3332  [StorableClass]
    34   public class IncreasingBlockSizeInteractionsInitializer : ParameterizedNamedItem, IInteractionInitializer {
    35 
     33  public sealed class IncreasingBlockSizeInteractionsInitializer : Item, IInteractionInitializer {
    3634    [StorableConstructor]
    37     protected IncreasingBlockSizeInteractionsInitializer(bool serializing) : base(serializing) { }
    38     protected IncreasingBlockSizeInteractionsInitializer(IncreasingBlockSizeInteractionsInitializer original, Cloner cloner) : base(original, cloner) { }
    39     public IncreasingBlockSizeInteractionsInitializer() {
    40     }
    41 
    42 
     35    private IncreasingBlockSizeInteractionsInitializer(bool serializing) : base(serializing) { }
     36    private IncreasingBlockSizeInteractionsInitializer(IncreasingBlockSizeInteractionsInitializer original, Cloner cloner) : base(original, cloner) { }
     37    public IncreasingBlockSizeInteractionsInitializer() { }
    4338    public override IDeepCloneable Clone(Cloner cloner) {
    4439      return new IncreasingBlockSizeInteractionsInitializer(this, cloner);
    4540    }
    4641
    47     #region IInteractionInitializer Members
    4842    public BoolMatrix InitializeInterations(int length, int nComponents, int nInteractions, IRandom random) {
    4943      Dictionary<int, int> bitInteractionCounts = new Dictionary<int, int>();
     
    7771      return m;
    7872    }
    79     #endregion
    8073  }
    8174}
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/LimitedRandomInteractionsInitializer.cs

    r12569 r12582  
    2929
    3030namespace HeuristicLab.Problems.NK {
    31 
    3231  [Item("LimitedRandomInteractionsInitializer", "Randomly assignes interactions across bits in the vicinity of each other respecting the maximum distances if possible.")]
    3332  [StorableClass]
    34   public class LimitedRandomInteractionsInitializer : ParameterizedNamedItem, IInteractionInitializer {
    35 
     33  public sealed class LimitedRandomInteractionsInitializer : ParameterizedNamedItem, IInteractionInitializer {
    3634    private class Bounds {
    3735      public readonly int Min;
     
    5351    }
    5452
     53    [StorableConstructor]
     54    private LimitedRandomInteractionsInitializer(bool serializing) : base(serializing) { }
     55    private LimitedRandomInteractionsInitializer(LimitedRandomInteractionsInitializer original, Cloner cloner) : base(original, cloner) { }
     56    public LimitedRandomInteractionsInitializer() {
     57      Parameters.Add(new ValueParameter<IntValue>("MaximumDistance", "Maximum distance of interactions in bits or 0 for unlimited"));
     58      Parameters.Add(new ValueParameter<DoubleValue>("MaximumDistanceRatio", "Maximum distance of interactions as ratio of the total length or 0 for unlimited"));
     59    }
     60
     61    public override IDeepCloneable Clone(Cloner cloner) {
     62      return new LimitedRandomInteractionsInitializer(this, cloner);
     63    }
     64
    5565    private int MaximumDistance(int length, int nInteractions) {
    5666      int maxBitDist = MaximumDistanceParameter.Value.Value;
     
    6474    }
    6575
    66     [StorableConstructor]
    67     protected LimitedRandomInteractionsInitializer(bool serializing) : base(serializing) { }
    68     protected LimitedRandomInteractionsInitializer(LimitedRandomInteractionsInitializer original, Cloner cloner) : base(original, cloner) { }
    69     public LimitedRandomInteractionsInitializer() {
    70       Parameters.Add(new ValueParameter<IntValue>("MaximumDistance", "Maximum distance of interactions in bits or 0 for unlimited"));
    71       Parameters.Add(new ValueParameter<DoubleValue>("MaximumDistanceRatio", "Maximum distance of interactions as ratio of the total length or 0 for unlimited"));
    72     }
    73 
    74     public override IDeepCloneable Clone(Cloner cloner) {
    75       return new LimitedRandomInteractionsInitializer(this, cloner);
    76     }
    77 
    78     #region IInteractionInitializer Members
    7976    public BoolMatrix InitializeInterations(int length, int nComponents, int nInteractions, IRandom random) {
    8077      BoolMatrix m = new BoolMatrix(length, nComponents);
     
    9794      return m;
    9895    }
    99     #endregion
    10096  }
    10197}
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/RandomInteractionsInitializer.cs

    r12566 r12582  
    2727
    2828namespace HeuristicLab.Problems.NK {
    29 
    3029  [Item("RandomInteractionsInitializer", "Randomly assignes interactions across all bits")]
    3130  [StorableClass]
    32   public class RandomInteractionsInitializer : NamedItem, IInteractionInitializer {
    33 
    34     public override bool CanChangeName { get { return false; } }
    35     public override bool CanChangeDescription { get { return false; } }
    36 
    37 
     31  public sealed class RandomInteractionsInitializer : Item, IInteractionInitializer {
    3832    [StorableConstructor]
    39     protected RandomInteractionsInitializer(bool serializing) : base(serializing) { }
    40     protected RandomInteractionsInitializer(RandomInteractionsInitializer original, Cloner cloner) : base(original, cloner) { }
    41     public RandomInteractionsInitializer() {
    42       name = ItemName;
    43       description = ItemDescription;
    44     }
     33    private RandomInteractionsInitializer(bool serializing) : base(serializing) { }
     34    private RandomInteractionsInitializer(RandomInteractionsInitializer original, Cloner cloner) : base(original, cloner) { }
     35    public RandomInteractionsInitializer() { }
    4536    public override IDeepCloneable Clone(Cloner cloner) {
    4637      return new RandomInteractionsInitializer(this, cloner);
    4738    }
    4839
    49     #region IInteractionInitializer Members
    5040    public BoolMatrix InitializeInterations(int length, int nComponents, int nInteractions, IRandom random) {
    5141      BoolMatrix m = new BoolMatrix(length, nComponents);
     
    6555      return m;
    6656    }
    67     #endregion
    6857  }
    6958}
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/SortedRandomInteractionsInitializer.cs

    r12569 r12582  
    3030
    3131namespace HeuristicLab.Problems.NK {
    32 
    3332  [Item("SortedRandomInteractionsInitializer", "Randomly assigns interactions across all bits and sorts components according to bit affinity.")]
    3433  [StorableClass]
    35   public class SortedRandomInteractionsInitializer : ParameterizedNamedItem, IInteractionInitializer {
     34  public sealed class SortedRandomInteractionsInitializer : ParameterizedNamedItem, IInteractionInitializer {
    3635    public IConstrainedValueParameter<IBinaryVectorComparer> ComparerParameter {
    3736      get { return (IConstrainedValueParameter<IBinaryVectorComparer>)Parameters["Comparer"]; }
     
    4241
    4342    [StorableConstructor]
    44     protected SortedRandomInteractionsInitializer(bool serializing) : base(serializing) { }
    45     protected SortedRandomInteractionsInitializer(SortedRandomInteractionsInitializer original, Cloner cloner) : base(original, cloner) { }
     43    private SortedRandomInteractionsInitializer(bool serializing) : base(serializing) { }
     44    private SortedRandomInteractionsInitializer(SortedRandomInteractionsInitializer original, Cloner cloner) : base(original, cloner) { }
    4645    public SortedRandomInteractionsInitializer() {
    4746      Parameters.Add(new ConstrainedValueParameter<IBinaryVectorComparer>("Comparer", "Comparison for sorting of component functions."));
     
    5958    }
    6059
    61     #region IInteractionInitializer Members
    6260    public BoolMatrix InitializeInterations(int length, int nComponents, int nInteractions, IRandom random) {
    6361      BinaryVector[] components = Enumerable.Range(0, nComponents).Select(i => new BinaryVector(length)).ToArray();
     
    8381      return m;
    8482    }
    85     #endregion
    8683  }
    8784}
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/NKLandscape.cs

    r12576 r12582  
    3131using HeuristicLab.PluginInfrastructure;
    3232using HeuristicLab.Problems.Binary;
    33 using HeuristicLab.Problems.NK.WeightInitializers;
    3433using HeuristicLab.Random;
    3534
     
    246245
    247246    #region Evaluation function
    248     public static long Hash(long x, HashAlgorithm hashAlg) {
     247    private static long Hash(long x, HashAlgorithm hashAlg) {
    249248      return BitConverter.ToInt64(hashAlg.ComputeHash(BitConverter.GetBytes(x), 0, 8), 0);
    250249    }
    251250
    252251    public static double F_i(long x, long i, long g_i, long seed, int q, double p) {
    253       var hash = new Func<long,long>(y => Hash(y, HashAlgorithm));
     252      var hash = new Func<long, long>(y => Hash(y, HashAlgorithm));
    254253      var fi = Math.Abs((double)hash((x & g_i) ^ hash(g_i ^ hash(i ^ seed)))) / long.MaxValue;
    255       if (q > 0) { fi = Math.Round(fi*q)/q; }
     254      if (q > 0) { fi = Math.Round(fi * q) / q; }
    256255      if (p > 0) {
    257256        hash = y => Hash(y, HashAlgorithmP);
     
    262261    }
    263262
    264     public static double F(long x, long[] g, double[] w, long seed, ref double[] f_i, int q, double p) {
     263    private static double F(long x, long[] g, double[] w, long seed, ref double[] f_i, int q, double p) {
    265264      double value = 0;
    266265      for (int i = 0; i < g.Length; i++) {
     
    311310
    312311    public override double Evaluate(BinaryVector vector, IRandom random) {
    313       double[] f_i;//not used atm
     312      double[] f_i; //useful for debugging
    314313      double quality = Evaluate(vector, GeneInteractions, Weights, InteractionSeed.Value, out f_i, Q, P);
    315314      return quality;
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/EqualWeightsInitializer.cs

    r12569 r12582  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.NK.WeightInitializers {
    28 
     27namespace HeuristicLab.Problems.NK {
    2928  [Item("EqualWeightsInitializer", "Initializes all weights to 1.0.")]
    3029  [StorableClass]
    31   public class EqualWeightsInitializer : NamedItem, IWeightsInitializer {
    32 
    33     public override bool CanChangeName { get { return false; } }
    34     public override bool CanChangeDescription { get { return false; } }
    35 
     30  public sealed class EqualWeightsInitializer : Item, IWeightsInitializer {
    3631    [StorableConstructor]
    37     protected EqualWeightsInitializer(bool deserializing) : base(deserializing) { }
    38     protected EqualWeightsInitializer(EqualWeightsInitializer original, Cloner cloner)
    39       : base(original, cloner) {
    40     }
    41     public EqualWeightsInitializer() {
    42       name = ItemName;
    43       description = ItemDescription;
    44     }
     32    private EqualWeightsInitializer(bool deserializing) : base(deserializing) { }
     33    private EqualWeightsInitializer(EqualWeightsInitializer original, Cloner cloner)
     34      : base(original, cloner) { }
     35    public EqualWeightsInitializer() { }
    4536    public override IDeepCloneable Clone(Cloner cloner) {
    4637      return new EqualWeightsInitializer(this, cloner);
    4738    }
    4839
    49     #region IWeightsInitializer Members
    50 
    5140    public IEnumerable<double> GetWeights(int nComponents) {
    5241      return new[] { 1.0 };
    5342    }
    54 
    55     #endregion
    5643  }
    57 
    5844}
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ExponentialDistributionWeightsInitializer.cs

    r12569 r12582  
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2929
    30 namespace HeuristicLab.Problems.NK.WeightInitializers {
    31 
     30namespace HeuristicLab.Problems.NK {
    3231  [Item("ExponentialDistributionWeightsInitializer", "Assigns exponentially decreasing weights using the rate parameter lambda.")]
    3332  [StorableClass]
    34   public class ExponentialDistributionWeightsInitializer : ParameterizedNamedItem, IWeightsInitializer {
    35 
    36     public override bool CanChangeName { get { return false; } }
    37     public override bool CanChangeDescription { get { return false; } }
     33  public sealed class ExponentialDistributionWeightsInitializer : ParameterizedNamedItem, IWeightsInitializer {
    3834    public IValueParameter<DoubleValue> LambdaParameter {
    3935      get { return (IValueParameter<DoubleValue>)Parameters["Lambda"]; }
     
    4137
    4238    [StorableConstructor]
    43     protected ExponentialDistributionWeightsInitializer(bool deserializing) : base(deserializing) { }
    44     protected ExponentialDistributionWeightsInitializer(ExponentialDistributionWeightsInitializer original, Cloner cloner)
     39    private ExponentialDistributionWeightsInitializer(bool deserializing) : base(deserializing) { }
     40    private ExponentialDistributionWeightsInitializer(ExponentialDistributionWeightsInitializer original, Cloner cloner)
    4541      : base(original, cloner) {
    4642    }
     
    5248    }
    5349
    54     public static double f(double x, double lambda) {
     50    private static double f(double x, double lambda) {
    5551      if (x < 0.0)
    5652        return 0.0;
     
    5854    }
    5955
    60     #region IWeightsInitializer Members
    6156    public IEnumerable<double> GetWeights(int nComponents) {
    6257      double lambda = LambdaParameter.Value.Value;
     
    6459        yield return f(i, lambda);
    6560    }
    66     #endregion
    6761  }
    68 
    6962}
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ExponentialWeightsInitializer.cs

    r12569 r12582  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Problems.NK.WeightInitializers {
    29 
     28namespace HeuristicLab.Problems.NK {
    3029  [Item("ExponentialWeightsInitializer", "Assigns exponentially increasing weights.")]
    3130  [StorableClass]
    32   public class ExponentialWeightsInitializer : NamedItem, IWeightsInitializer {
    33 
    34     public override bool CanChangeName { get { return false; } }
    35     public override bool CanChangeDescription { get { return false; } }
    36 
     31  public sealed class ExponentialWeightsInitializer : Item, IWeightsInitializer {
    3732    [StorableConstructor]
    38     protected ExponentialWeightsInitializer(bool deserializing) : base(deserializing) { }
    39     protected ExponentialWeightsInitializer(ExponentialWeightsInitializer original, Cloner cloner)
     33    private ExponentialWeightsInitializer(bool deserializing) : base(deserializing) { }
     34    private ExponentialWeightsInitializer(ExponentialWeightsInitializer original, Cloner cloner)
    4035      : base(original, cloner) {
    4136    }
    42     public ExponentialWeightsInitializer() {
    43       name = ItemName;
    44       description = ItemDescription;
    45     }
     37    public ExponentialWeightsInitializer() { }
    4638    public override IDeepCloneable Clone(Cloner cloner) {
    4739      return new ExponentialWeightsInitializer(this, cloner);
    4840    }
    49 
    50     #region IWeightsInitializer Members
    5141
    5242    public IEnumerable<double> GetWeights(int nComponents) {
     
    5444        yield return Math.Pow(2, i);
    5545    }
    56 
    57     #endregion
    5846  }
    59 
    6047}
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/IWeightsInitializer.cs

    r12569 r12582  
    2424
    2525namespace HeuristicLab.Problems.NK {
    26   public interface IWeightsInitializer : INamedItem {
     26  public interface IWeightsInitializer : IItem {
    2727    IEnumerable<double> GetWeights(int nComponents);
    2828  }
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/LinearWeightsInitializer.cs

    r12569 r12582  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.NK.WeightInitializers {
    28 
     27namespace HeuristicLab.Problems.NK {
    2928  [Item("LinearWeightsInitializer", "Assigns linear increasing weights.")]
    3029  [StorableClass]
    31   public class LinearWeightsInitializer : NamedItem, IWeightsInitializer {
    32 
    33     public override bool CanChangeName { get { return false; } }
    34     public override bool CanChangeDescription { get { return false; } }
    35 
     30  public sealed class LinearWeightsInitializer : Item, IWeightsInitializer {
    3631    [StorableConstructor]
    37     protected LinearWeightsInitializer(bool deserializing) : base(deserializing) { }
    38     protected LinearWeightsInitializer(LinearWeightsInitializer original, Cloner cloner)
     32    private LinearWeightsInitializer(bool deserializing) : base(deserializing) { }
     33    private LinearWeightsInitializer(LinearWeightsInitializer original, Cloner cloner)
    3934      : base(original, cloner) {
    4035    }
    41     public LinearWeightsInitializer() {
    42       name = ItemName;
    43       description = ItemDescription;
    44     }
     36    public LinearWeightsInitializer() { }
    4537    public override IDeepCloneable Clone(Cloner cloner) {
    4638      return new LinearWeightsInitializer(this, cloner);
    4739    }
    48 
    49     #region IWeightsInitializer Members
    5040
    5141    public IEnumerable<double> GetWeights(int nComponents) {
     
    5343        yield return i;
    5444    }
    55 
    56     #endregion
    5745  }
    58 
    5946}
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ReverseExponentialWeightsInitializer.cs

    r12569 r12582  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Problems.NK.WeightInitializers {
    29 
     28namespace HeuristicLab.Problems.NK {
    3029  [Item("ReverseExponentialWeightsInitializer", "Assigns exponentially decreasing weights.")]
    3130  [StorableClass]
    32   public class ReverseExponentialWeightsInitializer : NamedItem, IWeightsInitializer {
    33 
    34     public override bool CanChangeName { get { return false; } }
    35     public override bool CanChangeDescription { get { return false; } }
    36 
     31  public sealed class ReverseExponentialWeightsInitializer : Item, IWeightsInitializer {
    3732    [StorableConstructor]
    38     protected ReverseExponentialWeightsInitializer(bool deserializing) : base(deserializing) { }
    39     protected ReverseExponentialWeightsInitializer(ReverseExponentialWeightsInitializer original, Cloner cloner)
     33    private ReverseExponentialWeightsInitializer(bool deserializing) : base(deserializing) { }
     34    private ReverseExponentialWeightsInitializer(ReverseExponentialWeightsInitializer original, Cloner cloner)
    4035      : base(original, cloner) {
    4136    }
    42     public ReverseExponentialWeightsInitializer() {
    43       name = ItemName;
    44       description = ItemDescription;
    45     }
     37    public ReverseExponentialWeightsInitializer() { }
    4638    public override IDeepCloneable Clone(Cloner cloner) {
    4739      return new ReverseExponentialWeightsInitializer(this, cloner);
    4840    }
    49 
    50     #region IWeightsInitializer Members
    5141
    5242    public IEnumerable<double> GetWeights(int nComponents) {
     
    5444        yield return Math.Pow(2, i);
    5545    }
    56 
    57     #endregion
    5846  }
    59 
    6047}
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/WeightInitializers/ReverseLinearWeightsInitializer.cs

    r12569 r12582  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.NK.WeightInitializers {
    28 
     27namespace HeuristicLab.Problems.NK {
    2928  [Item("ReverseLinearWeightsInitializer", "Assigns exponentially decreasing weights.")]
    3029  [StorableClass]
    31   public class ReverseLinearWeightsInitializer : NamedItem, IWeightsInitializer {
    32 
    33     public override bool CanChangeName { get { return false; } }
    34     public override bool CanChangeDescription { get { return false; } }
    35 
     30  public sealed class ReverseLinearWeightsInitializer : Item, IWeightsInitializer {
    3631    [StorableConstructor]
    37     protected ReverseLinearWeightsInitializer(bool deserializing) : base(deserializing) { }
    38     protected ReverseLinearWeightsInitializer(ReverseLinearWeightsInitializer original, Cloner cloner)
     32    private ReverseLinearWeightsInitializer(bool deserializing) : base(deserializing) { }
     33    private ReverseLinearWeightsInitializer(ReverseLinearWeightsInitializer original, Cloner cloner)
    3934      : base(original, cloner) {
    4035    }
    41     public ReverseLinearWeightsInitializer() {
    42       name = ItemName;
    43       description = ItemDescription;
    44     }
     36    public ReverseLinearWeightsInitializer() { }
    4537    public override IDeepCloneable Clone(Cloner cloner) {
    4638      return new ReverseLinearWeightsInitializer(this, cloner);
    4739    }
    48 
    49     #region IWeightsInitializer Members
    5040
    5141    public IEnumerable<double> GetWeights(int nComponents) {
     
    5343        yield return i;
    5444    }
    55 
    56     #endregion
    5745  }
    58 
    5946}
Note: See TracChangeset for help on using the changeset viewer.