bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
rl_example_12::ExperienceBuffer< ExperienceType > Class Template Reference

The ExperienceBuffer class. A buffer based on boost::circular_buffer to accumulate items of type ExperienceType. see for example the A2C algorithm in A2C.h and rl_example_15. More...

#include <experience_buffer.h>

Inheritance diagram for rl_example_12::ExperienceBuffer< ExperienceType >:
Collaboration diagram for rl_example_12::ExperienceBuffer< ExperienceType >:

Public Types

typedef ExperienceType value_type
typedef ExperienceType experience_type
typedef boost::circular_buffer< ExperienceType >::iterator iterator
typedef boost::circular_buffer< ExperienceType >::const_iterator const_iterator
typedef boost::circular_buffer< ExperienceType >::reverse_iterator reverse_iterator
typedef boost::circular_buffer< ExperienceType >::const_reverse_iterator const_reverse_iterator

Public Member Functions

 ExperienceBuffer ()
 ExperienceBuffer.
 ExperienceBuffer (uint_t capacity)
 ExperienceBuffer.
void append (const experience_type &experience)
 append Add the experience item in the buffer
uint_t size () const noexcept
 size
uint_t capacity () const noexcept
 capacity
bool empty () const noexcept
 empty. Returns true if the buffer is empty
void clear () noexcept
 clear
value_type & operator[] (uint_t idx)
 operator []
const value_type & operator[] (uint_t idx) const
 operator []
void resize (uint_t new_size, const experience_type &item=experience_type())
 Resize the buffer.
template<typename BatchTp>
void sample (uint_t batch_size, BatchTp &batch, uint_t seed=42) const
 sample. Sample batch_size experiences from the buffer and transfer them in the BatchTp container.
template<typename ContainerType>
void get (ContainerType &container) const
 Copy the contents of the buffer to the given container.
template<typename ContainerType>
ContainerType get () const
 Copy the contents of the buffer to the given container.
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
reverse_iterator rbegin ()
const_reverse_iterator rbegin () const
reverse_iterator rend ()
const_reverse_iterator rend () const

Static Public Attributes

static const uint_t DEFAULT_CAPACITY = 100

Detailed Description

template<typename ExperienceType>
class rl_example_12::ExperienceBuffer< ExperienceType >

The ExperienceBuffer class. A buffer based on boost::circular_buffer to accumulate items of type ExperienceType. see for example the A2C algorithm in A2C.h and rl_example_15.

Member Typedef Documentation

◆ const_iterator

template<typename ExperienceType>
typedef boost::circular_buffer<ExperienceType>::const_iterator bitrl::utils::ExperienceBuffer< ExperienceType >::const_iterator

◆ const_reverse_iterator

template<typename ExperienceType>
typedef boost::circular_buffer<ExperienceType>::const_reverse_iterator bitrl::utils::ExperienceBuffer< ExperienceType >::const_reverse_iterator

◆ experience_type

template<typename ExperienceType>
typedef ExperienceType bitrl::utils::ExperienceBuffer< ExperienceType >::experience_type

◆ iterator

template<typename ExperienceType>
typedef boost::circular_buffer<ExperienceType>::iterator bitrl::utils::ExperienceBuffer< ExperienceType >::iterator

◆ reverse_iterator

template<typename ExperienceType>
typedef boost::circular_buffer<ExperienceType>::reverse_iterator bitrl::utils::ExperienceBuffer< ExperienceType >::reverse_iterator

◆ value_type

template<typename ExperienceType>
typedef ExperienceType bitrl::utils::ExperienceBuffer< ExperienceType >::value_type

Constructor & Destructor Documentation

◆ ExperienceBuffer() [1/2]

template<typename ExperienceTp>
bitrl::utils::ExperienceBuffer< ExperienceTp >::ExperienceBuffer ( )

◆ ExperienceBuffer() [2/2]

template<typename ExperienceTp>
bitrl::utils::ExperienceBuffer< ExperienceTp >::ExperienceBuffer ( uint_t capacity)
explicit

