|
bitsim
Model, simulate, estimate and control robots in C++
|
One agent of a multi-agent environment, in a process of its own. More...
#include <distributed_agent_env.h>
Public Types | |
| typedef EnvType | env_type |
| typedef EnvType::time_step_type | time_step_type |
| typedef EnvType::action_type | action_type |
| typedef EnvType::observation_type | observation_type |
| typedef EnvType::joint_action_type | joint_action_type |
Public Member Functions | |
| DistributedAgentEnv (EnvType &env, uint_t agent, bitsim::distributed::Transport &transport, const DistributedAgentConfig &config={}) | |
| time_step_type | reset () |
| Start a new episode with the next seed of the copy. | |
| time_step_type | reset (uint_t seed) |
| Start a new episode with seed; every participant must use the same. | |
| time_step_type | step (const action_type &action) |
| Send this agent's action, wait for the others', and step the copy. | |
| void | leave () |
| Tell the others that this participant stops. | |
| uint_t | agent () const noexcept |
| uint_t | n_agents () const noexcept |
| const EnvType & | env () const noexcept |
| const bitsim::distributed::Synchroniser & | synchroniser () const noexcept |
One agent of a multi-agent environment, in a process of its own.
Every agent of the environment is a participant with its own DistributedAgentEnv: a thread, a process or a machine, meeting the others through a bitsim::distributed::Transport. Every participant holds a copy of the whole environment, made with the same options, and only the actions travel: step() sends this agent's action, waits for the actions of the others at the same step, with bitsim::distributed::Synchroniser in lockstep, and steps its copy with the joint action. The copies start alike and get the same joint actions, so they stay alike, and the episodes are the same as in one process. That suits environments that are cheap next to the agents, such as a learner or a controller per robot, or a real robot's on-board computer, and that are deterministic; bitsim's distributed simulation, where every participant simulates only its own robots, suits worlds that are not.
With check_replicas, every action comes with a checksum of the observation its agent acted on, and step() throws if it is not the observation of that agent in this copy: an environment that is not deterministic, made with other options, or reset with another seed.
The time steps are those of the copy, so they hold the observation and the reward of every agent; a decentralised agent reads only its own, observation(agent()).
| EnvType | a bitrl::envs::multi_agent::MultiAgentEnvBase |
| typedef EnvType::action_type bitrl::envs::multi_agent::DistributedAgentEnv< EnvType >::action_type |
| typedef EnvType bitrl::envs::multi_agent::DistributedAgentEnv< EnvType >::env_type |
| typedef EnvType::joint_action_type bitrl::envs::multi_agent::DistributedAgentEnv< EnvType >::joint_action_type |
| typedef EnvType::observation_type bitrl::envs::multi_agent::DistributedAgentEnv< EnvType >::observation_type |
| typedef EnvType::time_step_type bitrl::envs::multi_agent::DistributedAgentEnv< EnvType >::time_step_type |
| bitrl::envs::multi_agent::DistributedAgentEnv< EnvType >::DistributedAgentEnv | ( | EnvType & | env, |
| uint_t | agent, | ||
| bitsim::distributed::Transport & | transport, | ||
| const DistributedAgentConfig & | config = {} ) |
| env | the copy of the environment, made; it must outlive this |
| agent | the agent this participant is |
| transport | where the participants meet; it must outlive this |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
Tell the others that this participant stops.
|
inlinenoexcept |
|
inline |
Start a new episode with the next seed of the copy.
|
inline |
Start a new episode with seed; every participant must use the same.
| DistributedAgentEnv< EnvType >::time_step_type bitrl::envs::multi_agent::DistributedAgentEnv< EnvType >::step | ( | const action_type & | action | ) |
Send this agent's action, wait for the others', and step the copy.
| std::runtime_error | if a peer did not send the step within timeout, or with check_replicas if the copies differ |
|
inlinenoexcept |