Tomographer  v5.4
Tomographer C++ Framework Documentation
MHRandomWalkTaskCData Interface

This is a ‘type interface.’ See Type Interfaces for more info on what that is.

A MHRandomWalkTaskCData is an object which provides data about how to conduct a repetition of random walks, while collecting statistics. It may store constant global data.

A MHRandomWalkTaskCData must inherit Tomographer::MHRWTasks::CDataBase<CountIntType,StepRealType>, in order to expose some basic types and functions.

A MHRandomWalkTaskCData must be copy-constructible, and different threads must be able to operate safely on different copies.

A MHRandomWalkTaskCData must further provide the following members:

typedef .. MHRWStatsResultsType
The type which stores the results from the statistics carried out during the random walk. This type may be any type which can be constructed using as single argument the result (specifically an r-value reference) of the stats collector created by setupRandomWalkAndRun() (see below). Typically, this is just the ResultType of the MHRWStatsCollector itself.
This is the type of the stats-collection part of the results which are communicated back to the caller of the multiprocessing task manager/dispatcher (see Tomographer::MHRWTasks::MHRandomWalkTaskResult) .
template void setupRandomWalkAndRun(Rng & rng, Logger & logger, RunFn run) const
This callback is responsible for setting up the random walk and executing run() to proceed with running it. This function should create a MHWalker Interface, a MHRWStatsCollector Interface, and optionally a MHRWController Interface, and pass them on to the given function run, which takes care of actually running the random walk.
Important: this method must be const and not modify the state of the CData object. Indeed, this function may be called multiple times in parallel from different threads.
Using this function call structure allows to create the MHWalker and friends on the stack, creating multiple stats collectors, having controllers refer to stats collectors etc., and not having to worry about creating unique instances of the objects and/or copying/moving them to the caller.
The run callable must be invoked with the following syntax:
run(mhwalker, stats_collector, controller); // with controller, OR:
run(mhwalker, stats_collector); // without controller
If the optional controller argument is omitted, a dummy Tomographer::MHRWNoController is used.
If you are using the tools in Tomographer::MHRWTasks::ValueHistogramTools, in particular inheriting from Tomographer::MHRWTasks::ValueHistogramTools::CDataBase, then you should use the base class method createValueStatsCollector() to create the value histogram stats collector.
Have a look at "test/minimal_tomorun.cxx", "test/minimal_tomorun_controlled.cxx", "py/cxx/pytomorun.cxx" and "tomorun/tomorun_dispatch.cxx" for examples.
Since
Changed in Tomographer 5.0: createMHWalker() and createStatsCollector() have been replaced by the more flexible setupRandomWalkAndRun().