Skip to content

Commit

Permalink
Merge pull request #220 from amlalejini/2024-alex-dev
Browse files Browse the repository at this point in the history
Update complex-syms-clean to use most recent version of Empirical
  • Loading branch information
anyaevostinar authored Oct 25, 2024
2 parents 32ce6b5 + fea4a88 commit 0818e57
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 54 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ jobs:
- name: run symbulation
run: cd SymbulationEmp && make debug-default && ./symbulation_default -GRID_X 5 -GRID_Y 5

- name: test web build
run: cd SymbulationEmp/emsdk && ./emsdk install 1.38.48 && ./emsdk activate 1.38.48 && source ./emsdk_env.sh && cd .. && make web

# Runs a single command using the runners shell
- name: Make tests
run: cd SymbulationEmp && make coverage


- name: test web build
run: cd SymbulationEmp/emsdk && ./emsdk install 1.38.48 && ./emsdk activate 1.38.48 && source ./emsdk_env.sh && cd .. && make web

- name: Generate coverage
run: cd SymbulationEmp && gcov -abcfu main.cc

- name: Upload coverage
uses: codecov/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
url = https://github.com/emscripten-core/emsdk
[submodule "signalgp-lite"]
path = signalgp-lite
url = https://github.com/tolziplohu/signalgp-lite
url = https://github.com/amlalejini/signalgp-lite
2 changes: 1 addition & 1 deletion Empirical
Submodule Empirical updated 891 files
21 changes: 11 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ EMP_DIR := Empirical/include
SGP_DIR := signalgp-lite/include

# Flags to use regardless of compiler
CFLAGS_all := -Wall -Wno-unused-function -std=c++17 -I$(EMP_DIR)/ -I$(SGP_DIR)/
VENDORIZE_EMP_FLAGS := -DUIT_VENDORIZE_EMP -DUIT_SUPPRESS_MACRO_INSEEP_WARNINGS
CFLAGS_all := -Wall -Wno-unused-function -std=c++20 -I$(EMP_DIR)/ -I$(SGP_DIR)/ ${VENDORIZE_EMP_FLAGS}

# Native compiler information
CXX_nat := g++
Expand Down Expand Up @@ -65,27 +66,27 @@ debug:
@echo SGP mode: make debug-sgp

debug-default: CFLAGS_nat := $(CFLAGS_nat_debug)
debug-default: default-mode
debug-default: default-mode
default-debug: debug-default

debug-parasite: CFLAGS_nat := $(CFLAGS_nat_debug)
debug-parasite: parasite-mode
debug-parasite: parasite-mode
parasite-debug: debug-parasite

debug-efficient: CFLAGS_nat := $(CFLAGS_nat_debug)
debug-efficient: efficient-mode
debug-efficient: efficient-mode
efficient-debug: debug-efficient

debug-lysis: CFLAGS_nat := $(CFLAGS_nat_debug)
debug-lysis: lysis-mode
debug-lysis: lysis-mode
lysis-debug: debug-lysis

debug-pgg: CFLAGS_nat := $(CFLAGS_nat_debug)
debug-pgg: pgg-mode
debug-pgg: pgg-mode
pgg-debug: debug-pgg

debug-sgp: CFLAGS_nat := $(CFLAGS_nat_debug)
debug-sgp: sgp-mode
debug-sgp: sgp-mode
sgp-debug: debug-sgp

debug-web: CFLAGS_web := $(CFLAGS_web_debug)
Expand All @@ -102,7 +103,7 @@ test:
@echo To run only the tests for each mode, use the following:
@echo Default mode testing: make test-default
@echo Efficient mode testing: make test-efficient
@echo Lysis mode testing: make test-lysis
@echo Lysis mode testing: make test-lysis
@echo PGG mode testing: make test-pgg
@echo SGP mode testing: make test-sgp

Expand All @@ -112,7 +113,7 @@ test-debug:
@echo To debug and test for each mode, use the following:
@echo Default mode: make test-debug-default
@echo Efficient mode: make test-debug-efficient
@echo Lysis mode: make test-debug-lysis
@echo Lysis mode: make test-debug-lysis
@echo PGG mode: make test-debug-pgg
@echo SGP mode: make test-debug-sgp

Expand Down Expand Up @@ -146,7 +147,7 @@ test-debug-pgg:

