diff --git a/Analysis/05-02-23-ParasitesLongSpatial/FinalUpdateHost.png b/Analysis/05-02-23-ParasitesLongSpatial/FinalUpdateHost.png index 8ff0a7f3..063e8443 100644 Binary files a/Analysis/05-02-23-ParasitesLongSpatial/FinalUpdateHost.png and b/Analysis/05-02-23-ParasitesLongSpatial/FinalUpdateHost.png differ diff --git a/Analysis/05-02-23-ParasitesLongSpatial/TaskComp.R b/Analysis/05-02-23-ParasitesLongSpatial/TaskComp.R index ad909b9c..a523ee81 100644 --- a/Analysis/05-02-23-ParasitesLongSpatial/TaskComp.R +++ b/Analysis/05-02-23-ParasitesLongSpatial/TaskComp.R @@ -8,9 +8,12 @@ library(scales) #Read in the data initial_data <- read.table("05-02-23-ParasitesLongSpatial/munged_basic.dat", h=T) initial_data$task <- factor(initial_data$task, levels=c("NOT", "NAND", "AND", "ORN", "OR", "ANDN", "NOR", "XOR", "EQU")) -initial_data[2] <- data.frame(lapply(initial_data[2], function(x) {gsub("Grid0", "Well-mixed", x)})) -initial_data[2] <- data.frame(lapply(initial_data[2], function(x) {gsub("Grid1", "Structured", x)})) -final_update <- subset(initial_data, update == "40000") +initial_data[2] <- data.frame(lapply(initial_data[2], function(x) {gsub("Grid0", "SA", x)})) +initial_data[2] <- data.frame(lapply(initial_data[2], function(x) {gsub("Grid1", "SP", x)})) +initial_data[2] <- data.frame(lapply(initial_data[2], function(x) {gsub("MOI0.0", "PA", x)})) +initial_data[2] <- data.frame(lapply(initial_data[2], function(x) {gsub("MOI1.0", "PP", x)})) +initial_data[2] <- data.frame(lapply(initial_data[2], function(x) {gsub("_", " ", x)})) +final_update <- subset(initial_data, update == "120000") host_data <- subset(final_update, partner == "Host") @@ -20,7 +23,7 @@ host_data <- subset(final_update, partner == "Host") ggplot(data=host_data, aes(x=treatment, y=count, color=treatment)) + geom_violin() + ylab("Task Count Final Update") + xlab("Parasites Present or Absent") + theme(panel.background = element_rect(fill='white', colour='black')) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) + guides(fill=FALSE) + scale_color_manual(name="Parasites", values=viridis(3)) + facet_wrap(~task, scales = "free") + geom_boxplot(alpha=0.5, outlier.size=0, width=0.1) #regular box plot -ggplot(data=host_data, aes(x=treatment, y=count, color=treatment)) + geom_boxplot(alpha=0.5, outlier.size=1) + ylab("Task Count Final Update") + xlab("Parasites Present or Absent") + theme(panel.background = element_rect(fill='white', colour='black')) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) + guides(fill=FALSE) + scale_color_manual(name="Parasites", values=viridis(3)) + facet_wrap(~task, scales = "free") +ggplot(data=host_data, aes(x=treatment, y=count, color=treatment)) + geom_boxplot(alpha=0.5, outlier.size=1) + ylab("Operation Count Final Update") + xlab("Structure and Parasites Absent or Present") + theme(panel.background = element_rect(fill='white', colour='black')) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) + guides(fill=FALSE) + scale_color_manual(name="Treatment", values=viridis(4), labels=c("\nStructure Absent,\nParasites Absent\n", "\nStructure Absent,\nParasites Present\n", "\nStructure Present,\nParasites Absent\n", "\nStructure Present,\nParasites Present\n")) + facet_wrap(~task, scales = "free")+ scale_x_discrete(guide = guide_axis(angle = -20)) @@ -38,7 +41,7 @@ median(subset(host_data, treatment=="Present" & task=="OR")$count) wilcox.test(subset(host_data, treatment=="Absent" & task=="ORN")$count, subset(host_data, treatment=="Present" & task=="ORN")$count) #All tasks over time -ggplot(data=initial_data, aes(x=update, y=count, group=treatment, colour=treatment)) + ylab("Task count") + xlab("Updates") + stat_summary(aes(color=treatment, fill=treatment),fun.data="mean_cl_boot", geom=c("smooth"), se=TRUE) + theme(panel.background = element_rect(fill='white', colour='black')) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) + guides(fill=FALSE) +scale_colour_manual(values=viridis(3)) + scale_fill_manual(values=viridis(3)) + facet_grid(task ~ partner, scales='free') +ggplot(data=initial_data, aes(x=update, y=count, group=treatment, colour=treatment)) + ylab("Task count") + xlab("Updates") + stat_summary(aes(color=treatment, fill=treatment),fun.data="mean_cl_boot", geom=c("smooth"), se=TRUE) + theme(panel.background = element_rect(fill='white', colour='black')) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) + guides(fill=FALSE) +scale_colour_manual(values=viridis(4)) + scale_fill_manual(values=viridis(4)) + facet_grid(task ~ partner, scales='free') # Specific host tasks over time host_over_time <- subset(initial_data, partner=="Host") diff --git a/source/default_mode/Host.h b/source/default_mode/Host.h index 849c3f14..9324f5fd 100644 --- a/source/default_mode/Host.h +++ b/source/default_mode/Host.h @@ -439,11 +439,12 @@ class Host: public Organism { * Purpose: To add a symbionts to a host's symbionts */ int AddSymbiont(emp::Ptr _in) { - if((int)syms.size() >= my_config->SYM_LIMIT()){ - emp::Ptr last_sym = syms.back(); - syms.pop_back(); - last_sym->SetDead(); - } + // Ousting code: + // if((int)syms.size() >= my_config->SYM_LIMIT()){ + // emp::Ptr last_sym = syms.back(); + // syms.pop_back(); + // last_sym->SetDead(); + // } if((int)syms.size() < my_config->SYM_LIMIT() && SymAllowedIn()){ syms.push_back(_in); diff --git a/source/sgp_mode/GenomeLibrary.h b/source/sgp_mode/GenomeLibrary.h index 3d97befe..8b6c4416 100644 --- a/source/sgp_mode/GenomeLibrary.h +++ b/source/sgp_mode/GenomeLibrary.h @@ -15,14 +15,15 @@ using Library = sgpl::OpLibrary< inst::ShiftLeft, inst::ShiftRight, inst::Increment, inst::Decrement, // biological operations // no copy or alloc - inst::Reproduce, inst::PrivateIO, - //inst::SharedIO, + inst::Reproduce, + //inst::PrivateIO, + inst::SharedIO, // double argument math inst::Add, inst::Subtract, inst::Nand, // Stack manipulation inst::Push, inst::Pop, inst::SwapStack, inst::Swap, // no h-search - //inst::Donate, + inst::Donate, inst::JumpIfNEq, inst::JumpIfLess, //inst::Reuptake, //fls basics @@ -72,6 +73,24 @@ class ProgramBuilder : emp::vector> { return program; } + sgpl::Program BuildNoRepro(size_t length) { + Add("Donate"); + Add("Donate"); + Add("Donate"); + Add("Donate"); + Add("Donate"); + sgpl::Program program; + // Set everything to 0 - this makes them no-ops since that's the first + // inst in the library + program.resize(length - size()); + program[0].op_code = Library::GetOpCode("Global Anchor"); + program[0].tag = START_TAG; + + program.insert(program.end(), begin(), end()); + + return program; + } + void AddNot() { // sharedio r0 // nand r0, r0, r0 @@ -289,6 +308,12 @@ sgpl::Program CreateSquareProgram(size_t length) { return program.Build(length); } +sgpl::Program CreateMutualistStart(size_t length) { + ProgramBuilder program; + program.AddNand(); + return program.BuildNoRepro(length); +} + /** * Picks what type of starting program should be created based on the config and * creates it. It will be either random, a program that does NOT, or a program @@ -298,7 +323,7 @@ sgpl::Program CreateStartProgram(emp::Ptr config) { if (config->RANDOM_ANCESTOR()) { return CreateRandomProgram(PROGRAM_LENGTH); } else if (config->TASK_TYPE() == 1) { - return CreatePrivateNotProgram(PROGRAM_LENGTH); + return CreateNotProgram(PROGRAM_LENGTH); } else { return CreateSquareProgram(PROGRAM_LENGTH); } diff --git a/source/sgp_mode/Instructions.h b/source/sgp_mode/Instructions.h index 429d1e24..5a132a29 100644 --- a/source/sgp_mode/Instructions.h +++ b/source/sgp_mode/Instructions.h @@ -124,7 +124,6 @@ void AddOrganismPoints(CPUState state, uint32_t output) { } // Set output to value of register and set register to new input INST(SharedIO, { - std::cout << "shared io" << std::endl; AddOrganismPoints(state, *a); uint32_t next; if (state.world->GetConfig()->RANDOM_IO_INPUT()) { diff --git a/source/sgp_mode/SGPWorldSetup.cc b/source/sgp_mode/SGPWorldSetup.cc index 59025640..9ecfe08a 100644 --- a/source/sgp_mode/SGPWorldSetup.cc +++ b/source/sgp_mode/SGPWorldSetup.cc @@ -9,10 +9,10 @@ void SGPWorld::SetupHosts(unsigned long *POP_SIZE) { for (size_t i = 0; i < *POP_SIZE; i++) { emp::Ptr new_org = emp::NewPtr( - &GetRandom(), this, my_config, CreatePrivateNotProgram(100), my_config->HOST_INT()); + &GetRandom(), this, my_config, CreateNotProgram(100), my_config->HOST_INT()); if(my_config->START_MOI()==1){ emp::Ptr new_sym = emp::NewPtr( - &GetRandom(), this, my_config, my_config->SYM_INT()); + &GetRandom(), this, my_config, CreateMutualistStart(100), my_config->SYM_INT()); new_org->AddSymbiont(new_sym); } InjectHost(new_org);