Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/10/17 21:42:31 (8 years ago)
Author:
abeham
Message:

#2730: Added similarity calculators and equality comparers

Location:
trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/SimilarityCalculators
Files:
1 added
1 copied

Legend:

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

    r14646 r14659  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Encodings.BinaryVectorEncoding {
    29   [Item("Hamming Similarity Calculator for BinaryVector", "Calculates the solution similarity based on the Hamming distance between two binary vectors.")]
     28namespace HeuristicLab.Encodings.IntegerVectorEncoding {
     29  [Item("Hamming Similarity Calculator for IntegerVector", "Calculates the solution similarity based on the Hamming distance between two integer vectors.")]
    3030  [StorableClass]
    3131  public sealed class HammingSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
     
    4343    }
    4444
    45     public static double CalculateSimilarity(BinaryVector left, BinaryVector right) {
     45    public static double CalculateSimilarity(IntegerVector left, IntegerVector right) {
    4646      if (left == null || right == null)
    4747        throw new ArgumentException("Cannot calculate similarity because one or both of the provided scopes is null.");
     
    5858
    5959    public override double CalculateSolutionSimilarity(IScope leftSolution, IScope rightSolution) {
    60       var left = leftSolution.Variables[SolutionVariableName].Value as BinaryVector;
    61       var right = rightSolution.Variables[SolutionVariableName].Value as BinaryVector;
     60      var left = leftSolution.Variables[SolutionVariableName].Value as IntegerVector;
     61      var right = rightSolution.Variables[SolutionVariableName].Value as IntegerVector;
    6262
    6363      return CalculateSimilarity(left, right);
Note: See TracChangeset for help on using the changeset viewer.