Repository navigation
updated configuration to work with parasites #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c7c22c8
2fcf61b
49a17b0
7010589
221fcd6
c6ace3d
ad7216c
394eb9d
faec2b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ class cParasite : public Systematics::Unit | |
|
|
||
| cPhenotype m_phenotype; | ||
| double virulence; | ||
| int m_seq_size; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mwb output: |
||
|
|
||
|
|
||
| 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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()); | ||
|
|
@@ -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; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above |
||
|
|
||
| ### GENERAL_GROUP ### | ||
| # General Settings | ||
|
|
@@ -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) | ||
|
|
||
| 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 |
| 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 |
| 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) | ||
|
|
@@ -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) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
There was a problem hiding this comment.
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?