Changeset 12582 for branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/BinaryVectorComparers
- Timestamp:
- 07/03/15 14:54:28 (10 years ago)
- Location:
- branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/BinaryVectorComparers
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/BinaryVectorComparers/AverageBitBinaryVectorComparer.cs
r12566 r12582 27 27 28 28 namespace HeuristicLab.Problems.NK { 29 30 29 [Item("Average Bit Binary Vector Comparer", "Compares two binary vectors by their average positive bit location")] 31 30 [StorableClass] 32 public sealed class AverageBitBinaryVectorComparer : BinaryVectorComparer { 33 31 public sealed class AverageBitBinaryVectorComparer : Item, IBinaryVectorComparer { 34 32 [StorableConstructor] 35 33 private AverageBitBinaryVectorComparer(bool deserializing) : base(deserializing) { } 36 34 private AverageBitBinaryVectorComparer(AverageBitBinaryVectorComparer original, Cloner cloner) 37 : base(original, cloner) { 38 } 35 : base(original, cloner) { } 39 36 public AverageBitBinaryVectorComparer() { } 40 37 public override IDeepCloneable Clone(Cloner cloner) { … … 42 39 } 43 40 44 p ublicstatic double AverageBit(BinaryVector x) {41 private static double AverageBit(BinaryVector x) { 45 42 return x.Select((b, i) => new { b, i }).Where(v => v.b).Average(v => v.i); 46 43 } 47 44 48 public overrideint Compare(BinaryVector x, BinaryVector y) {45 public int Compare(BinaryVector x, BinaryVector y) { 49 46 return (AverageBit(x) - AverageBit(y)).CompareTo(0); 50 47 } -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/BinaryVectorComparers/IBinaryVectorComparer.cs
r12569 r12582 25 25 26 26 namespace HeuristicLab.Problems.NK { 27 public interface IBinaryVectorComparer : I NamedItem, IComparer<BinaryVector> { }27 public interface IBinaryVectorComparer : IItem, IComparer<BinaryVector> { } 28 28 } -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/BinaryVectorComparers/LexicographicBinaryVectorComparer.cs
r12566 r12582 27 27 28 28 namespace HeuristicLab.Problems.NK { 29 30 29 [Item("Lexicographic Binary Vector Comparer", "Compares two binary vectors lexicographically")] 31 30 [StorableClass] 32 public sealed class LexicographicBinaryVectorComparer : BinaryVectorComparer { 33 31 public sealed class LexicographicBinaryVectorComparer : Item, IBinaryVectorComparer { 34 32 [StorableConstructor] 35 33 private LexicographicBinaryVectorComparer(bool deserializing) : base(deserializing) { } 36 34 private LexicographicBinaryVectorComparer(LexicographicBinaryVectorComparer original, Cloner cloner) 37 : base(original, cloner) { 38 } 35 : base(original, cloner) { } 39 36 public LexicographicBinaryVectorComparer() { } 40 37 public override IDeepCloneable Clone(Cloner cloner) { … … 42 39 } 43 40 44 public overrideint Compare(BinaryVector x, BinaryVector y) {41 public int Compare(BinaryVector x, BinaryVector y) { 45 42 for (int i = 0; i < Math.Min(x.Length, y.Length); i++) { 46 43 if (!x[i] && y[i]) -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/BinaryVectorComparers/MedianBitBinaryVectorComparer.cs
r12566 r12582 27 27 28 28 namespace HeuristicLab.Problems.NK { 29 30 29 [Item("Median Bit Binary Vector Comparer", "Compares two binary vectors by the median positive bit location")] 31 30 [StorableClass] 32 public sealed class MedianBitBinaryVectorComparer : BinaryVectorComparer { 33 31 public sealed class MedianBitBinaryVectorComparer : Item, IBinaryVectorComparer { 34 32 [StorableConstructor] 35 33 private MedianBitBinaryVectorComparer(bool deserializing) : base(deserializing) { } 36 34 private MedianBitBinaryVectorComparer(MedianBitBinaryVectorComparer original, Cloner cloner) 37 : base(original, cloner) { 38 } 35 : base(original, cloner) { } 39 36 public MedianBitBinaryVectorComparer() { } 40 37 public override IDeepCloneable Clone(Cloner cloner) { … … 42 39 } 43 40 44 p ublicstatic int MedianBit(BinaryVector x) {41 private static int MedianBit(BinaryVector x) { 45 42 var activeIndices = x.Select((b, i) => new { b, i }).Where(v => v.b).ToList(); 46 43 if (activeIndices.Count > 0) … … 49 46 return 0; 50 47 } 51 public override int Compare(BinaryVector x, BinaryVector y) { 48 49 public int Compare(BinaryVector x, BinaryVector y) { 52 50 return MedianBit(x) - MedianBit(y); 53 51 }
Note: See TracChangeset
for help on using the changeset viewer.