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.dev26.tar.gz (109.7 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.dev26-py3-none-any.whl (151.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: evolib-0.1.0.dev26.tar.gz
  • Upload date:
  • Size: 109.7 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.dev26.tar.gz
Algorithm Hash digest
SHA256 6fd944fbbd1171fd7b78149801844c11e23aad7eee1900f8ed1f6ed4cbaaa835
MD5 5ad85901b2b6d02723e54759f008ca96
BLAKE2b-256 326334104f0706a445ebf2a6249bba400eb8ade4fe2dcafe4f315c6c91bf2ab0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: evolib-0.1.0.dev26-py3-none-any.whl
  • Upload date:
  • Size: 151.4 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.dev26-py3-none-any.whl
Algorithm Hash digest
SHA256 1c4d84ba3dab277448c93464bbb83c75c5401eec112043b7f9c7239d05e7c7e7
MD5 5867adb75cea8b8a0c48326403df5784
BLAKE2b-256 d3eef0dc0a628b4c091746d25342a9a53047e4898d939f8a5f96dd915cd45c9e

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