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/WorstSelector.cs

    r7259 r7995  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    5152
    5253      // create a list for each scope that contains the scope's index in the original scope list
    53       var temp = qualities.Select((x, index) => new { index, x.Value });
     54      var temp = qualities.Where(x => IsValidQuality(x.Value)).Select((x, index) => new { index, x.Value });
    5455      if (maximization)
    5556        temp = temp.OrderBy(x => x.Value);
     
    5758        temp = temp.OrderByDescending(x => x.Value);
    5859      var list = temp.ToList();
     60
     61      //check if list with indexes is as long as the original scope list
     62      //otherwise invalid quality values were filtered
     63      if (list.Count != scopes.Count) {
     64        throw new ArgumentException("The scopes contain invalid quality values (either infinity or double.NaN) on which the selector cannot operate.");
     65      }
    5966
    6067      if (copy) {
Note: See TracChangeset for help on using the changeset viewer.