https://github.com/mmore500/signalgp-lite
https://github.com/mmore500/signalgp-lite
artificial-life digital-evolution genetic-programming
Last synced: 26 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mmore500/signalgp-lite
- Owner: mmore500
- License: mit
- Created: 2020-10-06T03:51:23.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-03-14T13:24:26.000Z (2 months ago)
- Last Synced: 2025-04-30T10:13:05.750Z (26 days ago)
- Topics: artificial-life, digital-evolution, genetic-programming
- Language: C++
- Homepage: https://osf.io/j8pge/
- Size: 26.8 MB
- Stars: 3
- Watchers: 2
- Forks: 6
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Citation: CITATION.cff
- Authors: AUTHORS.md
Awesome Lists containing this project
README
# signalgp-lite
[](https://github.com/mmore500/signalgp-lite/releases)
[](https://www.codacy.com/gh/mmore500/signalgp-lite/dashboard?utm_source=github.com&utm_medium=referral&utm_content=mmore500/signalgp-lite&utm_campaign=Badge_Grade)
[](https://github.com/mmore500/signalgp-lite/actions?query=workflow%3ACI)
[](https://signalgp-lite.readthedocs.io/en/latest/?badge=latest)
[](https://signalgp-lite.readthedocs.io/en/latest/)
[](https://codecov.io/gh/mmore500/signalgp-lite)
[](https://github.com/mmore500/signalgp-lite/search?q=todo+OR+fixme&type=)
[](https://github.com/mmore500/signalgp-lite)- Free software: MIT license
- Documentation:
- header-only, namespace-encapsulated softwareA genetic programming implementation designed for large-scale artificial life applications.
Organized as a header-only C++ library.
Inspired by [Alex Lalejini](http://lalejini.com/)'s [SignalGP](https://github.com/amlalejini/signalgp).## Quick Start
This "hello world" example throws together
* a custom hardware peripheral to manage greeting information,
* a custom operation to print a greeting, and
* generation of a random program,
* execution of that random program on a virtual multi-core CPU.`say-hello.cpp`:
```cpp
#include
#include
#include#include "Empirical/include/emp/math/Random.hpp"
#include "sgpl/algorithm/execute_cpu.hpp"
#include "sgpl/spec/Spec.hpp"
#include "sgpl/hardware/Cpu.hpp"
#include "sgpl/library/OpLibraryCoupler.hpp"
#include "sgpl/library/prefab/ControlFlowOpLibrary.hpp"
#include "sgpl/program/Program.hpp"emp::Random rng;
// custom hardware peripheral, can be written to or read from during execution
struct Peripheral {
size_t greet_count{};
std::string name;
};// custom CPU operation
struct SayHello {template
static void run(
sgpl::Core&,
const sgpl::Instruction&,
const sgpl::Program&,
typename Spec::peripheral_t& peripheral
) {
std::cout << "for the " << peripheral.greet_count++ << "th time... ";
std::cout << "hello there " << peripheral.name << '\n';
}static std::string name() { return "SayHello"; }
static size_t prevalence() { return 1; }
};
// extends prefab ControlFlowOpLibrary with SayHello operation
using library_t = sgpl::OpLibraryCoupler;// custom compile-time configurator type
using spec_t = sgpl::Spec;int main() {
sgpl::Cpu cpu;
Peripheral peripheral;
peripheral.name = "Grace Hopper";sgpl::Program program{ 100 }; // randomly generated, 100 instructions
cpu.InitializeAnchors( program ); // load program onto CPU
// generate random signals to launch available virtual cores
while ( cpu.TryLaunchCore( emp::BitSet<64>(rng) ) ) ;// execute up to one thousand instructions
sgpl::execute_cpu( std::kilo::num, cpu, program, peripheral );}
```compile:
```bash
g++ --std=c++17 -Iinclude/ -Ithird-party/ say-hello.cpp -o say-hello.out
```run:
```bash
./say-hello.out
```## Benchmarks
signalgp-lite provides several-times speedup over the current "vanilla" SignalGP implementation.
[](https://osf.io/2pdur/)
*[Speedup](https://en.wikipedia.org/wiki/Speedup) of mean instruction execution time provided by signalgp-lite compared to vanilla SignalGP.
Speedup is measured for random programs generated from different subsets of instructions ("libraries") over different-size populations of virtual CPUs ("num agents").*For randomly-generated programs composed of arbitrary instructions, signalgp-lite approaches a virtual instruction execution rate of around 10Mhz on a 3.5Ghz processor.
Virtual nop instructions execute at rate of around 200Mhz.[](https://osf.io/6te73/)
*[Wall clock](https://en.wikipedia.org/wiki/Elapsed_real_time) timings of twenty randomly-generated programs composed of instructions from different libraries.*Timings for `nop` and `arithmetic` libraries report the mean time to execute sixteen instructions on one core.
Timings for `complete` and `sans_regulation` libraries report timings for executing sixteen instructions, one each across sixteen virtual threads.
(`sans_regulation` refers to the `complete` library with tag-matching regulation disabled.)These results are associated with [commit c10ed70](https://github.com/mmore500/signalgp-lite/commit/c10ed70), measured at 1602292830 seconds since epoch.
Details on the machine used to perform these benchmarks are available via [Open Science Framework](https://osf.io/), e.g., .
[mimalloc](https://github.com/microsoft/mimalloc) memory allocator.Microbenchmarks are performed, graphed, and uploaded as part of the project's CI build, so check the [project's OSF page](https://osf.io/j8pge/) for up-to-the-minute profiling information!
## Citing
If signalgp-lite contributes to a scientific publication, please cite it as
> Moreno, M. A., Rodriguez Papa, S., & Ofria, C. (2021). SignalGP-Lite: Event Driven Genetic Programming Library for Large-Scale Artificial Life Applications. arXiv preprint arXiv:2108.00382.
```bibtex
@misc{moreno2021signalgp,
doi = {10.48550/ARXIV.2108.00382},
url = {https://arxiv.org/abs/2108.00382},
author = {Moreno, Matthew Andres and Rodriguez Papa, Santiago and Lalejini, Alexander and Ofria, Charles},
keywords = {Neural and Evolutionary Computing (cs.NE), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {SignalGP-Lite: Event Driven Genetic Programming Library for Large-Scale Artificial Life Applications},
publisher = {arXiv},
year = {2021},
copyright = {arXiv.org perpetual, non-exclusive license}
}
```Consider also citing [Empirical](https://github.com/devosoft/Empirical).
And don't forget to leave a [star on GitHub](https://github.com/mmore500/signalgp-lite/stargazers)!## Credits
This library draws heavily on Alex Lalejini's work with SignalGP.
This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [devosoft/cookiecutter-empirical-project](https://github.com/devosoft/cookiecutter-empirical-project) project template.
This package uses [Empirical](https://github.com/devosoft/Empirical#readme), a library of tools for scientific software development, with emphasis on also being able to build web interfaces using [Emscripten](https://emscripten.org/).