made `get_optimal_range`

Finds optimal max and min value useing an optimality criterion.