odatse.algorithm.exchange module

class odatse.algorithm.exchange.Algorithm(info: Info, runner: Runner = None, run_mode: str = 'initial')[source]

Bases: AlgorithmBase

Replica Exchange Monte Carlo

x

current configuration

Type:

np.ndarray

inode

current configuration index (discrete parameter space)

Type:

np.ndarray

fx

current “Energy”

Type:

np.ndarray

Tindex

current “Temperature” index

Type:

np.ndarray

istep

current step (or, the number of calculated energies)

Type:

int

best_x

best configuration

Type:

np.ndarray

best_fx

best “Energy”

Type:

float

best_istep

index of best configuration

Type:

int

nreplica

The number of replicas (= the number of procs)

Type:

int

T2rep

Mapping from temperature index to replica index

Type:

np.ndarray

rep2T

Reverse mapping from replica index to temperature index

Type:

np.ndarray

exchange_direction

Parity of exchange direction

Type:

bool

Initialize the Algorithm class.

Parameters:
  • info (odatse.Info) – Information object containing algorithm parameters.

  • runner (odatse.Runner, optional) – Runner object for executing the algorithm.

  • run_mode (str, optional) – Mode to run the algorithm in, by default “initial”.

__exchange_multi_walker(direction: bool) None

Exchange temperatures for multiple walkers.

Parameters:

direction (bool) – Direction of the exchange.

__exchange_single_walker(direction: bool) None

Exchange temperatures for a single walker.

Parameters:

direction (bool) – Direction of the exchange.

__init__(info: Info, runner: Runner = None, run_mode: str = 'initial') None[source]

Initialize the Algorithm class.

Parameters:
  • info (odatse.Info) – Information object containing algorithm parameters.

  • runner (odatse.Runner, optional) – Runner object for executing the algorithm.

  • run_mode (str, optional) – Mode to run the algorithm in, by default “initial”.

_exchange(direction: bool) None[source]

Try to exchange temperatures.

Parameters:

direction (bool) – Direction of the exchange.

_initialize() None[source]

Initialize the algorithm parameters and state.

_load_state(filename, mode='resume', restore_rng=True)[source]

Load the state of the algorithm from a file.

Parameters:
  • filename (str) – The name of the file to load the state from.

  • mode (str, optional) – The mode to load the state in, by default “resume”.

  • restore_rng (bool, optional) – Whether to restore the random number generator state, by default True.

_post() None[source]

Post-process the results of the algorithm.

_prepare() None[source]

Prepare the algorithm for execution.

_print_info() None[source]

Print information about the algorithm.

_run() None[source]

Run the algorithm.

_save_state(filename) None[source]

Save the current state of the algorithm.

Parameters:

filename (str) – The name of the file to save the state to.