Rosetta
Public Member Functions | Private Attributes | List of all members
numeric::random::WeightedReservoirSampler< T > Class Template Reference

#include <WeightedReservoirSampler.hh>

Inheritance diagram for numeric::random::WeightedReservoirSampler< T >:
Inheritance graph
[legend]

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...
 

Constructor & Destructor Documentation

◆ WeightedReservoirSampler()

template<typename T >
numeric::random::WeightedReservoirSampler< T >::WeightedReservoirSampler ( int  capacity)
inlineexplicit

Constructs a new weighted reservoir sampler with the given capacity.

References numeric::random::WeightedReservoirSampler< T >::capacity().

Member Function Documentation

◆ capacity()

template<typename T >
unsigned long numeric::random::WeightedReservoirSampler< T >::capacity ( ) const
inline

◆ consider_sample()

template<typename T >
void numeric::random::WeightedReservoirSampler< T >::consider_sample ( T  item,
double  fitness 
)
inline

◆ num_considered()

template<typename T >
unsigned long numeric::random::WeightedReservoirSampler< T >::num_considered ( ) const
inline

◆ reset()

template<typename T >
void numeric::random::WeightedReservoirSampler< T >::reset ( )
inline

◆ samples()

template<typename T >
void numeric::random::WeightedReservoirSampler< T >::samples ( utility::vector1< T > *  selected)
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().

Member Data Documentation

◆ capacity_

template<typename T >
unsigned long numeric::random::WeightedReservoirSampler< T >::capacity_
private

Capacity of the reservoir.

Referenced by numeric::random::WeightedReservoirSampler< T >::capacity().

◆ num_considered_

template<typename T >
unsigned long numeric::random::WeightedReservoirSampler< T >::num_considered_
private

◆ reservoir_

template<typename T >
std::priority_queue<WeightedReservoirItem<T> > numeric::random::WeightedReservoirSampler< T >::reservoir_
private

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