from typing import Union


def get_scaled_ranking(rank: int, population_size: int, ranking_bias: Union[float, int]) -> Union[float, int]:
    """
    Calculates scaled value of ranking.

    Algorithm used is proposed by Eiben, A.E., Smith, James E in
    'Introduction to Evolutionary Computing. Second edition.' (page 82).
    Note: Division by 'population_size' was skipped to reduce code complexity.

    :param rank: Rank of the solution in population (0: the worst, 1: second worst, ..., population_size-1: the best).
    :param population_size: Size of the population for which ranking scaling is performed.
    :param ranking_bias: Bias that represents selection pressure (the higher the value the higher the pressure).
        When ranking_bias == 1, then the function acts the same effect as uniform selection.
        When ranking_bias == 2, then the function acts like classic ranking selection.
        Expected value: 1 < ranking_bias <= 2

    :return: Scaled value of the solution ranking.
    """
    return 2 - ranking_bias + (2 * rank * (ranking_bias - 1) / (population_size - 1))