def get_bounds_x0_eps(tuning_options):
    """compute bounds, x0 (the initial guess), and eps"""
    values = tuning_options.tune_params.values()

    if tuning_options.scaling:
        #bounds = [(0, 1) for _ in values]
        #x0 = [0.5 for _ in bounds]
        eps = numpy.amin([1.0/len(v) for v in values])

        #reducing interval from [0, 1] to [0, eps*len(v)]
        bounds = [(0, eps*len(v)) for v in values]
        x0 = [0.5*eps*len(v) for v in values]
    else:
        bounds = get_bounds(tuning_options.tune_params)
        x0 = [(min_v+max_v)/2.0 for (min_v, max_v) in bounds]
        eps = 1e9
        for v_list in values:
            vals = numpy.sort(v_list)
            eps = min(eps, numpy.amin(numpy.gradient(vals)))

    tuning_options["eps"] = eps
    logging.debug('get_bounds_x0_eps called')
    logging.debug('bounds ' + str(bounds))
    logging.debug('x0 ' + str(x0))
    logging.debug('eps ' + str(eps))

    return bounds, x0, eps
def get_bounds_x0_eps ( tuning_options ) : values = tuning_options . tune_params . values ( ) if tuning_options . scaling : eps = numpy . amin ( [ 1.0 / len ( v ) for v in values ] ) bounds = [ ( 0 , eps * len ( v ) ) for v in values ] x0 = [ 0.5 * eps * len ( v ) for v in values ] else : bounds = get_bounds ( tuning_options . tune_params ) x0 = [ ( min_v + max_v ) / 2.0 for ( min_v , max_v ) in bounds ] eps = 1e9 for v_list in values : vals = numpy . sort ( v_list ) eps = min ( eps , numpy . amin ( numpy . gradient ( vals ) ) ) tuning_options [ "eps" ] = eps logging . debug ( 'get_bounds_x0_eps called' ) logging . debug ( 'bounds ' + str ( bounds ) ) logging . debug ( 'x0 ' + str ( x0 ) ) logging . debug ( 'eps ' + str ( eps ) ) return bounds , x0 , eps
compute bounds, x0 (the initial guess), and eps