Evolution/Evolution/Scaling/LinearRankScaling.cs
/// <summary>
/// Applies the linear rank scaling function to the list of fitneses
/// The i-th element of the returned list matches with the i-th element of the input list
/// </summary>
/// <param name="originalFitneses"></param>
/// <returns></returns>
Applies the linear rank scaling function to the list of fitneses
The i-th element of the returned list matches with the i-th element of the input list
Applies the linear rank scaling function to the list of fitneses The i - th element of the returned list matches with the i - th element of the input list
public List<double> Scale(List<double> originalFitneses)
        {
            List<double> sorted = originalFitneses.ToList();
            sorted.Sort();
            int count = originalFitneses.Count;
            return
                originalFitneses.Select(o => sorted.BinarySearch(o))
                    .Select(pos => 2 - SelectionPresure + 2*(SelectionPresure - 1)*(pos - 1)/(count - 1))
                    .ToList();
        }
public List < double > Scale ( List < double > originalFitneses ) { List < double > sorted = originalFitneses . ToList ( ) ; sorted . Sort ( ) ; int count = originalFitneses . Count ; return originalFitneses . Select ( o => sorted . BinarySearch ( o ) ) . Select ( pos => 2 - SelectionPresure + 2 * ( SelectionPresure - 1 ) * ( pos - 1 ) / ( count - 1 ) ) . ToList ( ) ; }
Applies the linear rank scaling function to the list of fitneses
The i-th element of the returned list matches with the i-th element of the input list
Applies the linear rank scaling function to the list of fitneses The i - th element of the returned list matches with the i - th element of the input list
None
originalFitneses
List<double>
None