From c7c22c87856228e88de12a7e031615a4362832b4 Mon Sep 17 00:00:00 2001 From: raul-ortega Date: Wed, 20 Apr 2022 12:52:55 +0200 Subject: [PATCH 1/8] allow parasites to keep genome size constant --- avida-core/source/main/cAvidaConfig.h | 2 ++ avida-core/source/main/cParasite.h | 3 +++ avida-core/source/main/cPopulation.cc | 18 +++++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/avida-core/source/main/cAvidaConfig.h b/avida-core/source/main/cAvidaConfig.h index 854c4dac22..00205dff7e 100644 --- a/avida-core/source/main/cAvidaConfig.h +++ b/avida-core/source/main/cAvidaConfig.h @@ -462,6 +462,8 @@ class cAvidaConfig { CONFIG_ADD_VAR(FULL_VERTICAL_TRANS, double, 0.0, "Determines if offspring of infected host is automatically infected. 0 for no, 1 for yes. If you want to keep parent infected as well, you need to set DIVIDE_METHOD to 2."); + CONFIG_ADD_VAR(PARASITE_GENOME_SIZE_AS_PARENT, int, 0, "Change this value to 1 to make the genome size of the parasite's offspring equal to that of its parent"); + // -------- CPU Archetecture CONFIG_ADD_GROUP(ARCHETECTURE_GROUP, "Details on how CPU should work"); diff --git a/avida-core/source/main/cParasite.h b/avida-core/source/main/cParasite.h index a2d7bd17f2..9d9074bde2 100644 --- a/avida-core/source/main/cParasite.h +++ b/avida-core/source/main/cParasite.h @@ -43,6 +43,7 @@ class cParasite : public Systematics::Unit cPhenotype m_phenotype; double virulence; + int m_seq_size; public: @@ -59,6 +60,8 @@ class cParasite : public Systematics::Unit cPhenotype& GetPhenotype() { return m_phenotype; } double GetVirulence() { return virulence; } void SetVirulence(double v) { virulence = v; } + void SetSeqSize(int seq_size) { m_seq_size = seq_size; } + int GetSeqSize() { return m_seq_size; } private: cParasite(); // @not_implemented diff --git a/avida-core/source/main/cPopulation.cc b/avida-core/source/main/cPopulation.cc index 109d5269ab..7d8eaa4cdd 100644 --- a/avida-core/source/main/cPopulation.cc +++ b/avida-core/source/main/cPopulation.cc @@ -1189,7 +1189,16 @@ bool cPopulation::ActivateParasite(cOrganism* host, Systematics::UnitPtr parent, // Quick check for empty parasites if (injected_code.GetSize() == 0) return false; - + // Get parent parasite + Apto::SmartPtr parent_parasite; + parent_parasite.DynamicCastFrom(parent); + + // Do not activate the parasite if the size of its genome is different from that of its parent + if(m_world->GetConfig().PARASITE_GENOME_SIZE_AS_PARENT.Get() == 1 && parent_parasite != NULL) { + if (parent_parasite->GetSeqSize() != injected_code.GetSize()) { + return false; + } + } // Pull the host cell const int host_id = host->GetOrgInterface().GetCellID(); assert(host_id >= 0 && host_id < cell_array.GetSize()); @@ -1266,8 +1275,8 @@ bool cPopulation::ActivateParasite(cOrganism* host, Systematics::UnitPtr parent, { //mutate virulence // m_world->GetConfig().PARASITE_VIRULENCE.Get() - Apto::SmartPtr parent_parasite; - parent_parasite.DynamicCastFrom(parent); + //Apto::SmartPtr parent_parasite; + //parent_parasite.DynamicCastFrom(parent); double oldVir = parent_parasite->GetVirulence(); //default to not mutating @@ -7149,6 +7158,9 @@ void cPopulation::InjectParasite(const cString& label, const InstructionSequence //default to configured parasite virulence parasite->SetVirulence(m_world->GetConfig().PARASITE_VIRULENCE.Get()); + + // set genome sequence size + parasite->SetSeqSize(injected_code.GetSize()); if (target_organism->ParasiteInfectHost(parasite)) { Systematics::Manager::Of(m_world->GetNewWorld())->ClassifyNewUnit(parasite); From 2fcf61bb68b8dd0b03c6a07c846185d6c27c222b Mon Sep 17 00:00:00 2001 From: raul-ortega Date: Wed, 20 Apr 2022 13:34:08 +0200 Subject: [PATCH 2/8] removed INJECT_IS_TASK_SPECIFIC (was replaced by INFECTION_MECHANISM) --- avida-core/source/main/cAvidaConfig.h | 1 - avida-core/support/config/avida.cfg | 1 - 2 files changed, 2 deletions(-) diff --git a/avida-core/source/main/cAvidaConfig.h b/avida-core/source/main/cAvidaConfig.h index 00205dff7e..44c926a984 100644 --- a/avida-core/source/main/cAvidaConfig.h +++ b/avida-core/source/main/cAvidaConfig.h @@ -441,7 +441,6 @@ class cAvidaConfig { CONFIG_ADD_GROUP(PARASITE_GROUP, "Parasite config options"); CONFIG_ADD_VAR(INJECT_METHOD, int, 0, "What should happen to a parasite when it gives birth?\n0 = Leave the parasite thread state untouched.\n1 = Resets the state of the calling thread (for SMT parasites, this must be 1)"); CONFIG_ADD_VAR(INFECTION_MECHANISM, int, 1, "0: Infection always succeeds. \n1: Infection succeeds if parasite matches at least one host task.\n2: Infection succeeds if parasite does NOT match at least one task.\n3: Parasite tasks must match host tasks exactly (Matching Alleles)."); - CONFIG_ADD_ALIAS(INJECT_IS_TASK_SPECIFIC); CONFIG_ADD_VAR(INJECT_QMA_EXPONENT, double, 0.2, "The exponent of the equation proportion_overlap^x that determines the probability of infection succeding given the amount a host and parasite phenotype match."); CONFIG_ADD_VAR(INJECT_STERILIZES_HOST, int, 0, "Infection causes host steralization"); diff --git a/avida-core/support/config/avida.cfg b/avida-core/support/config/avida.cfg index 3a3daaaa7d..d50b638a80 100644 --- a/avida-core/support/config/avida.cfg +++ b/avida-core/support/config/avida.cfg @@ -203,7 +203,6 @@ MATE_IN_GROUPS 0 # Require all mating to happen within groups INJECT_METHOD 0 # What should happen to a parasite when it gives birth? # 0 = Leave the parasite thread state untouched. # 1 = Resets the state of the calling thread (for SMT parasites, this must be 1) -INJECT_IS_TASK_SPECIFIC 1 # Inject occurs based on task overlap INJECT_STERILIZES_HOST 0 # Infection causes host steralization INJECT_IS_VIRULENT 0 # Infection causes host steralization and takes all cpu cycles (setting this to 1 will override inject_virulence) PARASITE_SKIP_REACTIONS 1 # Parasite tasks do not get processed in the environment (1) or they do trigger reactions (0) From 49a17b0896ec8c8b270fe1354843d4b72875b8a0 Mon Sep 17 00:00:00 2001 From: raul-ortega Date: Wed, 20 Apr 2022 13:57:04 +0200 Subject: [PATCH 3/8] added configuration of the infection mechanisms implemented --- avida-core/support/config/avida.cfg | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/avida-core/support/config/avida.cfg b/avida-core/support/config/avida.cfg index d50b638a80..2be71e25f3 100644 --- a/avida-core/support/config/avida.cfg +++ b/avida-core/support/config/avida.cfg @@ -203,6 +203,11 @@ MATE_IN_GROUPS 0 # Require all mating to happen within groups INJECT_METHOD 0 # What should happen to a parasite when it gives birth? # 0 = Leave the parasite thread state untouched. # 1 = Resets the state of the calling thread (for SMT parasites, this must be 1) +INFECTION_MECHANISM 0 # 0 = Infection always succeeds. + # 1 = Infection succeeds if parasite matches at least one host task + # 2 = Infection succeeds if parasite does NOT match at least one task + # 3 = Parasite tasks must match host tasks exactly (Matching Alleles) + # 4 = Parasite tasks must overcome hosts (GFG) INJECT_STERILIZES_HOST 0 # Infection causes host steralization INJECT_IS_VIRULENT 0 # Infection causes host steralization and takes all cpu cycles (setting this to 1 will override inject_virulence) PARASITE_SKIP_REACTIONS 1 # Parasite tasks do not get processed in the environment (1) or they do trigger reactions (0) From 70105899d5f55354a27aea0dfc11b57abdd79478 Mon Sep 17 00:00:00 2001 From: raul-ortega Date: Wed, 20 Apr 2022 14:19:27 +0200 Subject: [PATCH 4/8] update description of the infection mechanisms --- avida-core/source/main/cAvidaConfig.h | 2 +- avida-core/support/config/avida.cfg | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/avida-core/source/main/cAvidaConfig.h b/avida-core/source/main/cAvidaConfig.h index 44c926a984..851586df42 100644 --- a/avida-core/source/main/cAvidaConfig.h +++ b/avida-core/source/main/cAvidaConfig.h @@ -440,7 +440,7 @@ class cAvidaConfig { // -------- Parasite options -------- CONFIG_ADD_GROUP(PARASITE_GROUP, "Parasite config options"); CONFIG_ADD_VAR(INJECT_METHOD, int, 0, "What should happen to a parasite when it gives birth?\n0 = Leave the parasite thread state untouched.\n1 = Resets the state of the calling thread (for SMT parasites, this must be 1)"); - CONFIG_ADD_VAR(INFECTION_MECHANISM, int, 1, "0: Infection always succeeds. \n1: Infection succeeds if parasite matches at least one host task.\n2: Infection succeeds if parasite does NOT match at least one task.\n3: Parasite tasks must match host tasks exactly (Matching Alleles)."); + CONFIG_ADD_VAR(INFECTION_MECHANISM, int, 1, "0: Infection always succeeds. \n1: Infection succeeds if parasite matches at least one host task.\n2: Infection succeeds if parasite does NOT match at least one task.\n3: Parasite tasks must match host tasks exactly (Matching Alleles).\n4: Parasite tasks must overcome hosts (GFG)"); CONFIG_ADD_VAR(INJECT_QMA_EXPONENT, double, 0.2, "The exponent of the equation proportion_overlap^x that determines the probability of infection succeding given the amount a host and parasite phenotype match."); CONFIG_ADD_VAR(INJECT_STERILIZES_HOST, int, 0, "Infection causes host steralization"); diff --git a/avida-core/support/config/avida.cfg b/avida-core/support/config/avida.cfg index 2be71e25f3..a198bbf35e 100644 --- a/avida-core/support/config/avida.cfg +++ b/avida-core/support/config/avida.cfg @@ -203,11 +203,11 @@ MATE_IN_GROUPS 0 # Require all mating to happen within groups INJECT_METHOD 0 # What should happen to a parasite when it gives birth? # 0 = Leave the parasite thread state untouched. # 1 = Resets the state of the calling thread (for SMT parasites, this must be 1) -INFECTION_MECHANISM 0 # 0 = Infection always succeeds. - # 1 = Infection succeeds if parasite matches at least one host task - # 2 = Infection succeeds if parasite does NOT match at least one task - # 3 = Parasite tasks must match host tasks exactly (Matching Alleles) - # 4 = Parasite tasks must overcome hosts (GFG) +INFECTION MECHANISM 0 # 0 = Infection will succeed independent of task-based phenotypes + # 1 = Infection will succeed if the parasite and host have at least one overlapping task (Inverse Gene-for-Gene) + # 2 = Infection will succeed if the parasite does at least one task the host does not perform + # 3 = Infection will succeed if the parasite and host do the same tasks (Matching Alleles) + # 4 = Infection will succeed if the parasite performs all the tasks the host does as well as at least one additional task (Gene-for-Gene) INJECT_STERILIZES_HOST 0 # Infection causes host steralization INJECT_IS_VIRULENT 0 # Infection causes host steralization and takes all cpu cycles (setting this to 1 will override inject_virulence) PARASITE_SKIP_REACTIONS 1 # Parasite tasks do not get processed in the environment (1) or they do trigger reactions (0) From 221fcd62432b651203a9fb50a82723d9466207b9 Mon Sep 17 00:00:00 2001 From: raul-ortega Date: Wed, 20 Apr 2022 17:12:07 +0200 Subject: [PATCH 5/8] Update Version to 2.15.0 --- avida-core/include/public/avida/core/Version.h | 4 ++-- avida-core/support/config/avida.cfg | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/avida-core/include/public/avida/core/Version.h b/avida-core/include/public/avida/core/Version.h index 368752ee34..28b4578c37 100644 --- a/avida-core/include/public/avida/core/Version.h +++ b/avida-core/include/public/avida/core/Version.h @@ -31,9 +31,9 @@ namespace Avida { namespace Version { - LIB_EXPORT inline const char* String() { return "2.14.0"; } + LIB_EXPORT inline const char* String() { return "2.15.0"; } LIB_EXPORT inline int Major() { return 2; } - LIB_EXPORT inline int Minor() { return 14; } + LIB_EXPORT inline int Minor() { return 15; } LIB_EXPORT inline int Patch() { return 0; } LIB_EXPORT inline const char* Tag() { return ""; } diff --git a/avida-core/support/config/avida.cfg b/avida-core/support/config/avida.cfg index a198bbf35e..98d3668161 100644 --- a/avida-core/support/config/avida.cfg +++ b/avida-core/support/config/avida.cfg @@ -3,7 +3,7 @@ # For more information, see doc/config.html ############################################################################# -VERSION_ID 2.14.0 # Do not change this value. +VERSION_ID 2.15.0 # Do not change this value. ### GENERAL_GROUP ### # General Settings From c6ace3d6bd79f40cc211e9efd037bb8336c56be1 Mon Sep 17 00:00:00 2001 From: "Miguel A. Fortuna" Date: Wed, 20 Apr 2022 17:54:07 +0200 Subject: [PATCH 6/8] updated instruction set for parasites (instset-transsmt.cfg) --- .../support/config/instset-transsmt.cfg | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/avida-core/support/config/instset-transsmt.cfg b/avida-core/support/config/instset-transsmt.cfg index c5074540dd..f8c4136598 100644 --- a/avida-core/support/config/instset-transsmt.cfg +++ b/avida-core/support/config/instset-transsmt.cfg @@ -1,6 +1,6 @@ INSTSET transsmt:hw_type=2 -INST Nop-A #1 (a) +INST Nop-A #1 (a) INST Nop-B #2 (b) INST Nop-C #3 (c) INST Nop-D #4 (d) @@ -15,20 +15,21 @@ INST Val-Mod #12 (l) INST Val-Inc #13 (m) INST Val-Dec #14 (n) INST SetMemory #15 (o) -INST Divide #16 (p) -INST Inst-Read #17 (q) -INST Inst-Write #18 (r) -INST If-Equal #19 (s) -INST If-Not-Equal #20 (t) -INST If-Less #21 (u) -INST If-Greater #22 (v) -INST Head-Push #23 (w) -INST Head-Pop #24 (x) -INST Head-Move #25 (y) -INST Search #26 (z) -INST Push-Next #27 (A) -INST Push-Prev #28 (B) -INST Push-Comp #29 (C) -INST Val-Delete #30 (D) -INST Val-Copy #31 (E) -INST IO #32 (F) +INST Inst-Read #16 (p) +INST Inst-Write #17 (q) +INST If-Equal #18 (r) +INST If-Not-Equal #19 (s) +INST If-Less #20 (t) +INST If-Greater #21 (u) +INST Head-Push #22 (v) +INST Head-Pop #23 (w) +INST Head-Move #24 (x) +INST Search #25 (y) +INST Push-Next #26 (z) +INST Push-Prev #27 (A) +INST Push-Comp #28 (B) +INST Val-Delete #29 (C) +INST Val-Copy #30 (D) +INST IO #31 (E) +INST Inject #32 (F) +INST Divide-Erase #33 (G) From ad7216c0349e44c922afad122ee24110b509edb7 Mon Sep 17 00:00:00 2001 From: "Miguel A. Fortuna" Date: Thu, 21 Apr 2022 09:38:36 +0200 Subject: [PATCH 7/8] added default transsmt host and parasite organisms --- avida-core/CMakeLists.txt | 3 +- .../support/config/default-transsmt-host.org | 103 ++++++++++++++++++ .../config/default-transsmt-parasite.org | 103 ++++++++++++++++++ 3 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 avida-core/support/config/default-transsmt-host.org create mode 100644 avida-core/support/config/default-transsmt-parasite.org diff --git a/avida-core/CMakeLists.txt b/avida-core/CMakeLists.txt index d9d063ef64..015b6d2ee2 100644 --- a/avida-core/CMakeLists.txt +++ b/avida-core/CMakeLists.txt @@ -603,6 +603,7 @@ SET(CFG_FILES ${CFG_FILES_DIR}/instset-transsmt.cfg ${CFG_FILES_DIR}/default-heads.org ${CFG_FILES_DIR}/default-heads-sex.org - ${CFG_FILES_DIR}/default-transsmt.org + ${CFG_FILES_DIR}/default-transsmt-host.org + ${CFG_FILES_DIR}/default-transsmt-parasite.org ) INSTALL_FILES(/work FILES ${CFG_FILES}) diff --git a/avida-core/support/config/default-transsmt-host.org b/avida-core/support/config/default-transsmt-host.org new file mode 100644 index 0000000000..71a73dac5a --- /dev/null +++ b/avida-core/support/config/default-transsmt-host.org @@ -0,0 +1,103 @@ +#inst_set transsmt +#hw_type 2 + +Nop-A +Nop-A +If-Not-Equal +Push-Prev +SetMemory +SetMemory +Nop-B +Nop-D +If-Equal +Nop-C +Nop-C +Head-Move +Nop-C +Push-Next +SetMemory +Inst-Write +Inst-Read +Nop-D +IO +Inst-Read +Val-Inc +Nop-D +Val-Copy +Nop-B +Val-Mult +Val-Sub +Nop-C +Nop-B +Inst-Read +Push-Next +Search +Val-Shift-R +If-Less +Push-Prev +Val-Nand +Nop-D +IO +Search +Inst-Read +Nop-B +Push-Comp +Val-Nand +Nop-C +Nop-B +Nop-D +Inst-Write +Push-Next +If-Not-Equal +Head-Move +IO +Nop-C +Search +Inst-Read +SetMemory +If-Equal +Push-Prev +Nop-C +IO +Val-Delete +If-Greater +Val-Mod +Push-Prev +Inst-Read +Push-Prev +Val-Mult +Val-Div +Val-Dec +If-Greater +Inst-Read +Val-Mult +IO +Val-Div +Val-Div +Val-Inc +Push-Comp +Val-Inc +Val-Shift-R +Val-Mult +Val-Copy +IO +Val-Sub +If-Less +Inst-Read +IO +Val-Delete +Nop-B +Head-Push +Val-Delete +Val-Add +Val-Div +Val-Mod +If-Equal +If-Greater +Val-Dec +IO +Push-Comp +Push-Prev +Val-Div +Val-Sub +Divide-Erase diff --git a/avida-core/support/config/default-transsmt-parasite.org b/avida-core/support/config/default-transsmt-parasite.org new file mode 100644 index 0000000000..1ba25382cd --- /dev/null +++ b/avida-core/support/config/default-transsmt-parasite.org @@ -0,0 +1,103 @@ +#inst_set transsmt +#hw_type 2 + +Nop-A +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Nop-B +Inst-Read +Val-Add +Val-Dec +SetMemory +Nop-C +IO +Nop-C +Nop-B +Head-Move +Nop-C +Search +Inst-Write +Inst-Read +If-Greater +Head-Move +Val-Sub +Val-Dec +IO +Val-Div +Val-Dec +Val-Dec +Val-Dec +Val-Div +Inject From 394eb9d8ae742831e2a22ffc70e15928eb0f8c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Ortega?= Date: Wed, 1 Jun 2022 12:53:05 +0200 Subject: [PATCH 8/8] Missin "_" fixed --- avida-core/support/config/avida.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avida-core/support/config/avida.cfg b/avida-core/support/config/avida.cfg index 98d3668161..28ce2fb32c 100644 --- a/avida-core/support/config/avida.cfg +++ b/avida-core/support/config/avida.cfg @@ -203,7 +203,7 @@ MATE_IN_GROUPS 0 # Require all mating to happen within groups INJECT_METHOD 0 # What should happen to a parasite when it gives birth? # 0 = Leave the parasite thread state untouched. # 1 = Resets the state of the calling thread (for SMT parasites, this must be 1) -INFECTION MECHANISM 0 # 0 = Infection will succeed independent of task-based phenotypes +INFECTION_MECHANISM 0 # 0 = Infection will succeed independent of task-based phenotypes # 1 = Infection will succeed if the parasite and host have at least one overlapping task (Inverse Gene-for-Gene) # 2 = Infection will succeed if the parasite does at least one task the host does not perform # 3 = Infection will succeed if the parasite and host do the same tasks (Matching Alleles)