Skip to content

Commit

Permalink
Merge pull request #85 from devosoft/parasite-log-injections
Browse files Browse the repository at this point in the history
Impl, test opt-in injection logging
  • Loading branch information
mmore500 authored Nov 24, 2023
2 parents c79db26 + ed462b2 commit aaaa105
Show file tree
Hide file tree
Showing 14 changed files with 2,437 additions and 3 deletions.
1 change: 1 addition & 0 deletions avida-core/source/main/cAvidaConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ class cAvidaConfig {

// -------- Parasite options --------
CONFIG_ADD_GROUP(PARASITE_GROUP, "Parasite config options");
CONFIG_ADD_VAR(LOG_PARASITE_INJECTIONS, bool, 0, "Log parasite replications?");
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);
Expand Down
12 changes: 9 additions & 3 deletions avida-core/source/main/cPopulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1270,9 +1270,15 @@ bool cPopulation::ActivateParasite(cOrganism* host, Systematics::UnitPtr parent,
hw.GetNumThreads() == m_world->GetConfig().MAX_CPU_THREADS.Get()) return false;

//Handle host specific injection
if(TestForParasiteInteraction(host, target_organism) == false)
return false;

const bool parasite_interaction = TestForParasiteInteraction(host, target_organism);
if (m_world->GetConfig().LOG_PARASITE_INJECTIONS.Get()) {
Avida::Output::FilePtr df = Avida::Output::File::StaticWithPath(m_world->GetNewWorld(), "parasite_injection.dat");
cString UpdateStr = cStringUtil::Stringf("%d,%d,%d,%d", m_world->GetStats().GetUpdate(), target_organism->GetDemeID(), target_organism->GetCellID(), parasite_interaction);
df->WriteRaw(UpdateStr);
}

if(parasite_interaction == false) return false;


// Attempt actual parasite injection
// LZ - use parasige_genotype_list for the GenRepPtr instead IF Config says to
Expand Down
688 changes: 688 additions & 0 deletions avida-core/tests/parasites_log_injections/config/avida.cfg

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions avida-core/tests/parasites_log_injections/config/environment.cfg
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
57 changes: 57 additions & 0 deletions avida-core/tests/parasites_log_injections/config/events.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
##############################################################################
#
# 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
#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 aaaa105

Please sign in to comment.