bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
bitrl::dynamics::SysState< dim > Class Template Reference

SysState utility class describing the state of a system. More...

#include <system_state.h>

Public Types

typedef std::array< std::pair< std::string, real_t >, dim > value_type
 The type of the stored values.
 

Public Member Functions

 SysState ()
 Constructor. Initialize the state with no names.
 
 SysState (std::array< std::pair< std::string, real_t >, dim > &&values)
 Constructor. Initialize the state with the given names and values.
 
 SysState (std::array< std::string, dim > &&names, real_t val)
 Constructor. Initialize the state with the given names all variables will be initialized with val.
 
 SysState (const SysState< dim > &other)
 Copy constructor.
 
template<int other_dim>
 SysState (const SysState< other_dim > &other)
 Copy constructor.
 
SysStateoperator= (const SysState< dim > &other)
 Copy assignement constructor.
 
 SysState (SysState &&other)
 Move copy constructor.
 
SysStateoperator= (SysState &&other)
 Move copy constructor.
 
SysStateoperator+= (const DynVec< real_t > &vec)
 Add to this state the entries of the give vector.
 
SysStateoperator-= (const DynVec< real_t > &vec)
 Subtract from this state the entries of the give vector.
 
SysStateoperator*= (real_t val)
 Scale this state by the given factor.
 
real_t get (const std::string &name) const
 Returns the value for the variable name.
 
void set (const std::string &name, real_t val)
 Set the value for the variable name.
 
void set (uint_t i, const std::pair< std::string, real_t > &value)
 Set the name and value of the i-th variable.
 
void add (const DynVec< real_t > &container)
 Set the values of state variables container must be of size dim.
 
void add (const std::vector< real_t > &container)
 Set the values of state variables container must be of size dim.
 
uint_t size () const
 Returns the size of the system.
 
const std::array< real_t, dim > get_values () const
 Returns a copy of the state values.
 
const std::vector< std::string_view > get_names () const
 Returns a copy of the state names.
 
real_toperator[] (uint_t)
 Access operator.
 
const real_toperator[] (uint_t) const
 Access operator.
 
real_toperator[] (const std::string &name)
 Access operator.
 
const real_toperator[] (const std::string &name) const
 Access operator.
 
real_toperator() (const std::string &name)
 Access operator.
 
const real_toperator() (const std::string &name) const
 Access operator.
 
real_toperator() (const std::string_view name)
 Access operator.
 
const real_toperator() (const std::string_view name) const
 Access operator.
 
void clear ()
 clear the state
 
std::ostream & print (std::ostream &out) const
 Print the state at the given stream.
 
DynVec< real_tas_vector () const
 Returns the entries of this state as a DynVec.
 
const std::string as_string () const
 Return the state as string.
 
nlohmann::json as_json () const
 
void scale (real_t val)
 Scale the values of the state.
 
template<typename Container >
void set (const Container &container)
 Set the values.
 

Static Public Member Functions

template<int dim1, int dim2>
static void extract (const SysState< dim1 > &state, SysState< dim2 > &other)
 Extract a state of different dimension.
 

Static Public Attributes

static const int dimension = dim
 The dimension of the state.
 

Detailed Description

template<int dim>
class bitrl::dynamics::SysState< dim >

SysState utility class describing the state of a system.

Member Typedef Documentation

◆ value_type

template<int dim>
typedef std::array<std::pair<std::string, real_t>, dim> bitrl::dynamics::SysState< dim >::value_type

The type of the stored values.

Constructor & Destructor Documentation

◆ SysState() [1/6]

template<int dim>
bitrl::dynamics::SysState< dim >::SysState ( )

Constructor. Initialize the state with no names.

◆ SysState() [2/6]

template<int dim>
bitrl::dynamics::SysState< dim >::SysState ( std::array< std::pair< std::string, real_t >, dim > &&  values)

Constructor. Initialize the state with the given names and values.

◆ SysState() [3/6]

template<int dim>
bitrl::dynamics::SysState< dim >::SysState ( std::array< std::string, dim > &&  names,
real_t  val 
)

Constructor. Initialize the state with the given names all variables will be initialized with val.

◆ SysState() [4/6]

template<int dim>
bitrl::dynamics::SysState< dim >::SysState ( const SysState< dim > &  other)

Copy constructor.

◆ SysState() [5/6]

template<int dim>
template<int other_dim>
bitrl::dynamics::SysState< dim >::SysState ( const SysState< other_dim > &  other)

Copy constructor.

◆ SysState() [6/6]

template<int dim>
bitrl::dynamics::SysState< dim >::SysState ( SysState< dim > &&  other)

Move copy constructor.

Member Function Documentation

◆ add() [1/2]

template<int dim>
void bitrl::dynamics::SysState< dim >::add ( const DynVec< real_t > &  container)

Set the values of state variables container must be of size dim.

