Coder Social home page Coder Social logo

emi-group / evox Goto Github PK

View Code? Open in Web Editor NEW
171.0 3.0 29.0 4.08 MB

Distributed GPU-Accelerated Framework for Evolutionary Computation. Comprehensive Library of Evolutionary Algorithms & Benchmark Problems.

License: BSD 3-Clause "New" or "Revised" License

Python 99.64% Nix 0.36%
evolutionary-algorithms neuroevolution gpu-acceleration ray brax derivative-free-optimization evolutionary-optimization evolutionary-reinforcement-learinig gradient-free-optimization jax

evox's Introduction

EvoX Logo

arXiv Documentation PyPI-Version Python-Version Discord Server QQ Group GitHub User's Stars


🌟Distributed GPU-accelerated Framework for Scalable Evolutionary Computation🌟


Building upon JAX and Ray, EvoX offers a comprehensive suite of 50+ Evolutionary Algorithms (EAs) and a wide range of 100+ Benchmark Problems/Environments, all benefiting from distributed GPU-acceleration. It facilitates efficient exploration of complex optimization landscapes, effective tackling of black-box optimization challenges, and deep dives into neuroevolution with Brax. With a foundation in functional programming and hierarchical state management, EvoX offers a user-friendly and modular experience. For more details, please refer to our Paper and Documentation / 文档.

Key Features

  • 🚀 Fast Performance:

    • Experience GPU-Accelerated optimization, achieving speeds over 100x faster than traditional methods.
    • Leverage the power of Distributed Workflows for even more rapid optimization.
  • 🌐 Versatile Optimization Suite:

    • Cater to all your needs with both Single-objective and Multi-objective optimization capabilities.
    • Dive into a comprehensive library of Benchmark Problems/Environments, ensuring robust testing and evaluation.
    • Explore the frontier of AI with extensive tools for Neuroevolution/RL tasks.
  • 🛠️ Designed for Simplicity:

    • Embrace the elegance of Functional Programming, simplifying complex algorithmic compositions.
    • Benefit from Hierarchical State Management, ensuring modular and clean programming.

Main Contents

Evolutionary Algorithms for Single-objective Optimization

Category Algorithms
Differential Evolution CoDE, JaDE, SaDE, SHADE, IMODE, ...
Evolution Strategy CMA-ES, PGPE, OpenES, CR-FM-NES, xNES, ...
Particle Swarm Optimization FIPS, CSO, CPSO, CLPSO, SL-PSO, ...

Evolutionary Algorithms for Multi-objective Optimization

Category Algorithms
Dominance-based NSGA-II, NSGA-III, SPEA2, BiGE, KnEA, ...
Decomposition-based MOEA/D, RVEA, t-DEA, MOEAD-M2M, EAG-MOEAD, ...
Indicator-based IBEA, HypE, SRA, MaOEA-IGD, AR-MOEA, ...

For a comprehensive list and further details of all algorithms, please check the API Documentation.

Benchmark Problems/Environments

Category Problems/Environments
Numerical DTLZ, LSMOP, MaF, ZDT, CEC'22, ...
Neuroevolution/RL Brax, Gym, TorchVision Dataset, ...

For a comprehensive list and further details of all benchmark problems/environments, please check the API Documentation.

Setting Up EvoX

Install evox effortlessly via pip:

pip install evox

Note: To setup EvoX with GPU acceleration capabilities, you will need to setup JAX first. For detials, please refer to our comprehensive Installation Guide. Additionally, you can watch our instructional videos:

🎥 EvoX Installation Guide (Linux)

🎥 EvoX Installation Guide (Windows)

🎥 EvoX 安装指南 (Linux)

🎥 EvoX 安装指南 (Windows)

Quick Start

Kickstart your journey with EvoX in just a few simple steps:

  1. Import necessary modules:
import evox
from evox import algorithms, problems, workflows
  1. Configure an algorithm and define a problem:
pso = algorithms.PSO(
    lb=jnp.full(shape=(2,), fill_value=-32),
    ub=jnp.full(shape=(2,), fill_value=32),
    pop_size=100,
)
ackley = problems.numerical.Ackley()
  1. Compose and initialize the workflow:
workflow = workflows.StdWorkflow(pso, ackley)
key = jax.random.PRNGKey(42)
state = workflow.init(key)
  1. Run the workflow:
