A comprehensive research project investigating Evolution Strategies as pretraining mechanisms for Deep Reinforcement Learning algorithms
รcole Polytechnique Fรฉdรฉrale de Lausanne (EPFL)
In collaboration with Swiss Data Science Center
- ๐ Research Poster
- ๐ Abstract
- ๐ฏ Research Motivation
- ๐ Research Materials
- ๐งฎ Mathematical Formulation
- ๐๏ธ Architecture & Implementation
- ๐ Getting Started
- โ๏ธ Configuration
- ๐งช Experimental Results
- ๐ Monitoring & Logging
- ๐ฌ Reproducing Paper Results
- ๐ก Key Insights & Takeaways
- ๐ Citation
- ๐ฅ Authors
- ๐ Acknowledgments
Click the badge above to view the full research poster (PDF)
๐ Full Paper: RL_project.pdf
MuJoCo Humanoid Agent Trained with Evolution Strategies
https://github.com/MarioRicoIbanez/ES_DRL/assets/sim.mp4
๐ฅ Simulation Video: sim.mp4 - Watch the trained agent in action!
Although Deep Reinforcement Learning has proven highly effective for complex decision-making problems, it demands significant computational resources and careful parameter adjustment in order to develop successful strategies. Evolution strategies offer a more straightforward, derivative-free approach that is less computationally costly and simpler to deploy. However, ES generally do not match the performance levels achieved by DRL, which calls into question their suitability for more demanding scenarios.
This study examines the performance of ES and DRL across tasks of varying difficulty, including Flappy Bird, Breakout, and MuJoCo environments, as well as whether ES could be used for initial training to enhance DRL algorithms.
Key Findings:
- โ ES accelerates early learning in simple environments (Flappy Bird)
- โ ES struggles with high-dimensional state spaces (Breakout)
โ ๏ธ ES pretraining shows limited benefit for complex tasks (MuJoCo)- ๐ DRL algorithms achieve better final performance but require more tuning
|
๐ฌ Research Focus
|
๐ ๏ธ Technologies Used
|
|
๐ Environments Tested
|
โจ Key Contributions
|
Traditional Deep Reinforcement Learning approaches often require:
- Extensive training time and computational resources
- Careful hyperparameter tuning for convergence
- Gradient computation through complex backpropagation
Evolution Strategies offer an alternative:
- โจ Gradient-free optimization
- ๐ Simpler implementation and parallelization
- ๐ฐ Lower computational cost per update
- ๐ฒ Robust exploration through parameter space perturbations
Research Questions:
- Can ES reach intermediate performance benchmarks faster than DRL?
- Can ES serve as effective pretraining to improve DRL training speed and robustness?
This repository contains the complete implementation of the research presented in our paper:
| Resource | Description | Link |
|---|---|---|
| ๐ Full Paper | Complete research paper with detailed methodology and analysis | RL_project.pdf |
| ๐จ Research Poster | Visual summary of findings presented at EPFL | Poster PDF |
| ๐ฅ Demo Video | MuJoCo Humanoid agent trained with ES | sim.mp4 |
| ๐ป Source Code | Full implementation with experiments | This repository |
Publication Details:
- Institution: รcole Polytechnique Fรฉdรฉrale de Lausanne (EPFL)
- Collaboration: Swiss Data Science Center
- Year: 2025
- Conference: NeurIPS 2024 Format
Evolution Strategies optimize a smoothed version of the objective function through parameter perturbations:
Objective Function:
where:
-
$\theta$ = policy parameters -
$F(\theta)$ = total reward (fitness) for parameters$\theta$ -
$\sigma$ = noise standard deviation -
$\epsilon$ = Gaussian perturbation vector
Gradient Estimation:
Using the log-likelihood trick, the gradient can be estimated as:
Monte Carlo Approximation:
With
Update Rule:
where
Algorithm Pseudocode:
# Evolution Strategies Training Loop
def train_ES(policy, population_size, sigma, learning_rate, num_generations):
theta = initialize_parameters(policy)
for generation in range(num_generations):
# 1. Generate population
perturbations = [sample_gaussian() for _ in range(population_size)]
# 2. Evaluate fitness
rewards = []
for epsilon in perturbations:
theta_perturbed = theta + sigma * epsilon
reward = evaluate_policy(theta_perturbed)
rewards.append(reward)
# 3. Estimate gradient
gradient = (1 / (population_size * sigma)) * sum(
reward * epsilon for reward, epsilon in zip(rewards, perturbations)
)
# 4. Update parameters
theta = theta + learning_rate * gradient
return thetaKey Advantages:
- ๐ No backpropagation required
- ๐ Highly parallelizable
- ๐ Variance independent of episode length
- ๐ฏ Effective in sparse reward settings
DQN approximates the optimal action-value function using a neural network:
Bellman Optimality Equation:
Loss Function:
where the target is:
and
PPO uses a clipped surrogate objective for stable policy updates:
Clipped Objective:
where:
-
$r_t(\theta) = \frac{\pi_\theta(a_t|s_t)}{\pi_{\theta_{old}}(a_t|s_t)}$ is the probability ratio -
$\hat{A}_t$ is the advantage estimate -
$\epsilon$ is the clipping parameter (typically 0.2)
ES_DRL/
โโโ src/es_drl/
โ โโโ main_es.py # Main training script for ES
โ โโโ main_finetune.py # Main script for DRL fine-tuning
โ โโโ es/
โ โ โโโ base.py # Base ES class with common functionality
โ โ โโโ basic_es.py # Basic ES implementation
โ โ โโโ brax_training_utils.py # Training utilities for Brax
โ โ โโโ ppo.py # PPO implementation
โ โ โโโ ppo_training_utils.py # PPO training utilities
โ โ โโโ pretraining.py # ES + DRL pretraining strategy
โ โ โโโ tr_es.py # Trust-region ES variant
โ โโโ dpg/
โ โ โโโ td3_trainer.py # TD3 implementation
โ โโโ utils/
โ โโโ callbacks.py # Training callbacks
โ โโโ logger.py # Logging utilities
โโโ configs/
โ โโโ common.yaml # Common configuration
โ โโโ es/ # ES-specific configs
โ โ โโโ basic_es.yaml
โ โ โโโ ppo.yaml
โ โ โโโ pretraining.yaml
โ โ โโโ tr_es.yaml
โ โโโ td3/ # TD3-specific configs
โ โ โโโ td3_finetune.yaml
โ โโโ [environment].yaml # Environment-specific configs
โโโ scripts/
โ โโโ env.sh # Environment setup
โ โโโ run_es.sh # ES training script
โ โโโ run_finetune.sh # Fine-tuning script
โโโ results/ # Training results and plots
โโโ requirements.txt # Python dependencies
โโโ RL_project.pdf # Full research paper
โโโ Evolution_Strategies_for_Deep_RL_pretraining___Poster.pdf
- Policy Network: Fully connected MLP
- Hidden layers: [64, 64] with Tanh activation
- Output: Q-values for each discrete action
- Parameters: ~4,000 (Flappy Bird), ~850,000 (Breakout CNN)
-
Actor Network: Fully connected MLP
- Hidden layers: [32, 32, 32, 32]
- Output: Mean and std for action distribution
- Parameters: ~10,000 - 15,000 depending on environment
-
Critic Network (PPO only):
- Same architecture as actor
- Output: Single value estimate
- Python 3.8+
- CUDA-capable GPU (recommended for faster training)
- 8GB+ RAM
- Clone the repository:
git clone https://github.com/MarioRicoIbanez/ES_DRL.git
cd ES_DRL- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Verify installation:
python -c "import jax; import brax; print('โ Installation successful!')"Train an agent in 30 seconds:
# Evolution Strategies on Walker2d
python src/es_drl/main_es.py --config configs/es/basic_es.yaml --env_config configs/walker2d.yaml --seed 42
# PPO on Hopper
python src/es_drl/main_es.py --config configs/es/ppo.yaml --env_config configs/hopper.yaml --seed 42
# ES Pretraining โ PPO Fine-tuning
python src/es_drl/main_es.py --config configs/es/pretraining.yaml --env_config configs/hopper.yaml --seed 42# Basic ES training on Walker2d
python src/es_drl/main_es.py \
--config configs/es/basic_es.yaml \
--env_config configs/walker2d.yaml \
--seed 42
# ES training on Hopper
python src/es_drl/main_es.py \
--config configs/es/basic_es.yaml \
--env_config configs/hopper.yaml \
--seed 42# PPO training on Walker2d
python src/es_drl/main_es.py \
--config configs/es/ppo.yaml \
--env_config configs/walker2d.yaml \
--seed 42# Step 1: Pretrain with ES
python src/es_drl/main_es.py \
--config configs/es/pretraining.yaml \
--env_config configs/hopper.yaml \
--seed 42
# Step 2: Fine-tune with PPO (automatically loads ES weights)
python src/es_drl/main_finetune.py \
--config configs/td3/td3_finetune.yaml \
--env_config configs/hopper.yaml \
--pretrained_path results/es/hopper/checkpoint.pkl \
--seed 42# Set up environment variables
source scripts/env.sh
# Run ES training
bash scripts/run_es.sh walker2d 42
# Run fine-tuning
bash scripts/run_finetune.sh walker2d 42Training is configured through YAML files with hierarchical structure:
Common Settings (configs/common.yaml):
training:
num_timesteps: 1000000
episode_length: 1000
num_envs: 2048
logging:
wandb_project: "es-drl"
log_interval: 100
save_interval: 1000ES-Specific (configs/es/basic_es.yaml):
algorithm:
name: "basic_es"
sigma: 0.05 # Noise standard deviation
population_size: 128 # Number of perturbations per iteration
learning_rate: 0.01 # Update step size
elite_fraction: 0.2 # Top performers for fitness shaping
network:
hidden_sizes: [32, 32, 32, 32]
activation: "tanh"PPO-Specific (configs/es/ppo.yaml):
algorithm:
name: "ppo"
learning_rate: 3e-4
batch_size: 512
num_minibatches: 32
num_updates_per_batch: 64
gamma: 0.997 # Discount factor
gae_lambda: 0.95 # GAE parameter
clip_epsilon: 0.2 # PPO clipping parameter
entropy_coef: 0.0
value_coef: 0.5Environment-Specific (configs/walker2d.yaml):
environment:
name: "walker2d"
backend: "brax" # Physics engine
reward_scaling: 5.0
# Environment parameters
ctrl_cost_weight: 1e-3
forward_reward_weight: 1.0
healthy_reward: 1.0
healthy_z_range: [0.8, 2.0]| Parameter | ES | PPO | Description |
|---|---|---|---|
population_size |
128 | - | Number of parameter perturbations |
sigma |
0.05 | - | Noise standard deviation for ES |
learning_rate |
0.01 | 3e-4 | Step size for updates |
num_envs |
- | 2048-8192 | Parallel environments for PPO |
gamma |
0.99 | 0.997 | Discount factor |
clip_epsilon |
- | 0.2 | PPO clipping parameter |
| Environment | Type | State Dim | Action Dim | Complexity |
|---|---|---|---|---|
| Flappy Bird | Discrete | Low (~10) | 2 | Simple |
| Breakout | Discrete | High (84ร84ร4) | 4 | Medium |
| Hopper | Continuous | 11 | 3 | Medium |
| Walker2d | Continuous | 17 | 6 | High |
| HalfCheetah | Continuous | 17 | 6 | High |
โ ES shows strong early performance
- Quickly finds stable policies
- Reaches intermediate rewards ~5x faster than DQN
- Effective pretraining for DQN acceleration
๐ Results:
- ES: Converges in ~100 episodes
- DQN: Requires ~500 episodes for similar performance
- ESโDQN: Reaches high rewards ~2x faster than DQN alone
โ ES struggles with complexity
- Plateaus at mean reward ~1.5 (image-based)
- Limited improvement even with large populations (n=50)
- RAM-based input (128-D) only marginally better (reward ~4)
๐ฏ DQN outperforms:
- Achieves mean reward ~30
- CNN architecture effectively processes visual input
- Higher variance but better final performance
HalfCheetah:
- โ PPO converges 20ร faster than ES
- โ ES pretraining provides no benefit
Walker2d:
- โ PPO fails to converge consistently
โ ๏ธ ES shows stable but slow learning- โ ES pretraining doesn't improve PPO robustness
Hopper:
โ ๏ธ PPO shows high variance across seeds- โ ES demonstrates more stable training
- โ ES pretraining doesn't enhance PPO performance
Algorithm Performance Across Key Metrics
| Method | Training Speed | Final Performance | Stability | Hyperparameter Sensitivity | Best Use Case |
|---|---|---|---|---|---|
| ES | ๐ก Moderate | ๐ก Moderate | ๐ข High | ๐ข Low | Simple environments, initial exploration |
| DQN/PPO | ๐ข Fast* | ๐ข High | ๐ก Moderate | ๐ด High | Complex tasks when tuned |
| ESโDRL | ๐ข Fast** | ๐ข High | ๐ก Moderate | ๐ก Moderate | Simple to medium complexity |
*When properly tuned | **Only in simple environments
| Environment | ES Performance | DRL Performance | ES Pretraining Benefit | Winner |
|---|---|---|---|---|
| Flappy Bird | ๐ข Good | ๐ข Excellent | โ Significant | ESโDQN |
| Breakout | ๐ด Poor | ๐ข Excellent | โ None | DQN |
| HalfCheetah | ๐ก Moderate | ๐ข Excellent | โ None | PPO |
| Hopper | ๐ก Moderate | ๐ก Unstable | โ None | ES (stability) |
| Walker2d | ๐ก Moderate | ๐ด Poor | โ None | ES |
Legend:
- ๐ข Excellent/High - ๐ก Moderate/Medium - ๐ด Poor/Low
- โ
Beneficial - โ Not beneficial -
โ ๏ธ Conditional
All experiments are tracked using W&B:
# Automatic logging includes:
- Episode rewards (mean, std, min, max)
- Training time and timesteps
- Parameter statistics (norm, updates)
- Environment-specific metrics
- Videos of agent behaviorView logs:
wandb login
# Logs automatically sync to your W&B projectCSV files are saved to results/[algorithm]/[environment]/:
results/
โโโ es/
โโโ walker2d/
โโโ basic_es_seed42.csv
โโโ basic_es_seed42.png
โโโ checkpoints/
โโโ generation_1000.pkl
Generate training plots:
python scripts/plot_results.py \
--results_dir results/es/walker2d \
--output plots/walker2d_comparison.png# ES training
python src/es_drl/main_es.py \
--config configs/es/basic_es.yaml \
--env_config configs/flappy_bird.yaml \
--seed 42
# DQN training
python src/es_drl/main_es.py \
--config configs/dqn/dqn.yaml \
--env_config configs/flappy_bird.yaml \
--seed 42
# ES pretraining + DQN fine-tuning
python src/es_drl/main_es.py \
--config configs/es/pretraining.yaml \
--env_config configs/flappy_bird.yaml \
--seed 42# ES on RAM-based input
python src/es_drl/main_es.py \
--config configs/es/basic_es.yaml \
--env_config configs/breakout_ram.yaml \
--seed 42
# DQN on image-based input
python src/es_drl/main_es.py \
--config configs/dqn/dqn_cnn.yaml \
--env_config configs/breakout.yaml \
--seed 42# Run all MuJoCo experiments with different seeds
for env in hopper walker2d halfcheetah; do
for seed in 42 123 456; do
# ES
python src/es_drl/main_es.py \
--config configs/es/basic_es.yaml \
--env_config configs/${env}.yaml \
--seed ${seed}
# PPO
python src/es_drl/main_es.py \
--config configs/es/ppo.yaml \
--env_config configs/${env}.yaml \
--seed ${seed}
# ESโPPO pretraining
python src/es_drl/main_es.py \
--config configs/es/pretraining.yaml \
--env_config configs/${env}.yaml \
--seed ${seed}
done
doneโ ES is effective for:
- Simple environments with low-dimensional state spaces
- Sparse or deceptive reward landscapes
- Quick prototyping and initial exploration
- Parallel computation with limited communication
- Non-differentiable environments
โ ES struggles with:
- High-dimensional observations (images, complex sensors)
- Environments requiring fine-grained control
- Tasks demanding very high final performance
- Long-horizon temporal dependencies
Effective pretraining requires:
- โ Environment simplicity (low-dimensional states)
- โ Architectural compatibility (ES and DRL networks must align)
- โ Sparse rewards where ES excels at initial exploration
- โ Not recommended for actor-critic methods (PPO, SAC) where ES only optimizes actor
Limitation: ES pretraining is less effective for actor-critic algorithms (PPO, SAC) because:
- ES optimizes a single policy network
- Actor-critic methods require separate value functions
- Transferring only the actor may not provide sufficient benefit
Future directions:
- Co-evolving actor and critic networks
- Architecture-aware hybrid approaches
- Adaptive transfer strategies
รcole Polytechnique Fรฉdรฉrale de Lausanne (EPFL)
|
Adrian Martรญnez Lรณpez EPFL |
Ananya Gupta EPFL |
Hanka Goralija EPFL |
|
Mario Rico Ibรกรฑez EPFL |
Saรบl Fenollosa Arguedas EPFL |
Tamar Alphaidze EPFL |
This research was conducted in collaboration with the Swiss Data Science Center (SDSC), a joint venture between EPFL and ETH Zurich. The SDSC provided:
- ๐ Academic Supervision: Expert guidance on research methodology
- ๐ป Computational Resources: Access to high-performance computing infrastructure
- ๐ Data Science Expertise: Technical support and best practices
- ๐ Research Network: Connections to the broader data science community
About Swiss Data Science Center:
The Swiss Data Science Center develops and deploys cutting-edge data science and machine learning techniques to help solve complex societal challenges. By bridging the gap between academic research and real-world applications, SDSC enables researchers to leverage state-of-the-art tools and methodologies.
๐ Learn more: www.datascience.ch
This project is licensed under the MIT License - see the LICENSE file for details.
We would like to express our gratitude to:
- ๐๏ธ Swiss Data Science Center (SDSC) for their invaluable collaboration, computational resources, and technical guidance throughout this research project
- ๐ รcole Polytechnique Fรฉdรฉrale de Lausanne (EPFL) for providing the academic environment and infrastructure
- ๐ฌ Brax Team at Google Research for the differentiable physics engine that enabled efficient experimentation
- ๐ฎ OpenAI Gym for standardized RL environment interfaces
- ๐ Stable-Baselines3 team for reference implementations and best practices
- ๐ JAX Team for the high-performance numerical computing framework
- ๐ Weights & Biases for experiment tracking and visualization tools
- ๐ก The broader reinforcement learning research community for open-source tools and reproducible research practices
Special Thanks:
- To our reviewers and colleagues who provided valuable feedback
- To the open-source community for making this research possible
- To all contributors and users of this codebase
-
Salimans, T., et al. (2017). "Evolution Strategies as a Scalable Alternative to Reinforcement Learning." arXiv preprint arXiv:1703.03864.
-
Mnih, V., et al. (2013). "Playing Atari with Deep Reinforcement Learning." arXiv preprint arXiv:1312.5602.
-
Schulman, J., et al. (2017). "Proximal Policy Optimization Algorithms." arXiv preprint arXiv:1707.06347.
-
Todorov, E., et al. (2012). "MuJoCo: A physics engine for model-based control." IROS 2012.
-
Freeman, C. D., et al. (2021). "Brax - A Differentiable Physics Engine for Large Scale Rigid Body Simulation." NeurIPS 2021 Datasets and Benchmarks Track.
1. CUDA out of memory
# Reduce number of parallel environments
# In config file: num_envs: 1024 # instead of 81922. Wandb authentication
wandb login
# Enter your API key from https://wandb.ai/authorize3. MuJoCo installation issues
# Install MuJoCo dependencies
sudo apt-get install libglew-dev patchelf4. Slow training
# Enable JAX GPU acceleration
pip install --upgrade "jax[cuda]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.htmlQ: When should I use ES instead of DRL?
Use ES when:
- ๐ฏ You have a simple environment with low-dimensional states
- ๐ You need quick initial exploration
- ๐ป You have access to many parallel workers
- ๐ฒ Your reward function is sparse or deceptive
Use DRL when:
- ๐ผ๏ธ You have high-dimensional observations (images)
- ๐ฏ You need the highest possible performance
- โฑ๏ธ Sample efficiency is critical
- ๐ง You can afford hyperparameter tuning
Q: Why doesn't ES pretraining help PPO in MuJoCo?
ES only optimizes a single policy network, while PPO uses separate actor and critic networks. When we pretrain with ES:
- โ We get a reasonable actor initialization
- โ The critic still starts from scratch
โ ๏ธ The architectural mismatch limits knowledge transfer
Future work: Co-evolution of actor and critic networks may address this limitation.
Q: How do I choose hyperparameters?
For ES:
- Start with
sigma=0.05,population_size=128,lr=0.01 - Increase population size for complex environments
- Reduce sigma if training is unstable
For PPO:
- Use configs from
configs/es/ppo.yamlas baseline - Adjust
num_envsbased on available memory - Tune learning rate if training diverges
General advice: ES is more robust to hyperparameters than PPO!
Q: Can I use this for my own environments?
Yes! The code is designed to be extensible:
- Create a new environment config in
configs/your_env.yaml - Ensure your environment follows the Gym API
- Run training with your config
python src/es_drl/main_es.py --config configs/es/basic_es.yaml --env_config configs/your_env.yamlFor Brax environments, no changes needed. For custom environments, you may need to add a wrapper.
Q: How can I visualize my trained agents?
During training:
- Enable video recording in your config
- Videos are saved to
results/[algorithm]/[env]/videos/
After training:
python scripts/visualize_agent.py \
--checkpoint results/es/hopper/checkpoint.pkl \
--env hopper \
--num_episodes 5Q: What computational resources do I need?
Minimum:
- 8GB RAM
- 4 CPU cores
- Training time: Hours to days
Recommended:
- 16GB+ RAM
- GPU with 8GB+ VRAM
- 8+ CPU cores for parallelization
- Training time: Minutes to hours
Note: ES benefits more from CPU parallelization, while DRL benefits more from GPU acceleration.
Q: Where can I find more details about the experiments?
๐ Full paper: RL_project.pdf - Contains complete methodology, results, and analysis
๐จ Poster: Poster PDF - Visual summary of key findings
๐ Code: Browse src/ for implementation details
๐ Results: Check results/ for training curves and checkpoints
- Implement co-evolution of actor and critic networks
- Test on more complex environments (Humanoid, manipulation tasks)
- Explore trust-region ES variants
- Integrate with other DRL algorithms (SAC, TD3)
- Develop architecture-aware transfer learning
- Multi-task and transfer learning experiments
- ๐ Documentation: Start with this README and the full paper
- โ Issues: Open an issue on GitHub for bugs or questions
- ๐ฌ Discussions: Use GitHub Discussions for general questions
- ๐ง Contact: Reach out to the authors for research-related inquiries
We welcome contributions! Here's how you can help:
- ๐ Report bugs via GitHub Issues
- ๐ก Suggest features or improvements
- ๐ง Submit pull requests with bug fixes or enhancements
- ๐ Improve documentation or add examples
- ๐ Star the repo if you find it useful!
Contribution Guidelines:
- Follow existing code style
- Add tests for new features
- Update documentation as needed
- Reference related issues in PRs
Interested in collaborating or extending this research? We're open to:
- ๐ฌ Joint research projects
- ๐ Supervising thesis projects
- ๐ค Industry partnerships
- ๐ Applying these methods to new domains
Contact the authors or Swiss Data Science Center for collaboration opportunities.
For questions, collaboration opportunities, or research inquiries, please open an issue or contact the authors.
Made with โค๏ธ at EPFL in collaboration with Swiss Data Science Center
ยฉ 2025 รcole Polytechnique Fรฉdรฉrale de Lausanne. All rights reserved.