Skip to main content

Genetic Programming with Types and Grammars

Project description

Genetic Engine

Documentation codecov

GeneticEngine is not a search-based Python library that allows you to describe the structure of your solutions as Python dataclasses and abstract classes, and explores the solution space using different algorithms, such as enumerative search, hill climbing, and several flavors of Genetic Programming.

Documentation

class MyExpr(ABC):
	"MyExpr is a non-terminal/abstract class."
	def eval(self):
		...

@dataclass
class Plus(MyExpr):
	"E -> E + E"
	left: MyExpr
	right: MyExpr

	def eval(self):
		return self.left.eval() + self.right.eval()

@dataclass
class Literal(MyExpr):
	"E -> <int>"
	value: int

	def eval(self):
		return self.value

In this small example, we are defining the language that supports the plus operator and integer literals. GeneticEngine will be able to automatically generate all possible expressions, such as Plus(left=Plus(left=Literal(12), right=Literal(12)), right=Literal(15)), and guide the search towards your goal (e.g., lambda x: abs(x-2022)). For this very simple toy problem, it will find an expression that computes 2022, ideally as small as possible. And this is a very uninteresting example. But if you introduce variables into the mix, you have a very powerful symbolic regression toolkit for arbitrarily complex expressions.

Contributing

After cloning the repo, please run source setup_dev.sh to install virtualenv, all dependencies and setup all pre-commit hooks.

Pull Requests are more than welcome!

Authors

GeneticEngine has been developed at LASIGE, University of Lisbon by:

Acknowledgements

This work was supported by Fundação para a Ciência e Tecnologia (FCT) through:

  • the LASIGE Research Unit (ref. UID/00408/2025)
  • Pedro Barbosa PhD fellowship (SFRH/BD/137062/2018)
  • Guilherme Espada PhD fellowship (UI/BD/151179/2021)
  • Paulo Santos CMU|Portugal PhD fellowship (SFRH/BD/151469/2021)
  • the FCT Exploratory project RAP (EXPL/CCI-COM/1306/2021)
  • the FCT Advanced Computing projects (2022.15800.CPCA.A1, CPCA/A1/395424/2021, CPCA/A1/5613/2020, CPCA/A2/6009/2020)

And by Lisboa2020, Compete2020 and FEDER through:

Publications

Applications of GeneticEngine

Let us know if your paper uses Genetic Engine, to list it here.

Please cite as:

Espada, Guilherme, et al. "Data types as a more ergonomic frontend for Grammar-Guided Genetic Programming.", GPCE '22: Concepts and Experiences, 2022

Bibtex:

@inproceedings{espada2022data,
  author={Guilherme Espada and Leon Ingelse and Paulo Canelas and Pedro Barbosa and Alcides Fonseca},
  editor    = {Bernhard Scholz and Yukiyoshi Kameyama},
  title={Datatypes as a More Ergonomic Frontend for Grammar-Guided Genetic Programming},
  booktitle = {{GPCE} '22: Concepts and Experiences, Auckland, NZ, December 6 - 7, 2022},
  pages     = {1},
  publisher = {{ACM}},
  year      = {2022},
}

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

geneticengine-0.8.10.tar.gz (131.4 kB view details)

Uploaded Source

Built Distribution

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

geneticengine-0.8.10-py3-none-any.whl (208.5 kB view details)

Uploaded Python 3

File details

Details for the file geneticengine-0.8.10.tar.gz.

File metadata

  • Download URL: geneticengine-0.8.10.tar.gz
  • Upload date:
  • Size: 131.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for geneticengine-0.8.10.tar.gz
Algorithm Hash digest
SHA256 8c44d05b2fe6e89a98955f6e38fb4f88aaa7875c8c0ee238064b7125c5b94092
MD5 9ce65e13260f3cbd766df68882bfbb4b
BLAKE2b-256 b1dfb0852477aaf5acf075053a84467be4e8504b53a1b607259b9b3eb89f49eb

See more details on using hashes here.

File details

Details for the file geneticengine-0.8.10-py3-none-any.whl.

File metadata

File hashes

Hashes for geneticengine-0.8.10-py3-none-any.whl
Algorithm Hash digest
SHA256 a731f756583e8a26e3d03d8204b7776f188b05ac8628c1a3ce98eaea90960b70
MD5 0d99586659d4b9b5ade8add7317da3d5
BLAKE2b-256 c2ac3f52d756331a7b3fc3961dcf2dd8b13fbc614e8a4e9cbd41ef00c4855c2f

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