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

    r7259 r7995  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    5455
    5556      // create a list for each scope that contains the scope's index in the original scope list and its lots
    56       var temp = qualities.Select((x, index) => new { index, x.Value });
     57      var temp = qualities.Where(x => IsValidQuality(x.Value)).Select((x, index) => new { index, x.Value });
    5758      if (maximization)
    5859        temp = temp.OrderBy(x => x.Value);
     
    6061        temp = temp.OrderByDescending(x => x.Value);
    6162      var list = temp.Select((x, index) => new { x.index, lots = index + 1 }).ToList();
     63
     64      //check if list with indexes is as long as the original scope list
     65      //otherwise invalid quality values were filtered
     66      if (list.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      int lotSum = list.Count * (list.Count + 1) / 2;
Note: See TracChangeset for help on using the changeset viewer.