Nested Sampling

class nested_sampling.NestedSampling(replicas, mc_walker, stepsize=0.1, nproc=1, verbose=True, max_stepsize=0.5, iprint=1, cpfile=None, cpfreq=10000, cpstart=False, dispatcher_URI=None, serializer='pickle')[source]

Bases: object

the main class for implementing nested sampling

Parameters :

replicas : list

list of objects of type Replica

mc_walker: callable

class of type MonteCarloWalker or similar. It performs a Monte Carlo walk to sample phase space. It should return an object with attributes x, energy, nsteps, naccept, etc.

nproc : int

number of processors to use for parallel nested sampling

verbose : bool

print status messages

iprint : int

if verbose is true, then status messages will be printed every iprint iterations

cpfile: str

checkpoint file name

cpfreq: int

checkpointing frequency in number of steps

cpstart: bool

start calculation from checkpoint binary file

dispatcher_URI: str

address (URI) of dispatcher (required for distributed parallelisation)

serializer: str

choice of serializer

Attributes

———-

nreplicas : integer

number of replicas

stepsize : float

starting stepsize. It is then adapted to meet some target MC acceptance by default 0.5

max_energies : list

array of stored energies (at each step the highest energy configuration is stored and replaced by a valid configuration)

store_all_energies: bool

store the energy of all the nproc replicas replaced when running NS in parallel

Methods

add_new_replicas(rlist) add new replicas the the list and keep the list sorted
adjust_step_size(results) Adjust the stepsize to keep the acceptance ratio at a good value ..
collectresults()
do_monte_carlo_chain(configs, Emax) from an initial configuration do a monte carlo walk
get_starting_configurations(Emax) return nproc replicas to be used as starting configurations
get_starting_configurations_from_replicas() use existing replicas as starting configurations
one_iteration() do one iteration of the nested sampling algorithm
pop_replicas() remove the replicas with the largest energies and store them in the max_energies array
sort_replicas() sorts the replicas in decreasing order of energy
add_new_replicas(rlist)[source]

add new replicas the the list and keep the list sorted

adjust_step_size(results)[source]

Adjust the stepsize to keep the acceptance ratio at a good value

Notes

when ratio naccept/nsteps < target_ratio then decrease step size by a correction factor f (new-step-size = old-step-size*f, where 0<f<1), else if naccept/nsteps > target_ratio, then increases the step size (new-step-size = old-step-size/f, where 0<f<1), although this is increased with an upper bound: max_stepsize.

collectresults()[source]
do_monte_carlo_chain(configs, Emax)[source]

from an initial configuration do a monte carlo walk

the steps will be accepted subject only to a maximum energy criterion. At the end of the walk, update stepize to meet the target_ratio.

get_starting_configurations(Emax)[source]

return nproc replicas to be used as starting configurations

get_starting_configurations_from_replicas()[source]

use existing replicas as starting configurations

one_iteration()[source]

do one iteration of the nested sampling algorithm

pop_replicas()[source]

remove the replicas with the largest energies and store them in the max_energies array

sort_replicas()[source]

sorts the replicas in decreasing order of energy

class nested_sampling.Replica(x, energy, niter=0, from_random=True)[source]

Bases: object

object to represent the state of a system

also attached is some additional information

Parameters :

x : array

the structural coordinates

energy : float

the energy of the structure

niter : int

the number of MC iterations this structure has already been through

from_random : bool

if true, this replica started life as a completely random configuration

Methods

copy() return a complete copy of self
copy()[source]

return a complete copy of self

class nested_sampling.Forwarditem(replica, Emax, stepsize, seed, itemId)[source]

Bases: nested_sampling._nested_sampling.Replica

wrapper to Replica for distributed parallel calculations

Methods

copy() return a complete copy of self

Nested Sampling Runner

nested_sampling.run_nested_sampling(ns, label='ns_out', etol=0.01, maxiter=None, iprint_replicas=1000)[source]

Table Of Contents

Previous topic

Getting started