Changeset 8622 for branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3/SimilarityCalculator/QualitySimilarityCalculator.cs
- Timestamp:
- 09/10/12 17:10:27 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3/SimilarityCalculator/QualitySimilarityCalculator.cs
r8406 r8622 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 43 44 44 45 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); 46 50 } 47 51
Note: See TracChangeset
for help on using the changeset viewer.