# Execute the workflow for 100 iterations
for i in range(100):
    state = workflow.step(state)

Use-cases and Applications

Try out ready-to-play examples in your browser with Colab:

Example Link
Basic Usage Open in Colab
Numerical Optimization Open in Colab
Neuroevolution with Gym Open in Colab
Neuroevolution with Brax Open in Colab
Custom Algorithm/Problem Open in Colab

For more use-cases and applications, pleae check out Example Directory.

Community & Support

Sister Projects

  • TensorNEAT: Tensorized NeuroEvolution of Augmenting Topologies (NEAT) for GPU Acceleration. Check out here.
  • TensorRVEA: Tensorized Reference Vector Guided Evolutionary Algorithm (RVEA) for GPU Acceleration. Check out here.
  • TensorACO: Tensorized Ant Colony Optimization (ACO) for GPU Acceleration. Check out here.
  • EvoXBench: A benchmark platform for Neural Architecutre Search (NAS) without the requirement of GPUs/PyTorch/Tensorflow, supporting various programming languages such as Java, Matlab, Python, ect. Check out here.

Citing EvoX

If you use EvoX in your research and want to cite it in your work, please use:

@article{evox,
  title = {{EvoX}: {A} {Distributed} {GPU}-accelerated {Framework} for {Scalable} {Evolutionary} {Computation}},
  author = {Huang, Beichen and Cheng, Ran and Li, Zhuozhao and Jin, Yaochu and Tan, Kay Chen},
  journal = {IEEE Transactions on Evolutionary Computation},
  year = 2024,
  doi = {10.1109/TEVC.2024.3388550}
}

Star History

Star History Chart

evox's People

Contributors

alpaca0072 avatar artanisax avatar billhuang2001 avatar christinaljc avatar fee-mugre avatar haoyuwang141 avatar jiangtao97 avatar kelvin-doremi avatar lihao-ms avatar nam-dada avatar qxiao0521 avatar ranchengcn avatar scorpionkid avatar shepherd29 avatar sses7757 avatar starquakee avatar tier123 avatar wls2002 avatar xiaomingzhm avatar xinyaoli0212 avatar zaberko avatar zhenyu2liang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

evox's Issues

Metric

We need metrics, mostly for multi-objective problems.

  • GD
  • IGD
  • HV

Some problems of cpso_s algorithm

Desciption:

When calling the CPSOS algorithm from evoX, the following issues may arise:

ValueError: Incompatible shapes for broadcasting: shapes=[(2, 100), (2,)]

It seems that there is an issue with the cpso_s.py at line 100.
In the comments of this algorithm, the shape of 'fitness' is 'dim, pop_size', which is different from how it's done in other algorithms?

Additionally, there might be a small error in the EvoX tutorial.
This algorithm should be named 'CPSO_S' instead of 'CLPSO_S'

 Algorithms 
    - Single-objective 
       - 【CLPSO_S】

Move to Gymnasium and Brax

We should move to Gymnasium as Gym is no longer maintained.
Brax is also a good choice.

  • Gymnasium
  • Brax

Problem labels

Assign labels like noisy/multi-objective/single-objective to problems

CSO algorithm's new population is not clipped

The CSO algorithm's generation of new population ends here, and it seems that there is no code like jnp.clip or jnp.min, jnp.max. Is it okay to let the population run free on an unconstrained sapce?

Quick start example results in AttributeError

Greetings everyone,

I'm currently facing an issue while attempting to run the quick start code. This is leading to an error message: "AttributeError: 'tuple' object has no attribute 'evaluate'".

from evox import algorithms, problems, pipelines
import jax
import jax.numpy as jnp

algorithm = algorithms.PSO(
    lb=jnp.full(shape=(2,), fill_value=-32),
    ub=jnp.full(shape=(2,), fill_value=32),
    pop_size=100,
)

problem = problems.classic.Ackley(),


pipeline = pipelines.StdPipeline(
    algorithm,
    problem,
)

key = jax.random.PRNGKey(42)
state = pipeline.init(key)


for i in range(100):
    state = pipeline.step(state)

Traceback:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/home/sh/test_evox.py in line 27
     25 # run the pipeline for 100 steps
     26 for i in range(100):
---> 27     state = pipeline.step(state)

