Abstract
ObjectRL is an open-source Python codebase for deep reinforcement learning (RL), designed for research-oriented prototyping with minimal programming effort. Unlike existing codebases, ObjectRL is built on Object-Oriented Programming (OOP) principles, providing a clear structure that simplifies the implementation, modification, and evaluation of new algorithms. ObjectRL lowers the entry barrier for deep RL research by organizing best practices into explicit, clearly separated components, making them easier to understand and adapt. Each algorithmic component is a class with attributes that describe key RL concepts and methods that intuitively reflect their interactions. The class hierarchy closely follows common ontological relationships, enabling data encapsulation, inheritance, and polymorphism, which are core features of OOP. We demonstrate the efficiency of ObjectRL's design through representative use cases that highlight its flexibility and suitability for rapid prototyping.
Introduction: The Codebase Dilemma
Deep Reinforcement Learning (RL) research is often hindered by a significant "codebase dilemma." Researchers typically choose between two extremes: monolithic, single-file implementations that are readable but brittle, or production-grade frameworks that offer scalability at the cost of extreme complexity and steep learning curves. For a researcher wanting to test a specific modification—such as a new exploration bonus or a custom loss function—navigating these existing structures can be prohibitively time-consuming.
ObjectRL aims to fill this gap by providing a modular and intuitive structure that mirrors the conceptual building blocks of RL theory. By applying strict Object-Oriented Programming (OOP) principles, ObjectRL allows for rapid prototyping and modification with significantly less boilerplate than traditional frameworks.
The ObjectRL Architecture
The core philosophy of ObjectRL is the application of the four pillars of OOP—encapsulation, inheritance, composition, and polymorphism—to the domain of RL. This design ensures that algorithmic components are decoupled into independent, reusable classes.
Key Design Principles
- Encapsulation: Components like the Agent, Actor, Critic, and Replay Buffer are dedicated classes. This isolation ensures that modifications to one component, such as a Critic's network architecture, do not inadvertently affect the logic of another, like the Actor.
- Inheritance and Composition: Rather than rewriting algorithms, researchers can leverage inheritance. For instance, a
SACActorinherits from a baseActorclass, while aSoftActorCriticagent is composed of specific actor and critic instances. - Polymorphism: A common interface allows for seamless swapping of components. A deterministic actor can be replaced by a stochastic one without altering the main training loop, as both adhere to the same
select_action()method signature. - Ontology-Driven Design: The class hierarchy follows a "class ontology" that reflects the natural interactions of RL concepts, making the code a direct translation of theoretical RL frameworks.
Experimental Validation
To validate the codebase, we benchmarked a variety of algorithms using the Gymnasium interface on the MuJoCo suite, including standard environments like Ant-v4, HalfCheetah-v4, Hopper-v4, Humanoid-v4, and Walker2d-v4.
Performance Benchmarks
We implemented a wide array of algorithms, ranging from established baselines (DQN, DDPG, PPO, TD3, SAC) to more advanced exploration methods (OAC, REDQ, DRND, PBAC). The results demonstrate that ObjectRL’s modular implementations achieve performance parity with established baselines across all tasks.
As shown in the performance curves, algorithms like DRND, SAC, and PBAC converge to high return values within 1 million timesteps on the Cheetah environment. These results confirm that the library's abstractions do not sacrifice algorithmic correctness or computational performance.
Discussion and Future Work
ObjectRL excels at research prototyping by providing a structured configuration system using Python dataclasses, which avoids the "nested dictionary hell" common in deep learning projects. This makes hyperparameters easier to manage and track.
While the library is highly flexible, it is currently optimized for single-machine research rather than massive, multi-GPU distributed computing. Future work will focus on expanding environment support beyond standard continuous control tasks and integrating emerging RL paradigms like offline RL and multi-agent systems. The modular design of ObjectRL is uniquely suited for such expansions, as new paradigms can be integrated by simply adding new class definitions to the existing ontology.
Conclusion
ObjectRL provides a robust, OOP-based foundation for deep RL research. By lowering the entry barrier and reducing programming overhead, it enables researchers to focus on algorithmic innovation rather than codebase maintenance.
Source Code: github.com/adinlab/objectrl
Documentation: objectrl.readthedocs.io
Summary updated