TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
triqs::mc_tools::move_set< MCSignType >

#include <triqs/mc_tools/mc_move_set.hpp>

Detailed Description

template<DoubleOrComplex MCSignType>
class triqs::mc_tools::move_set< MCSignType >

Set of MC moves.

It combines multiple MC moves.

Since it models the triqs::mc_tools::MCMove concept, it can be used just like any other MC move:

Template Parameters
MCSignTypeType of the sign/weight of a MC configuration (triqs::mc_tools::DoubleOrComplex).

Definition at line 63 of file mc_move_set.hpp.

Public Member Functions

 move_set (move_set &&)=default
 Default move constructor.
 move_set (move_set const &)=delete
 Deleted copy constructor.
 move_set (random_generator &rng)
 Construct a move set with a given random number generator (stored in a std::reference_wrapper).
MCSignType accept ()
 Accept the new MC configuration.
template<typename T>
requires (MCMove<T, MCSignType>)
void add (T &&m, std::string name, double weight)
 Add a new move to the set with a given name and weight.
double attempt ()
 Propose a new MC configuration.
auto attempt_sign () const
 Get the sign of the acceptance ratio of the last attempt.
void calibrate (mpi::communicator const &c)
 Calibrate all the moves in the set.
void clear_statistics ()
 Clear the statistics of all the moves in the set.
void collect_statistics (mpi::communicator const &c)
 Collect statistics for all the moves in the set from multiple MPI processes.
auto current () const
 Get the index of the current move.
std::map< std::string, double > get_acceptance_rates () const
 Get the acceptance rates of all moves in the set.
std::string get_statistics (std::string const &prefix="") const
 Get a formatted string showing the acceptance rates of all moves.
std::string get_timings (std::string const &prefix="") const
 Get a formatted string with the timings of all moves.
move_setoperator= (move_set &&)=default
 Default move assignment operator.
move_setoperator= (move_set const &)=delete
 Deleted copy assignment operator.
auto const & probabilities () const
 Get the probabilities with which the moves are selected.
void reject ()
 Reject the new MC configuration.
double total_duration () const
 Get the total duration of all moves.

Static Public Member Functions

static std::string hdf5_format ()
 Get the HDF5 format tag.

Friends

void h5_read (h5::group g, std::string const &name, move_set &ms)
 Read the move set object from HDF5.
void h5_write (h5::group g, std::string const &name, move_set const &ms)
 Write the move set object to HDF5.

Constructor & Destructor Documentation

◆ move_set()

template<DoubleOrComplex MCSignType>
triqs::mc_tools::move_set< MCSignType >::move_set ( random_generator & rng)
inline

Construct a move set with a given random number generator (stored in a std::reference_wrapper).

Parameters
rngRNG object.

Definition at line 69 of file mc_move_set.hpp.

Member Function Documentation

◆ accept()

template<DoubleOrComplex MCSignType>
MCSignType triqs::mc_tools::move_set< MCSignType >::accept ( )
inline

Accept the new MC configuration.

It calls the move::accept method of the previously attempted move.

Returns
Sign correction returned by move::accept times the sign of the acceptance ratio from move::attempt.

Definition at line 119 of file mc_move_set.hpp.

◆ add()

template<DoubleOrComplex MCSignType>
template<typename T>
requires (MCMove<T, MCSignType>)
void triqs::mc_tools::move_set< MCSignType >::add ( T && m,
std::string name,
double weight )
inline

Add a new move to the set with a given name and weight.

It adds a new MC move to the set, normalizes the weights of all moves and calculates the accumulated probabilities.

Throws a std::runtime_error if the weight is negative.

Template Parameters
Ttriqs::mc_tools::MCMove type.
Parameters
mMC move to add to the set.
nameName of the move.
weightWeight of the move ( \( \geq 0 \)).

Definition at line 98 of file mc_move_set.hpp.

◆ attempt()

template<DoubleOrComplex MCSignType>
double triqs::mc_tools::move_set< MCSignType >::attempt ( )

Propose a new MC configuration.

It selects a move from the set based on the given weights and calls the move::attempt method of the selected move.

Returns
The acceptance ratio of the proposed move.

Definition at line 44 of file mc_move_set.cpp.

◆ calibrate()

template<DoubleOrComplex MCSignType>
void triqs::mc_tools::move_set< MCSignType >::calibrate ( mpi::communicator const & c)

Calibrate all the moves in the set.

It calls the move::calibrate method for each move.

Parameters
cMPI communicator.

Definition at line 63 of file mc_move_set.cpp.

◆ clear_statistics()

template<DoubleOrComplex MCSignType>
void triqs::mc_tools::move_set< MCSignType >::clear_statistics ( )

Clear the statistics of all the moves in the set.

It calls the move::clear_statistics method for each move.

Definition at line 55 of file mc_move_set.cpp.

◆ collect_statistics()

template<DoubleOrComplex MCSignType>
void triqs::mc_tools::move_set< MCSignType >::collect_statistics ( mpi::communicator const & c)

Collect statistics for all the moves in the set from multiple MPI processes.

It calls the move::collect_statistics method for each move.

Parameters
cMPI communicator.

Definition at line 59 of file mc_move_set.cpp.

◆ get_acceptance_rates()

template<DoubleOrComplex MCSignType>
std::map< std::string, double > triqs::mc_tools::move_set< MCSignType >::get_acceptance_rates ( ) const
nodiscard

Get the acceptance rates of all moves in the set.

Returns
std::map containing the names of the moves and their acceptance rates.

Definition at line 67 of file mc_move_set.cpp.

◆ get_statistics()

template<DoubleOrComplex MCSignType>
std::string triqs::mc_tools::move_set< MCSignType >::get_statistics ( std::string const & prefix = "") const
nodiscard

Get a formatted string showing the acceptance rates of all moves.

Parameters
prefixPrefix string to be added to the beginning of each line (not intended for the user).
Returns
String containing the number of proposed and accepted configurations and the acceptance rate of all moves in the set.

Definition at line 77 of file mc_move_set.cpp.

◆ get_timings()

template<DoubleOrComplex MCSignType>
std::string triqs::mc_tools::move_set< MCSignType >::get_timings ( std::string const & prefix = "") const
nodiscard

Get a formatted string with the timings of all moves.

Parameters
prefixPrefix string to be added to the beginning of each line (not intended for the user).
Returns
String containing the duration of all moves in the set.

Definition at line 83 of file mc_move_set.cpp.

◆ reject()

template<DoubleOrComplex MCSignType>
void triqs::mc_tools::move_set< MCSignType >::reject ( )
inline

Reject the new MC configuration.

It calls the move::reject method of the previously attempted move.

Definition at line 125 of file mc_move_set.hpp.

◆ h5_read

template<DoubleOrComplex MCSignType>
void h5_read ( h5::group g,
std::string const & name,
move_set< MCSignType > & ms )
friend

Read the move set object from HDF5.

It loops over all registered moves and calls the h5_read function for each move.

Parameters
gh5::group to be read from.
nameName of the subgroup.
msMove set object to be read into.

Definition at line 211 of file mc_move_set.hpp.

◆ h5_write

template<DoubleOrComplex MCSignType>
void h5_write ( h5::group g,
std::string const & name,
move_set< MCSignType > const & ms )
friend

Write the move set object to HDF5.

It loops over all registered moves and calls the h5_write function for each move.

Parameters
gh5::group to be written to.
nameName of the subgroup.
msMove set object to be written.

Definition at line 196 of file mc_move_set.hpp.


The documentation for this class was generated from the following files: