Revised 2006-09-03 DMB

Return to the Index | The Events File | The Analyze File

# List of Actions

## Action Categories

There is a large library of actions available for scheduling as events. Additionally, all of these actions can be used within analyze scripts. Below you will find a listing of the high level groupings of these actions, along with detailed sections for each them.

Print
  Print actions are the primary way of saving data from an Avida experiments.
Population
  Population actions modify the state of the population, and will actually change the course of the run.
Environment
  Actions that allow user to change properties of the environment, including resources.
Save and Load
  Actions that allow for saving and loading large data sets, such as full populations.
Landscape Analysis
  Actions that use data from the current state of Avida, process it and then output the results.
Driver
  Actions that allow user to control program execution, including experiment termination.

For a brief overview of writing a new action, please see Creating an Action below.

## Alphabetical Listing of Available Actions

AnalyzeLandscape
AnalyzePopulation
CompeteDemes
ConnectCells
CopyDeme
DeletionLandscape
DisconnectCells
DumpDonorGrid
DumpFitnessGrid
DumpGenotypeIDGrid
DumpMemory
DumpPopulation
DumpReceiverGrid
DumpTaskGrid
Echo
Exit
ExitAveLineageLabelGreater
ExitAveLineageLabelLess
FullLandscape
HillClimb
Inject
InjectAll
InjectParasite
InjectRandom
InjectRange
InjectResource
InjectScaledResource
InjectSequence
InsertionLandscape
JoinGridCol
JoinGridRow
KillProb
KillRate
KillRectangle
LoadClone

LoadPopulation
ModMutProb
OutflowScaledResource
PairTestLandscape
PrecalcLandscape
PredictNuLandscape
PredictWLandscape
PrintAverageData
PrintCCladeCounts
PrintCCladeFitnessHistogram
PrintCCladeRelativeFitnessHistogram
PrintCountData
PrintData
PrintDebug
PrintDemeStats
PrintDepthHistogram
PrintDetailedFitnessData
PrintDivideMutData
PrintDominantData
PrintDominantGenotype
PrintDominantParaData
PrintDominantParasiteGenotype
PrintErrorData
PrintGeneticDistanceData
PrintGenomicSiteEntropy
PrintGenotypeAbundanceHistogram
PrintGenotypeMap
PrintGenotypes
PrintInstructionAbundanceHistogram
PrintInstructionData
PrintLineageCounts
PrintLineageTotals
PrintLogFitnessHistogram
PrintMutationRateData
PrintPhenotypeData

PrintPhenotypeStatus
PrintPhenotypicPlasticity
PrintPopulationDistanceData
PrintRelativeFitnessHistogram
PrintResourceData
PrintSpeciesAbundanceData
PrintStatsData
PrintTasksSnapshot
PrintTasksExeData
PrintTasksQualData
PrintTimeData
PrintTotalsData
PrintTreeDepths
PrintVarianceData
PrintViableTasksData
RandomLandscape
ResetDemes
SampleLandscape
SaveClone
SaveHistoricPopulation
SaveHistoricSexPopulation
SaveParasitePopulation
SavePopulation
SaveSexPopulation
SerialTransfer
SetMutProb
SetReactionInst
SetReactionValue
SetReactionValueMult
SetResource
SetVerbose
SeverGridCol
SeverGridRow
TestDominant
ZeroMuts

## Print Actions

Output events are the primary way of saving data from an Avida experiments. The main two types are continuous output, which append to a single file every time the event is trigged, and singular output, which produce a single, complete file for each trigger.

- PrintAverageData [string filename='average.dat']

  Print all of the population averages the specified file.

- PrintCCladeCounts [string filename="cclade_count.dat"]

  Print a count of the number of oraganisms belonging to a each coalescence clade currently in the population.
  This action will only work in run mode.
  This action will require TRACK_CCLADE to be enabled.

- PrintCCladeFitnessHistogram [string filename="cclade_fitness_hist.dat"] [string mode="CURRENT"] [double lower_bound=-3.0] [double step=0.5] [double upper_bound=12.0]

  Print a histogram of fitnesses for each coalescence clade in the population.
  This action will only work in run mode.
  This action will rerequire TRACK_CCLADE to be enabled.
  `mode` may be {`CURRENT, ACTUAL, TESTCPU`}, where
  `CURRENT` uses the current phenotype value of fitness

