From 2685e0cff0505f040355f113b18bc198643e2c52 Mon Sep 17 00:00:00 2001 From: Will Handley Date: Sat, 5 Mar 2022 16:41:23 +0000 Subject: [PATCH] Polychord 1.20.0 (#232) * Updated for PolyChord 1.20.0 * added missing nfail * Updated version number * Fixed flake8 --- cobaya/samplers/polychord/polychord.py | 18 +++++++++--------- cobaya/samplers/polychord/polychord.yaml | 19 ++++++++++++++++++- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/cobaya/samplers/polychord/polychord.py b/cobaya/samplers/polychord/polychord.py index 4b06c603f..af386ae02 100644 --- a/cobaya/samplers/polychord/polychord.py +++ b/cobaya/samplers/polychord/polychord.py @@ -35,7 +35,7 @@ class polychord(Sampler): """ # Name of the PolyChord repo and version to download _pc_repo_name = "PolyChord/PolyChordLite" - _pc_repo_version = "1.18.2" + _pc_repo_version = "1.20.0" _base_dir_suffix = "polychord_raw" _clusters_dir = "clusters" _at_resume_prefer_old = Sampler._at_resume_prefer_old + ["blocking"] @@ -84,7 +84,7 @@ def initialize(self): if getattr(self, p) is not None: setattr(self, p, NumberWithUnits( getattr(self, p), "d", scale=self.nDims, dtype=int).value) - self._quants_nlive_units = ["nprior"] + self._quants_nlive_units = ["nprior", "nfail"] for p in self._quants_nlive_units: if getattr(self, p) is not None: setattr(self, p, NumberWithUnits( @@ -138,13 +138,13 @@ def initialize(self): int(o * read_dnumber(self.num_repeats, dim_block)) for o, dim_block in zip(oversampling_factors, self.grade_dims)] # Assign settings - pc_args = ["nlive", "num_repeats", "nprior", "do_clustering", - "precision_criterion", "max_ndead", "boost_posterior", "feedback", - "logzero", "posteriors", "equals", "compression_factor", - "cluster_posteriors", "write_resume", "read_resume", "write_stats", - "write_live", "write_dead", "base_dir", "grade_frac", "grade_dims", - "feedback", "read_resume", "base_dir", "file_root", "grade_frac", - "grade_dims"] + pc_args = ["nlive", "num_repeats", "nprior", "nfail", "do_clustering", + "feedback", "precision_criterion", "logzero", + "max_ndead", "boost_posterior", "posteriors", "equals", + "cluster_posteriors", "write_resume", "read_resume", + "write_stats", "write_live", "write_dead", "write_prior", + "maximise", "compression_factor", "synchronous", "base_dir", + "file_root", "seed", "grade_dims", "grade_frac", "nlives"] # As stated above, num_repeats is ignored, so let's not pass it pc_args.pop(pc_args.index("num_repeats")) settings: Any = load_module('pypolychord.settings', path=self._poly_build_path, diff --git a/cobaya/samplers/polychord/polychord.yaml b/cobaya/samplers/polychord/polychord.yaml index 24e586bc5..e4d2b747b 100644 --- a/cobaya/samplers/polychord/polychord.yaml +++ b/cobaya/samplers/polychord/polychord.yaml @@ -16,6 +16,8 @@ num_repeats: 2d # Number of prior samples drawn before starting compression # Can be in units of nlive (but not dimension) as Xnlive nprior: 10nlive +# Number of failed spawns before stopping nested sampling. +nfail : nlive # Whether to check for and explore multi-modality on the posterior do_clustering: True # Stopping criterion: fraction of the total evidence contained in the live points @@ -35,6 +37,20 @@ logzero: -1e30 boost_posterior: 0 # increase up to `num_repeats` # Verbosity during the sampling process. Set to one of [0,1,2,3] feedback: # default: Same as global `verbosity` +# Parallelise with synchronous workers, rather than asynchronous ones. +# This can be set to False if the likelihood speed is known to be +# approximately constant across the parameter space. Synchronous +# parallelisation is less effective than asynchronous by a factor ~O(1) +# for large parallelisation. +synchronous : True +# Variable number of live points option. This dictionary is a mapping +# between loglike contours and nlive. +# You should still set nlive to be a sensible number, as this indicates +# how often to update the clustering, and to define the default value. +nlives : {} +# Perform maximisation at the end of the run to find the maximum +# likelihood point and value +maximise : False # Exploiting speed hierarchy # -------------------------- # whether to measure actual speeds for your machine/threading at starting rather @@ -57,7 +73,7 @@ blocking: confidence_for_unbounded: 0.9999995 # 5 sigmas of the prior # Seeding runs # ------------ -seed: # postitive integer +seed: # positive integer # Raw output of PolyChord (no need to change them, normally) # ---------------------------------------------------------- file_root: @@ -69,3 +85,4 @@ read_resume: True write_stats: True write_live: True write_dead: True +write_prior: True