Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion avida-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
4 changes: 2 additions & 2 deletions avida-core/include/public/avida/core/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think we should be bumping the Avida version, unless this is intended as a new release? In that case, it would probably be best to do the bump as a separate PR?

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 ""; }

Expand Down
5 changes: 3 additions & 2 deletions avida-core/source/main/cAvidaConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +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_ALIAS(INJECT_IS_TASK_SPECIFIC);
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");
Expand All @@ -462,6 +461,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");
Expand Down
3 changes: 3 additions & 0 deletions avida-core/source/main/cParasite.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class cParasite : public Systematics::Unit

cPhenotype m_phenotype;
double virulence;
int m_seq_size;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new field doesn’t appear to be being initialized in parasite setup paths other than InjectParasite, leading to UB (both in the sense of undefined behavior and, likely, unwanted behavior haha)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mwb:

git clone https://github.com/fortunalab/avida.git
cd avida
git checkout faec2b9df7897e1f1de63dfb247e3ab1fa600a56
./build_avida -DCMAKE_BUILD_TYPE=RelWithDebInfo
cd cbuild/work
cat > avida.cfg <<CFG
VERSION_ID 2.15.0
#include INST_SET=instset-transsmt.cfg
HARDWARE_TYPE 2
WORLD_X 20
WORLD_Y 20
RANDOM_SEED 1
BIRTH_METHOD 4
INJECT_METHOD 1
INFECTION_MECHANISM 0
MAX_CPU_THREADS 2
PARASITE_VIRULENCE 0.85
COPY_MUT_PROB 0.0
DIVIDE_INS_PROB 0.0
DIVIDE_DEL_PROB 0.0
INJECT_MUT_PROB 0.0
INJECT_INS_PROB 0.0
INJECT_DEL_PROB 0.0
PARASITE_GENOME_SIZE_AS_PARENT 1
CFG
cat > events.cfg <<'CFG'
u begin InjectAll filename=host.org
u 50 InjectParasite parasite.org ABB 0 100
u 200 Exit
CFG
cat > environment.cfg <<'CFG'
REACTION  NOT  not   process:value=1.0:type=pow  requisite:max_count=1
REACTION  NAND nand  process:value=1.0:type=pow  requisite:max_count=1
REACTION  AND  and   process:value=2.0:type=pow  requisite:max_count=1
REACTION  ORN  orn   process:value=2.0:type=pow  requisite:max_count=1
REACTION  OR   or    process:value=3.0:type=pow  requisite:max_count=1
REACTION  ANDN andn  process:value=3.0:type=pow  requisite:max_count=1
REACTION  NOR  nor   process:value=4.0:type=pow  requisite:max_count=1
REACTION  XOR  xor   process:value=4.0:type=pow  requisite:max_count=1
REACTION  EQU  equ   process:value=5.0:type=pow  requisite:max_count=1
CFG
cat > instset-transsmt.cfg <<'CFG'
INSTSET transsmt:hw_type=2
INST Nop-A
INST Nop-B
INST Nop-C
INST Nop-D
INST Val-Shift-R
INST Val-Shift-L
INST Val-Nand
INST Val-Add
INST Val-Sub
INST Val-Mult
INST Val-Div
INST Val-Mod
INST Val-Inc
INST Val-Dec
INST SetMemory
INST Inst-Read
INST Inst-Write
INST If-Equal
INST If-Not-Equal
INST If-Less
INST If-Greater
INST Head-Push
INST Head-Pop
INST Head-Move
INST Search
INST Push-Next
INST Push-Prev
INST Push-Comp
INST Val-Delete
INST Val-Copy
INST IO
INST Inject
INST Divide-Erase
CFG
cat > host.org <<'CFG'
#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
CFG
cat > parasite.org <<'CFG'
#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
CFG
valgrind --error-exitcode=1 --exit-on-first-error=yes ./avida

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mwb output:

==9068== Memcheck, a memory error detector
==9068== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==9068== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==9068== Command: ./avida
==9068== 
Avida 2.15.0
--------------------------------------------------------------------------------
by Charles Ofria
Lead Developer: David M. Bryson

Active developers include:
Aaron P. Wagner and Anya E. Johnson
For a more complete list of contributors, see the AUTHORS file.

Copyright 1999-2014 Michigan State University.
Copyright 1993-2003 California Institute of Technology.

Avida comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain
conditions. See file COPYING for details.

For more information, see: http://avida.devosoft.org/
--------------------------------------------------------------------------------

