Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/12/17 21:02:01 (7 years ago)
Author:
abeham
Message:

#2666, #2706, #2730, #2736: merged revisions 14412, 14475, 14476, 14659, 14660, 14663, 14779, 14780, 14912, 15050, 15067, 15069, 15079, 15162, 15166, 15172, 15173 to stable

Location:
stable
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Encodings.PermutationEncoding

  • stable/HeuristicLab.Encodings.PermutationEncoding/3.3/SimilarityCalculators/HammingSimilarityCalculator.cs

    r14659 r15217  
    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.