Member Function Documentation

◆ append()

template<typename ExperienceTp>
void bitrl::utils::ExperienceBuffer< ExperienceTp >::append ( const experience_type & experience)

append Add the experience item in the buffer

◆ begin() [1/2]

template<typename ExperienceType>
iterator bitrl::utils::ExperienceBuffer< ExperienceType >::begin ( )
inline

◆ begin() [2/2]

template<typename ExperienceType>
const_iterator bitrl::utils::ExperienceBuffer< ExperienceType >::begin ( ) const
inline

◆ capacity()

template<typename ExperienceType>
uint_t bitrl::utils::ExperienceBuffer< ExperienceType >::capacity ( ) const
inlinenoexcept

capacity

Returns

◆ clear()

template<typename ExperienceType>
void bitrl::utils::ExperienceBuffer< ExperienceType >::clear ( )
inlinenoexcept

clear

◆ empty()

template<typename ExperienceType>
bool bitrl::utils::ExperienceBuffer< ExperienceType >::empty ( ) const
inlinenoexcept

empty. Returns true if the buffer is empty

Returns

◆ end() [1/2]

template<typename ExperienceType>
iterator bitrl::utils::ExperienceBuffer< ExperienceType >::end ( )
inline

◆ end() [2/2]

template<typename ExperienceType>
const_iterator bitrl::utils::ExperienceBuffer< ExperienceType >::end ( ) const
inline

◆ get() [1/2]

template<typename ExperienceType>
template<typename ContainerType>
ContainerType bitrl::utils::ExperienceBuffer< ExperienceType >::get ( ) const

Copy the contents of the buffer to the given container.

◆ get() [2/2]

template<typename ExperienceType>
template<typename ContainerType>
void bitrl::utils::ExperienceBuffer< ExperienceType >::get ( ContainerType & container) const

Copy the contents of the buffer to the given container.

◆ operator[]() [1/2]

template<typename ExperienceType>
value_type & bitrl::utils::ExperienceBuffer< ExperienceType >::operator[] ( uint_t idx)
inline

operator []

Parameters
idx
Returns

◆ operator[]() [2/2]

template<typename ExperienceType>
const value_type & bitrl::utils::ExperienceBuffer< ExperienceType >::operator[] ( uint_t idx) const
inline

operator []

Parameters
idx
Returns

◆ rbegin() [1/2]

template<typename ExperienceType>
reverse_iterator bitrl::utils::ExperienceBuffer< ExperienceType >::rbegin ( )
inline

◆ rbegin() [2/2]

template<typename ExperienceType>
const_reverse_iterator bitrl::utils::ExperienceBuffer< ExperienceType >::rbegin ( ) const
inline

◆ rend() [1/2]

template<typename ExperienceType>
reverse_iterator bitrl::utils::ExperienceBuffer< ExperienceType >::rend ( )
inline

◆ rend() [2/2]

template<typename ExperienceType>
const_reverse_iterator bitrl::utils::ExperienceBuffer< ExperienceType >::rend ( ) const
inline

◆ resize()

template<typename ExperienceTp>
void bitrl::utils::ExperienceBuffer< ExperienceTp >::resize ( uint_t new_size,
const experience_type & item = experience_type() )

Resize the buffer.

◆ sample()

template<typename ExperienceTp>
template<typename BatchTp>
void bitrl::utils::ExperienceBuffer< ExperienceTp >::sample ( uint_t batch_size,
BatchTp & batch,
uint_t seed = 42 ) const

sample. Sample batch_size experiences from the buffer and transfer them in the BatchTp container.

◆ size()

template<typename ExperienceType>
uint_t bitrl::utils::ExperienceBuffer< ExperienceType >::size ( ) const
inlinenoexcept

size

Returns

Member Data Documentation

◆ DEFAULT_CAPACITY

template<typename ExperienceType>
const uint_t bitrl::utils::ExperienceBuffer< ExperienceType >::DEFAULT_CAPACITY = 100
static

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