Random Seed: 1

UD: 0       Gen: 0.000000   Fit: 0.000000   Orgs: 400     
...
UD: 80      Gen: 2.812500   Fit: 0.2454280  Orgs: 400     
==9068== Conditional jump or move depends on uninitialised value(s)
==9068==    at 0x410F4A: cPopulation::ActivateParasite(cOrganism*, Apto::SmartPtr<Avida::Systematics::Unit, Apto::InternalRCObject, Apto::HeapStorage>, cString const&, Avida::InstructionSequence const&) (cPopulation.cc:1198)
==9068==    by 0x447A93: cPopulationInterface::InjectParasite(cOrganism*, Apto::SmartPtr<Avida::Systematics::Unit, Apto::InternalRCObject, Apto::HeapStorage>, cString const&, Avida::InstructionSequence const&) (cPopulationInterface.cc:507)
==9068==    by 0x3B7447: cOrganism::InjectParasite(Apto::SmartPtr<Avida::Systematics::Unit, Apto::InternalRCObject, Apto::HeapStorage>, cString const&, Avida::InstructionSequence const&) (cOrganism.cc:686)
==9068==    by 0x3788BD: cHardwareTransSMT::InjectParasite(cAvidaContext&, double) (cHardwareTransSMT.cc:678)
==9068==    by 0x3707C0: cHardwareTransSMT::SingleProcess_ExecuteInst(cAvidaContext&, Avida::Instruction const&) (cHardwareTransSMT.cc:326)
==9068==    by 0x37C4B0: SingleProcess (cHardwareTransSMT.cc:285)
==9068==    by 0x37C4B0: cHardwareTransSMT::SingleProcess(cAvidaContext&, bool) (cHardwareTransSMT.cc:205)
==9068==    by 0x41F175: cPopulation::ProcessStepSpeculative(cAvidaContext&, double, int) (cPopulation.cc:5759)
==9068==    by 0x2A33BA: Avida2Driver::Run() (Avida2Driver.cc:115)
==9068==    by 0x236AF2: main (primitive.cc:73)
==9068== 
==9068== 
==9068== Exit program on first error (--exit-on-first-error=yes)



public:
Expand All @@ -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
Expand Down
18 changes: 15 additions & 3 deletions avida-core/source/main/cPopulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<cParasite, Apto::InternalRCObject> 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());
Expand Down Expand Up @@ -1266,8 +1275,8 @@ bool cPopulation::ActivateParasite(cOrganism* host, Systematics::UnitPtr parent,
{
//mutate virulence
// m_world->GetConfig().PARASITE_VIRULENCE.Get()
Apto::SmartPtr<cParasite, Apto::InternalRCObject> parent_parasite;
parent_parasite.DynamicCastFrom(parent);
//Apto::SmartPtr<cParasite, Apto::InternalRCObject> parent_parasite;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these lines just be deleted? unclear what they were doing if anything in the first place

//parent_parasite.DynamicCastFrom(parent);
double oldVir = parent_parasite->GetVirulence();

//default to not mutating
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to look into @mmore500: is this limited to the scope of the proposed new config modes, or does this impact all config modes?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change does appear to be limited to scope of just proposed new config mode, so that’s ok

parasite->SetSeqSize(injected_code.GetSize());

if (target_organism->ParasiteInfectHost(parasite)) {
Systematics::Manager::Of(m_world->GetNewWorld())->ClassifyNewUnit(parasite);
Expand Down
8 changes: 6 additions & 2 deletions avida-core/support/config/avida.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above


### GENERAL_GROUP ###
# General Settings
Expand Down Expand Up @@ -203,7 +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)
INJECT_IS_TASK_SPECIFIC 1 # Inject occurs based on task overlap
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)
Expand Down
103 changes: 103 additions & 0 deletions avida-core/support/config/default-transsmt-host.org
Original file line number Diff line number Diff line change
@@ -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
103 changes: 103 additions & 0 deletions avida-core/support/config/default-transsmt-parasite.org
Original file line number Diff line number Diff line change
@@ -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
37 changes: 19 additions & 18 deletions avida-core/support/config/instset-transsmt.cfg
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to follow up on @mmore500, is this a breaking change for existing code using this instruction set?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the sequence reordering may break existing files using this config with genomes stored in single-letter alphabet encoding.

If the specific re-ordering (and other tweaks) is necessary, perhaps it would be more prudent to simply create a second named instruction set?

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)