Skip to main content

A modular framework for evolutionary strategies and neuroevolution.

Project description

EvoLib – A Modular Framework for Evolutionary Computation

Docs Status Code Quality & Tests License: MIT PyPI version Project Status: Alpha

EvoLib Logo

EvoLib is a modular and extensible Python framework for designing, analyzing, and teaching evolutionary algorithms. It supports classical strategies such as (μ, λ) and (μ + λ), with configurable mutation, selection, and crossover operators, as well as neuroevolution.


Key Features

  • Configurable Evolution: Define evolutionary strategies via simple YAML files.
  • Modular Design: Easily swap mutation, selection, and crossover strategies.
  • Built-in Logging: Fitness tracking and history recording out-of-the-box.
  • Educational Focus: Includes didactic examples and an extensible code structure.
  • Neuroevolution: Structured neural networks (EvoNet) and evolvable parameter vectors supported.
  • Type-Checked: With mypy and PEP8 compliance.

⚠️ This project is in alpha stage. APIs and configuration structure may change.


Sample Plott


Directory Structure

evolib/
├── core/           # Individual, Population
├── config/         # Typed component configuration (Vector, EvoNet, etc.)
├── interfaces/     # Enums, types, helper protocols
├── initializers/   # Initializer registry and implementations
├── operators/      # Mutation, crossover, selection, etc.
├── registry/       # Strategy and operator registries
├── representation/ # ParaBase + Vector, EvoNet, Composite etc.
├── utils/          # Logging, plotting, math, config loader
└── examples/       # Educational examples and test runs


Installation

pip install evolib

Requirements: Python 3.9+ and packages in requirements.txt.


Example Usage

from evolib import Pop

def my_fitness(indiv):
    # Custom fitness function (example: sum of vector)
    indiv.fitness = sum(indiv.para["main"].vector)

pop = Pop(config_path="config/my_experiment.yaml",
          fitness_function=my_fitness)

# Run the evolutionary process
pop.run()

For full examples, see 📁examples/ – including adaptive mutation, controller evolution, and network approximation.


Configuration Example (YAML)

parent_pool_size: 20
offspring_pool_size: 60
max_generations: 100
num_elites: 2
max_indiv_age: 0

stopping:
  target_fitness: 0.01
  patience: 20
  min_delta: 0.0001
  minimize: true

evolution:
  strategy: mu_comma_lambda

modules:
  controller:
    type: vector
    dim: 8
    initializer: normal_vector
    bounds: [-1.0, 1.0]
    mutation:
      strategy: adaptive_individual
      probability: 1.0
      strength: 0.1

  brain:
    type: evonet
    dim: [4, 6, 2]
    activation: [linear, tanh, tanh]
    initializer: normal_evonet
    mutation:
      strategy: constant
      probability: 1.0
      strength: 0.05

      # Optional fine-grained control
      activations:
        probability: 0.01
        allowed: [tanh, relu, sigmoid]

      structural:
        add_neuron: 0.01
        add_connection: 0.05
        remove_connection: 0.02
        recurrent: local  # none | direct | local | all
        keep_connected: true

Supported Parameter Representations

Type Structure Description
vector flat, net, tensor, blocks Evolvable vectors or neural network encodings
evonet Neural networks via EvoNet

ℹ️ Multiple parameter types (e.g. vector + evonet) can be combined in a single individual. Each component evolves independently, using its own configuration.


Use Cases

EvoLib is designed for both research and education in evolutionary computation. It supports a wide range of applications, including:

  • Function optimization: Test and visualize search behavior on standard functions (e.g., Sphere, Ackley)
  • Hyperparameter tuning: Use evolutionary strategies to optimize black-box functions.
  • Strategy comparison: Test and evaluate different mutation, selection, and crossover methods.
  • Educational use: Clear API and examples for teaching evolutionary computation concepts.
  • Neuroevolution: Evolve neural networks with weights and structure.

Roadmap

  • Adaptive Mutation (global, individual, per-parameter)
  • Flexible Crossover Strategies (BLX, intermediate, none)
  • Strategy Comparisons via Examples
  • Structured Neural Representations (EvoNet)
  • Composite Parameters (multi-module individuals)
  • Neuroevolution
  • Topological Evolution (add/remove neurons, edges)
  • Co-Evolution & Speciation Support
  • Advanced Visualization Tools
  • Ray Support for Parallel Evaluation
  • Game Environment Integration (pygame, PettingZoo)

Documentation

Documentation for EvoLib is available at: 👉 https://evolib.readthedocs.io/en/latest/


License

MIT License – see MIT License.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

evolib-0.1.0.dev30.tar.gz (111.3 kB view details)

Uploaded Source

Built Distribution

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

evolib-0.1.0.dev30-py3-none-any.whl (154.2 kB view details)

Uploaded Python 3

File details

Details for the file evolib-0.1.0.dev30.tar.gz.

File metadata

  • Download URL: evolib-0.1.0.dev30.tar.gz
  • Upload date:
  • Size: 111.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for evolib-0.1.0.dev30.tar.gz
Algorithm Hash digest
SHA256 eb79c0078c54a7eb134159cbda9ae762ee206fa8da25ec8c7858234323ed86fc
MD5 ec84911d462a0bf52bc25682233a207c
BLAKE2b-256 f0f0f7a4e602a41f0379e7f89108edbd7eebc0dfe3f3087cbb7f99fff0ae2eed

See more details on using hashes here.

File details

Details for the file evolib-0.1.0.dev30-py3-none-any.whl.

File metadata

  • Download URL: evolib-0.1.0.dev30-py3-none-any.whl
  • Upload date:
  • Size: 154.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for evolib-0.1.0.dev30-py3-none-any.whl
Algorithm Hash digest
SHA256 e70173a70c69a307f5a374e416c03007847a36c4edf3365572e0acd825106c38
MD5 c6420a684bcf298ddf1d2f68e8971a59
BLAKE2b-256 aef1c8182ec59bfce60607fbee102ab2ae029de8a69ba1587b6dccb54c910118

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