vSMC
vSMC: Scalable Monte Carlo
|
Particle class representing the whole particle set. More...
#include <vsmc/core/particle.hpp>
Public Types | |
typedef ConstSingleParticle< T > | csp_type |
typedef traits::ResampleCopyFromReplicationTypeTrait< T >::type | resample_copy_from_replication_type |
typedef traits::ResamplePostCopyTypeTrait< T >::type | resample_post_copy_type |
typedef traits::ResampleRngTypeTrait< T >::type | resample_rng_type |
typedef cxx11::function< void(std::size_t, std::size_t, resample_rng_type &, const double *, size_type *)> | resample_type |
typedef traits::RngSetTypeTrait< T >::type | rng_set_type |
typedef rng_set_type::rng_type | rng_type |
typedef traits::SizeTypeTrait< T >::type | size_type |
typedef SingleParticle< T > | sp_type |
typedef T | value_type |
typedef traits::WeightSetTypeTrait< T >::type | weight_set_type |
Public Member Functions | |
Particle (size_type N) | |
Particle< T > | clone (bool new_rng) const |
Clone the particle system except the RNG engines. More... | |
Particle< T > & | clone (const Particle< T > &other, bool retain_rng) |
Clone another particle system except the RNG engines. More... | |
Particle< T > & | clone (Particle< T > &&other, bool retain_rng) |
csp_type | csp (size_type id) |
Get a ConstSingleParticle. More... | |
csp_type | csp (size_type id) const |
Get a ConstSingleParticle. More... | |
bool | resample (const resample_type &op, double threshold) |
Performing resampling if ESS/N < threshold. More... | |
resample_rng_type & | resample_rng () |
Get the (sequential) RNG used stream for resampling. More... | |
rng_type & | rng (size_type id) |
Get an (parallel) RNG stream for a given particle. More... | |
rng_set_type & | rng_set () |
Read and write access to the RNG collection object. More... | |
const rng_set_type & | rng_set () const |
Read only access to the RNG collection object. More... | |
size_type | size () const |
Number of particles. More... | |
sp_type | sp (size_type id) |
Get a SingleParticle. More... | |
csp_type | sp (size_type id) const |
Get a ConstSingleParticle. More... | |
value_type & | value () |
Read and write access to the value collection object. More... | |
const value_type & | value () const |
Read only access to the value collection object. More... | |
weight_set_type & | weight_set () |
Read and write access to the weight collection object. More... | |
const weight_set_type & | weight_set () const |
Read only access to the weight collection object. More... | |
Particle class representing the whole particle set.
Definition at line 48 of file particle.hpp.
typedef ConstSingleParticle<T> vsmc::Particle< T >::csp_type |
Definition at line 59 of file particle.hpp.
typedef traits::ResampleCopyFromReplicationTypeTrait<T>::type vsmc::Particle< T >::resample_copy_from_replication_type |
Definition at line 64 of file particle.hpp.
typedef traits::ResamplePostCopyTypeTrait<T>::type vsmc::Particle< T >::resample_post_copy_type |
Definition at line 66 of file particle.hpp.
typedef traits::ResampleRngTypeTrait<T>::type vsmc::Particle< T >::resample_rng_type |
Definition at line 56 of file particle.hpp.
typedef cxx11::function<void (std::size_t, std::size_t, resample_rng_type &, const double *, size_type *)> vsmc::Particle< T >::resample_type |
Definition at line 62 of file particle.hpp.
typedef traits::RngSetTypeTrait<T>::type vsmc::Particle< T >::rng_set_type |
Definition at line 55 of file particle.hpp.
typedef rng_set_type::rng_type vsmc::Particle< T >::rng_type |
Definition at line 57 of file particle.hpp.
typedef traits::SizeTypeTrait<T>::type vsmc::Particle< T >::size_type |
Definition at line 52 of file particle.hpp.
typedef SingleParticle<T> vsmc::Particle< T >::sp_type |
Definition at line 58 of file particle.hpp.
typedef T vsmc::Particle< T >::value_type |
Definition at line 53 of file particle.hpp.
typedef traits::WeightSetTypeTrait<T>::type vsmc::Particle< T >::weight_set_type |
Definition at line 54 of file particle.hpp.
|
inlineexplicit |
Definition at line 68 of file particle.hpp.
|
inline |
Clone the particle system except the RNG engines.
new_rng | If true, the new particle system has new-seeded RNG. Otherwise false, it is exactly the same as the current. |
Definition at line 80 of file particle.hpp.
|
inline |
Clone another particle system except the RNG engines.
other | The particle system to be cloned |
retain_rng | If true, retain the current system's RNG. Otherwise, it is exactly the same as the new one. |
Definition at line 96 of file particle.hpp.
|
inline |
Definition at line 126 of file particle.hpp.
|
inline |
Get a ConstSingleParticle.
Definition at line 176 of file particle.hpp.
|
inline |
Get a ConstSingleParticle.
Definition at line 179 of file particle.hpp.
|
inline |
Performing resampling if ESS/N < threshold.
op | The resampling operation funcitor |
threshold | The threshold of ESS/N below which resampling will be performed |
The out of box behavior are suitable for most applications. However, the user can also gain full control over the internal of this function by changing the weight_set_type
and other type traits for specific value collection type. The sequence of operations of this function is listed as in the following pseudo-code
N = weight_set.resample_size()
resampled = weight_set.ess() < threshold * N
!resampled
, GO TO Step 8. Otherwise, GO TO Step 2resampled
ensures that collective actions like copy
will be called by all nodes. However, the resampling replication numbers can be computed by one node instead of by all. Therefore, the program can actually collect and read the resampling weights on one node, and do nothing on other nodes. This difference shall be reflected by the returning iterator of read_resample_weight
double *weight
for size N
)double *end = weight_set.read_resample_weight(weight)
end != weight + N
, GO TO step 5. Otherwise, GO TO Step 3size_type *replication
for size N
)resample_rng
according to traits::ResampleRngTypeTrait)op(N, resample_rng, weight, replication)
size_type *copy_from
for size N
)r2c
according to traits::ResampleCopyFromReplicationTypeTrait)r2c(N, replication, copy_from)
const size_type *cptr
according to results of Step 2.cptr = 0
. Otherwise,cptr = copy_from
value.copy(N, cptr)
post
according to traits::ResamplePostCopyTypeTrait)post(weight_set)
return resampled
Definition at line 234 of file particle.hpp.
|
inline |
Get the (sequential) RNG used stream for resampling.
Definition at line 182 of file particle.hpp.
|
inline |
Get an (parallel) RNG stream for a given particle.
Definition at line 167 of file particle.hpp.
|
inline |
Read and write access to the RNG collection object.
Definition at line 161 of file particle.hpp.
|
inline |
Read only access to the RNG collection object.
Definition at line 164 of file particle.hpp.
|
inline |
Number of particles.
Definition at line 146 of file particle.hpp.
|
inline |
Get a SingleParticle.
Definition at line 170 of file particle.hpp.
|
inline |
Get a ConstSingleParticle.
Definition at line 173 of file particle.hpp.
|
inline |
Read and write access to the value collection object.
Definition at line 149 of file particle.hpp.
|
inline |
Read only access to the value collection object.
Definition at line 152 of file particle.hpp.
|
inline |
Read and write access to the weight collection object.
Definition at line 155 of file particle.hpp.
|
inline |
Read only access to the weight collection object.
Definition at line 158 of file particle.hpp.