Skip to main content

Cartesian genetic programming (CGP) in pure Python.

Project description

https://badge.fury.io/py/hal-cgp.svg https://img.shields.io/badge/python-3.6-red.svg https://img.shields.io/badge/python-3.7-red.svg https://img.shields.io/badge/python-3.8-red.svg https://img.shields.io/badge/License-GPLv3-blue.svg https://github.com/Happy-Algorithms-League/hal-cgp/actions/workflows/tests.yaml/badge.svg http://www.mypy-lang.org/static/mypy_badge.svg https://img.shields.io/badge/code%20style-black-000000.svg https://coveralls.io/repos/github/Happy-Algorithms-League/python-gp/badge.svg?branch=master https://readthedocs.org/projects/hal-cgp/badge/?version=latest

Cartesian genetic programming (CGP) in pure Python.

hal-cgp is an extensible pure Python library implementing Cartesian genetic programming to represent, mutate and evaluate populations of individuals encoding symbolic expressions targeting applications with computationally expensive fitness evaluations. It supports the translation from a CGP genotype, a two-dimensional Cartesian graph, into the corresponding phenotype, a computational graph implementing a particular mathematical expression. These computational graphs can be exported as pure Python functions, NumPy-compatible functions (Walt et al., 2011), SymPy expressions (Meurer et al., 2017) or PyTorch modules (Paszke et al., 2019).

The library implements a mu + lambda evolution strategy (Beyer and Schwefel, 2002) to evolve a population of individuals to optimize an objective function.

Design decisions/use cases

We designed hal-cgp for optimization problems in which individual fitness evaluations are computationally expensive. The library is hence not optimized for high performance, but rather puts ease of use and extensibility first. Furthermore we take steps to reduce the number of redundant fitness evaluations, for example by avoiding reevaluating parents at the beginning of each episode and providing a convenient decorator to cache results on disk. If for your use case individual fitness evaluations are fast and the performance of the library itself becomes a relevant factor, you may want to check out https://github.com/darioizzo/dcgp or http://www.cgplibrary.co.uk/files2/About-txt.html.

CGP Sketch

Figure from Jordan, Schmidt, Senn & Petrovici, “Evolving to learn: discovering interpretable plasticity rules for spiking networks”, arxiv:2005.14149.

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

hal-cgp-0.3.0.tar.gz (61.8 kB view details)

Uploaded Source

Built Distribution

hal_cgp-0.3.0-py3-none-any.whl (46.9 kB view details)

Uploaded Python 3

File details

Details for the file hal-cgp-0.3.0.tar.gz.

File metadata

  • Download URL: hal-cgp-0.3.0.tar.gz
  • Upload date:
  • Size: 61.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200311 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for hal-cgp-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5f3d493b11010e019acd1afe1db63cb59fc26c34ade8a436f015dc92bbaa4977
MD5 163cf832a32f7a93034b9f9ecb76e043
BLAKE2b-256 8700019a0826774f2f0add62c826248e809a373fad4237477917ec65ecac04a0

See more details on using hashes here.

File details

Details for the file hal_cgp-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: hal_cgp-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 46.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200311 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for hal_cgp-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c21e114906f6a7c1191f1846991f24d6ea17d257960cf0d422ac9c44a2150140
MD5 15c9d55bb7d62f035f0a3a54700ce2af
BLAKE2b-256 94e3f477c5e0a9b8d397275a5ba5e8ddd7310c741635984bed4a4cb5c52afb90

See more details on using hashes here.

Supported by

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