autofit.BFGS#

class BFGS[source]#

Bases: AbstractBFGS

Abstract wrapper for the BFGS and L-BFGS scipy non-linear searches.

Parameters:
  • tol (Optional[float]) – Tolerance for termination.

  • disp (bool) – Set to True to print convergence messages.

  • maxiter (int) – Maximum number of iterations.

  • maxfun (int) – Maximum number of function evaluations.

  • clipper (Optional[AbstractClipper]) –

    Enforcement of prior support (see autofit.non_linear.clipper). Unlike the multi-start gradient searches, which project the parameters themselves after every update, this search declares the box to scipy and lets scipy enforce it — L-BFGS-B supports box bounds natively.

    Default ClipperNone, under which no bounds= is passed at all and behaviour is unchanged. Only bound-supporting methods accept a real clipper; see _bounds_from.

Methods

apply_test_mode

Reduce the search's budget for test mode: the generic reduction sets each attribute of the declared test_mode_budget (apply_test_mode of this module).

check_model

copy_with_paths

exact_fit

execution_settings

How this search executes its objective on analysis, resolved once: batching, eager or jitted execution, gradient use and the resolved gradient mode, plus the Fitness keyword arguments the backend builds its Fitness with (autofit.non_linear.search.preflight.ExecutionSettings).

finalize_result

The one ending of a fit that ran (or was bypassed in test mode): build the Result, run the analysis' save_results hooks, unfreeze the model and complete the fit (archive, then .completed).

finalize_search_internal

Archive search_internal (output_search_internal) when the search retains its internal state, otherwise remove the search_internal folder.

fit

Fit a model, M with some function f that takes instances of the class represented by model M and gives a score for their fitness: the search produces instances of the model by picking points in its N dimensional space.

fitness_overrides

The Fitness stores its evaluation history when the start point is plotted: the samples are then the whole optimisation path (raw_samples_from).

info_from

The samples_info entries of a run(ctx) search's internal state, the info its raw_samples_from puts on the RawSamples (autofit.non_linear.samples.adapter).

load_search_internal

The search's internal state as stored in its output folder, or None when its paths store nothing (NullPaths, DatabasePaths).

make_fitness

The Fitness this search evaluates its likelihood through, the one construction site every search shares.

optimise

Optimise one expectation-propagation factor with this search (autofit.graphical.expectation_propagation.SearchFactorOptimiser).

output_search_internal

Archive search_internal through the search's checkpointer and, once a fit has completed, discard its resume state (there is nothing left to resume).

perform_update

Perform an update of the non-linear search's model-fitting results.

perform_visualization

Perform visualization of the non-linear search's model-fitting results.

plot_latent_results

The search's plots of the model's latent parameters (the corner plot of a shear's magnitude and angle, say), by its posterior_kind; nothing for a search without one.

plot_results

The search's own plots of its samples, by its declared posterior_kind (autofit.non_linear.search.posterior_kind): the chain, weighted or point plotter.

plot_start_point

Visualize the starting point of the non-linear search, using an instance of the model at the starting point of the maximum likelihood estimator.

post_fit_output

Archives the output folder of a completed non-linear search into its .zip file (always), and then removes the folder so only the .zip is left (for supercomputers with a file-count limit) only when remove_files=True in the general.yaml output section; with remove_files=False both are kept.

pre_fit_output

Outputs attributes of fit before the non-linear search begins: the model composition (files/model.json), the search settings (files/search.json), the info dictionary (files/info.json), the analysis' save_attributes (e.g. files/data.json) and its visualize_before_fit / visualize_before_fit_combined visuals (quantities that do not change during the model-fit, e.g. the data).

progress

The run's progress for the status record (autofit.non_linear.status): the iterations taken of maxiter (scipy stops earlier once converged).

raw_samples_from

The LBFGS internal results as raw samples: the full history when the start point is plotted, otherwise the single optimum x.

result_via_completed_fit

Returns the result of the non-linear search of a completed model-fit.

run

Run scipy's minimize (the run(ctx) hook; see docs/design/run_ctx.md) and return its OptimizeResult.

samples_from

Loads the samples of a non-linear search from its output files.

samples_via_internal_from

The samples of the search, converted from its internal state.

start_points

The search's n initial points, drawn by its initializer, with the start-point plot made once, here, from the first of them.

start_resume_fit

Attributes

batched

checkpointer

where the backend's final state is stored when a fit completes, for Result.search_internal and samples_via_internal_from.

citation_keys

gradient

honours_gradient_mode

install_extra

invalid_value

jax_use

logger

Log 'msg % args' with severity 'DEBUG'.

method

name

objective_target

options

paths

posterior_kind

produces_evidence

quick_update_message

The one-line quick-update cadence logged at the start of every fit.

requires_fp64

resumable

resume_state

The file an interrupted run resumes from, for searches that genuinely resume (None otherwise).

retains_search_internal

always when the archive declares retain_after_completion (its results cannot be rebuilt without it), otherwise when the output.search_internal config is on.

should_plot_start_point

status

test_mode_budget

timer

The timer of the search (how long the search took, how much parallelization sped it up), or None when the paths keep no timer (has_timer: NullPaths, DatabasePaths).

upstream_url

warm_start

method = 'BFGS'#