A hybrid between strongly-typed (STGP) and grammar-guided genetic programming (GGGP).
GeneticEngine is a Genetic Programming framework for single- and multi-objective optimization. GeneticEngine allows the user to provide domain knowledge about the shape of the solution (using type annotations) and by defining the fitness function.
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.
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!
GeneticEngine has been developed at LASIGE, University of Lisbon by:
This work was supported by Fundação para a Ciência e Tecnologia (FCT) through:
And by Lisboa2020, Compete2020 and FEDER through:
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},
}