Manager for all the states and handle reading / writing from / to databse. More...
#include <chainarray.hpp>
Public Member Functions | |
| ChainArray (uint nStacks, uint nChains, double tempFactor, double initialSigma, double sigmaFactor, db::Database &db, uint cacheLength, bool recover) | |
| Create a chain array. More... | |
| uint | length (uint id) |
| Get the length of a chain. More... | |
| bool | append (uint id, const State &proposedState) |
| Append a state to a chain. More... | |
| void | initialise (uint id, const State &state) |
| Initialise a chain (by definitely accepting a new state). More... | |
| State | lastState (uint id) |
| Return the last state from a chain. More... | |
| State | state (uint id, uint index) |
| Return a particular state. More... | |
| std::vector< State > | states (uint id) |
| Return all states from a chain. More... | |
| bool | swap (uint id1, uint id2) |
| Attempt to swap the states in two different chains. More... | |
| double | sigma (uint id) const |
| Get the proposal width of a specific chain. More... | |
| void | setSigma (uint id, double sigma) |
| Set the proposal width of a specific chain. More... | |
| double | beta (uint id) const |
| Get the inverse temperature of a specific chain. More... | |
| void | setBeta (uint id, double beta) |
| Set the inverse temperature of a specific chain. More... | |
| uint | numStacks () const |
| Get the number of stacks. More... | |
| uint | numChains () const |
| Get the number of chains per stack. More... | |
| uint | numTotalChains () const |
| Get the total number of chains in every stack. More... | |
| void | flushCache (uint id) |
| Forcibly flush the cache for a particular chain. More... | |
| void | recoverFromCache (uint id) |
| Recover a particular chain from cached. More... | |
Manager for all the states and handle reading / writing from / to databse.
This class works with Ids:
| stateline::mcmc::ChainArray::ChainArray | ( | uint | nStacks, |
| uint | nChains, | ||
| double | tempFactor, | ||
| double | initialSigma, | ||
| double | sigmaFactor, | ||
| db::Database & | db, | ||
| uint | cacheLength, | ||
| bool | recover | ||
| ) |
Create a chain array.
| nStacks | The number of stacks. Each stack have the same temperature sequence. |
| nChains | The number of chains in each stack. |
| tempFactor | The ratio between the temperatures of consecutive chains in a stack. |
| initialSigma | The initial step sizes of the chains. |
| sigmaFactor | The ratio between the temperatures of consectuive chains in a stack. |
| db | The database to store chain data. |
| cacheLength | The size of the memory cache used to store the chains. |
| recover | If set to true, chain data will be recovered from the database |
| bool stateline::mcmc::ChainArray::append | ( | uint | id, |
| const State & | proposedState | ||
| ) |
Append a state to a chain.
| id | The id of the chain (see The chain ID used by MCMC sampler.). |
| proposedState | The new state to append. |
| double stateline::mcmc::ChainArray::beta | ( | uint | id | ) | const |
Get the inverse temperature of a specific chain.
| id | The id of the second chain (see The chain ID used by MCMC sampler.). |
| void stateline::mcmc::ChainArray::flushCache | ( | uint | id | ) |
Forcibly flush the cache for a particular chain.
| id | The id of the chain to flush. |
| void stateline::mcmc::ChainArray::initialise | ( | uint | id, |
| const State & | state | ||
| ) |
Initialise a chain (by definitely accepting a new state).
| id | The id of the chain (see The chain ID used by MCMC sampler.). |
| state | the new state to append |
| State stateline::mcmc::ChainArray::lastState | ( | uint | id | ) |
Return the last state from a chain.
| id | The id of the chain (see The chain ID used by MCMC sampler.). |
| uint stateline::mcmc::ChainArray::length | ( | uint | id | ) |
Get the length of a chain.
| id | The id of the chain (see The chain ID used by MCMC sampler.). |
| uint stateline::mcmc::ChainArray::numChains | ( | ) | const |
Get the number of chains per stack.
| uint stateline::mcmc::ChainArray::numStacks | ( | ) | const |
Get the number of stacks.
| uint stateline::mcmc::ChainArray::numTotalChains | ( | ) | const |
Get the total number of chains in every stack.
| void stateline::mcmc::ChainArray::recoverFromCache | ( | uint | id | ) |
Recover a particular chain from cached.
| id | The id of the chain to recover. |
| void stateline::mcmc::ChainArray::setBeta | ( | uint | id, |
| double | beta | ||
| ) |
Set the inverse temperature of a specific chain.
| id | The id of the second chain (see The chain ID used by MCMC sampler.). |
| beta | The new inverse temperature of the chain. |
| void stateline::mcmc::ChainArray::setSigma | ( | uint | id, |
| double | sigma | ||
| ) |
Set the proposal width of a specific chain.
| id | The id of the second chain (see The chain ID used by MCMC sampler.). |
| sigma | The new proposal width value. |
| double stateline::mcmc::ChainArray::sigma | ( | uint | id | ) | const |
Get the proposal width of a specific chain.
| id | The id of the second chain (see The chain ID used by MCMC sampler.). |
| State stateline::mcmc::ChainArray::state | ( | uint | id, |
| uint | index | ||
| ) |
Return a particular state.
| id | The id of the chain (see The chain ID used by MCMC sampler.). |
| index | The index of the state (0 for first state). |
| std::vector< State > stateline::mcmc::ChainArray::states | ( | uint | id | ) |
Return all states from a chain.
| id | The id of the chain (see The chain ID used by MCMC sampler.). |
| bool stateline::mcmc::ChainArray::swap | ( | uint | id1, |
| uint | id2 | ||
| ) |
Attempt to swap the states in two different chains.
| id1 | The id of the first chain (see The chain ID used by MCMC sampler.). |
| id2 | The id of the second chain (see The chain ID used by MCMC sampler.). |