Skip to content

Commit

Permalink
Merge pull request #466 from FergusonAJ/virtual_cpu_merge
Browse files Browse the repository at this point in the history
Merge misc. MABE2 support branches into MABE_devel
  • Loading branch information
FergusonAJ authored Jul 19, 2022
2 parents e9efd8c + b4b2024 commit f552287
Show file tree
Hide file tree
Showing 38 changed files with 5,026 additions and 1,376 deletions.
42 changes: 19 additions & 23 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
tidy:
name: Enforce Tidyness
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -31,7 +31,7 @@ jobs:
- run: ./ci/test_tidy.sh
test:
name: Tests
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
Expand All @@ -50,11 +50,14 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
with:
version: 11
- run: sudo apt-get update -qq
- run: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- run: sudo apt-get update -qq
- run: sudo apt-get install -qq g++-8 cmake build-essential python3-pip python3-virtualenv nodejs tar gzip libpthread-stubs0-dev libc6-dbg gdb
- run: sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 90
- run: sudo apt-get install -qq cmake build-essential python3-pip python3-virtualenv nodejs tar gzip libpthread-stubs0-dev libc6-dbg gdb
- run: git fetch origin master:refs/remotes/origin/master
- run: make install-test-dependencies
- run: ${CXX} --version
Expand All @@ -63,46 +66,39 @@ jobs:
make ${TEST_SET} CXX=${CXX}
test-web:
name: Web Tests
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
with:
version: 11
- run: sudo apt-get update -qq
- run: sudo apt-get install -qq g++-8 cmake build-essential python3-pip python3-virtualenv nodejs tar gzip libpthread-stubs0-dev libc6-dbg gdb
- run: sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 90
- run: sudo apt-get install -qq cmake build-essential python3-pip python3-virtualenv nodejs tar gzip libpthread-stubs0-dev libc6-dbg gdb
- run: make install-test-dependencies
- name: Run headless test
uses: GabrielBB/xvfb-action@v1
with:
run: make test-web
test-coverage:
name: Measure Test Coverage
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- run: sudo apt-get update -qq
- run: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- run: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
- run: sudo apt-add-repository "deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main"
- run: sudo apt-get update -qq
- run: sudo apt-get install -qq g++-8
- run: sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 90
- run: sudo apt-get install cmake build-essential python3-virtualenv python3-pip nodejs tar gzip libclang-7-dev llvm llvm-dev libllvm7 llvm-7 llvm-7-dev clang-7 libstdc++-7-dev # might have to happen after we update g++
- run: sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-7 90
- run: sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-7 90
- run: sudo update-alternatives --install /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-7 90
- run: sudo update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-7 90
- run: sudo apt-get install cmake build-essential python3-virtualenv python3-pip nodejs tar gzip clang llvm-dev libclang-dev
- run: git fetch origin master:refs/remotes/origin/master
- run: make install-test-dependencies
- run: export CXX=clang++-7 && make install-coverage-dependencies
- run: export CXX=clang++-7 && make coverage
- run: export CXX=clang++ && make install-coverage-dependencies
- run: export CXX=clang++ && make coverage
- run: curl -s https://codecov.io/bash | bash
test-documentation:
name: Test Documentation Build
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -119,7 +115,7 @@ jobs:
dst: stats/doc-coverage.json
deploy-dockerhub:
name: Deploy to DockerHub
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/master'
needs:
- tidy
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace, so it is simple to incorporate into existing projects.
[![CI](https://github.com/devosoft/Empirical/workflows/CI/badge.svg)](https://github.com/devosoft/Empirical/actions?query=workflow%3ACI+branch%3Amaster) [![Documentation Status](https://readthedocs.org/projects/empirical/badge/?version=latest)](https://empirical.readthedocs.io/en/latest/?badge=latest) [![DOI](https://zenodo.org/badge/24824563.svg)](https://zenodo.org/badge/latestdoi/24824563) [![codecov](https://codecov.io/gh/devosoft/Empirical/branch/master/graph/badge.svg)](https://codecov.io/gh/devosoft/Empirical)
[![DockerHub](https://img.shields.io/badge/DockerHub-Hosted-blue)](https://hub.docker.com/r/devosoft/empirical)
![Documentation Coverage](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fdevosoft%2FEmpirical%2Fgh-storage%2Fstats%2Fdoc-coverage.json)
[![GitHub contributors](https://img.shields.io/github/contributors/devosoft/Empirical.svg?style=flat-square)](https://github.com/devosoft/Empirical/graphs/contributors)


See our [Built With Empirical Gallery](https://empirical.readthedocs.io/en/latest/BuiltWithEmpiricalGallery) for examples of web tools built with Empirical.

Expand Down
2 changes: 1 addition & 1 deletion doc/blogs/Binomial.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ before introducing the next bug?

A **Poisson Distribution** is a continuous version of a Binomial Distribution, used for measuring
the number of independent events that occur in a time period rather than during a specified
number of events.
number of events.
30 changes: 30 additions & 0 deletions doc/library/Evolve/evolve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Evolution tools

## World

```{eval-rst}
.. doxygenfile:: emp/Evolve/World.hpp
:project: Empirical
:no-link:
```

## Systematics

```{ref} systematics
```

## NK

```{eval-rst}
.. doxygenfile:: emp/Evolve/NK.hpp
:project: Empirical
:no-link:
```

## Selection

```{eval-rst}
.. doxygenfile:: emp/Evolve/World_select.hpp
:project: Empirical
:no-link:
```
195 changes: 195 additions & 0 deletions doc/library/Evolve/systematics.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
.. SystematicsDocumentation documentation master file, created by
sphinx-quickstart on Thu May 28 16:40:07 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Documentation for Systematics
====================================================

.. toctree::
:maxdepth: 2
:caption: Contents:

modules

Systematics
===========

Systematics is a classification of organisms based on evolutionary (phylogenetic) relationships.

***************
Systematics.h
***************

This file is part of Empirical and is located in ``Empirical/source/Evolve/Systematics.h``

The systematics manager is used to track genotypes, species, clades, or lineages of organisms in a world.

Systematics allows a user to generate data to form phylogenetic trees.

The program can be run with different levels of abstraction, meaning the data can be generated by position,
phenotype, or even genotype if you have a lot of RAM.

**Note**: You are responsible for filling in templates! Adding the template just gives you a place to store your data.

Taxon Specifics
===============

* Taxon - a group of species with similar characteristics
* Genotypes are the most commonly used Taxon

A user can see the type and number of mutations that ocurred to bring about a taxon.

Some information that can be accessed is:

* taxon ID# ``GetID()``
* details of organisms in the taxon ``GetInfo()``
* pointer to the parent group (will return a null pointer if the species was injected) ``GetParent()``
* how many organisms currently exist in the group and how many total organisms have ever existed in the group ``GetNumOrgs()`` or ``GetTotOrgs()``
* how many direct offspring groups exist from this group and how many total extant offspring that exist from this taxa ``GetTotalOffspring()``
* how deep in the tree the node you are examining is ``GetDepth()``
* when did this taxon first appear in the population ``GetOriginationTime()``
* when did the taxon leave the population ``GetDestructionTime()``

New organisms are added to the taxon using ``AddOrg()``.
New offspring are added to the taxon with ``AddOffspring()`` .

Organisms are removed with ``RemoveOrg()``.
Offspring are removed with ``RemoveOffspring()`` .

If there are no more remaining organisms or offspring the taxon will deactivate.


General Systematics Data
=========================

Things that systematics can tell you about a phylogeny and how to access them:

* Are we tracking a synchronous population? ``GetTrackSynchronous()`` ``SetTrackSynchronous()``
* Are we storing all taxa that are still alive in the population? ``GetStoreActive()`` ``SetStoreActive()``
* Are we storing all taxa that are ancestors of the living organisms in the population? ``GetStoreAncestors()`` ``SetStoreAncestors()``
* Are we storing all taxa that have died out, as have all of their descendants? ``GetStoreOutside()`` ``SetStoreOutside()``
* Are we storing any taxa types that have died out? ``GetArchive()`` ``SetArchive()``
* Are we storing the positions of taxa? ``GetStorePosition()`` ``SetStorePosition()``
* How many living organisms are currently being tracked? ``GetTotalOrgs()``
* How many independent trees are being tracked? ``GetNumRoots()``
* What ID will the next taxon have? ``GetNextID()``
* What is the average phylogenetic depth of organisms in the population? ``GetAveDepth()``
* To find the most recent common ancestor (MRCA) use ``GetMRCA()`` or ``GetMRCADepth()`` to find the distance to the MRCA.

**The systematics class tracks the relationships among all organisms bases on the INFO_TYPE
provided. If an offspring has the same value for INFO_TYPE as its parent, it is grouped into
the same taxon. Otherwise a new Taxon is created and the old one is used as its parent in
the phylogeny. If the provided INFO_TYPE is the organism's genome, a traditional phylogeny
is formed, with genotypes. If the organism's behavior/task set is used, then organisms are
grouped by phenotypes. If the organism's position is used, the evolutionary path through
space is tracked. Any other aspect of organisms can be tracked this way as well.**


**Generally, all living organisms' taxa should be tracked and ancestral organisms' taxa should be maintained for lineage.
However, not all dead taxa should be maintained, it gets too big.**

***************************
Diversity and Distinction
***************************

Systematics.h can also be used to find phylogenetic diversity for all extant taxa in the tree,
assuming all edges from parent to child have a length of one.

When all branch lengths are equal, the phylogenetic diversity is the number of internal nodes plus the number of
extant taxa minus 1.

You can also find how distinct a specific taxa is from the rest of the population
based on the amount of unique evolutionary history that it represents.

*****************************
Synchronous Populations
*****************************

A synchronous population is a population in which each generation is a discrete time point
and a completely new set of individual organisms is created for each generation. This means that
an organism and its parent can never exist at the same time.

An asynchronous population is the opposite, where generations overlap and organisms reproduce
when they are ready.

In the systematics manager, synchronicity is controlled with

``GetTrackSynchronous()`` which returns true or false and
``SetTrackSynchronous(input true or false)`` which allows you to use a synchronous or asynchronous population.


Using the Systematics Manager
==============================

The systematics.h file alone will not give you any useful information. You must use a test file in conjunction with the systematics manager
in order to see output.

To retrieve some results we will use the file Systematics.cc
which is located in Empirical/tests/Evolve/Systematics.cc.

To compile to code use this command in the tests directory::

make test-Systematics


**********
Output
**********

Terminal Output::

AddOrg 25 (id1, no parent)

AddOrg -10 (id2; parent id1)

AddOrg 26 (id3, parent id1)

AddOrg 27 (id4, parent id2)

The first line of output shows the first organism in the examined phylogeny. This organism is added with AddOrg
and is assigned an ID of id1. The organism has no parent, as seen in the farthest column of output, meaning that
organism id1 will be the root of the phylogeny and produce offspring.

If we then look at the first number is parenthesis, we see the second organism with and ID of id2. Id2 is a direct descendant of the id1 organism.

Lastly, if we look at id4, we see that its parent is id2, meaning that we have created another node in the tree
as the organisms move through generations, producing new offspring.

The terminal output should also include this section::

Active count: 11 [18|1,0|17] [17|1,2|11] [15|1,0|null] [12|1,1|11] [16|1,0|11] [11|1,3|null] [6|1,0|5] [19|1,0|17] [5|1,1|null] [4|1,0|null] [3|1,0|null]


The 11 at the front refers to the number of total taxa in the phylogeny.

If we look at the first set of numbers: ``[18|1, 0|17]``

The first number in brackets, 18 in this case, is the taxon of the organism where
a mutation occurred. 1, the next number, is the number of mutations that led to this branch.
0 is the number of offspring from this organism. Lastly, 17 is the id of the parent organism.

As for the second set ``[17|1, 2|11]`` -- this is taxon 17, one mutation occurred,
id17 had 2 offspring, and its parent is id11.

The last portion of the output has several lines of 3 numbers.

It should look like this: ::

1 : 0 : -1
2 : 0 : -1
3 : 0 : 0
4 : 0 : 0
5 : 0 : 0
6 : 0 : 0
7 : 0 : 0
8 : 0 : 987
9 : 0 : 986
10 : 0 : 987
11 : 0 : 988
12 : 0 : 987
13 : 0 : 988

The first number is the organism number. The second number is the position of the organism.
The third number is the fitness of the organism at position 0.
1 change: 1 addition & 0 deletions doc/library/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ compiler/compiler
data/data
datastructs/datastructs
debug/debug
Evolve/evolve
functional/functional
io/io
math/math
Expand Down
35 changes: 35 additions & 0 deletions examples/math/CombinedBinomialDistribution.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @note This file is part of Empirical, https://github.com/devosoft/Empirical
* @copyright Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
* @date 2022-2022
*
* @file CombinedBinomialDistribution.cpp
* @brief Some examples code for using emp::CombinedBinomialDistribution
*/


#include "emp/math/CombinedBinomialDistribution.hpp"
#include "emp/math/Random.hpp"

int main(int argc, char* argv[])
{
if(argc != 4){
std::cout << "Error! Expecting exactly three command line arguments: "
<< "p n num_trials" << std::endl;
emp_assert(false);
}
double p = std::stod(argv[1]);
size_t n = std::stoi(argv[2]);
size_t num_trials = std::stoi(argv[3]);

emp::Random random;
emp::CombinedBinomialDistribution distribution(p, 1);

double mean = 0;

for(size_t i = 0; i < num_trials; i++){
mean += (double)distribution.PickRandom(n, random) / num_trials;
}
std::cout << "Mean after " << num_trials << " trials: " << mean << std::endl;
return 0;
}
2 changes: 1 addition & 1 deletion examples/math/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CFLAGS_web_debug := $(CFLAGS_all) $(OFLAGS_web_debug) --js-library ../../include
CFLAGS_web_opt := $(CFLAGS_all) $(OFLAGS_web_opt) --js-library ../../include/emp/web/library_emp.js -s EXPORTED_FUNCTIONS="['_main', '_empCppCallback']" -s NO_EXIT_RUNTIME=1
#CFLAGS_web := $(CFLAGS_all) $(OFLAGS_web) --js-library ../../include/emp/web/library_emp.js -s EXPORTED_FUNCTIONS="['_main', '_empCppCallback']" -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=1

TARGETS := combos constants Distribution info_theory math Random Range stats
TARGETS := combos constants Distribution info_theory math Random Range stats CombinedBinomialDistribution

default: native

Expand Down
Loading

0 comments on commit f552287

Please sign in to comment.