- Timestamp:
- 07/15/17 14:25:44 (7 years ago)
- Location:
- branches/PerformanceComparison/HeuristicLab.Encodings.PermutationEncoding
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.Encodings.PermutationEncoding
- Property svn:mergeinfo changed
-
branches/PerformanceComparison/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationEqualityComparer.cs
r14600 r15256 30 30 public class PermutationEqualityComparer : EqualityComparer<Permutation> { 31 31 public override bool Equals(Permutation x, Permutation y) { 32 if (ReferenceEquals(x, y)) return true; 33 if (x == null || y == null) return false; 34 if (x.Length != y.Length) return false; 32 35 if (x.PermutationType != y.PermutationType) return false; 33 if (x.Length != y.Length) return false;34 36 switch (x.PermutationType) { 35 37 case PermutationTypes.Absolute: … … 67 69 68 70 public override int GetHashCode(Permutation obj) { 69 if (obj == null) return 0;71 if (obj == null) throw new ArgumentNullException("obj", "PermutationEqualityComparer: Cannot compute hash value of null."); 70 72 return GenerateHashString(obj).GetHashCode(); 71 73 } -
branches/PerformanceComparison/HeuristicLab.Encodings.PermutationEncoding/3.3/SimilarityCalculators/HammingSimilarityCalculator.cs
r14659 r15256 24 24 using HeuristicLab.Core; 25 25 using HeuristicLab.Optimization.Operators; 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 27 27 28 namespace HeuristicLab.Encodings.PermutationEncoding { 28 29 [Item("Hamming Similarity Calculator for Permutation", "An operator that performs similarity calculation between two permutation-encoded solutions.")] 30 [StorableClass] 29 31 public sealed class HammingSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator { 30 32 protected override bool IsCommutative { get { return true; } } 31 33 34 [StorableConstructor] 32 35 private HammingSimilarityCalculator(bool deserializing) : base(deserializing) { } 33 36 private HammingSimilarityCalculator(HammingSimilarityCalculator original, Cloner cloner) : base(original, cloner) { } … … 40 43 public static double CalculateSimilarity(Permutation left, Permutation right) { 41 44 if (left == null || right == null) 42 throw new ArgumentException("Cannot calculate similarity because one o f the provided solutions or both arenull.");45 throw new ArgumentException("Cannot calculate similarity because one or both of the provided solutions is null."); 43 46 if (left.PermutationType != right.PermutationType) 44 throw new ArgumentException("Cannot calculate similarity because the provided solutions have different types.");47 throw new ArgumentException("Cannot calculate similarity because the provided solutions have different permutation types."); 45 48 if (left.Length != right.Length) 46 49 throw new ArgumentException("Cannot calculate similarity because the provided solutions have different lengths."); 47 if (object.ReferenceEquals(left, right)) return 1.0; 50 if (left.Length == 0) 51 throw new ArgumentException("Cannot calculate similarity because solutions are of length 0."); 52 if (ReferenceEquals(left, right)) return 1.0; 48 53 49 54 switch (left.PermutationType) {
Note: See TracChangeset
for help on using the changeset viewer.