rexfw.remasters package

Module contents

Master classes implementing exchange criteria for RE and derived algorithms

class rexfw.remasters.ExchangeMaster(name, replica_names, swap_params, sampling_statistics, swap_statistics, comm, swap_list_generator=None)[source]

Bases: object

_calculate_acceptance(works)[source]

Determines whether swaps are being accepted or rejected

Parameters:works (numpy.ndarray) – array of works with shape (number of swaps, 2), the 2nd dimension are the works for forward- and backward trajectory
Returns:array of Boolean (0 / 1) values indicating whether swaps have been accepted (1) or rejected (0)
Return type:numpy.ndarray
_calculate_swap_list(step)[source]

Creates the swap list for a given step

Parameters:step (int) – the sampling step for which to create the swap list
Returns:a list of list in which each list element contains two replica names involved in a swap an an ExchangeParams object
Return type:list
_get_no_ex_replicas(swap_list)[source]

For a given swap list, calculate which replicas do NOT perform swaps and thus will continue normal sampling.

Parameters:swap_list (list) – a list of list in which each list element contains two replica names involved in a swap an an ExchangeParams object
Returns:a list of replica names
Return type:list
_perform_exchanges(swap_list)[source]

Attempts exchanges defined in swap_list.

Parameters:swap_list (list) – a list of list in which each list element contains two replica names involved in a swap an an ExchangeParams object
Returns:three lists: acceptance statuses (0 / 1), works and heats
Return type:list
_receive_and_update_stats(replicas)[source]

Receive sampling statistics from replicas and update statistics object

Parameters:replicas (list) – replica names
_receive_works(swap_list)[source]

Receives works from all swapping replicas.

Parameters:swap_list (list) – a list of list in which each list element contains two replica names involved in a swap an an ExchangeParams object
Returns:lists of works and heats
Return type:list
_send_accept_exchange_request(dest)[source]

Sends a request to accept a proposed swap state.

Parameters:dest (str) – name of destination replica
_send_dump_samples_request(smin, smax, offset, dump_step)[source]

Send requests to write samples to files

Parameters:
  • smin (int) – first sample index
  • smax (int) – last sample index
  • offset (int) – offset which to add to sample index
  • dump_step (int) – sub-sampling step; write only every dump_step-th sample
_send_get_state_and_energy_request(replica1, replica2)[source]

Sends a request to replica1 to make it send a request to replica2 ordering it (replica2) to send its (replica2) state and and energy to replica1. Receives a None from replica1 and replica2; sent once buffered state / energies have been set. This is to sync everything and really hacky

Parameters:
  • replica1 (str) – name of 1st replica involved in swap
  • replica2 (str) – name of 2nd replica involved in swap
_send_propose_request(replica1, replica2, params)[source]

Sends a request to replica1 telling it to propose a state for replica2 using information in params (an ExchangeParams object defined in )

Parameters:
  • replica1 (str) – name of 1st replica involved in swap
  • replica2 (str) – name of 2nd replica involved in swap
  • params (ExchangeParams) – an ExchangeParams object holding information required to perform the swap
_send_reject_exchange_request(dest)[source]

Sends a request to reject a proposed swap state.

Parameters:dest (str) – name of destination replica
_send_sample_requests(replicas)[source]

Send requests to replicas to sample from their respective PDFs

Parameters:replicas (list) – replicas which are supposed to perform a sampling step
_send_send_stats_requests(replicas)[source]

Send requests to replicas to send sampling statistics to this master object.

Parameters:replica – replica names
_trigger_exchanges(swap_list, acc)[source]

Sends accept / reject exchange requests to all involved replicas

Parameters:
  • swap_list (list) – a list of list in which each list element contains two replica names involved in a swap an an ExchangeParams object
  • acc (numpy.ndarray) – array containing boolean (0 / 1) values indicating which swaps have been accepted and which haven’t
_trigger_proposal_calculation(swap_list)[source]

Makes all involved replicas propose states.

Parameters:swap_list (list) – a list of list in which each list element contains two replica names involved in a swap an an ExchangeParams object
_update_sampling_statistics(which_replicas=None)[source]

Update sampling statistics

Params which_replicas:
 replicas for which to update statistics
_update_swap_stats(swap_list, results, step)[source]

Updates replica exchange statistics.

Parameters:
  • swap_list (list) – a list of list in which each list element contains two replica names involved in a swap an an ExchangeParams object
  • results (list) – a two-dimensional list of shape (number of swaps, 3), in which the 2nd dimension is (0 / 1 (reject / accept), works, heats)
  • step (int) – the sampling step at which the swaps were performed
_write_statistics(step)[source]

Write sampling and swap statistics

Parameters:step (int) – sampling step
run(n_iterations, swap_interval=5, status_interval=100, dump_interval=250, offset=0, dump_step=5, statistics_update_interval=100)[source]

Runs the main loop of length n_iterations (number of sampling steps), in which normal sampling and swaps are performed. Furthermore, in given intervals, statistics are updated and statistics and samples are written to files.

Parameters:
  • n_iterations (int) – number of sampling steps to perform
  • swap_interval (int) – the interval with which to perform swaps
  • status_interval (int) – the interval with which to write sampling statistics
  • dump_interval (int) – the interval with which to write samples to files
  • offset (int) – an offset to add to the sample counter when writing samples to files. This allows to continue simulations.
  • dump_step (int) – allows to perform sub-sampling: write only every dump_step-th sample to a file
  • statistics_update_interval (int) – interval with which to update sampling statistics
terminate_replicas()[source]

Makes all replicas break from their listening loop and quit