def map_value(val, min_in=0, max_in=100, min_out=0, max_out=100):
    """
    Maps a value from an allowed range to a other range
    :type val: float
    :type min_in: float
    :type max_in: float
    :type min_out: float
    :type max_out:float
    :param val: the value to be mapped
    :param min_in: the minimal input value
    :param max_in: the maximal input value
    :param min_out: the minimal output value
    :param max_out: the maximal output value
    :return: :raise Exception: if maximum values are smaller or equal to minimal values
    or if the input value is not in the allowed range
    """
    if max_in == min_in:
        return (max_out - min_out) / 2
    if max_in < min_in:
        raise Exception('The max input value must be larger than the min input value. min={min}; max={max}'
                        .format(min=max_in, max=max_in))
    if max_out < min_out:
        raise Exception('The max output value must be larger than the min output value. min={min}; max={max}'
                        .format(min=max_in, max=max_in))
    if not min_in <= val <= max_in:
        raise Exception('The input value is not between the minimal and the maximal input.'
                        ' min={min}; val={val}; max={max}'.format(min=min_in, val=val, max=max_in))
    return min_out + (val - min_in) * (max_out - min_out) / (max_in - min_in)