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
from my_fitness import fitness_function

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

for _ in range(pop.max_generations):
    pop.run_one_generation()

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
max_indiv_age: 0
num_elites: 2

evolution:
  strategy: "mu_plus_lambda"

modules:
  main:
    type: vector
    dim: 16
    initializer: random_vector
    bounds: [-2.0, 2.0]
    init_bounds: [-1.0, 1.0]

    mutation:
      strategy: constant
      probability: 1.0
      strength: 0.05


# Example: Multiple Modules
# modules:
#   controller:
#     type: vector
#     dim: 8
#     initializer: normal_vector
#     mutation:
#       strategy: constant
#       strength: 0.1
#
#   brain:
#     type: evonet
#     dim: [4, 8, 2]
#     initializer: normal_evonet
#     mutation:
#       strategy: constant
#       strength: 0.05

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

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.dev21.tar.gz (102.4 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.dev21-py3-none-any.whl (146.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: evolib-0.1.0.dev21.tar.gz
  • Upload date:
  • Size: 102.4 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.dev21.tar.gz
Algorithm Hash digest
SHA256 8b05191468a2d5982d5e807ea4d43e1c594ff898317a053a65e75fad46410a7a
MD5 85be874c16cb89405e71ffa05d984bee
BLAKE2b-256 e0f46c7d70357383694d7698978c2a16ae7e44a66ce4578f69d3198baf8fd2a0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: evolib-0.1.0.dev21-py3-none-any.whl
  • Upload date:
  • Size: 146.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.dev21-py3-none-any.whl
Algorithm Hash digest
SHA256 0647e1fe85338de1af7c3970f893fd2206c770023fdaa11500cd4acb910251d3
MD5 0de56326bb38dc219e80fa227b37ae4c
BLAKE2b-256 6302eed0486dad0bb02aa0b71a0fcddcb3d0ae8a9f7dd655a461057dfc5ad990

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