Rosetta  2020.37
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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

Constructs a new weighted reservoir sampler with the given capacity.

Member Function Documentation

template<typename T >
unsigned long numeric::random::WeightedReservoirSampler< T >::capacity ( ) const
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().

template<typename T >
void numeric::random::WeightedReservoirSampler< T >::consider_sample ( T  item,
double  fitness 
)
inline
template<typename T >
unsigned long numeric::random::WeightedReservoirSampler< T >::num_considered ( ) const
inline
template<typename T >
void numeric::random::WeightedReservoirSampler< T >::reset ( )
inline
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

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

Capacity of the reservoir.

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

template<typename T >
unsigned long numeric::random::WeightedReservoirSampler< T >::num_considered_
private
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: