Skip to content

Commit

Permalink
Merge pull request #84 from devosoft/parasite-inject-features
Browse files Browse the repository at this point in the history
Parasite inject features
  • Loading branch information
mmore500 authored Nov 24, 2023
2 parents aaaa105 + 0c5d40f commit 0433001
Show file tree
Hide file tree
Showing 25 changed files with 3,813 additions and 4 deletions.
16 changes: 12 additions & 4 deletions avida-core/source/actions/PopulationActions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -682,23 +682,31 @@ class cActionInjectParasite : public cAction
cString m_label;
int m_cell_start;
int m_cell_end;
int m_cell_stride;
int m_only_if_parasites_extinct;
public:
cActionInjectParasite(cWorld* world, const cString& args, Feedback&) : cAction(world, args), m_cell_start(0), m_cell_end(-1)
cActionInjectParasite(cWorld* world, const cString& args, Feedback&) : cAction(world, args), m_cell_start(0), m_cell_end(-1), m_cell_stride(1), m_only_if_parasites_extinct(0)
{
cString largs(args);
m_filename = largs.PopWord();
m_label = largs.PopWord();
if (largs.GetSize()) m_cell_start = largs.PopWord().AsInt();
if (largs.GetSize()) m_cell_end = largs.PopWord().AsInt();
if (largs.GetSize()) m_cell_stride = largs.PopWord().AsInt();
if (largs.GetSize()) m_only_if_parasites_extinct = largs.PopWord().AsInt();

if (m_cell_end == -1) m_cell_end = m_cell_start + 1;
}

static const cString GetDescription() { return "Arguments: <string filename> <string label> [int cell_start=0] [int cell_end=-1]"; }
static const cString GetDescription() { return "Arguments: <string filename> <string label> [int cell_start=0] [int cell_end=-1] [int cell_stride=1] [int only_if_parasites_extinct=0]"; }

