Rosetta
|
#include <WeightedReservoirSampler.hh>
Public Member Functions | |
WeightedReservoirSampler (int capacity) | |
Constructs a new weighted reservoir sampler with the given capacity. More... | |
void | consider_sample (T item, double fitness) |
Considers the given item for inclusion in the reservoir. Items with non-positive fitnesses are not considered. More... | |
void | samples (utility::vector1< T > *selected) |
Populates <selected> with the contents of the reservoir. More... | |
void | reset () |
Restores the reservoir to its initial state. More... | |
unsigned long | num_considered () const |
Returns the number of items considered by the sampler. More... | |
unsigned long | capacity () const |
Returns the capacity of the reservoir (i.e. number of samples) More... | |
Private Attributes | |
unsigned long | capacity_ |
Capacity of the reservoir. More... | |
unsigned long | num_considered_ |
Number of samples considered for inclusion. More... | |
std::priority_queue< WeightedReservoirItem< T > > | reservoir_ |
Maintains the current set of samples selected from the population. More... | |
|
inlineexplicit |
Constructs a new weighted reservoir sampler with the given capacity.
References numeric::random::WeightedReservoirSampler< T >::capacity().
|
inline |
Returns the capacity of the reservoir (i.e. number of samples)
References numeric::random::WeightedReservoirSampler< T >::capacity_.
Referenced by numeric::random::WeightedReservoirSampler< T >::consider_sample(), and numeric::random::WeightedReservoirSampler< T >::WeightedReservoirSampler().
|
inline |
Considers the given item for inclusion in the reservoir. Items with non-positive fitnesses are not considered.
References numeric::random::WeightedReservoirSampler< T >::capacity(), numeric::log(), numeric::random::WeightedReservoirSampler< T >::num_considered(), numeric::random::WeightedReservoirSampler< T >::num_considered_, numeric::random::WeightedReservoirSampler< T >::reservoir_, numeric::random::uniform(), and basic::options::OptionKeys::sc::weight.
|
inline |
Returns the number of items considered by the sampler.
References numeric::random::WeightedReservoirSampler< T >::num_considered_.
Referenced by numeric::random::WeightedReservoirSampler< T >::consider_sample().
|
inline |
Restores the reservoir to its initial state.
References numeric::random::WeightedReservoirSampler< T >::num_considered_, and numeric::random::WeightedReservoirSampler< T >::reservoir_.
Referenced by numeric::random::WeightedReservoirSampler< T >::samples().
|
inline |
Populates <selected> with the contents of the reservoir.
TODO(cmiles) use a data structure that provides iterator access. As a result of calling this method, the reservoir is emptied and the sampler's state restored to its initial condition.
References numeric::random::WeightedReservoirItem< T >::item(), numeric::random::WeightedReservoirSampler< T >::reservoir_, and numeric::random::WeightedReservoirSampler< T >::reset().
|
private |
Capacity of the reservoir.
Referenced by numeric::random::WeightedReservoirSampler< T >::capacity().
|
private |
Number of samples considered for inclusion.
Referenced by numeric::random::WeightedReservoirSampler< T >::consider_sample(), numeric::random::WeightedReservoirSampler< T >::num_considered(), and numeric::random::WeightedReservoirSampler< T >::reset().
|
private |
Maintains the current set of samples selected from the population.
Referenced by numeric::random::WeightedReservoirSampler< T >::consider_sample(), numeric::random::WeightedReservoirSampler< T >::reset(), and numeric::random::WeightedReservoirSampler< T >::samples().