|
| template<typename... Args> |
| | ParallelEnvs (uint_t n, Args &&...args) |
| | n copies, each built with args
|
| void | make (const std::string &version, const std::unordered_map< std::string, std::any > &make_options, const std::unordered_map< std::string, std::any > &reset_options) |
| | Make every copy with the same options; copy i resets first with the seed task_seed(seed, i), where seed is the reset option "seed" (42 if not given).
|
| const std::vector< time_step_type > & | reset () |
| | Start a new episode in every copy, each with its next seed.
|
| const std::vector< time_step_type > & | step (const std::vector< action_type > &actions) |
| | Step every copy whose episode is not over with its action.
|
| uint_t | size () const noexcept |
| bool | done (uint_t i) const |
| | Whether the episode of copy i is over.
|
| bool | all_done () const |
| | Whether the episode of every copy is over.
|
| const std::vector< time_step_type > & | time_steps () const noexcept |
| EnvType & | env (uint_t i) |
| const EnvType & | env (uint_t i) const |
| void | set_pool (bitsim::utils::concurrency::ThreadPool &pool) noexcept |
| | Step on the threads of pool, the default pool if not set.
|
| void | use_threads (bool threads) noexcept |
| | Step on threads, or on this thread one copy after the other.
|
| bool | is_created () const noexcept |
| void | close () |
| | Close every copy.
|
template<typename EnvType>
class bitrl::envs::ParallelEnvs< EnvType >
Several copies of an environment, stepped at the same time on the threads of a bitsim::utils::concurrency::ThreadPool.
step() takes an action per copy and steps every copy whose episode is not over; a copy whose episode is over keeps its last time step, and ignores its action, until the next reset(). Every copy is an environment of its own, so the copies share nothing, and what they do does not depend on the threads: a run with one thread is the same as one with many.
Stepping on threads pays off for environments that take time: a physics engine, a server over the network. For a cheap environment, step them on this thread, with use_threads(false); what is left to gain then is in acting for all the copies at once, as ParallelPPOSolver does.
- Template Parameters
-