void Process(cAvidaContext& ctx)
{
if (m_cell_start < 0 || m_cell_end > m_world->GetPopulation().GetSize() || m_cell_start >= m_cell_end) {
if (m_only_if_parasites_extinct && m_world->GetStats().GetNumParasites()) {
return;
}

if (m_cell_start < 0 || m_cell_end > m_world->GetPopulation().GetSize() || m_cell_start >= m_cell_end || m_cell_stride <= 0) {
ctx.Driver().Feedback().Warning("InjectParasite has invalid range!");
} else {
GenomePtr genome;
Expand All @@ -715,7 +723,7 @@ class cActionInjectParasite : public cAction
if (!genome) return;
ConstInstructionSequencePtr seq;
seq.DynamicCastFrom(genome->Representation());
for (int i = m_cell_start; i < m_cell_end; i++) {
for (int i = m_cell_start; i < m_cell_end; i+=m_cell_stride) {
m_world->GetPopulation().InjectParasite(m_label, *seq, i);
}
m_world->GetPopulation().SetSyncEvents(true);
Expand Down
688 changes: 688 additions & 0 deletions avida-core/tests/parasites_inject_only_if_extinct/config/avida.cfg

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#for analyze mode, uncomment this line
#RESOURCE resECHO:initial=10000000:inflow=40:outflow=0.10
RESOURCE resECHO:inflow=40:outflow=0.10

#REACTION ECHO echo process:resource=resECHO:value=0.0:type=pow:frac=0.5:min=1:max=1: requisite:noreaction=ECHO

REACTION NOT
REACTION NAND
REACTION AND
REACTION ORN
REACTION OR
REACTION ANDN
REACTION NOR
REACTION XOR
REACTION EQU

REACTION NOT not process:resource=resECHO:value=0.0:type=pow:frac=0.5:min=1:max=1: requisite:noreaction=EQU:noreaction=XOR:noreaction=NOR:noreaction=ANDN:noreaction=OR:noreaction=ORN:noreaction=AND:noreaction=NAND:noreaction=NOT
REACTION NAND nand process:resource=resECHO:value=0.0:type=pow:frac=0.5:min=1:max=1: requisite:noreaction=EQU:noreaction=XOR:noreaction=NOR:noreaction=ANDN:noreaction=OR:noreaction=ORN:noreaction=AND:noreaction=NAND:noreaction=NOT
REACTION AND and process:resource=resECHO:value=0.0:type=pow:frac=0.5:min=1:max=1: requisite:noreaction=EQU:noreaction=XOR:noreaction=NOR:noreaction=ANDN:noreaction=OR:noreaction=ORN:noreaction=AND:noreaction=NAND:noreaction=NOT
REACTION ORN orn process:resource=resECHO:value=0.0:type=pow:frac=0.5:min=1:max=1: requisite:noreaction=EQU:noreaction=XOR:noreaction=NOR:noreaction=ANDN:noreaction=OR:noreaction=ORN:noreaction=AND:noreaction=NAND:noreaction=NOT
REACTION OR or process:resource=resECHO:value=0.0:type=pow:frac=0.5:min=1:max=1: requisite:noreaction=EQU:noreaction=XOR:noreaction=NOR:noreaction=ANDN:noreaction=OR:noreaction=ORN:noreaction=AND:noreaction=NAND:noreaction=NOT
REACTION ANDN andn process:resource=resECHO:value=0.0:type=pow:frac=0.5:min=1:max=1: requisite:noreaction=EQU:noreaction=XOR:noreaction=NOR:noreaction=ANDN:noreaction=OR:noreaction=ORN:noreaction=AND:noreaction=NAND:noreaction=NOT
REACTION NOR nor process:resource=resECHO:value=0.0:type=pow:frac=0.5:min=1:max=1: requisite:noreaction=EQU:noreaction=XOR:noreaction=NOR:noreaction=ANDN:noreaction=OR:noreaction=ORN:noreaction=AND:noreaction=NAND:noreaction=NOT
REACTION XOR xor process:resource=resECHO:value=0.0:type=pow:frac=0.5:min=1:max=1: requisite:noreaction=EQU:noreaction=XOR:noreaction=NOR:noreaction=ANDN:noreaction=OR:noreaction=ORN:noreaction=AND:noreaction=NAND:noreaction=NOT
REACTION EQU equ process:resource=resECHO:value=0.0:type=pow:frac=0.5:min=1:max=1: requisite:noreaction=EQU:noreaction=XOR:noreaction=NOR:noreaction=ANDN:noreaction=OR:noreaction=ORN:noreaction=AND:noreaction=NAND:noreaction=NOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
##############################################################################
#
# This is the setup file for the events system. From here, you can
# configure any actions that you want to have happen during the course of
# an experiment, including setting the times for data collection.
#
# basic syntax: [trigger] [start:interval:stop] [action/event] [arguments...]
#
# This file is currently setup to record key information every 100 updates.
#
# For information on how to use this file, see: doc/events.html
# For other sample event configurations, see: support/config/
#
##############################################################################

# Seed the population with a single organism
u begin Inject evolved-not.org

u 600 InjectParasite parasite-smt.org ABB 0 400 1
u 601 PrintParasiteData ParasiteData.dat
u 602 InjectParasite parasite-smt.org ABB 800 1000 1 1
u 603 PrintParasiteData ParasiteData.dat
#u 0:100:end PrintDepthHistogram
#u 0:100:end PrintHostDepthHistogram
#u 0:100:end PrintParasiteDepthHistogram

#u 0:200:end DumpHostTaskGrid
#u 0:200:end DumpParasiteTaskGrid
#u 0:100:end PrintMutationRateData

#u 0:100:end PrintPhenotypeData
#u 0:100:end PrintHostPhenotypeData
#u 0:100:end PrintParasitePhenotypeData

#u 0:100:end PrintHostTasksData
u 0:100:end PrintParasiteTasksData

#u 0:100:end PrintParasiteData ParasiteData.dat

# Print all of the standard data files...
#u 0:100:end PrintAverageData # Save info about they average genotypes
#u 0:100:end PrintDominantData # Save info about most abundant genotypes
#u 0:100:end PrintStatsData # Collect satistics about entire pop.
#u 0:100:end PrintCountData # Count organisms, genotypes, species, etc.
#u 0:100:end PrintTasksData # Save organisms counts for each task.
#u 0:100:end PrintTimeData # Track time conversion (generations, etc.)
#u 0:100:end PrintResourceData # Track resource abundance.

# A few data files not printed by default
# u 100:100 PrintDominantGenotype # Save the most abundant genotypes
# u 100:100:end PrintErrorData # Std. Error on averages.
# u 100:100:end PrintVarianceData # Variance on averages.
# u 100:100:end PrintTotalsData # Total counts over entire run.
# u 100:100:end PrintTasksExeData # Num. times tasks have been executed.
# u 100:100:end PrintTasksQualData # Task quality information

# Setup the exit time and full population data collection.
u 600 SavePopulation # Save current state of population.
u 900 SavePopulation
u 900 Exit # exit
Loading

0 comments on commit 0433001

Please sign in to comment.