Tomographer  v5.3
Tomographer C++ Framework Documentation
Tomographer::MHRWTasks::CDataBase< MHWalkerParams_, IterCountIntType_, RngSeedType_ > Struct Template Reference

Data needed to be accessible to the working code. More...

#include <tomographer/mhrwtasks.h>

+ Inheritance diagram for Tomographer::MHRWTasks::CDataBase< MHWalkerParams_, IterCountIntType_, RngSeedType_ >:
+ Collaboration diagram for Tomographer::MHRWTasks::CDataBase< MHWalkerParams_, IterCountIntType_, RngSeedType_ >:

Public Types

typedef IterCountIntType_ IterCountIntType
 Type used to count the number of iterations.
 
typedef MHWalkerParams_ MHWalkerParams
 Type used to specify the step size.
 
typedef RngSeedType_ RngSeedType
 Type used to specify the seed of the random number generator. More...
 
typedef MHRWParams< MHWalkerParams, IterCountIntTypeMHRWParamsType
 Type to store the parameters of the Metropolis-Hastings random walk (number of runs, sweep size, etc.) More...
 

Public Member Functions

template<typename MHRWParamsType >
 CDataBase (MHRWParamsType &&p, RngSeedType base_seed_)
 Constructor. More...
 
template<typename MHRWParamsType >
 CDataBase (MHRWParamsType &&p, std::vector< RngSeedType > task_seeds_)
 Constructor. More...
 
 CDataBase ()
 Construct an invalid object – ONLY for use with Boost.serialization.
 
template<typename TaskNoCountIntType >
RngSeedType getTaskInput (TaskNoCountIntType k) const
 Returns a random seed to seed the random number generator with for run number k. More...
 
void printBasicCDataMHRWInfo (std::ostream &str) const
 Get some human-readable info about the random walk as a string. More...
 
std::string getBasicCDataMHRWInfo () const
 Get some human-readable info about the random walk as a string, see printBasicCDataMHRWInfo()
 

Public Attributes

MHRWParamsType mhrw_params
 Parameters of the random walk. More...
 
RngSeedType base_seed
 A base random seed from which each run seed will be derived. More...
 
std::vector< RngSeedTypetask_seeds
 A list of random seeds to use for each task. More...
 

Detailed Description

template<typename MHWalkerParams_, typename IterCountIntType_ = int, typename RngSeedType_ = std::mt19937::result_type>
struct Tomographer::MHRWTasks::CDataBase< MHWalkerParams_, IterCountIntType_, RngSeedType_ >

Data needed to be accessible to the working code.

This is only a base class for the actual CData. The actual CData must additionally provide some methods, e.g. to create the random walk and stats collectors. See MHRandomWalkTaskCData Interface.

Stores the parameters to the random walk.

Since
Since Tomographer 5.3, you can specify an arbitrary list of seeds as inputs to each random number generator for each task (alternative constructor).
Since Tomographer 5.3, this class can be serialized with Boost.Serialization.

Definition at line 81 of file mhrwtasks.h.

Member Typedef Documentation

§ MHRWParamsType

template<typename MHWalkerParams_ , typename IterCountIntType_ = int, typename RngSeedType_ = std::mt19937::result_type>
typedef MHRWParams<MHWalkerParams, IterCountIntType> Tomographer::MHRWTasks::CDataBase< MHWalkerParams_, IterCountIntType_, RngSeedType_ >::MHRWParamsType

Type to store the parameters of the Metropolis-Hastings random walk (number of runs, sweep size, etc.)

See MHRWParams<MHWalkerParams,IterCountIntType>

Definition at line 99 of file mhrwtasks.h.

§ RngSeedType

template<typename MHWalkerParams_ , typename IterCountIntType_ = int, typename RngSeedType_ = std::mt19937::result_type>
typedef RngSeedType_ Tomographer::MHRWTasks::CDataBase< MHWalkerParams_, IterCountIntType_, RngSeedType_ >::RngSeedType

Type used to specify the seed of the random number generator.

Since
Added in Tomographer 5.0

Definition at line 92 of file mhrwtasks.h.

Constructor & Destructor Documentation

§ CDataBase() [1/2]

template<typename MHWalkerParams_ , typename IterCountIntType_ = int, typename RngSeedType_ = std::mt19937::result_type>
template<typename MHRWParamsType >
Tomographer::MHRWTasks::CDataBase< MHWalkerParams_, IterCountIntType_, RngSeedType_ >::CDataBase ( MHRWParamsType &&  p,
RngSeedType  base_seed_ 
)
inline

