EMI-Group/metade 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,采用 GNU General Public License v3.0 许可证,目前获得 241 个 Star、23 次 Fork。
仓库全名
EMI-Group/metade
开源许可证
GNU General Public License v3.0
Star 数
241
Fork 数
23
README 摘要
🌟 MetaDE: Evolving Differential Evolution by Differential Evolution 🌟 MetaDE is an advanced evolutionary framework that dynamically optimizes the strategies and hyperparameters of Differential Evolution (DE) through meta-level evolution. By leveraging DE to fine-tune its own configurations, MetaDE adapts mutation and crossover strategies to suit varying problem landscapes in real-time. With GPU acceleration, it…
MetaDE is a GPU-accelerated evolutionary framework that optimizes Differential Evolution (DE) strategies via meta-level evolution. Supporting both JAX and PyTorch, it dynamically adapts mutation and crossover strategies for efficient large-scale black-box optimization.
🌟 MetaDE: Evolving Differential Evolution by Differential Evolution 🌟
MetaDE is an advanced evolutionary framework that dynamically optimizes the strategies and hyperparameters of Differential Evolution (DE) through meta-level evolution. By leveraging DE to fine-tune its own configurations, MetaDE adapts mutation and crossover strategies to suit varying problem landscapes in real-time. With GPU acceleration, it handles large-scale, complex black-box optimization problems efficiently, delivering faster convergence and superior performance. MetaDE is compatible with the EvoX framework.
New in this version:
MetaDE now fully supports both JAX and PyTorch backends.
PyTorch backend updates:
Now supports Brax-based RL tasks(requires additional installation of JAX).
Significant performance improvements when used with EvoX v1.1.1, achieving up to 2x speedup compared to previous versions.
Strongly recommended to use EvoX 1.1.1 and GPU-enabled PyTorch for optimal performance.
JAX backend:
Remains fully supported and recommended if you prefer CUDA-enabled JAX.
Generally offers approximately 2x the speed compared to the PyTorch backend.
To replicate experiments from the paper exactly, you may still opt for the JAX backend with a CUDA-enabled JAX (and Brax) installation.
Features
Meta-level Evolution 🌱: Uses DE at a meta-level to evolve hyperparameters and strategies of DE applied at a problem-solving level.
Parameterized DE (PDE) 🛠️: A customizable variant of DE that offers dynamic mutation and crossover strategies adaptable to different optimization problems.
Multi-Backend Support 🔥: Provides both JAX and PyTorch implementations for broader hardware/software compatibility.
GPU-Accelerated 🚀: Integrated with GPU acceleration on both JAX and PyTorch, enabling efficient large-scale optimizations.
End-to-End Optimization 🔄: MetaDE provides a seamless workflow from hyperparameter tuning to solving optimization problems in a fully automated process.
Wide Applicability 🤖: Supports various benchmarks, including CEC2022, and real-world tasks like evolutionary reinforcement learning in robotics.
RL Tasks Visualization
Using the MetaDE algorithm to solve RL tasks.
The following animations show the behaviors in Brax environments:
Hopper
Swimmer
Reacher
Hopper: Aiming for maximum speed and jumping height.
Swimmer: Enhancing movement efficiency in fluid environments.
Reacher: Moving the fingertip to a random target.
Requirements
Depending on which backend you plan to use (JAX or PyTorch), you should install the proper libraries and GPU dependencies:
Install Brax(Optional, if you want to solve Brax RL problems):
pip install brax==0.10.3
Components
Evolver
MetaDE employs Differential Evolution (DE) as the evolver to optimize the parameters of its executor.
Mutation: DE’s mutation strategies evolve based on feedback from the problem landscape.
Crossover: Different crossover strategies (binomial, exponential, arithmetic) can be used and adapted.
Executor
The executor is a Parameterized Differential Evolution (PDE), a variant of DE designed to accommodate various mutation and crossover strategies dynamically.
Parameterization: Flexible mutation strategies like DE/rand/1/bin or DE/best/2/exp can be selected based on problem characteristics.
Parallel Execution: Core operations of PDE are optimized for parallel execution on GPUs(via JAX or PyTorch).
GPU Acceleration
MetaDE integrates with the EvoX framework for distributed, GPU-accelerated evolutionary computation, significantly enhancing performance on large-scale optimization tasks.
If you want to use the PyTorch backend, please refer to the PyTorch examples under examples/pytorch/example_cec2022.py in this repository.
Robotics Control (Evolutionary Reinforcement Learning)
MetaDE can also be used for real-world tasks like robotic control through evolutionary reinforcement learning. Note that running these examples requires installing CUDA-enabled JAX and brax==0.10.3.
from tqdm import tqdm
import metade.problems
from jax import random
from flax import linen as nn
import jax.numpy as jnp
import jax
from metade.util import StdSOMonitor, StdWorkflow, TreeAndVector, parse_opt_direction
from metade.algorithms.jax import create_batch_algorithm, decoder_de, MetaDE, ParamDE, DE
steps = 20
pop_size = 100
key = jax.random.PRNGKey(42)
class HopperPolicy(nn.Module):
@nn.compact
def __call__(self, x):
x = x.astype(jnp.float32)
x = x.reshape(-1)
x = nn.Dense(32)(x)
x = nn.tanh(x)
x = nn.Dense(32)(x)
x = nn.tanh(x)
x = nn.Dense(3)(x)
x = nn.tanh(x)
return x
model = HopperPolicy()
weights = model.init(random.PRNGKey(42), jnp.zeros((11,)))
adapter = TreeAndVector(weights)
vector_form_weights = adapter.to_vector(weights)
tiny_num = 1e-5
param_lb = jnp.array([0, 0, 0, 0, 1, 0])
param_ub = jnp.array([1, 1, 4 - tiny_num, 4 - tiny_num, 5 - tiny_num, 3 - tiny_num])
algorithm = DE(
lb=param_lb,
ub=param_ub,
pop_size=pop_size,
base_vector="rand", differential_weight=0.5, cross_probability=0.9
)
BatchDE = create_batch_algorithm(ParamDE, pop_size, 1)
batch_de = BatchDE(
lb=jnp.full((vector_form_weights.shape[0],), -10.0),
ub=jnp.full((vector_form_weights.shape[0],), 10.0),
pop_size=100,
)
base_problem = metade.problems.jax.Brax(
env_name="hopper",
policy=jax.jit(model.apply),
cap_episode=500,
)
meta_problem = MetaDE(
batch_de,
base_problem,
batch_size=pop_size,
num_runs=1,
base_alg_steps=50,
base_opt_direction="max",
base_pop_transform=adapter.batched_to_tree,
)
monitor = StdSOMonitor(record_fit_history=False)
workflow = StdWorkflow(
algorithm=algorithm,
problem=meta_problem,
monitor=monitor,
pop_transform=decoder_de,
record_pop=True,
)
monitor.set_opt_direction(parse_opt_direction("max"))
key, _ = jax.random.split(key)
state = workflow.init(key)
for i in tqdm(range(steps)):
power_up = 1 if i == steps - 1 else 0
state = state.update_child("problem", {"power_up": power_up})
state = workflow.step(state)
print(f"Best fitness: {monitor.get_best_fitness()}")
If you want to use the PyTorch backend, please refer to the PyTorch examples under examples/pytorch/example_brax.py in this repository.
@article{metade,
title = {{MetaDE}: Evolving Differential Evolution by Differential Evolution},
author = {Chen, Minyang and Feng, Chenchen and Cheng, Ran},
journal = {IEEE Transactions on Evolutionary Computation},
year = 2025,
doi = {10.1109/TEVC.2025.3541587}
}
评论