bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitrl::rl::multi_agent::QLearningAgent Class Reference

One agent of a multi-agent environment that learns its own Q-table with Q-learning, as if the others were part of the environment. More...

#include <q_learning_agent.h>

Classes

struct  Greedy
 An actor that acts greedily with this table. More...

Public Types

typedef uint_t action_type

Public Member Functions

 QLearningAgent (uint_t agent, uint_t n_states, uint_t n_actions, const IndependentQLearningConfig &config={})
uint_t agent () const noexcept
 The index of the agent in the time steps.
template<typename TimeStepType>
uint_t act (const TimeStepType &step)
 An exploring action; 0 if the agent is done.
template<typename TimeStepType>
uint_t act_greedy (const TimeStepType &step) const
 The greedy action; 0 if the agent is done.
template<typename TimeStepType>
void update (const TimeStepType &step, uint_t action, const TimeStepType &next)
 Learn from the transition step –action--> next; nothing once the agent is done.
void on_episode_begin (uint_t)
void on_episode_end (uint_t episode)
 Decay the exploration.
real_t epsilon () const noexcept
const DynMat< real_t > & q_table () const noexcept
Greedy greedy () const

Detailed Description

One agent of a multi-agent environment that learns its own Q-table with Q-learning, as if the others were part of the environment.

It reads its own observation, reward and done flag from the multi-agent time steps, and explores with an epsilon-greedy policy whose generator is seeded with bitsim::utils::concurrency::task_seed(config.seed, agent). IndependentQLearning is a team of them; on its own, the agent can learn in a process of its own, see bitrl::envs::multi_agent::DistributedAgentEnv, and learns there exactly what it learns in the team.

Member Typedef Documentation

◆ action_type

Constructor & Destructor Documentation

◆ QLearningAgent()

bitrl::rl::multi_agent::QLearningAgent::QLearningAgent ( uint_t agent,
uint_t n_states,
uint_t n_actions,
const IndependentQLearningConfig & config = {} )
inline

Member Function Documentation

◆ act()

template<typename TimeStepType>
uint_t bitrl::rl::multi_agent::QLearningAgent::act ( const TimeStepType & step)

An exploring action; 0 if the agent is done.

◆ act_greedy()

template<typename TimeStepType>
uint_t bitrl::rl::multi_agent::QLearningAgent::act_greedy ( const TimeStepType & step) const

The greedy action; 0 if the agent is done.

◆ agent()

uint_t bitrl::rl::multi_agent::QLearningAgent::agent ( ) const
inlinenoexcept

The index of the agent in the time steps.

◆ epsilon()

real_t bitrl::rl::multi_agent::QLearningAgent::epsilon ( ) const
inlinenoexcept

◆ greedy()

Greedy bitrl::rl::multi_agent::QLearningAgent::greedy ( ) const
inline

◆ on_episode_begin()

void bitrl::rl::multi_agent::QLearningAgent::on_episode_begin ( uint_t )
inline

◆ on_episode_end()

void bitrl::rl::multi_agent::QLearningAgent::on_episode_end ( uint_t episode)
inline

Decay the exploration.

◆ q_table()

const DynMat< real_t > & bitrl::rl::multi_agent::QLearningAgent::q_table ( ) const
inlinenoexcept

◆ update()

template<typename TimeStepType>
void bitrl::rl::multi_agent::QLearningAgent::update ( const TimeStepType & step,
uint_t action,
const TimeStepType & next )

Learn from the transition step –action--> next; nothing once the agent is done.


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