autofit.PySwarmsGlobal#

class PySwarmsGlobal[source]#

Bases: AbstractPySwarms

A PySwarms Particle Swarm Optimizer global non-linear search.

For a full description of PySwarms, checkout its Github and readthedocs webpages:

https://github.com/ljvmiranda921/pyswarms

https://pyswarms.readthedocs.io/en/latest/index.html

Parameters
  • name (Optional[str]) – The name of the search, controlling the last folder results are output.

  • path_prefix (Optional[str]) – The path of folders prefixing the name folder where results are output.

  • unique_tag (Optional[str]) – The name of a unique tag for this model-fit, which will be given a unique entry in the sqlite database and also acts as the folder after the path prefix and before the search name.

  • initializer (Optional[AbstractInitializer]) – Generates the initialize samples of non-linear parameter space (see autofit.non_linear.initializer).

  • number_of_cores (Optional[int]) – The number of cores sampling is performed using a Python multiprocessing Pool instance.

Methods

check_model

config_dict_with_test_mode_settings_from

copy_with_paths

exact_fit

rtype

Tuple[MeanField, Status]

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.

fit_sequential

Fit multiple analyses contained within the analysis sequentially.

make_pool

Make the pool instance used to parallelize a NonLinearSearch alongside a set of unique ids for every process in the pool.

make_sneakier_pool

rtype

SneakierPool

make_sneaky_pool

Create a pool for multiprocessing that uses slight-of-hand to avoid copying the fitness function between processes multiple times.

optimise

Perform optimisation for expectation propagation.

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_results

post_fit_output

Cleans up the output folderds after a completed non-linear search.

pre_fit_output

Outputs attributes of fit before the non-linear search begins.

remove_state_files

result_via_completed_fit

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

sampler_from

Get the static Dynesty sampler which performs the non-linear search, passing it all associated input Dynesty variables.

samples_from

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

samples_via_csv_from

Returns a Samples object from the samples.csv and samples_info.json files.

samples_via_internal_from

Returns a Samples object from the pyswarms internal results.

start_resume_fit

Start a non-linear search from scratch, or resumes one which was previously terminated mid-way through.

Attributes

config_dict_run

A property that is only computed once per instance and then replaces itself with an ordinary attribute.

config_dict_search

A property that is only computed once per instance and then replaces itself with an ordinary attribute.

config_dict_settings

rtype

Dict

config_type

logger

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

name

paths

rtype

Optional[AbstractPaths]

samples_cls

timer

using_mpi

Whether the search is being performing using MPI for parallelisation or not.

sampler_from(model, fitness, bounds, init_pos)[source]#

Get the static Dynesty sampler which performs the non-linear search, passing it all associated input Dynesty variables.