`ACTUAL` uses the current merit and the true gestation time (via test cpu calculation)
`TESTCPU` uses the test cpu measurement.
`lower_bound, step, upper_bound` are log10 values for the individual histogram bins.
- PrintCCladeRelativeFitnessHistogram [string filename="cclade_rel_fitness_histogram.dat"] [string mode="CURRENT"] [double lower_bound=0.0] [double step=0.1] [double upper_bound=2.0]

  Print a histogram of parent-relative fitness ratios for each coalescence clade in the population.
  This action will only work in run mode.
  This action will rerequire TRACK_CCLADE to be enabled.
  `mode` may be {`CURRENT, ACTUAL, TESTCPU`}, where
  `CURRENT` uses the current phenotype value of fitness

`ACTUAL` uses the current merit and the true gestation time (via test cpu calculation)
`TESTCPU` uses the test cpu measurement.
`lower_bound, step, upper_bound` are values for the individual histogram bins.
- PrintErrorData [string filename='error.dat']

  Print all of the standard errors of the average population statistics.

- PrintVarianceData [string filename='variance.dat']

  Print all of the variances of the average population statistics.

- PrintDominantData [string filename='dominant.dat']

  Print all of the statistics relating to the dominant genotype.

- PrintStatsData [string filename='stats.dat']

  Print all of the miscellanous population statistics.

- PrintCountData [string filename='count.dat']

  Print all of the statistics the keep track of counts (such as the number of organisms in the population or the number of instructions executed).

- PrintTotalsData [string filename='totals.dat']

  Print various totals for the entire length of the run (for example, the total number of organisms ever).

- PrintTasksData [string filename='tasks.dat']

  Print the number of organisms that are able to perform each task. This uses the environment configuration to determine what tasks are in use.

- PrintTasksExeData [string filename='tasks_exe.dat']

  Print number of times the particular task has been executed this update.

- PrintTasksQualData [string filename='tasks_quality.dat']

  Print the total quality of each task. By default a successful task is valued as 1.0. Some tasks, however, can grant partial values and/or special bonuses via the quality value.

- PrintResourceData [string filename='resource.dat']

  Print the current counts of each resource available to the population. This uses the environment configuration to determine what resources are in use. Also creates seperate files `resource_resource_name.m` (in a format that is designed to be read into Matlab) for each spatial resource.

- PrintTimeData [string filename='time.dat']

  Print all of the timing related statistics.

- PrintMutationRateData [string filename='mutation_rates.dat']

  Output (regular and log) statistics about individual copy mutation rates (aver, stdev, skew, cur). Useful only when mutation rate is set per organism.

- PrintDivideMutData [string filename='divide_mut.dat']

  Output (regular and log) statistics about individual, per site, rates divide mutation rates (aver, stdev, skew, cur) to divide_mut.dat. Use with multiple divide instuction set.

- PrintDominantParaData [string filename='parasite.dat']

  Print various quantites related to the dominant parasite.

- PrintInstructionData [string filename='instruction.dat']

  Print the by-organisms counts of what instructions they _successfully_ executed beteween birth and divide. Prior to their first divide, organisms values for their parents.

- PrintGenotypeMap [string filename='genotype_map.m']

  This event is used to output a map of the genotype IDs for the population grid to a file that is suitable to be read into Matlab.

- PrintPhenotypeData [string filename='phenotype_count.dat']

  Print the number of phenotypes based on tasks executed this update. Executing a task any number of times is considered the same as executing it once.

- PrintPhenotypeStatus [string filename='phenotype_status.dat']

- PrintDemeStats

- PrintData <string fname> <string format>

  Append to the file specified (continuous output), the data given in the column list. The column list needs to be a comma-seperated list of keywords representing the data types. Many possible data types can be output; see the complete listing for details. Note that this event will even create a detailed column legend at the top of your file so you don't need to seperately keep track of what the columns mean.

