Parallel Environment Simulation with Multiprocessing
Advanced & Deep RL DS practice problem on Onlearn.
Difficulty: hard.
Topics: Understanding Parallel Environment Vectorization in Reinforcement Learning, Global Interpreter Lock (GIL) limitations, Shared Memory Buffers, Non-blocking I/O, Daemon Process Spawning, Message Passing Interface (MPI) patterns, Reinforcement Learning, Parallel Computing, Concurrency Patterns, System Architecture, Software Engineering, Environment Vectorization, Multiprocessing Pipes, Process Lifecycle Management, Asynchronous Execution, State Synchronization.
Implement a 'ParallelEnvManager' class that handles 'n' instances of a Gym like environment using the multiprocessing module. The class must support a 'step all(actions)' method that executes actions across all environments in parallel and returns a list of observations, rewards, and done flags. Ensure the implementation handles process cleanup using a close() method.