tracts.core.optimize_bfgs#
- optimize_bfgs(p0, bins, Ls, data, nsamp, model_func, outofbounds_fun=None, cutoff=0, verbose=0, flush_delay=0.5, epsilon=0.001, gtol=1e-05, maxiter=None, full_output=True, func_args=None, fixed_params=None, ll_scale=1)#
Optimizes model parameters using the BFGS method. Best suited for cases where initial values are close to the optimum, converging to a single minimum, and for parameters spanning different scales.
- Parameters:
p0 – Initial parameters.
data – Spectrum with data.
model_function – Function to evaluate model spectrum. Should take arguments (params, pts).
out_of_bounds_fun (default: None) – A funtion evaluating to True if the current parameters are in a forbidden region.
cutoff (default: 0) – The number of bins to drop at the beginning of the array. This could be achieved with masks.
verbose (default: 0) – If greater than zero, print optimization status every
verbosesteps.flush_delay (default: 0.5) – Standard output will be flushed once every
flush_delayminutes. This is useful to avoid overloading I/O on clusters.epsilon (default: 1e-3) – Step-size to use for finite-difference derivatives.
gtol (default: 1e-5) – Convergence criterion for optimization. For more info, see
help(scipy.optimize.fmin_bfgs).maxiter (default: None) – Maximum iterations to run for.
full_output (default: True) – If True, return full outputs as described in
help(scipy.optimize.fmin_bfgs).func_args (default: None) – List of additional arguments to
model_func. It is assumed thatmodel_func’s first argument is an array of parameters to optimize.fixed_params (default: None) – (Not yet implemented). If not None, should be a list used to fix model parameters at particular values. For example, if the model parameters are
(nu1,nu2,T,m), thenfixed_params = [0.5,None,None,2]will holdnu1=0.5andm=2. The optimizer will only changeTandm. Note that the bounds lists must include all parameters. Optimization will fail if the fixed values lie outside their bounds. A full-lengthp0should be passed in; values corresponding to fixed parameters are ignored.ll_scale (default: 1) – The BFGS algorithm may fail if the initial log-likelihood is too large. Using
ll_scale > 1reduces the log-likelihood magnitude, helping the optimizer reach a reasonable region. Afterward, re-optimize withll_scale=1.