- PrintInstructionAbundanceHistogram [string filename='instruction_histogram.dat']

  Appends a line containing the bulk count (abundance) of each instruction in the population onto a file.

- PrintDepthHistogram [string filename='depth_histogram.dat']

- Echo <string message>

  Print the supplied message to standard output.

- PrintGenotypeAbundanceHistogram [string fname='genotype_abundance_histogram.dat']

  Writes out a genotype abundance histogram.

- PrintSpeciesAbundanceHistogram [string fname='species_abundance_histogram.dat']

  Writes out a species abundance histogram.

- PrintLineageTotals [string fname='lineage_totals.dat'] [int verbose=1]

- PrintLineageCounts [string fname='lineage_counts.dat'] [int verbose=1]

- PrintDominantGenotype [string fname='']

  Print the dominant organism's genome (and lots of information about it) into the file specified. If no filename is given, the genotype's assigned name is used and the file is placed into the archive subdirectory.

- PrintDominantParasiteGenotype [string fname='']

  Print the dominant parasite's genome (and lots of information about it) into the file specified. If no filename is given, the parasite's assigned name is used and the file is placed into the archive subdirectory.

- PrintDetailedFitnessData [int save_max_f_genotype=0] [int print_fitness_histo=0] [double hist_fmax=1] [double hist_fstep=0.1] [string datafn='fitness.dat'] [string histofn='fitness_histos.dat'] [string histotestfn='fitness_histos_testCPU.dat']

- PrintLogFitnessHistogram [string filename="fitness_log_hist.dat"] [string mode="CURRENT"] [double lower_bound=-3.0] [double step=0.5] [double upper_bound=12.0]

  Print a histogram of organism fitnesses in the current population.
  This action will only work in run mode.
  `mode` may be {`CURRENT, ACTUAL, TESTCPU`}, where
  `CURRENT` uses the current phenotype value of fitness

`ACTUAL` uses the current merit and the true gestation time (via test cpu calculation)
`TESTCPU` uses the test cpu measurement.
`lower_bound, step, upper_bound` are log10 values for the individual histogram bins.
- PrintRelativeFitnessHistogram [string filename="rel_fitness_histogram.dat"] [string mode="CURRENT"] [double lower_bound=0.0] [double step=0.1] [double upper_bound=2.0]

  Print a histogram of parent-relative fitness ratios for each coalescence clade in the population.
  This action will only work in run mode.
  `mode` may be {`CURRENT, ACTUAL, TESTCPU`}, where
  `CURRENT` uses the current phenotype value of fitness

`ACTUAL` uses the current merit and the true gestation time (via test cpu calculation)
`TESTCPU` uses the test cpu measurement.
`lower_bound, step, upper_bound` are values for the individual histogram bins.
- PrintGenomicSiteEntropy [string filename="GenomicSiteEntropy.dat"]

  This function will take the initial genotype for each organism in the population/batch, align them, and calculate the per-site entropy of the aligned sequences. Please note that there may be a variable number of columns in each line if the runs are not fixed length. The site entropy will be measured in mers, normalized by the instruction set size. This is a population/batch measure of entropy, not a mutation-selection balance measure.

- PrintPhenotypicPlasticity [string filename="phenplast.dat | phenplast-Update.dat"] [int num_trials=1000]

  This function will provided detailed information about the phenotypic varients of the current population/batch by running each genome through a test cpu `num_trials` times. If this command is executed in run mode, the `filename` will be appeneded with `-Update.dat` where `Update` is the current update. In analyze mode, the default file is merely phenplast.dat. The output file contains the following: id, parent_id, phenotypic_varient_number, frequency, fitness, merit, gestation_time, and task counts for each phenotypic variant of each genotype.

- PrintGeneticDistanceData [string ref_creature_file='START_CREATURE'] [string filename='genetic_distance.dat']

- PrintPopulationDistanceData [string creature='START_CREATURE'] [string fname=''] [int save_genotypes=0]

- PrintDebug

