bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType > Class Template Reference

What a multi-agent environment returns after a reset or a joint step: an observation, a reward and a done flag for every agent. More...

#include <multi_agent_time_step.h>

Public Types

typedef ObservationType observation_type

Public Member Functions

 MultiAgentTimeStep ()=default
 MultiAgentTimeStep (TimeStepTp type, std::vector< observation_type > observations, std::vector< real_t > rewards, std::vector< bool > dones, bool truncated=false, std::unordered_map< std::string, std::any > extra={})
 A time step of n agents, with every vector of size n.
TimeStepTp type () const noexcept
 The type of the step: FIRST after a reset, LAST once the episode is over.
bool first () const noexcept
bool mid () const noexcept
bool last () const noexcept
 Whether the episode is over.
bool truncated () const noexcept
 Whether the step limit ended the episode before every agent was done.
uint_t n_agents () const noexcept
const observation_type & observation (uint_t agent) const
const std::vector< observation_type > & observations () const noexcept
real_t reward (uint_t agent) const
const std::vector< real_t > & rewards () const noexcept
real_t total_reward () const noexcept
 The sum of the rewards of the agents, the team's reward.
bool done (uint_t agent) const
const std::vector< bool > & dones () const noexcept
const std::unordered_map< std::string, std::any > & extra () const noexcept
 Anything else the environment reports, collisions for example.
template<typename T>
T get_extra (const std::string &name) const
 Read an entry of extra().

Detailed Description

template<typename ObservationType>
class bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >

What a multi-agent environment returns after a reset or a joint step: an observation, a reward and a done flag for every agent.

An agent is done when it finished its own task, a robot that reached its goal for example; the environment ignores its actions from then on. The episode is over, last(), when every agent is done, or when the environment stopped it at its step limit, truncated(). Agents are numbered 0, 1, ..., n_agents() - 1 in every vector.

Member Typedef Documentation

◆ observation_type

template<typename ObservationType>
typedef ObservationType bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::observation_type

Constructor & Destructor Documentation

◆ MultiAgentTimeStep() [1/2]

template<typename ObservationType>
bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::MultiAgentTimeStep ( )
default

◆ MultiAgentTimeStep() [2/2]

template<typename ObservationType>
bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::MultiAgentTimeStep ( TimeStepTp type,
std::vector< observation_type > observations,
std::vector< real_t > rewards,
std::vector< bool > dones,
bool truncated = false,
std::unordered_map< std::string, std::any > extra = {} )

A time step of n agents, with every vector of size n.

Member Function Documentation

◆ done()

template<typename ObservationType>
bool bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::done ( uint_t agent) const
inline

◆ dones()

template<typename ObservationType>
const std::vector< bool > & bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::dones ( ) const
inlinenoexcept

◆ extra()

template<typename ObservationType>
const std::unordered_map< std::string, std::any > & bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::extra ( ) const
inlinenoexcept

Anything else the environment reports, collisions for example.

◆ first()

template<typename ObservationType>
bool bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::first ( ) const
inlinenoexcept

◆ get_extra()

template<typename ObservationType>
template<typename T>
T bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::get_extra ( const std::string & name) const

Read an entry of extra().

◆ last()

template<typename ObservationType>
bool bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::last ( ) const
inlinenoexcept

Whether the episode is over.

◆ mid()

template<typename ObservationType>
bool bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::mid ( ) const
inlinenoexcept

◆ n_agents()

template<typename ObservationType>
uint_t bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::n_agents ( ) const
inlinenoexcept

◆ observation()

template<typename ObservationType>
const observation_type & bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::observation ( uint_t agent) const
inline

◆ observations()

template<typename ObservationType>
const std::vector< observation_type > & bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::observations ( ) const
inlinenoexcept

◆ reward()

template<typename ObservationType>
real_t bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::reward ( uint_t agent) const
inline

◆ rewards()

template<typename ObservationType>
const std::vector< real_t > & bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::rewards ( ) const
inlinenoexcept

◆ total_reward()

template<typename ObservationType>
real_t bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::total_reward ( ) const
inlinenoexcept

The sum of the rewards of the agents, the team's reward.

◆ truncated()

template<typename ObservationType>
bool bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::truncated ( ) const
inlinenoexcept

Whether the step limit ended the episode before every agent was done.

◆ type()

template<typename ObservationType>
TimeStepTp bitrl::envs::multi_agent::MultiAgentTimeStep< ObservationType >::type ( ) const
inlinenoexcept

The type of the step: FIRST after a reset, LAST once the episode is over.


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