Gread
grammar-evolving algorithm designer
Install / Use
/learn @sesco-llc/GreadREADME
gread
Grammar-Evolving Algorithm Designer
What Is It?
It's currently a basic genetic programming system built to explore some ideas for algorithm design, and specifically, grammatical evolution.
The architecture is generic to the user's choice of language.
So It's Bring Your Own Language?
Yes; the genome is merely a blob of binary data and language support is generalized by a generic language type. You specify the grammar for your language using a form of BNF notation in a string.
We're initially testing against Lua, which is (unreasonably) powerful as genetic programming languages go, but still quite performant.
So You Evolve Lua Programs?
Yes, you can evolve Lua programs by importing gread/lua and defining the Lua
grammar you wish to use.
I'm (still) finding Fennel easier; it's a lisp which compiles and runs in the Lua VM.
So You Evolve Fennel Programs!
An evolved Fennel program is evaluated after being compiled into Lua. This is a small performance penalty that we will design out eventually.
Does It Evolve Nim Programs?
It's possible to evolve Nim programs with Gread. The Nim VM is fairly complex and expensive to run. Also, there is presently no tree-sitter support for Nim's grammar.
What About Other Languages?
To add novel language support to the framework, you merely implement a few key functions that Gread will exploit.
Future support here will probably revolve around tighter integration with htsparse (tree-sitter) so that if tree-sitter supports your language, so will Gread.
Installation
You probably need some flavor of Linux for this, but it might work under OSX.
Gread requires the tree-sitter library for parsing extant programs into AST; this was not always the case, but going forward, I think it will be more valuable as a full dependency we can rely upon, rather than an optional one.
$ nimph clone sesco-llc/gread
or if you're still using Nimble like it's 2012,
$ nimble install https://github.com/sesco-llc/gread
Usage
Check out the examples; the average example does not use threads
and serves as a simple and fast smoke-test.
The lls example performs a linear least-squares regression across threads; it
learns quickly but may not find a perfect solution before you lose interest.
Note the following required compilation switches:
--define:danger(because otherwise it's debugging)--define:useMalloc(due to bugs in the Nim allocator)--gc:arcor--gc:orc(because we use CPS)--panics:on(because we use CPS)--define:lunacyLuaJIT(enables use of luajit)
Debugging
defines
greadPinpin each thread to a coregreadCoresspecial desired maximum thread countgreadDebugmight enable some debugging here and theregreadProfileprofiles some interesting parts of the system
Documentation
Nim's documentation generator does not work, but the code is documented.
License
GPLv3
