Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12129


Ignore:
Timestamp:
03/04/15 16:36:40 (10 years ago)
Author:
bburlacu
Message:

#2332: SolutionSimilarityCalculator: throw exception in the CheckQualityEquality method if the double arrays are not of the same length, simplify equality check for double arrays.

File:
1 edited

Legend:

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

    r12126 r12129  
    146146      var da2 = q2 as DoubleArray;
    147147
    148       if (da1 != null && da2 != null)
    149         return !da1.Zip(da2, Tuple.Create).Any(x => !x.Item1.IsAlmost(x.Item2));
     148      if (da1 != null && da2 != null) {
     149        if (da1.Length != da2.Length)
     150          throw new ArgumentException("The quality arrays must have the same length.");
     151
     152        for (int i = 0; i < da1.Length; ++i) {
     153          if (!da1[i].IsAlmost(da2[i]))
     154            return false;
     155        }
     156
     157        return true;
     158      }
    150159
    151160      throw new ArgumentException("Could not determine quality equality.");
Note: See TracChangeset for help on using the changeset viewer.