Skip to content

updated configuration to work with parasites - #55

Open
miguelfortuna wants to merge 9 commits into
devosoft:masterfrom
fortunalab:master
Open

miguelfortuna wants to merge 9 commits into
devosoft:masterfrom
fortunalab:master

Conversation

@miguelfortuna

Copy link
Copy Markdown

No description provided.

@mmore500 mmore500 left a comment

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.

tentative pre-review, a few things in here for me to follow up on

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?

// 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

//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

#############################################################################

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

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?

@mmore500 mmore500 left a comment

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.

Following up on my earlier pre-review a few minutes ago (#55 (review))

Main code review points:

  1. undefined behavior where new size field isn’t being initialized on all parasite setup paths (see comment)
  2. potential breaking change to existing instruction library might be more prudent as just creating a new library?
  3. is version bump necessary/intended? Not sure what the process/semantics for Avida releases are now that the project is in a bit of a more nebulous long term maintenance state with no clear owner

On another note, CI needs updates to run (#98), this is left open for the time being. I had this code compiled and run thru unit tests locally.

AI use disclosure: AI assistance was used to run code locally, investigate follow-up issues, and create mwb script. All written comments are my own.


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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants