Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/10/12 17:10:27 (12 years ago)
Author:
jkarder
Message:

#1247:

  • fixed some bugs
  • minor code improvements
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3/SimilarityCalculator/QualitySimilarityCalculator.cs

    r8406 r8622  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    4344
    4445    public static double CalculateSimilarity(IScope left, IScope right, string qualityVariableName) {
    45       return ((DoubleValue)left.Variables[qualityVariableName].Value).Value == ((DoubleValue)right.Variables[qualityVariableName].Value).Value ? 1.0 : 0.0;
     46      double leftQuality = ((DoubleValue)left.Variables[qualityVariableName].Value).Value;
     47      double rightQuality = ((DoubleValue)right.Variables[qualityVariableName].Value).Value;
     48      double delta = leftQuality.IsAlmost(rightQuality) ? 0.0 : Math.Abs(leftQuality - rightQuality);
     49      return 1.0 - delta / Math.Max(leftQuality, rightQuality);
    4650    }
    4751
Note: See TracChangeset for help on using the changeset viewer.