autofit.DynestyDynamic#
- class autofit.DynestyDynamic(name: Optional[str] = None, path_prefix: Optional[str] = None, unique_tag: Optional[str] = None, prior_passer=None, iterations_per_update: Optional[int] = None, number_of_cores: Optional[int] = None, **kwargs)[source]#
Bases:
AbstractDynestyA Dynesty non-linear search, using a dynamically changing number of live points.
For a full description of Dynesty, checkout its GitHub and readthedocs webpages:
https://github.com/joshspeagle/dynesty https://dynesty.readthedocs.io/en/latest/index.html
- Parameters:
name – The name of the search, controlling the last folder results are output.
path_prefix – The path of folders prefixing the name folder where results are output.
unique_tag – 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.
prior_passer – Controls how priors are passed from the results of this NonLinearSearch to a subsequent non-linear search.
iterations_per_update – The number of iterations performed between every Dynesty back-up (via dumping the Dynesty instance as a pickle).
number_of_cores – The number of cores Emcee sampling is performed using a Python multiprocessing Pool instance. If 1, a pool instance is not created and the job runs in serial.
session – An SQLalchemy session instance so the results of the model-fit are written to an SQLite database.
Methods
check_modelcheck_poolconfig_dict_with_test_mode_settings_fromcopy_with_pathsexact_fitfitFit 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_sequentialFit multiple analyses contained within the analysis sequentially.
fitness_function_from_model_and_analysisiterations_fromReturns the next number of iterations that a dynesty call will use and the total number of iterations that have been performed so far.
live_points_init_fromBy default, dynesty live points are generated via the sampler's in-built initialization.
make_poolMake the pool instance used to parallelize a NonLinearSearch alongside a set of unique ids for every process in the pool.
make_sneaky_poolCreate a pool for multiprocessing that uses slight-of-hand to avoid copying the fitness function between processes multiple times.
optimisePerform optimisation for expectation propagation.
perform_updatePerform an update of the non-linear search's model-fitting results.
perform_visualizationPerform visualization of the non-linear search's model-fitting results.
plot_resultsread_uses_poolIf a Dynesty fit does not use a parallel pool, and is then resumed using one, this causes significant slow down.
remove_state_filesrun_samplerRun the Dynesty sampler, which could be either the static of dynamic sampler.
Returns an instance of the Dynesty dynamic sampler set up using the input variables of this class.
Create a Samples object from this non-linear search's output files on the hard-disk and model.
write_uses_poolIf a Dynesty fit does not use a parallel pool, and is then resumed using one, this causes significant slow down.
Attributes
checkpoint_fileThe path to the file used by dynesty for checkpointing.
config_dict_runA property that is only computed once per instance and then replaces itself with an ordinary attribute.
config_dict_searchA property that is only computed once per instance and then replaces itself with an ordinary attribute.
config_dict_settingsconfig_typeloggerLog 'msg % args' with severity 'DEBUG'.
namepathssamples_clstimertotal_live_points- samples_from(model)[source]#
Create a Samples object from this non-linear search’s output files on the hard-disk and model.
For Dynesty, all information that we need is available from the instance of the dynesty sampler.
- Parameters:
model – The model which generates instances for different points in parameter space. This maps the points from unit cube values to physical values via the priors.
- sampler_from(model: AbstractPriorModel, fitness_function, checkpoint_exists: bool, pool: Optional, queue_size: Optional[int])[source]#
Returns an instance of the Dynesty dynamic sampler set up using the input variables of this class.
If no existing dynesty sampler exist on hard-disk (located via a checkpoint_file) a new instance is created with which sampler is performed. If one does exist, the dynesty restore() function is used to create the instance of the sampler.
Dynesty samplers with a multiprocessing pool may be created by inputting a dynesty Pool object, however non pooled instances can also be created by passing pool=None and queue_size=None.
- Parameters:
model – The model which generates instances for different points in parameter space.
fitness_function – An instance of the fitness class used to evaluate the likelihood of each model.
pool – A dynesty Pool object which performs likelihood evaluations over multiple CPUs.
queue_size – The number of CPU’s over which multiprocessing is performed, determining how many samples are stored in the dynesty queue for samples.