bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType > Class Template Referencefinal

A2C solver assuming separate networks for the actor and the critic. Similar to the Reinforce algorithm implementation, the PolicyType should expose an act method with the following signature. More...

#include <a2c.h>

Inheritance diagram for bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >:
Collaboration diagram for bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >:

Public Types

typedef EnvType env_type
 The environment type.
typedef PolicyType policy_type
 The policy or action type.
typedef CriticType critic_type
 The critic type.
typedef env_type::state_type state_type
typedef env_type::action_type action_type
typedef A2CMonitor< action_type, state_type >::experience_buffer_type experience_buffer_type
Public Types inherited from bitrl::rl::algos::RLSolverBase< EnvType >
typedef EnvType env_type

Public Member Functions

 A2CSolver (const A2CConfig &config, policy_type &policy, critic_type &critic, std::unique_ptr< torch::optim::Optimizer > &policy_optimizer, std::unique_ptr< torch::optim::Optimizer > &critic_optimizer)
 A2C.
virtual void actions_before_training_begins (env_type &)
 actions_before_training_begins. Execute any actions the algorithm needs before starting the iterations
virtual void actions_after_training_ends (env_type &) override final
 actions_after_training_ends. Actions to execute after the training iterations have finisehd
virtual void actions_before_episode_begins (env_type &, uint_t) override final
 actions_before_training_episode
virtual void actions_after_episode_ends (env_type &, uint_t, const EpisodeInfo &) override final
 actions_after_training_episode
virtual EpisodeInfo on_training_episode (env_type &, uint_t)
 on_episode Do one on_episode of the algorithm
void set_train_mode () noexcept
 set_train_mode for both the Actor and the Critic
void set_evaluation_mode () noexcept
 set_evaluation_mode for both the Actor and the Critic
A2CMonitor< action_type, state_type > & get_monitor ()
 Read-write access to the monitor object.
Public Member Functions inherited from bitrl::rl::algos::RLSolverBase< EnvType >
virtual ~RLSolverBase ()=default
 Destructor.

Additional Inherited Members

Protected Member Functions inherited from bitrl::rl::algos::RLSolverBase< EnvType >
 RLSolverBase ()=default
 Constructor.

Detailed Description

template<typename EnvType, typename PolicyType, typename CriticType>
class bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >

A2C solver assuming separate networks for the actor and the critic. Similar to the Reinforce algorithm implementation, the PolicyType should expose an act method with the following signature.

std::tuple[ActioType, torch::Tensor> act(StateType)

In addition the CriticType should expose an evaluate method with the following signature

torch::Tensor evaluate(StateType)

Member Typedef Documentation

◆ action_type

template<typename EnvType, typename PolicyType, typename CriticType>
typedef env_type::action_type bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::action_type

◆ critic_type

template<typename EnvType, typename PolicyType, typename CriticType>
typedef CriticType bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::critic_type

The critic type.

◆ env_type

template<typename EnvType, typename PolicyType, typename CriticType>
typedef EnvType bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::env_type

The environment type.

◆ experience_buffer_type

template<typename EnvType, typename PolicyType, typename CriticType>
typedef A2CMonitor<action_type,state_type>::experience_buffer_type bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::experience_buffer_type

◆ policy_type

template<typename EnvType, typename PolicyType, typename CriticType>
typedef PolicyType bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::policy_type

The policy or action type.

◆ state_type

template<typename EnvType, typename PolicyType, typename CriticType>
typedef env_type::state_type bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::state_type

Constructor & Destructor Documentation

◆ A2CSolver()

template<typename EnvType, typename PolicyType, typename CriticType>
bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::A2CSolver ( const A2CConfig & config,
policy_type & policy,
critic_type & critic,
std::unique_ptr< torch::optim::Optimizer > & policy_optimizer,
std::unique_ptr< torch::optim::Optimizer > & critic_optimizer )

A2C.

Parameters
config
policy

Member Function Documentation

◆ actions_after_episode_ends()

template<typename EnvType, typename PolicyType, typename CriticType>
virtual void bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::actions_after_episode_ends ( env_type & ,
uint_t ,
const EpisodeInfo &  )
inlinefinaloverridevirtual

actions_after_training_episode

Reimplemented from bitrl::rl::algos::RLSolverBase< EnvType >.

◆ actions_after_training_ends()

template<typename EnvType, typename PolicyType, typename CriticType>
virtual void bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::actions_after_training_ends ( env_type & )
inlinefinaloverridevirtual

actions_after_training_ends. Actions to execute after the training iterations have finisehd

Implements bitrl::rl::algos::RLSolverBase< EnvType >.

◆ actions_before_episode_begins()

template<typename EnvType, typename PolicyType, typename CriticType>
virtual void bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::actions_before_episode_begins ( env_type & ,
uint_t  )
inlinefinaloverridevirtual

actions_before_training_episode

Reimplemented from bitrl::rl::algos::RLSolverBase< EnvType >.

◆ actions_before_training_begins()

template<typename EnvType, typename PolicyType, typename CriticType>
void bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::actions_before_training_begins ( env_type & )
virtual

actions_before_training_begins. Execute any actions the algorithm needs before starting the iterations

Implements bitrl::rl::algos::RLSolverBase< EnvType >.

◆ get_monitor()

template<typename EnvType, typename PolicyType, typename CriticType>
A2CMonitor< action_type, state_type > & bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::get_monitor ( )
inline

Read-write access to the monitor object.

◆ on_training_episode()

template<typename EnvType, typename PolicyType, typename CriticType>
EpisodeInfo bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::on_training_episode ( env_type & env,
uint_t episode_idx )
virtual

on_episode Do one on_episode of the algorithm

Implements bitrl::rl::algos::RLSolverBase< EnvType >.

◆ set_evaluation_mode()

template<typename EnvType, typename PolicyType, typename CriticType>
void bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::set_evaluation_mode ( )
noexcept

set_evaluation_mode for both the Actor and the Critic

◆ set_train_mode()

template<typename EnvType, typename PolicyType, typename CriticType>
void bitrl::rl::algos::pg::A2CSolver< EnvType, PolicyType, CriticType >::set_train_mode ( )
noexcept

set_train_mode for both the Actor and the Critic


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