Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/13/12 09:01:31 (12 years ago)
Author:
mkommend
Message:

#1871: Added quality checks in all SingleObjectiveSelectors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Selection/3.3/TournamentSelector.cs

    r7259 r7995  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    5758      IRandom random = RandomParameter.ActualValue;
    5859      bool maximization = MaximizationParameter.ActualValue.Value;
    59       List<double> qualities = QualityParameter.ActualValue.Select(x => x.Value).ToList();
     60      List<double> qualities = QualityParameter.ActualValue.Where(x => IsValidQuality(x.Value)).Select(x => x.Value).ToList();
    6061      int groupSize = GroupSizeParameter.ActualValue.Value;
    6162      IScope[] selected = new IScope[count];
     63
     64      //check if list with indexes is as long as the original scope list
     65      //otherwise invalid quality values were filtered
     66      if (qualities.Count != scopes.Count) {
     67        throw new ArgumentException("The scopes contain invalid quality values (either infinity or double.NaN) on which the selector cannot operate.");
     68      }
    6269
    6370      for (int i = 0; i < count; i++) {
Note: See TracChangeset for help on using the changeset viewer.