Skip to main content

EvoRL

An evolutionary reinforcement learning framework that combines evolutionary algorithms with deep RL.

Website Twitter PyPI version License: MIT

Features

  • 🧬 Evolutionary optimization of RL agents
  • 🤖 Multiple agent types (DQN, PPO)
  • 🔄 Various evolution strategies (CEM, PGPE, NES)
  • 📊 Environment normalization and preprocessing
  • 🚀 Easy to extend and customize

Installation

pip install evorl

For development installation with additional tools:

pip install "evorl[dev]"

Quick Start

Basic Usage

from evorl import DQNAgent, NormalizedEnv
import gymnasium as gym

# Create environment
env = NormalizedEnv(gym.make("CartPole-v1"))

# Create and train a single agent
agent = DQNAgent(
    state_dim=env.observation_space.shape[0],
    action_dim=env.action_space.n
)

# Training loop
episodes = 100
for episode in range(episodes):
    obs, _ = env.reset()
    done = False
    total_reward = 0

    while not done:
        action = agent.select_action(obs)
        next_obs, reward, terminated, truncated, _ = env.step(action)
        done = terminated or truncated
        agent.update((obs, action, reward, next_obs, done))
        total_reward += reward
        obs = next_obs

    print(f"Episode {episode}: Reward = {total_reward}")

Evolutionary Training

from evorl import Population, CEM

# Create population of agents
population = Population(
    agent_class=DQNAgent,
    state_dim=env.observation_space.shape[0],
    action_dim=env.action_space.n,
    population_size=10
)

# Create evolution strategy
strategy = CEM(elite_frac=0.2)

# Evolution loop
generations = 20
for generation in range(generations):
    # Evaluate population
    metrics = population.evaluate(env, n_episodes=3)
    print(f"Generation {generation}: Mean Fitness = {metrics['mean_fitness']:.2f}")

    # Create next generation
    updates = strategy.compute_updates(population.population, population.fitness_scores)
    population.apply_updates(updates)

Documentation

For detailed documentation, visit evorl.ai

Available Components

Agents

  • DQNAgent: Deep Q-Network implementation
  • PPOAgent: Proximal Policy Optimization implementation

Evolution Strategies

  • CEM: Cross-Entropy Method
  • PGPE: Policy Gradients with Parameter Exploration
  • NES: Natural Evolution Strategies

Environment Wrappers

  • NormalizedEnv: Observation and reward normalization

Development

# Clone the repository
git clone https://github.com/zhangalex1/evorl.git
cd evorl

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest tests/

# Run with coverage
pytest tests/ --cov=evorl

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE for details

Metadata

Release files for evorl 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for evorl 2.0.0
File Size Uploaded Provenance Actions
evorl-2.0.0.tar.gz 13.2 kB Without provenance Details for evorl-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for evorl 2.0.0
File Interpreter ABI Platform Actions
evorl-2.0.0-py3-none-any.whl Python 3 none any Details for evorl-2.0.0-py3-none-any.whl

Total release size: 27.0 kB

Release files / evorl-2.0.0.tar.gz

Download URL evorl-2.0.0.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
98a19deccde04b6bedc9f55c8fe772c75a6c4aee80e892e4f91f0ab3c34ee567
BLAKE2b-256 checksum
How to use checksums
0d48c9e7ff388f6f98bf3fedbfaa63d8e6b80cfdf7fefdb64466ca87dc25ee00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.6

Release files / evorl-2.0.0-py3-none-any.whl

Download URL evorl-2.0.0-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a2b95e38db973b2eb04c7d9681523f5879daf1ae41b4a1e929863b4d3305727
BLAKE2b-256 checksum
How to use checksums
c0a7b076d76ec79561de424eb9fc7b22abeb2ff03fb02c044d7fd90bb9e1f1aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.6

Security for evorl 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page