Constructor.

Make sure to initialize base_seed to something quite random (e.g. current time in seconds) so that independent runs of your program won't produce the exact same results.

Definition at line 109 of file mhrwtasks.h.

§ CDataBase() [2/2]

template<typename MHWalkerParams_ , typename IterCountIntType_ = int, typename RngSeedType_ = std::mt19937::result_type>
template<typename MHRWParamsType >
Tomographer::MHRWTasks::CDataBase< MHWalkerParams_, IterCountIntType_, RngSeedType_ >::CDataBase ( MHRWParamsType &&  p,
std::vector< RngSeedType task_seeds_ 
)
inline

Constructor.

Using this constructor the seed list is set, which takes precedence over base_seed.

Since
Introduced in Tomographer 5.3

Definition at line 124 of file mhrwtasks.h.

Member Function Documentation

§ getTaskInput()

template<typename MHWalkerParams_ , typename IterCountIntType_ = int, typename RngSeedType_ = std::mt19937::result_type>
template<typename TaskNoCountIntType >
RngSeedType Tomographer::MHRWTasks::CDataBase< MHWalkerParams_, IterCountIntType_, RngSeedType_ >::getTaskInput ( TaskNoCountIntType  k) const
inline

Returns a random seed to seed the random number generator with for run number k.

This function provides the input of the k-th task. Each task must of course have a different seed, otherwise we will just repeat the same "random" walks!

If task_seeds is not empty, then this function simply returns task_seeds[k]. It is an error if k is not in range for that vector. In other words, if you give a list of seeds with task_seeds, you need to specify enough seeds to cover all tasks.

If task_seeds is empty, then this simply returns base_seed + k.

Definition at line 194 of file mhrwtasks.h.

§ printBasicCDataMHRWInfo()

template<typename MHWalkerParams_ , typename IterCountIntType_ = int, typename RngSeedType_ = std::mt19937::result_type>
void Tomographer::MHRWTasks::CDataBase< MHWalkerParams_, IterCountIntType_, RngSeedType_ >::printBasicCDataMHRWInfo ( std::ostream str) const
inline

Get some human-readable info about the random walk as a string.

Definition at line 216 of file mhrwtasks.h.

Member Data Documentation

§ base_seed

template<typename MHWalkerParams_ , typename IterCountIntType_ = int, typename RngSeedType_ = std::mt19937::result_type>
RngSeedType Tomographer::MHRWTasks::CDataBase< MHWalkerParams_, IterCountIntType_, RngSeedType_ >::base_seed

A base random seed from which each run seed will be derived.

For each new random walk, a new pseudorandom number generator instance is created with a new seed.

In order to be able to reproduce results, the seeds are set deterministically from the base_seed, by using for the random seed of the k-th random walk: seed[k] = base_seed + k

Thus, by setting the base_seed to a fixed value you can reproduce all the results of a run. However, in order for your program not to output exactly the same thing if it is run a second time, and to make sure the points are indeed random, you must randomize base_seed, e.g. using the current time.

Since
In Tomographer 5.3: Removed the const attribute (to make serialization easier; anyway in multiprocessing implementations a const pointer to this class is kept ensuring const-ness already)

Definition at line 166 of file mhrwtasks.h.

§ mhrw_params

template<typename MHWalkerParams_ , typename IterCountIntType_ = int, typename RngSeedType_ = std::mt19937::result_type>
MHRWParamsType Tomographer::MHRWTasks::CDataBase< MHWalkerParams_, IterCountIntType_, RngSeedType_ >::mhrw_params

Parameters of the random walk.

Stores the number of iterations per sweep, the number of thermalizing sweeps, the number of "live" sweeps, and the step size of the random walk.

See MHRWParams<MHWalkerParams,IterCountIntType>

Since
In Tomographer 5.3: Removed the const attribute (to make serialization easier; anyway in multiprocessing implementations a const pointer to this class is kept ensuring const-ness already)

Definition at line 146 of file mhrwtasks.h.

§ task_seeds

template<typename MHWalkerParams_ , typename IterCountIntType_ = int, typename RngSeedType_ = std::mt19937::result_type>
std::vector<RngSeedType> Tomographer::MHRWTasks::CDataBase< MHWalkerParams_, IterCountIntType_, RngSeedType_ >::task_seeds

A list of random seeds to use for each task.

If set, this list of seeds takes precedence over base_seed. The seed at index number k will be fed to the corresponding task.

Since
Introduced in Tomographer 5.3

Definition at line 175 of file mhrwtasks.h.


The documentation for this struct was generated from the following file: