Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8988


Ignore:
Timestamp:
12/03/12 13:32:42 (12 years ago)
Author:
jkarder
Message:

#1331: Equals method in SingleObjectiveSolutionSimilarityCalculator now only performs structural comparison if solutions have almost the same quality

Location:
trunk/sources/HeuristicLab.Optimization.Operators/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Operators/3.3/SingleObjectiveSolutionSimilarityCalculator.cs

    r8334 r8988  
    4848    protected SingleObjectiveSolutionSimilarityCalculator() : base() { }
    4949
     50    public override bool Equals(IScope x, IScope y) {
     51      if (object.ReferenceEquals(x, y)) return true;
     52      if (x == null || y == null) return false;
     53      double q1 = ((DoubleValue)x.Variables[QualityVariableName].Value).Value;
     54      double q2 = ((DoubleValue)y.Variables[QualityVariableName].Value).Value;
     55      return q1.IsAlmost(q2) && CalculateSolutionSimilarity(x, y).IsAlmost(1.0);
     56    }
     57
    5058    public override int GetHashCode(IScope scope) {
    5159      return ((DoubleValue)scope.Variables[QualityVariableName].Value).Value.GetHashCode();
  • trunk/sources/HeuristicLab.Optimization.Operators/3.3/SolutionSimilarityCalculator.cs

    r8413 r8988  
    8080    }
    8181
    82     public bool Equals(IScope x, IScope y) {
    83       if (object.ReferenceEquals(x, y)) return true;
    84       if (x == null || y == null) return false;
    85       return CalculateSolutionSimilarity(x, y) == 1.0;
    86     }
    87 
    8882    public abstract double CalculateSolutionSimilarity(IScope leftSolution, IScope rightSolution);
     83    public abstract bool Equals(IScope x, IScope y);
    8984    public abstract int GetHashCode(IScope obj);
    9085  }
Note: See TracChangeset for help on using the changeset viewer.