◆ add() [2/2]

template<int dim>
void bitrl::dynamics::SysState< dim >::add ( const std::vector< real_t > &  container)

Set the values of state variables container must be of size dim.

◆ as_json()

template<int dim>
nlohmann::json bitrl::dynamics::SysState< dim >::as_json ( ) const

Convert to json format

Returns

◆ as_string()

template<int dim>
const std::string bitrl::dynamics::SysState< dim >::as_string ( ) const

Return the state as string.

◆ as_vector()

template<int dim>
DynVec< real_t > bitrl::dynamics::SysState< dim >::as_vector ( ) const

Returns the entries of this state as a DynVec.

◆ clear()

template<int dim>
void bitrl::dynamics::SysState< dim >::clear ( )

clear the state

◆ extract()

template<int dim>
template<int dim1, int dim2>
void bitrl::dynamics::SysState< dim >::extract ( const SysState< dim1 > &  state,
SysState< dim2 > &  other 
)
static

Extract a state of different dimension.

◆ get()

template<int dim>
real_t bitrl::dynamics::SysState< dim >::get ( const std::string &  name) const

Returns the value for the variable name.

◆ get_names()

template<int dim>
const std::vector< std::string_view > bitrl::dynamics::SysState< dim >::get_names ( ) const

Returns a copy of the state names.

◆ get_values()

template<int dim>
const std::array< real_t, dim > bitrl::dynamics::SysState< dim >::get_values ( ) const

Returns a copy of the state values.

◆ operator()() [1/4]

template<int dim>
real_t & bitrl::dynamics::SysState< dim >::operator() ( const std::string &  name)

Access operator.

◆ operator()() [2/4]

template<int dim>
const real_t & bitrl::dynamics::SysState< dim >::operator() ( const std::string &  name) const

Access operator.

◆ operator()() [3/4]

template<int dim>
real_t & bitrl::dynamics::SysState< dim >::operator() ( const std::string_view  name)
inline

Access operator.

◆ operator()() [4/4]

template<int dim>
const real_t & bitrl::dynamics::SysState< dim >::operator() ( const std::string_view  name) const
inline

Access operator.

◆ operator*=()

template<int dim>
SysState< dim > & bitrl::dynamics::SysState< dim >::operator*= ( real_t  val)

Scale this state by the given factor.

◆ operator+=()

template<int dim>
SysState< dim > & bitrl::dynamics::SysState< dim >::operator+= ( const DynVec< real_t > &  vec)

Add to this state the entries of the give vector.

◆ operator-=()

template<int dim>
SysState< dim > & bitrl::dynamics::SysState< dim >::operator-= ( const DynVec< real_t > &  vec)

Subtract from this state the entries of the give vector.

◆ operator=() [1/2]

template<int dim>
SysState< dim > & bitrl::dynamics::SysState< dim >::operator= ( const SysState< dim > &  other)

Copy assignement constructor.

◆ operator=() [2/2]

template<int dim>
SysState< dim > & bitrl::dynamics::SysState< dim >::operator= ( SysState< dim > &&  other)

Move copy constructor.

◆ operator[]() [1/4]

template<int dim>
real_t & bitrl::dynamics::SysState< dim >::operator[] ( const std::string &  name)
inline

Access operator.

◆ operator[]() [2/4]

template<int dim>
const real_t & bitrl::dynamics::SysState< dim >::operator[] ( const std::string &  name) const
inline

Access operator.

◆ operator[]() [3/4]

template<int dim>
real_t & bitrl::dynamics::SysState< dim >::operator[] ( uint_t  i)

Access operator.

◆ operator[]() [4/4]

template<int dim>
const real_t & bitrl::dynamics::SysState< dim >::operator[] ( uint_t  i) const

Access operator.

◆ print()

template<int dim>
std::ostream & bitrl::dynamics::SysState< dim >::print ( std::ostream &  out) const

Print the state at the given stream.

◆ scale()

template<int dim>
void bitrl::dynamics::SysState< dim >::scale ( real_t  val)

Scale the values of the state.

◆ set() [1/3]

template<int dim>
template<typename Container >
void bitrl::dynamics::SysState< dim >::set ( const Container &  container)

Set the values.

◆ set() [2/3]

template<int dim>
void bitrl::dynamics::SysState< dim >::set ( const std::string &  name,
real_t  val 
)

Set the value for the variable name.

◆ set() [3/3]

template<int dim>
void bitrl::dynamics::SysState< dim >::set ( uint_t  i,
const std::pair< std::string, real_t > &  value 
)

Set the name and value of the i-th variable.

◆ size()

template<int dim>
uint_t bitrl::dynamics::SysState< dim >::size ( ) const
inline

Returns the size of the system.

Member Data Documentation

◆ dimension

template<int dim>
const int bitrl::dynamics::SysState< dim >::dimension = dim
static

The dimension of the state.


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