- PrintGenotypes [string data_fields='all'] [int print_historic=0] [string filename='genotypes-<update>.dat']

  This command is used to print out information about all of the genotypes in the population. The file output from here can be read back into the analyze mode of Avida with the `LOAD` command.

  The data_fields parameter indicates what columns should be included in the file, which must be comma seperated. Options are: all, id, parent_id, parent2_id (for sex), parent_dist, num_cpus, total_cpus, length, merit, gest_time, fitness, update_born, update_dead, depth, lineage, sequence. Use all (the default) if you want all of the fields included.

  The print_historic parameter indicates how many updates back in time should be included in this output. For example, '200' would indicate that any ancestor of the current population that died out in the last 200 updates should also be printed. A '-1' in this field indicates that all ancestors should be printed.

  The filename parameter simply indicates what you want to call the file.

  Example:
  `u 1000:1000 print_genotypes id,parent_id,fitness 1000`
  This will print out the full population every 1000 updates, including all genotypes that have died out since the last time it was printed.

- TestDominant [string fname='dom-test.dat']

- PrintTaskSnapshot [string fname='']

  Run all organisms in the population through test cpus and print out the number of tasks each can perform.

- PrintViableTasksData [string fname='viable_tasks.dat']

- PrintTreeDepths [string fname='']

  Reconstruction of phylogenetic trees.

- DumpMemory [string filename='memory_dump-<update>.dat']

  Dump memory summary information.

- DumpFitnessGrid [string filename='grid_fitness.<update>.dat']

  Print out the grid of organism fitness values.

- DumpGenotypeIDGrid [string filename='grid_genotype_id.<update>.dat']

  Print out the grid of genotype IDs.

- DumpTaskGrid [string filename='grid_task.<update>.dat']

  Print out the grid of takss that organisms do. For each organism, tasks are first encoded as a binary string (e.g. 100000001 means that organism is doing NOT and EQU and then reported as a base-10 number (257 in the example above).

- DumpDonorGrid [string filename='grid_donor.<update>.dat']

  Print out the grid of organisms who donated their merit.

- DumpRecieverGrid [string filename='grid_receiver.<update>.dat']

  Print out the grid of organisms who received merit.

- SetVerbose [string verbosity='']

  Change the level of output verbosity. Verbose messages will print all of the details of what is happening to the screen. Minimal messages will only briefly state the process being run. Verbose messages are recommended if you're in interactive analysis mode. When no arguments are supplied, action will toggle between NORMAL and ON.
  Levels: SILENT, NORMAL, ON, DETAILS, DEBUG

## Population Actions

Population events modify the state of the population, and will actually change the course of the run. There are a wide variety of these.

- Inject [string fname='START_CREATURE'] [int cell_id=0] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]

  Inject a single organisms into the population. Arguments must be included from left to right; if all arguments are left out, the default creature is the ancestral organism, and it will be injected into cell 0, have an uninitialized merit, and be marked as liniage id 0.

- InjectRandom <int length> [int cell_id=0] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]

  Injects a randomly generated genome of the supplied length into the population.

- InjectAll [string fname='START_CREATURE'] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]

  Same as Inject, but no cell_id is specified and the organism is placed into all cells in the population.

- InjectRange [string fname='START_CREATURE'] [int cell_start=0] [int cell_end=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]

  Injects identical organisms into a range of cells of the population.

  Example:
  `InjectRange 000-aaaaa.org 0 10`
  Will inject 10 organisms into cells 0 through 9.

- InjectSequence <string sequence> [int cell_start=0] [int cell_end=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]

  Injects identical organisms based on the supplied genome sequence into a range of cells of the population.

  Example:
  `InjectSequence ckdfhgklsahnfsaggdsgajfg 0 10 100`
  Will inject 10 organisms into cells 0 through 9 with a merit of 100.

- InjectParasite <string filename> <string label> [int cell_start=0] [int cell_end=-1]

  Attempt to inject a parasite genome into the supplied population cell range with the specified label.

- InjectParasitePair <string filename_genome> <string filename_parasite> <string label> [int cell_start=0] [int cell_end=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]

  Inject host parasite pairs into the population cell range specified.

- KillProb [double probability=0.9]

  Using the specified probability, test each organism to see if it is killed off.

