Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/26/17 23:13:15 (7 years ago)
Author:
abeham
Message:

#2730:

  • Unified implementation of all equality comparers and similarity calculators in BinaryVector, IntegerVector, RealVector, Permutation, and LinearLinkage encodings
  • Added Euclidean distance-based similarity calculators for real and integer vectors using a transformation function with scaling parameter
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/SimilarityCalculators/HammingSimilarityCalculator.cs

    r14659 r15067  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Optimization.Operators;
     26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2627
    2728namespace HeuristicLab.Encodings.PermutationEncoding {
    2829  [Item("Hamming Similarity Calculator for Permutation", "An operator that performs similarity calculation between two permutation-encoded solutions.")]
     30  [StorableClass]
    2931  public sealed class HammingSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
    3032    protected override bool IsCommutative { get { return true; } }
    3133
     34    [StorableConstructor]
    3235    private HammingSimilarityCalculator(bool deserializing) : base(deserializing) { }
    3336    private HammingSimilarityCalculator(HammingSimilarityCalculator original, Cloner cloner) : base(original, cloner) { }
     
    4043    public static double CalculateSimilarity(Permutation left, Permutation right) {
    4144      if (left == null || right == null)
    42         throw new ArgumentException("Cannot calculate similarity because one of the provided solutions or both are null.");
     45        throw new ArgumentException("Cannot calculate similarity because one or both of the provided solutions is null.");
    4346      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.");
    4548      if (left.Length != right.Length)
    4649        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;
    4853
    4954      switch (left.PermutationType) {
Note: See TracChangeset for help on using the changeset viewer.