bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
bitrl::utils::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 bitrl::utils::ExperienceBuffer< ExperienceType >:
Collaboration diagram for bitrl::utils::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_typeoperator[] (uint_t idx)
 operator []
 
void resize (uint_t new_size, const experience_type &item=experience_type())
 Resize the buffer.
 
const value_typeoperator[] (uint_t idx) const
 operator []
 
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 ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 

Static Public Attributes

static const uint_t DEFAULT_CAPACITY = 100
 

Detailed Description

template<typename ExperienceType>
class bitrl::utils::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

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

◆ const_reverse_iterator

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

◆ experience_type

◆ iterator

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

◆ reverse_iterator

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

◆ value_type

Constructor & Destructor Documentation

◆ ExperienceBuffer() [1/2]

◆ ExperienceBuffer() [2/2]

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

Member Function Documentation

◆ append()

append Add the experience item in the buffer

◆ begin() [1/2]

◆ begin() [2/2]

◆ capacity()

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

capacity

Returns

◆ clear()

clear

◆ empty()

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

empty. Returns true if the buffer is empty

Returns

◆ end() [1/2]

◆ end() [2/2]

◆ get() [1/2]

Copy the contents of the buffer to the given container.

◆ get() [2/2]

Copy the contents of the buffer to the given container.

◆ operator[]() [1/2]

operator []

Parameters
idx
Returns

◆ operator[]() [2/2]

operator []

Parameters
idx
Returns

◆ rbegin() [1/2]

◆ rbegin() [2/2]

◆ rend() [1/2]

◆ rend() [2/2]

◆ resize()

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()

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

size

Returns

Member Data Documentation

◆ DEFAULT_CAPACITY

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

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