- KillRate [double probability=0.9]

  Randomly removes a certain proportion of the population. In principle, this action does the same thing as the KillProb event. However, instead of a probability, here one has to specify a rate. The rate has the same unit as fitness. So if the average fitness is 20000, than you remove 50% of the population on every update with a removal rate of 10000.

- KillRectangle [int x1=0] [int y1=0] [int x2=0] [int y2=0]

  Kill off all organisms in a rectangle defined by the points (x1, y1) and (x2, y2).

- SerialTransfer [int transfer_size=1] [int ignore_deads=1]

  Similar to KillProb, but we specify the exact number of organisms to keep alive after the event. The ignore_deads argument determines whether only living organisms are retainted.

- SetMutProb [string mut_type='copy'] [double prob=0.0] [int start_cell=-1] [int end_cell=-1]

- ModMutProb [string mut_type='copy'] [double prob=0.0] [int start_cell=-1] [int end_cell=-1]

- ZeroMuts

  This event will set all mutation rates to zero.

- CompeteDemes [int type=1]

- ResetDemes

- CopyDeme <int src_id> <int dest_id>

- SeverGridCol [int col_id=-1] [int min_row=0] [int max_row=-1]

  Remove the connections between cells along a column in an Avida grid.

- SeverGridRow [int row_id=-1] [int min_col=0] [int max_col=-1]

  Remove the connections between cells along a row in an Avida grid.

- JoinGridCol [int col_id=-1] [int min_row=0] [int max_row=-1]

  Add connections between cells along a column in an Avida grid.

- JoinGridRow [int row_id=-1] [int min_col=0] [int max_col=-1]

  Add connections between cells along a row in an Avida grid.

- ConnectCells <int cellA_x> <int cellA_y> <int cellB_x> <int cellB_y>

  Connects a pair of specified cells.

- DisconnectCells <int cellA_x> <int cellA_y> <int cellB_x> <int cellB_y>

  Disconnects a pair of specified cells.

## Environment Actions

Events that allow user to change environment properties, such as resources and reaction parameters.

- InjectResource <string res_name> <double res_count>

  Inject (add) a specified amount of a specified resource. res_name must already exist as a resource in environment file.

- InjectScaledResource <string res_name> <double res_count>

- OutflowScaledResource <string res_name> <double res_percent>

- SetResource <string res_name> <double res_count>

  Set the resource amount to a specific level. res_name must already exist as a resource in environment file.

- SetReactionValue <string reaction_name> <double value>

  Set the reaction value to a specific level. reaction_name must already exist in the environment file. value can be negative.

- SetReactionValueMult <string reaction_name> <double value>

  Multiply the reaction value by the value. reaction_name must already exist in the environment file. value can be negative.

- SetReactionInst <string reaction_name> <string inst>

  Set the instruction triggered by this reaction. reaction_name must already exist in the environment file. inst must be in the instruction set.

## Save Load Actions

- SaveClone [string fname='']

  Save a clone of this organism to the file specified; if no filename is given, use the name clone.update. The update number allows regular clones with distinct filenames to be saved with the same periodic event. Running `avida -l filename` will start an Avida population with the saved clone. Note that a clone only consists of the genomes in the population, and their current state is lost, so the run may not proceed identically as to if it had continued as it was going.

- LoadClone <string fname>

- LoadPopulation <string fname> [int update=-1]

  Sets up a population based on a save file such as written out by SavePopulation. It is also possible to append a history file to the save file, in order to preserve the history of a previous run.

- DumpPopulation [string fname='']

- SavePopulation [string fname='']

  Save the genotypes and lots of statistics about the population to the file specified; if not filename is given, use the name `detail-update.pop`. As with clones, the update number allows a single event to produce many detail files. The details are used to collect crossection data about the population.

- SaveSexPopulation [string fname='']

- SaveParasitePopulation [string fname='']

- SaveHistoricPopulation [int back_dist=-1] [string fname='']

  This action is used to output all of the ancestors of the currently living population to the file specified, or `historic-update.pop`.

- SaveHistoricSexPopulation [string fname='']

## Landscape Analysis Actions

