Skip to main content

evomo

Project description

EvoX Logo

🌟 EvoMO: Bridging Evolutionary Multiobjective Optimization and GPU Acceleration via Tensorization 🌟

Table of Contents

  1. Overview
  2. Key Features
  3. Installation Guide
  4. Examples
  5. Community & Support

Overview

EvoMO is a GPU-accelerated library for evolutionary multiobjective optimization (EMO) that leverages advanced tensorization techniques. By transforming key data structures and operations into tensor representations, EvoMO enables more efficient mathematical modeling and delivers significant performance improvements. Designed with scalability in mind, EvoMO can efficiently handle large populations and complex optimization tasks. Additionally, EvoMO includes MoRobtrol, a multiobjective robot control benchmark suite, providing a platform for testing tensorized EMO algorithms in real-world, black-box environments. EvoMO is a sister project of EvoX.

[!NOTE] To use the JAX version of EvoMO, you can switch to the v0.0.1-dev branch. This branch is fully compatible with EvoX version 0.9.0.

Key Features

💻 High-Performance Computing

🚀 General Tensorization Methodology

  • EvoMO adopts a unified tensorization approach, restructuring EMO algorithms into tensor representations, enabling efficient GPU acceleration.

⚡ Ultra Performance

  • Supports tensorized implementations of NSGA-II, NSGA-III, MOEA/D, RVEA, HypE, and more, achieving up to 1113× speedup while preserving solution quality.

📈 Scalability

  • Handles large populations, scaling to hundreds of thousands for complex optimization tasks, ensuring scalability for real-world applications.

📊 Benchmarking

🤖 MoRobtrol Benchmark

  • Includes MoRobtrol, a multiobjective robot control benchmark, for testing tensorized EMO algorithms in challenging black-box environments.

🔧 Easy-to-Use Integration

🔄 Shared Name with EvoX

  • After installation, you can directly import EvoMO algorithms using import evox, making it seamless to access both EvoX and EvoMO algorithms with a unified interface.

Installation Guide

To install EvoMO, you need to install EvoX first.

  1. Install EvoX:
pip install evox
  1. Install EvoMO:
pip install evomo

For the latest development version, you can install from the source:

git clone https://github.com/EMI-Group/evomo.git
cd evomo
pip install -e.

Examples

Numerical optimization problem

Solve the DTLZ2 problem using the TensorMOEA/D algorithm:

import time
import torch
from evox.workflows import StdWorkflow
from evox.algorithms import TensorMOEAD
from evox.problems.numerical import DTLZ2
from evox.metrics import igd

if __name__ == "__main__":
    torch.set_default_device("cuda" if torch.cuda.is_available() else "cpu")

    algo = TensorMOEAD(pop_size=100, n_objs=3, lb=-torch.zeros(12), ub=torch.ones(12))
    prob = DTLZ2(m=3)
    pf = prob.pf()
    workflow = StdWorkflow(algo, prob)
    workflow.init_step()
    jit_state_step = torch.compile(workflow.step)

    t = time.time()
    for i in range(100):
        print(i)
        jit_state_step()
        fit = workflow.algorithm.fit
        fit = fit[~torch.any(torch.isnan(fit), dim=1)]
        print(f"Generation {i + 1} IGD: {igd(fit, pf)}")

    print(f"Total time: {time.time() - t} seconds")

MoRobtrol

Solve the MoSwimmer problem in MoRobtrol using the TensorMOEA/D algorithm:

import time

import torch
import torch.nn as nn
from evox.algorithms import TensorMOEAD
from evox.problems import MoRobtrol
from evox.utils import ParamsAndVector
from evox.workflows import EvalMonitor, StdWorkflow


class SimpleMLP(nn.Module):
    def __init__(self):
        super(SimpleMLP, self).__init__()
        self.features = nn.Sequential(nn.Linear(8, 4), nn.Tanh(), nn.Linear(4, 2))

    def forward(self, x):
        return torch.tanh(self.features(x))


def setup_workflow(model, pop_size, max_episode_length, num_episodes, device):
    adapter = ParamsAndVector(dummy_model=model)
    model_params = dict(model.named_parameters())
    pop_center = adapter.to_vector(model_params)
    lower_bound = torch.full_like(pop_center, -5)
    upper_bound = torch.full_like(pop_center, 5)

    problem = MoRobtrol(
        policy=model,
        env_name="mo_swimmer",
        max_episode_length=max_episode_length,
        num_episodes=num_episodes,
        pop_size=pop_size,
        device=device,
        num_obj=2,
        observation_shape=8,
        obs_norm={"clip_val": 5.0, "std_min": 1e-6, "std_max": 1e6},
    )

    algorithm = TensorMOEAD(
        pop_size=pop_size, lb=lower_bound, ub=upper_bound, n_objs=2, device=device
    )
    monitor = EvalMonitor(device=device)

    workflow = StdWorkflow(
        algorithm=algorithm,
        problem=problem,
        monitor=monitor,
        opt_direction="max",
        solution_transform=adapter,
        device=device,
    )
    return workflow


def run_workflow(workflow, compiled=True, generations=10):
    workflow.init_step()
    step_function = torch.compile(workflow.step) if compiled else workflow.step
    for index in range(generations):
        print(f"In generation {index}:")
        t = time.time()
        step_function()
        print(f"\tFitness: {-workflow.algorithm.fit}.")
    print(f"\tTime elapsed: {time.time() - t: .4f}(s).")


if __name__ == "__main__":
    device = "cuda" if torch.cuda.is_available() else "cpu"

    model = SimpleMLP().to(device)
    workflow = setup_workflow(model, 12, 100, 2, device)
    run_workflow(workflow)

Community & Support

We welcome contributions and look forward to your feedback!

  • Engage in discussions and share your experiences on GitHub Issues.
  • Join our QQ group (ID: 297969717).

Citing EvoMO

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

@article{evomo,
  title = {Bridging Evolutionary Multiobjective Optimization and {GPU} Acceleration via Tensorization},
  author = {Liang, Zhenyu and Li, Hao and Yu, Naiwei and Sun, Kebin and Cheng, Ran},
  journal = {IEEE Transactions on Evolutionary Computation},
  year = 2025,
  doi = {10.1109/TEVC.2025.3555605}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

evomo-0.1.0rc3.tar.gz (54.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

evomo-0.1.0rc3-py3-none-any.whl (45.2 kB view details)

Uploaded Python 3

File details

Details for the file evomo-0.1.0rc3.tar.gz.

File metadata

  • Download URL: evomo-0.1.0rc3.tar.gz
  • Upload date:
  • Size: 54.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for evomo-0.1.0rc3.tar.gz
Algorithm Hash digest
SHA256 882c6b7f11750152ea44a55affca5f5598d8a56a4a47e777bec7c7b2b0f218ad
MD5 648b70fbcd2beebd06244acd6feac382
BLAKE2b-256 3af6d13c914b955f9cb011ea5ef3498b16a945a5e1f621991ef62c94f0c04225

See more details on using hashes here.

File details

Details for the file evomo-0.1.0rc3-py3-none-any.whl.

File metadata

  • Download URL: evomo-0.1.0rc3-py3-none-any.whl
  • Upload date:
  • Size: 45.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for evomo-0.1.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 1a51d1b65725f82ca02988c7a671e2d236d8e4d6d9fa1fe48f18afd4a29c26d6
MD5 472d103df0e0c674de6fe50a43a9d28d
BLAKE2b-256 3880ac4bcb05d022679b8190fb7f853e6864bf52216305499adb5f4b94a88db8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page