How pku-marl/harl works
Main Components
• Environment Interfaces and Wrappers:
– These are implemented under the “harl/envs” directory and subdirectories (e.g. “dexhands”, “football”, “gym”, “lag”, “mamujoco”, “pettingzoo_mpe”, “smac”, “smacv2”).
– Their role is to provide a unified API (wrap-reset-step-render interfaces) that hide environment-specific details.
• HARL Algorithms:
– Located under “harl/algorithms” (with further segregation into “actors” for policy updates and “critics” for value functions) and base classes under “harl/algorithms/actors/on_policy_base.py” and “off_policy_base.py”.
– This is where heterogeneous update schemes (e.g. the sequential update scheme) are implemented.
• Model Definitions:
– Found in “harl/models”, this includes policy models (under “policy_models”) and value function models (in “value_function_models”).
– They are built using standard deep network architectures (CNNs, MLPs, RNNs, etc.), as defined in “harl/models/base”.
• Training Runners:
– Under “harl/runners”, these files (such as “off_policy_base_runner.py”, “on_policy_base_runner.py”, etc.) orchestrate training by interacting with the algorithm implementations, environment interfaces, and models.
– They manage the training loop, logging, saving, and (optionally) rendering.
• Configuration Management:
– “harl/configs” houses configuration files (YAML) for algorithms and for environment settings.
– Additionally, tuned configuration files are provided under “tuned_configs” for reproducing experiments.
• Utilities and Helpers:
– The “harl/utils” folder contains configuration tools, logging and data transformation utilities to support smooth integration between components.
• Logging and Experiment Management:
– Loggers are implemented under “harl/common/base_logger.py” and several environment-specific loggers exist in each environment folder.
– They output feedback and metrics during training.
• Examples and Entry Points:
– The “examples” folder contains the main training scripts (train.py, train.sh) that users execute.
– They tie together configuration, algorithm, runner, and environment layers to launch training experiments.
Architectural Patterns and Design Principles
• Modularity/Separation of Concerns:
– Each major package (algorithms, models, environments, configurations) is clearly segregated, making it easy for researchers to modify or extend specific parts without impacting others.
• Abstraction and Interface Hiding:
– The environment interfaces abstract away details from external systems such as SMAC, Bi-DexterousHands, etc.
– The runner and configuration tools are designed for easy reproduction of experiments.
• Extensibility:
– New algorithms or environments can be plugged into the existing training loop by following the implemented abstractions.
– Core algorithm components (policy, critics, runners)
– External interfaces (environments)
– Support utilities (logging, configuration management)
• Notes or small callouts about key design decisions such as “sequential update scheme” or “unified environment interface” to capture the distinctive ideas of HARL.
• Detail the flow:
1. Experiment setup (configs, tuned_configs, CLI parameters)
2. Training Runner initializes algorithm objects and model networks
3. Algorithm modules interact with environment interfaces to generate experiences
4. Experiences are processed by utility modules (e.g., buffers, loggers) and update the model parameters
5. Logging and performance metrics are pushed back to the user