test-sgp:
$(CXX_nat) $(CFLAGS_nat) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test [sgp]
./symbulation.test [sgp]
test-debug-sgp:
$(CXX_nat) $(CFLAGS_nat_debug) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test [sgp]
Expand Down
2 changes: 1 addition & 1 deletion signalgp-lite
Submodule signalgp-lite updated 104 files
4 changes: 2 additions & 2 deletions source/default_mode/Host.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class Host: public Organism {

/**
* Input: None
*
*
* Output: Name of class as string, Host
*
* Purpose: To know which subclass the object is
Expand Down Expand Up @@ -546,7 +546,7 @@ class Host: public Organism {
if (mutation_rate == -1) mutation_rate = my_config->MUTATION_RATE();

if(random->GetDouble(0.0, 1.0) <= mutation_rate){
interaction_val += random->GetRandNormal(0.0, mutation_size);
interaction_val += random->GetNormal(0.0, mutation_size);
if(interaction_val < -1) interaction_val = -1;
else if (interaction_val > 1) interaction_val = 1;
}
Expand Down
12 changes: 6 additions & 6 deletions source/default_mode/SymWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class SymWorld : public emp::World<Organism>{
}

if(my_config->PHYLOGENY()){ //host systematic deletion is handled by empirical world destructor
Clear(); // delete hosts here so that hosted symbionts get
Clear(); // delete hosts here so that hosted symbionts get
// deleted and unlinked from the sym_sys
sym_sys.Delete();
}
Expand Down Expand Up @@ -263,7 +263,7 @@ class SymWorld : public emp::World<Organism>{
* Purpose: To add a symbiont to the systematic and to set it to track its taxon
*/
emp::Ptr<emp::Taxon<int>> AddSymToSystematic(emp::Ptr<Organism> sym, emp::Ptr<emp::Taxon<int>> parent_taxon=nullptr){
emp::Ptr<emp::Taxon<int>> taxon = sym_sys->AddOrg(*sym, emp::WorldPosition(0,0), parent_taxon, GetUpdate());
emp::Ptr<emp::Taxon<int>> taxon = sym_sys->AddOrg(*sym, emp::WorldPosition(0,0), parent_taxon);
sym->SetTaxon(taxon);
return taxon;
}
Expand All @@ -281,7 +281,7 @@ class SymWorld : public emp::World<Organism>{
*/
float PullResources(float desired_resources) {
// if LIMITED_RES_TOTAL == -1, unlimited, even if limited resources was on before
if (total_res == -1 || my_config->LIMITED_RES_TOTAL() == -1) {
if (total_res == -1 || my_config->LIMITED_RES_TOTAL() == -1) {
return desired_resources;
} else {
if (total_res>=desired_resources) {
Expand Down Expand Up @@ -524,7 +524,7 @@ class SymWorld : public emp::World<Organism>{
* Input: The pointer to the symbiont that is moving, the WorldPosition of its
* current location.
*
* Output: The WorldPosition object describing the symbiont's new location (it describes an
* Output: The WorldPosition object describing the symbiont's new location (it describes an
* invalid position if the symbiont is deleted during movement)
*
* Purpose: To move a symbiont into a new world position.
Expand Down Expand Up @@ -669,7 +669,7 @@ class SymWorld : public emp::World<Organism>{
/**
* Input: A size_t location to check in the symbiont population vector.
*
* Output: A boolean representing whether the the position is valid and
* Output: A boolean representing whether the the position is valid and
* occupied by a free living symbiont/
*
* Purpose: To determine if a given index is valid and occipied in the symbiont
Expand Down Expand Up @@ -781,7 +781,7 @@ class SymWorld : public emp::World<Organism>{
if (counts.size() <= result.size()) {
result.resize(counts.size());
}

return result;
}

Expand Down
8 changes: 4 additions & 4 deletions source/default_mode/Symbiont.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ class Symbiont: public Organism {
* Purpose: To destruct the symbiont and remove the symbiont from the systematic.
*/
~Symbiont() {
if(my_config->PHYLOGENY() == 1) {my_world->GetSymSys()->RemoveOrg(my_taxon, my_world->GetUpdate());}
if(my_config->PHYLOGENY() == 1) {my_world->GetSymSys()->RemoveOrg(my_taxon);}
}

/**
* Input: None
*
*
* Output: Name of class as string, Symbiont
*
* Purpose: To know which subclass the object is
Expand Down Expand Up @@ -396,13 +396,13 @@ class Symbiont: public Organism {
double local_size = my_config->MUTATION_SIZE();

if (random->GetDouble(0.0, 1.0) <= local_rate) {
interaction_val += random->GetRandNormal(0.0, local_size);
interaction_val += random->GetNormal(0.0, local_size);
if(interaction_val < -1) interaction_val = -1;
else if (interaction_val > 1) interaction_val = 1;

//also modify infection chance, which is between 0 and 1
if(my_config->FREE_LIVING_SYMS()){
infection_chance += random->GetRandNormal(0.0, local_size);
infection_chance += random->GetNormal(0.0, local_size);
if (infection_chance < 0) infection_chance = 0;
else if (infection_chance > 1) infection_chance = 1;
}
Expand Down
10 changes: 5 additions & 5 deletions source/efficient_mode/EfficientSymbiont.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class EfficientSymbiont: public Symbiont {

/**
* Input: None
*
*
* Output: Name of class as string, EfficientSymbiont
*
* Purpose: To know which subclass the object is
Expand Down Expand Up @@ -189,19 +189,19 @@ class EfficientSymbiont: public Symbiont {
}

if (random->GetDouble(0.0, 1.0) <= int_rate) {
interaction_val += random->GetRandNormal(0.0, local_size);
interaction_val += random->GetNormal(0.0, local_size);
if(interaction_val < -1) interaction_val = -1;
else if (interaction_val > 1) interaction_val = 1;

//also modify infection chance, which is between 0 and 1
if(efficient_config->FREE_LIVING_SYMS()){
infection_chance += random->GetRandNormal(0.0, local_size);
infection_chance += random->GetNormal(0.0, local_size);
if (infection_chance < 0) infection_chance = 0;
else if (infection_chance > 1) infection_chance = 1;
}
}
if (random->GetDouble(0.0, 1.0) <= eff_mut_rate) {
efficiency += random->GetRandNormal(0.0, local_size);
efficiency += random->GetNormal(0.0, local_size);
if(efficiency < 0) efficiency = 0;
else if (efficiency > 1) efficiency = 1;
}
Expand Down Expand Up @@ -239,7 +239,7 @@ class EfficientSymbiont: public Symbiont {
return sym_baby;
}
#pragma clang diagnostic pop


/**
* Input: The pointer to the organism that is the new host baby
Expand Down
8 changes: 4 additions & 4 deletions source/lysis_mode/Bacterium.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class Bacterium : public Host {
emp::Ptr<LysisWorld> my_world = NULL;

/**
*
* Purpose: Holds all configuration settings and points to same configuration
*
* Purpose: Holds all configuration settings and points to same configuration
* object as my_config from superclass, but with the correct subtype.
*
*/
Expand Down Expand Up @@ -82,7 +82,7 @@ class Bacterium : public Host {

/**
* Input: None
*
*
* Output: Name of class as string, Bacterium
*
* Purpose: To know which subclass the object is
Expand Down Expand Up @@ -139,7 +139,7 @@ class Bacterium : public Host {

//mutate host genome if enabled
if(lysis_config->MUTATE_INC_VAL()){
host_incorporation_val += random->GetRandNormal(0.0, lysis_config->MUTATION_SIZE());
host_incorporation_val += random->GetNormal(0.0, lysis_config->MUTATION_SIZE());

if(host_incorporation_val < 0) host_incorporation_val = 0;

Expand Down
12 changes: 6 additions & 6 deletions source/lysis_mode/Phage.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Phage: public Symbiont {

/**
*
* Purpose: Holds all configuration settings and points to same configuration
* Purpose: Holds all configuration settings and points to same configuration
* object as my_config from superclass, but with the correct subtype.
*
*/
Expand Down Expand Up @@ -110,7 +110,7 @@ class Phage: public Symbiont {

/**
* Input: None
*
*
* Output: Name of class as string, Phage
*
* Purpose: To know which subclass the object is
Expand All @@ -135,7 +135,7 @@ class Phage: public Symbiont {
*
* Purpose: To increment a phage's burst timer.
*/
void IncBurstTimer() {burst_timer += random->GetRandNormal(1.0, 1.0);}
void IncBurstTimer() {burst_timer += random->GetNormal(1.0, 1.0);}


/**
Expand Down Expand Up @@ -261,17 +261,17 @@ class Phage: public Symbiont {
if (random->GetDouble(0.0, 1.0) <= local_rate) {
//mutate chance of lysis/lysogeny, if enabled
if(lysis_config->MUTATE_LYSIS_CHANCE()){
chance_of_lysis += random->GetRandNormal(0.0, local_size);
chance_of_lysis += random->GetNormal(0.0, local_size);
if(chance_of_lysis < 0) chance_of_lysis = 0;
else if (chance_of_lysis > 1) chance_of_lysis = 1;
}
if(lysis_config->MUTATE_INDUCTION_CHANCE()){
induction_chance += random->GetRandNormal(0.0, local_size);
induction_chance += random->GetNormal(0.0, local_size);
if(induction_chance < 0) induction_chance = 0;
else if (induction_chance > 1) induction_chance = 1;
}
if(lysis_config->MUTATE_INC_VAL()){
incorporation_val += random->GetRandNormal(0.0, local_size);
incorporation_val += random->GetNormal(0.0, local_size);
if(incorporation_val < 0) incorporation_val = 0;
else if (incorporation_val > 1) incorporation_val = 1;
}
Expand Down
10 changes: 5 additions & 5 deletions source/pgg_mode/PGGSymbiont.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ class PGGSymbiont: public Symbiont {
*
*/
emp::Ptr<PGGWorld> my_world = NULL;

/**
*
* Purpose: Holds all configuration settings and points to same configuration
* Purpose: Holds all configuration settings and points to same configuration
* object as my_config from superclass, but with the correct subtype.
*
*/
emp::Ptr<SymConfigPGG> pgg_config = NULL;

public:
PGGSymbiont(emp::Ptr<emp::Random> _random, emp::Ptr<PGGWorld> _world, emp::Ptr<SymConfigPGG> _config, double _intval = 0.0, double _donation = 0.0, double _points = 0.0) : Symbiont(_random, _world, _config, _intval, _points), PGG_donate(_donation) {
pgg_config = _config;
pgg_config = _config;
my_world = _world;
}

Expand Down Expand Up @@ -86,7 +86,7 @@ class PGGSymbiont: public Symbiont {

/**
* Input: None
*
*
* Output: Name of class as string, PGGSymbiont
*
* Purpose: To know which subclass the object is
Expand Down Expand Up @@ -127,7 +127,7 @@ class PGGSymbiont: public Symbiont {
void Mutate(){
Symbiont::Mutate();
if (random->GetDouble(0.0, 1.0) <= pgg_config->MUTATION_RATE()) {
PGG_donate += random->GetRandNormal(0.0, pgg_config->MUTATION_SIZE());
PGG_donate += random->GetNormal(0.0, pgg_config->MUTATION_SIZE());
if(PGG_donate < 0) PGG_donate = 0;
else if (PGG_donate > 1) PGG_donate = 1;
}
Expand Down
4 changes: 2 additions & 2 deletions source/pgg_mode/PGGWorldSetup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ void PGGWorld::SetupSymbionts(long unsigned int* total_syms) {
//If the user wants the symbionts' donation rate to be randomly initialized
if (pgg_config->PGG_DONATE_RANDOM()) {
//If the user wants the initialization of the symbionts' donation
//rate to be selected using a normal distribution
//rate to be selected using a normal distribution
if (pgg_config->PGG_DONATE_NORMAL()) {
double mean = pgg_config->PGG_DONATE_NORMAL_MEAN();
double std = pgg_config->PGG_DONATE_NORMAL_STD();

sym_donation = random_ptr->GetRandNormal(mean, std);
sym_donation = random_ptr->GetNormal(mean, std);

//If selected value is out of the initialization range
if (sym_donation > pgg_config->PGG_DONATE_MAX()) {
Expand Down
4 changes: 2 additions & 2 deletions source/sgp_mode/Instructions.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ INST(PrivateIO, {
}
uint32_t next;
if (state.world->GetConfig()->RANDOM_IO_INPUT()) {
next = sgpl::tlrand.Get().GetBits50();
next = sgpl::tlrand.Get().GetUInt();
} else {
next = 1;
}
Expand All @@ -127,7 +127,7 @@ INST(SharedIO, {
AddOrganismPoints(state, *a);
uint32_t next;
if (state.world->GetConfig()->RANDOM_IO_INPUT()) {
next = sgpl::tlrand.Get().GetBits50();
next = sgpl::tlrand.Get().GetUInt();
} else {
next = 1;
}
Expand Down

0 comments on commit 0818e57

Please sign in to comment.