def process_conf(conf, kwargs): """ Missing items are set to default values. Example configuration, all items:: solver_0 = { 'name' : 'fmin_sd', 'kind' : 'opt.fmin_sd', 'i_max' : 10, 'eps_rd' : 1e-5, # Relative delta of objective function 'eps_of' : 1e-4, 'eps_ofg' : 1e-8, 'norm' : nm.Inf, 'ls' : True, # Linesearch. 'ls_method' : 'backtracking', # 'backtracking' or 'full' 'ls0' : 0.25, 'ls_red' : 0.5, 'ls_red_warp' : 0.1, 'ls_on' : 0.99999, 'ls_min' : 1e-5, 'check' : 0, 'delta' : 1e-6, 'output' : None, # 'itc' 'log' : {'text' : 'output/log.txt', 'plot' : 'output/log.png'}, 'yscales' : ['linear', 'log', 'log', 'linear'], } """ get = make_get_conf(conf, kwargs) common = OptimizationSolver.process_conf(conf) log = get_logging_conf(conf) log = Struct(name='log_conf', **log) is_any_log = (log.text is not None) or (log.plot is not None) return Struct(i_max=get('i_max', 10), eps_rd=get('eps_rd', 1e-5), eps_of=get('eps_of', 1e-4), eps_ofg=get('eps_ofg', 1e-8), norm=get('norm', nm.Inf), ls=get('ls', True), ls_method=get('ls_method', 'backtracking'), ls0=get('ls0', 0.25), ls_red=get('ls_red', 0.5), ls_red_warp=get('ls_red_warp', 0.1), ls_on=get('ls_on', 0.99999), ls_min=get('ls_min', 1e-5), check=get('check', 0), delta=get('delta', 1e-6), output=get('output', None), yscales=get('yscales', ['linear', 'log', 'log', 'linear']), log=log, is_any_log=is_any_log) + common
def process_conf(conf, kwargs): """ Missing items are set to default values. Example configuration, all items:: solver_0 = { 'name' : 'fmin_sd', 'kind' : 'opt.fmin_sd', 'i_max' : 10, 'eps_rd' : 1e-5, # Relative delta of objective function 'eps_of' : 1e-4, 'eps_ofg' : 1e-8, 'norm' : nm.Inf, 'ls' : True, # Linesearch. 'ls_method' : 'backtracking', # 'backtracking' or 'full' 'ls0' : 0.25, 'ls_red' : 0.5, 'ls_red_warp' : 0.1, 'ls_on' : 0.99999, 'ls_min' : 1e-5, 'check' : 0, 'delta' : 1e-6, 'output' : None, # 'itc' 'log' : {'text' : 'output/log.txt', 'plot' : 'output/log.png'}, 'yscales' : ['linear', 'log', 'log', 'linear'], } """ get = make_get_conf(conf, kwargs) common = OptimizationSolver.process_conf(conf) log = get_logging_conf(conf) log = Struct(name='log_conf', **log) is_any_log = (log.text is not None) or (log.plot is not None) return Struct(i_max=get('i_max', 10), eps_rd=get('eps_rd', 1e-5), eps_of=get('eps_of', 1e-4), eps_ofg=get('eps_ofg', 1e-8), norm=get('norm', nm.Inf), ls=get('ls', True), ls_method=get('ls_method', 'backtracking'), ls0=get('ls0', 0.25), ls_red=get('ls_red', 0.5), ls_red_warp=get('ls_red_warp', 0.1), ls_on=get('ls_on', 0.99999), ls_min=get('ls_min', 1e-5), check=get('check', 0), delta=get('delta', 1e-6), output=get('output', None), yscales=get('yscales', ['linear', 'log', 'log', 'linear']), log=log, is_any_log=is_any_log) + common
def process_conf(conf): """ Missing items are set to default values. Example configuration, all items: solver_0 = { 'name' : 'fmin_sd', 'kind' : 'opt.fmin_sd', 'i_max' : 10, 'eps_rd' : 1e-5, # Relative delta of objective function 'eps_of' : 1e-4, 'eps_ofg' : 1e-8, 'norm' : nm.Inf, 'ls' : True, # Linesearch. 'ls_method' : 'backtracking', # 'backtracking' or 'full' 'ls0' : 0.25, 'ls_red' : 0.5, 'ls_red_warp' : 0.1, 'ls_on' : 0.99999, 'ls_min' : 1e-5, 'check' : 0, 'delta' : 1e-6, 'output' : None, # 'itc' 'log' : True, 'yscales' : ['linear', 'log', 'log'], } """ get = conf.get_default_attr i_max = get("i_max", 10) eps_rd = get("eps_rd", 1e-5) eps_of = get("eps_of", 1e-4) eps_ofg = get("eps_ofg", 1e-8) norm = get("norm", nm.Inf) ls = get("ls", True) ls_method = get("ls_method", "backtracking") ls0 = get("ls0", 0.25) ls_red = get("ls_red", 0.5) ls_red_warp = get("ls_red_warp", 0.1) ls_on = get("ls_on", 0.99999) ls_min = get("ls_min", 1e-5) check = get("check", 0) delta = get("delta", 1e-6) output = get("output", None) log = get("log", True) yscales = get("yscales", ["linear", "log", "log"]) common = OptimizationSolver.process_conf(conf) return Struct(**locals()) + common
def process_conf(conf, kwargs): """ Missing items are left to SciPy defaults. Unused options are ignored. Besides 'i_max', use option names according to scipy.optimize function arguments. The 'i_max' translates either to 'maxiter' or 'maxfun' as available. Example configuration:: solver_1 = { 'name' : 'fmin', 'kind' : 'nls.scipy_fmin_like', 'method' : 'bfgs', 'i_max' : 10, 'verbose' : True, 'gtol' : 1e-7 } """ get = make_get_conf(conf, kwargs) common = OptimizationSolver.process_conf(conf) opts = Struct(method=get('method', 'fmin'), i_max=get('i_max', 10), verbose=get('verbose', False)) + common other = {} keys = opts.to_dict().keys() for key, val in conf.to_dict().iteritems(): if key not in keys: other[key] = val return opts + Struct(**other)
def process_conf(conf, kwargs): """ Missing items are left to SciPy defaults. Unused options are ignored. Besides 'i_max', use option names according to scipy.optimize function arguments. The 'i_max' translates either to 'maxiter' or 'maxfun' as available. Example configuration:: solver_1 = { 'name' : 'fmin', 'kind' : 'nls.scipy_fmin_like', 'method' : 'bfgs', 'i_max' : 10, 'verbose' : True, 'gtol' : 1e-7 } """ get = make_get_conf(conf, kwargs) common = OptimizationSolver.process_conf(conf) opts = Struct(method=get('method', 'fmin'), i_max=get('i_max', 10), verbose=get('verbose', False)) + common other = {} keys = opts.to_dict().keys() for key, val in conf.to_dict().iteritems(): if key not in keys: other[key] = val return opts + Struct(**other)