File ~/anaconda3/envs/EVOX_test/lib/python3.10/site-packages/evox/core/module.py:31, in use_state..wrapper(self, state, *args, **kwargs)
     28 # find the state that match the current module
     29 path, matched_state = state.find_path_to(self._node_id, self._module_name)
---> 31 return_value = func(self, matched_state, *args, **kwargs)
     33 # single return value, the value must be a State
     34 if not isinstance(return_value, tuple):

File ~/anaconda3/envs/EVOX_test/lib/python3.10/site-packages/evox/pipelines/standard.py:24, in StdPipeline.step(self, state)
     21 if self.pop_transform is not None:
     22     pop = self.pop_transform(pop)
---> 24 fitness, state = self.problem.evaluate(state, pop)
     26 if self.fitness_transform is not None:
     27     fitness = self.fitness_transform(fitness)

AttributeError: 'tuple' object has no attribute 'evaluate'

I'm running this code in a clean anaconda env with cuda 12.2.

Best
Sebastian

NaN may occur in the CEC2022 SO benchmark

Desciption

In the CEC2022 single objective benchmark, F10 ~ F12 all use the compose_operat function in OperatFunc class, where the codes below may lead to NaN items in term1, resulting in final NaN in the evaluated fitness.

diff_square_sum = jnp.sum((x - Os_mat) ** 2, axis=1)
term1 = 1 / jnp.sqrt(diff_square_sum)
term2 = jnp.exp(-0.5 * diff_square_sum / (sigma**2 * D))
W = term1 * term2
W_norm = W / jnp.sum(W)

Possible Solution

diff_square_sum = jnp.sum((x - Os_mat) ** 2, axis=1)
term1 = 1 / jnp.sqrt(diff_square_sum)
term2 = jnp.exp(-0.5 * diff_square_sum / (sigma**2 * D))
W = term1 * term2
term1_nan = jnp.isnan(term1)
W_norm = jnp.select(jnp.any(term1_nan), term1_nan / jnp.count_nonzero(term1_nan), W / jnp.sum(W))

Location

- problems
  - numerical
    - cec2022_so.py
      - line 121

Is this the intended behavior of CEC2022 single objective benchmark or a bug?

Note

The overall code of CEC2022 benchmark is hard to read due to the lack of documentations and improper abbreviations, please fix these problems if possible.

`evox` git repository size

Found this project from cs.NE; thanks for sharing! 🦎

I cloned the repo; it's too large due to all the blobs committed in git.

Currently 300mb.

For reference:

  • JAX: ~67mb
    • EvoJAX: 56mb
    • evosax: 7mb
  • NumPy: 117mb

blobs.txt

(For reference, the command to find these):

git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| sed -n 's/^blob //p' \
| sort --numeric-sort --key=2 \
| cut -c 1-12,41- \
| numfmt --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest

It might be worth considering rewriting your git history so users can hack around more tractably.

Glad to see more activity in this space! 💪🏻
Thanks for the cool lib!

JAX_repo_size

NumPy_repo_size

pip安装包不包含workflows包

使用pip安装后缺少workflows依赖包
image
image

且在示例中的import建议将import的依赖项添加完全

from jax import numpy as jnp
import jax

EA Operators

  • Sampling
    • Uniform
    • Latin Hypercube
  • Selection
    • Uniform
    • Tournament
  • Mutation
    • Polynomial
    • Discrete
  • Crossover
    • Uniform
    • Simulated Binary
    • DE (binary/best)
    • One point

Better non-dominate sort

The current non-dominate sort is quite naive and not jit-compatible, we need a better implementation.

Issue of calling dtlz1()

super().__init__(d, m, ref_num)

When I initialize the dzlt1
dtlz1 = problems.numerical.DTLZ1()

if parameter m is not given, it would show 'TypeError: unsupported operand type(s) for *: 'int' and 'NoneType''

I think the reason is when you call parent's init funtion, the m was given instead of self.m

Cite EvoJAX and evosax

Hi there! Nice to see more enthusiasm for JAX and evolutionary optimization. Any reason why you don't mention EvoJAX and evosax in your paper? Would love to know how they compare.

Adding a new algorithm

Hi,

Thank you for providing this fantastic library. I'm interested in adding a new algorithm, specifically the 'cross-entropy method.'
Could you please provide an example or guidance on how to do this?

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.