This is a reference C++17 implementation for the organism generation method AGIO.
- Clone using --recurse-submodules to pull all the submodules.
- Open the folder with Visual Studio 2017 or later (the Community versions work fine).
- Wait for CMake to create the solution files. The first time it will take a while as it fetches boost.
- Select the experiment you want and compile as usual.
Note : When switching between debug and release, you'll need to do a clean first, otherwise you get (at least with VS 2019) linker errors.
-
Install SMFL. On ubuntu you can do
sudo apt-get install libsfml-dev
-
Run cmake to configure the project. Need CMake 3.12 or higher. The first time it will take a while as it fetches boost. Supported configurations are Release, Debug and RelWithDebInfo.
cmake -DCMAKE_BUILD_TYPE=Release .
3.1) You can turn off the build_tests option to not build the experiments. 4) Run make. You can build all the experiments or just the one you want. A couple experiments are exclusive to windows.
make
AGIO is built as a static library, which is later linked by the different experiments. All source files are located on the src folder. As a note, while the paper uses the term "Organism" to refer to AGIO's agents and "Individual" for NEAT agents, in the code is the other way around. I'm sorry about that.
All code is under the AGIO namespace, and is organized on the following folders.
-
Core : Global configuration parameters and support for loading it from files.
-
Utils : General helper functions for math, SFML support, threading, and others.
-
Evolution : Code for organism and population generation, and the public interface
- PublicInterface: The PublicInteface class, defined on Globals.h, is the way AGIO interacts with a specific problem. The user must specialize the class and assign an instance to the Interface global variable before using any AGIO method or object. This class is responsible of specifying the component groups, manage the state of the organisms and the environment, and compute the fitness.
-
Interface : Contains the base individual definition, which is the base class for organisms during evolution and evolved organisms.
-
Serialization : Support for saving a population to disk and reading it back, with a thinner organism implementation. This is useful for using the evolved individuals in your games/apps.
There are several experiments all on the Tests folder. The folders are separated by what interface implementation they use. After compilation the binaries for the different experiments with their lowercase underscored names will be on the bin folder.
When running the experiments it's important that the working directory is the bin folder, otherwise it'll fail to find the files it needs to work.
-
3D Experiment : The experiment here is not reported on the paper as it's an unfinished test of integrating AGIO organisms into an Unreal Engine 4 project.
-
Greedy : A greedy comparison algorithm for the prey-predator system. Currently unused.
-
PreyPredator : This folder contains two experiments, prey_predator (main.cpp) and sim_size_test (SimSizeTest.cpp).
-
prey_predator : Verification experiment with two species, one of carnivores and the other of herbivores. The experiment has two modes, selected at startup. One runs the evolution and stores several CSV files with per generation values like fitness or species age. The other presents a 2D visualization of the simulation, with round sprites being herbivores, star-like sprites carnivores and green "smudges" food. The evolution needs to be run before the visualization, otherwise it won't have any evolved individuals to load.
Note: For some reason I never managed to fix (not that I dedicated much time trying tbh), the SFML visualizations only seems to work on Windows on Debug builds. Outputs the following CSV files, where XXXX is a timestamp value :
- XXXX_age_herbivore.csv
- XXXX_age_carnivore.csv
- XXXX_avg_eaten_herbivore.csv
- XXXX_avg_eaten_carnivore.csv
- XXXX_avg_failed_herbivore.csv
- XXXX_avg_failed_carnivore.csv
- XXXX_avg_coverage_herbivore.csv
- XXXX_avg_coverage_carnivore.csv
- XXXX_min_eaten_herbivore.csv
- XXXX_min_failed_herbivore.csv
- XXXX_min_coverage_herbivore.csv
- XXXX_max_eaten_herbivore.csv
- XXXX_max_failed_herbivore.csv
- XXXX_max_coverage_herbivore.csv
- XXXX_min_eaten_carnivore.csv
- XXXX_min_failed_carnivore.csv
- XXXX_min_coverage_carnivore.csv
- XXXX_max_eaten_carnivore.csv
- XXXX_max_failed_carnivore.csv
- XXXX_max_coverage_carnivore.csv
-
sim_size_test : Does multiple evolutions testing different simulation sizes but keeping the population size constant. Meant to show the impact the simulation size has on the behavior, as a justification for the decoupling of simulation and population sizes.
Outputs a CSV (sim_size.csv) with the per species metrics on the last generation of each evolution.
-
-
ComplexSystem : This folder contains several experiments
-
complex_system : Equivalent to the prey_predator experiment but for the complex system. On the visualizer the two sprites from prey_predator are reused, with the addition of a third one for omnivores. Different species use different colors. This experiment is also used for the parametric configuration.
This experiment does not generate any output files, it just logs to the console.
-
perf_test : Profiles average partial and total (considering sensor and action evaluation) decision time, along with evolution time as a factor of the number of generations and population size multiplier.
Evolution times are printed on the console while decision times are stored on two CSVs (total_times.csv and decision_times.csv).
-
nn_graph_dump : Does an evolution run on the complex system and generates DOT files for the neural networks of the evolved organisms. Squares are inputs, triangles outputs and hexagon bias signals.
-
interrelations_test : Evaluates interrelations between species. It outputs three CSV files, interrelations.csv, baseline.csv and species_ref.csv, which can be processed by the process_interrel.py script.
-
human_test (Windows exclusive) : Used to compare AGIO with a player. If no evolved population is found (human_test_evolved_g400.txt) it will first evolve the population before proceeding to the experiment, where the player is tasked to control an organism.
It outputs a timestamped CSV file of the form history_[showing_descs]_XXXX_.csv and also prints to the console.
-
memory_test (Windows exclusive) : Profiles memory usage during evolution and of the evolved organisms.
Outputs two CSV files, mem_evo.csv and mem_org.csv.
-
In addition to the library and the experiments, there are a few python scripts to help processing the results and doing the parametric configuration. The scripts require matplotlib, scipy and numpy.
-
Parametric configuration : The first step of the parametric configuration is running the SensibilityTest.py script, which will generate the files to select the most relevant parameters. After that's finished running process_sensibility.py will output the coefficient of variation for each parameter.
After selecting the parameters to adjust the ParametricConfig.py script needs to be run to generate the results. By default it will test values for the parameters on the range array on line 16, that needs to be manually modified if it doesn't match the selected parameters. Keep in mind that even with a good computer this is a slow process. The script takes as input the number of workers to use, try to balance this with the number of workers used during evolution (12 by default).
Finally, the process_params.py script will output the best configurations in importance order (the ones further from the center and closest to the y = x line on the fitness - species count plane).
-
Interrelations : The process_interrel.py script will process the results from the interrelations experiment and generate both an interrelations graph in DOT format and a table in latex format with the statistics. On the graph diamonds represent omnivores, ellipses herbivores and diamonds carnivores. A dashed line from A to B signifies that A's fitness decreased when B was not on the simulation, while a solid line means it increased.
-
Timing experiments : process_times.py is a simple script that computes mean and standard deviation for the values generated by the different timing experiments.