Landscape analysis actions perform various types mutation studies to calculate properties of the fitness landscape for a particular genome. When scheduled as an event during a run, these actions will typically perform analysis on the dominant genotype. In analyze mode, analysis is performed on the entire currently selected batch.

These actions are often very computationally intensive, thus will take a long time to compute. In order to take advantage of increasingly available multi-processor/multi-core systems, a number of these actions have been enhanced to make use of multiple threads to parallize work. Set the configuration setting `MT_CONCURRENCY` to the number of logical processors available to make use of all processor resources for these compuations.

- AnalyzeLandscape [filename='land-analyze.dat'] [int trials=1000] [int min_found=0] [int max_trials=0] [int max_dist=10]

- PrecalcLandscape

  Precalculate the distance 1 full landscape for the current batch in parallel using multiple threads. The resulting data is stored into the current batch and can be used by many subsequent output commands within Analyze mode.

- FullLandscape [string filename='land-full.dat'] [int distance=1] [string entropy_file=''] [string sitecount_file='']

  Do a landscape analysis of the dominant genotype or current batch of genotypes, depending on the current mode. The resulting output is a collection of statistics obtained from examining all possible mutations at the distance specified. The default distance is one.

- DeletionLandscape [string filename='land-del.dat'] [int distance=1] [string sitecount_file='']

- InsertionLandscape [string filename='land-ins.dat'] [int distance=1] [string sitecount_file='']

- PredictWLandscape [string filename='land-predict.dat']

- PredictNuLandscape [string filename='land-predict.dat']

- RandomLandscape [string filename='land-random.dat'] [int distance=1] [int trials=0]

- SampleLandscape [string filename='land-sample.dat'] [int trials=0]

- HillClimb [string filename='hillclimb.dat']

  Does a hill climb with the dominant genotype.

- PairTestLandscape [string filename=''] [int sample_size=0]

  If sample_size = 0, pairtest the full landscape.

- AnalyzePopulation [double sample_prob=1] [int landscape=0] [int save_genotype=0] [string filename='']

## Driver Actions

These actions control the driver object responsible for executing the current run.

- Exit

  Unconditionally terminate the current run.

- ExitAveLineageLabelGreater <double threshold>

  Halts the run if the current average lineage label is larger than threshold.

- ExitAveLineageLabelLess <double threshold>

  Halts the run if the current average lineage label is smaller than threshold.

## Creating an Action

The action source code is contained in the source/action directory. Each of the individual action categories has its own source code files (e.g. Landcape Actions are located in the LandscapeActions files).

Each action is derrived from the cAction class. Briefly, to get an action to work you must create a child class that has a Process and GetDescription function defined as well as a constructor. You must also register this new class with the action library.

So, with that quick review of what must be done, here is a step by step guide to creating an action:

1. Identify which of the action categories your action should be assigned to. There are six different action categories described above. Each category has a similar means of creating a new action, but do note that some action commands are generated via macros defined at the top of the files. For instance, in the PrintActions file, you will notice a number of STATS_OUT_FILE macros being used to generate rather repetitively coded standard output files.

2. Create a new class in the file that follows proper naming conventions. Any class should begin with "cAction" and be followed by the name of the action command you will register with the library. For instance, if we were to create a new command "MyAction", we'd name the class cActionMyAction. Below is a stub for this new action class:

       class cActionMyAction : public cAction
       {
       	private:
       		// Private data members for this action
       	public:
       		cActionMyAction(cWorld* world, const cString& args) : cAction(world, args) { ; }

       		static const cString GetDescription() { return "Arguments: My Arguments"; }

       		void Process(cAvidaContext& ctx)
       		{
       			//Perform whatever processing is needed when the action is triggered.
       		}
       };

3. Define the private data members, constructor, description string in GetDescription, and the Process function. Any arguments that you specify after the action name in the events configuration will be passed to your new class via the args argument in the constructor.

4. Register the new action with the action library. At the bottom of each action definitions file, there are the commands that register the individual actions with the action library. In the PrintActions.cc file, for instance, this function is called RegisterPrintActions.

   To register our example action "MyAction", we'd write:

       action_lib->Register<cActionMyAction>("MyAction");

5. Test your action.

Return to the Index | The Events File | The Analyze File