Neat Python, Amplified by C++ A high-performance, C++-backed Python library for NEAT (NeuroEvolution of Augmenting Topologies) algorithms and beyond.
Overview neat3p is designed to bring the flexibility of Python together with the performance of C++. By leveraging nanobind for C++/Python interoperability, neat3p aims to provide an efficient implementation of NEAT-based methods with the ease-of-use of a Python API.
Features High-Performance: Core functionality implemented in modern C++ (C++20) for speed and efficiency. Python-Friendly API: Exposes a user-friendly interface using nanobind.
- Clean env first (Debugging)
conda deactivate
conda env remove -n neat3p- Create a Conda Virtual Environment with Python 3.12:
conda create --name neat3p python=3.12
conda activate neat3p- Install nanobind via Conda:
(Optional) For some reason nanobind dependency is managed by build + pyproject.toml configurations. So this step can be ignored. But if built manually might be necessary to install.
conda install -c conda-forge nanobindRequired libraries
conda install --name neat3p -c conda-forge msgpack-c
conda install --name neat3p -c conda-forge spdlog- Install Python Package Requirements:
Ensure you have a requirements.txt file in your repository root (see below for an example). Then run:
conda run -n neat3p pip install -r requirements.txt
conda run -n neat3p pip install --upgrade build scikit-build-coreBefore installing, clear any previous build artifacts:
rm -rf buildThen, install the library in your active environment:
pip install . --verbosedocker build --rm -t neat3p-builder .
docker run --rm -it -v "$(pwd)/dist":/project/dist neat3p-builderOnce installed, you can import and use neat3p directly from Python. For example:
import neat3p
# Create a GenomeConfig instance
config = neat3p.GenomeConfig()
config.compatibility_weight_coefficient = 1.5
# You can also work with other exposed classes, e.g., DefaultNodeGene
# node = neat3p.DefaultNodeGene(1)
# print(node.to_string())Check the documentation for more detailed usage instructions and API reference.