Empirical
|
Setup a World with a population of organisms that can evolve or deal with ecological effects. More...
#include <World.h>
Public Types | |
using | this_t = World< ORG > |
Resolved type of this templated class. More... | |
using | org_t = ORG |
Type of organisms in this world. More... | |
using | value_type = org_t |
Identical to org_t; vector compatibility. More... | |
using | pop_t = emp::vector< Ptr< ORG >> |
Type for whole populations. More... | |
using | iterator_t = World_iterator< this_t > |
Type for this world's iterators. More... | |
using | fit_cache_t = emp::vector< double > |
Type for fitness caches for pops. More... | |
using | genome_t = typename emp::find_genome_t< ORG > |
Type of underlying genomes. More... | |
using | fun_calc_fitness_t = std::function< double(ORG &)> |
Function type for calculating fitness. More... | |
using | fun_calc_dist_t = std::function< double(ORG &, ORG &)> |
Function type for calculating the distance between two organisms. More... | |
using | fun_do_mutations_t = std::function< size_t(ORG &, Random &)> |
Function type for a mutation operator on an organism. More... | |
using | fun_print_org_t = std::function< void(ORG &, std::ostream &)> |
Function type for printing an organism's info to an output stream. More... | |
using | fun_get_genome_t = std::function< const genome_t &(ORG &)> |
Function type for retrieving a genome from an organism. More... | |
using | fun_find_inject_pos_t = std::function< WorldPosition(Ptr< ORG >)> |
Function type for injecting organisms into a world (returns inject position) More... | |
using | fun_find_birth_pos_t = std::function< WorldPosition(Ptr< ORG >, WorldPosition)> |
Function type for adding a newly born organism into a world (returns birth position) More... | |
using | fun_kill_org_t = std::function< WorldPosition()> |
Function type for determining picking and killing an organism (returns newly empty position) More... | |
using | fun_get_neighbor_t = std::function< WorldPosition(WorldPosition)> |
Function type for identifying an organism's random neighbor. More... | |
Public Member Functions | |
World (std::string _name="", bool gen_random=true) | |
World (Random &rnd, std::string _name="") | |
~World () | |
size_t | GetSize () const |
How many organisms can fit in the world? More... | |
size_t | GetNumOrgs () const |
How many organisms are currently in the world? More... | |
size_t | GetUpdate () const |
What update number is the world currently on? (assumes Update() is being used) More... | |
size_t | GetWidth () const |
How many cells wide is the world? (assumes grids are active.) More... | |
size_t | GetHeight () const |
How many cells tall is the world? (assumes grids are active.) More... | |
const pop_t & | GetFullPop () const |
Get the full population to analyze externally. More... | |
const emp::TraitSet< ORG > & | GetPhenotypes () const |
What phenotypic traits is the population tracking? More... | |
DataFile & | AddDataFile (emp::Ptr< DataFile > file) |
Add an already-constructed datafile. More... | |
DataFile & | GetFile (const std::string &filename) |
Lookup a file by name. More... | |
bool | IsOccupied (WorldPosition pos) const |
Does the specified cell ID have an organism in it? More... | |
bool | IsCacheOn () const |
Are we currently caching fitness values? More... | |
bool | IsSynchronous () const |
bool | IsSpaceStructured () const |
bool | IsPhenoStructured () const |
this_t & | MarkSynchronous (bool in=true) |
this_t & | MarkSpaceStructured (bool in=true) |
this_t & | MarkPhenoStructured (bool in=true) |
const ORG & | operator[] (size_t id) const |
ORG & | GetOrg (size_t id) |
ORG & | GetOrg (size_t x, size_t y) |
const Ptr< ORG > | GetOrgPtr (size_t id) const |
ORG & | GetNextOrg (size_t id) |
const genome_t & | GetGenome (ORG &org) |
Retrieve the genome corresponding to a specified organism. More... | |
const genome_t & | GetGenomeAt (size_t id) |
Retrive the genome corresponding to the organism at the specified position. More... | |
Ptr< SystematicsBase< ORG > > | GetSystematics (int id=0) |
Ptr< SystematicsBase< ORG > > | GetSystematics (std::string label) |
void | RemoveSystematics (int id) |
void | RemoveSystematics (std::string label) |
template<typename ORG_INFO , typename DATA_STRUCT > | |
void | AddSystematics (Ptr< Systematics< ORG, ORG_INFO, DATA_STRUCT > > s, std::string label="systematics") |
fun_calc_fitness_t | GetFitFun () |
Get the fitness function currently in use. More... | |
void | SetPopStruct_Grow (bool synchronous_gen=false) |
void | SetPopStruct_Mixed (bool synchronous_gen=false) |
void | SetPopStruct_Grid (size_t width, size_t height, bool synchronous_gen=false) |
void | SetAutoMutate () |
void | SetAutoMutate (std::function< bool(size_t pos)> test_fun) |
void | SetSynchronousSystematics (bool synchronous) |
Tell systematics managers that this world has synchronous generations. More... | |
template<typename... Ts> | |
void | AddPhenotype (Ts &&...args) |
Add a new phenotype measuring function. More... | |
Ptr< DataMonitor< double > > | GetFitnessDataNode () |
Ptr< DataMonitor< double > > | AddDataNode (const std::string &name) |
Ptr< DataMonitor< double > > | GetDataNode (const std::string &name) |
DataFile & | SetupFile (const std::string &filename) |
Setup an arbitrary file; no default filename available. More... | |
DataFile & | SetupFitnessFile (const std::string &filename="fitness.csv", const bool &print_header=true) |
Setup a file to be printed that collects fitness information over time. More... | |
DataFile & | SetupSystematicsFile (std::string label, const std::string &filename="systematics.csv", const bool &print_header=true) |
Setup a file (by label) to be printed that collects systematics information over time. More... | |
DataFile & | SetupSystematicsFile (size_t id=0, const std::string &filename="systematics.csv", const bool &print_header=true) |
Setup a file (by id) to be printed that collects systematics information over time. More... | |
DataFile & | SetupPopulationFile (const std::string &filename="population.csv", const bool &print_header=true) |
Setup a file to be printed that collects population information over time. More... | |
void | SetFitFun (const fun_calc_fitness_t &fit_fun) |
void | SetMutFun (const fun_do_mutations_t &mut_fun) |
void | SetPrintFun (const fun_print_org_t &print_fun) |
void | SetGetGenomeFun (const fun_get_genome_t &_fun) |
void | SetAddInjectFun (const fun_find_inject_pos_t &_fun) |
void | SetAddBirthFun (const fun_find_birth_pos_t &_fun) |
void | SetKillOrgFun (const fun_kill_org_t &_fun) |
void | SetGetNeighborFun (const fun_get_neighbor_t &_fun) |
void | SetSharedFitFun (const fun_calc_fitness_t &fit_fun, const fun_calc_dist_t &dist_fun, double sharing_threshold, double alpha) |
SignalControl & | GetSignalControl () |
Access signal controller used for this world directly. More... | |
SignalKey | OnBeforeRepro (const std::function< void(size_t)> &fun) |
SignalKey | OnOffspringReady (const std::function< void(ORG &)> &fun) |
SignalKey | OnInjectReady (const std::function< void(ORG &)> &fun) |
SignalKey | OnBeforePlacement (const std::function< void(ORG &, size_t)> &fun) |
SignalKey | OnPlacement (const std::function< void(size_t)> &fun) |
SignalKey | OnUpdate (const std::function< void(size_t)> &fun) |
SignalKey | OnOrgDeath (const std::function< void(size_t)> &fun) |
SignalKey | OnSwapOrgs (const std::function< void(WorldPosition, WorldPosition)> &fun) |
SignalKey | OnWorldDestruct (const std::function< void()> &fun) |
bool | HasAttribute (const std::string &name) const |
std::string | GetAttribute (const std::string) const |
Get the value for an attribute that you know exists. More... | |
template<typename T > | |
void | SetAttribute (const std::string &name, T &&val) |
void | Update () |
template<typename... ARGS> | |
void | Process (ARGS &&...args) |
template<typename... ARGS> | |
void | ProcessID (size_t id, ARGS &&...args) |
void | ResetHardware () |
Reset the hardware for all organisms. More... | |
double | CalcFitnessOrg (ORG &org) |
Use the configured fitness function on the specified organism. More... | |
double | CalcFitnessID (size_t id) |
Use the configured fitness function on the organism at the specified position. More... | |
void | CalcFitnessAll () const |
Calculate the fitness of all organisms, storing the results in the cache. More... | |
void | SetCache (bool _in=true) |
Turn on (or off) fitness caching for individual organisms. More... | |
void | ClearCache () |
Remove all currently cached fitness values (useful with changing environments, etc.) More... | |
void | DoMutationsOrg (ORG &org) |
Use mutation function on a single, specified organism. More... | |
void | DoMutationsID (size_t id) |
Use mutation function on the organism at the specified position in the population. More... | |
void | DoMutations (size_t start_id=0) |
Use mutation function on ALL organisms in the population. More... | |
void | Clear () |
Remove all organisms from the world. More... | |
void | Reset () |
Clear all of the orgs and reset stats. More... | |
void | Swap (WorldPosition pos1, WorldPosition pos2) |
Swap the positions of two organisms. More... | |
void | Resize (size_t new_size) |
void | Resize (size_t new_width, size_t new_height) |
Change the size of the world based on width and height. More... | |
void | Resize (const emp::vector< size_t > &dims) |
Change the size of the world based on a vector of dimensions. More... | |
void | AddOrgAt (Ptr< ORG > new_org, WorldPosition pos, WorldPosition p_pos=WorldPosition()) |
void | RemoveOrgAt (WorldPosition pos) |
void | Inject (const genome_t &mem, size_t copy_count=1) |
Inject an organism using the default injection scheme. More... | |
void | InjectAt (const genome_t &mem, const WorldPosition pos) |
Inject an organism at a specific position. More... | |
template<typename... ARGS> | |
void | InjectRandomOrg (ARGS &&...args) |
Inject a random organism (constructor must facilitate!) More... | |
WorldPosition | DoBirth (const genome_t &mem, size_t parent_pos, size_t copy_count=1) |
Place one or more copies of an offspring into population; return position of last placed. More... | |
void | DoDeath (const WorldPosition pos) |
void | DoDeath () |
Random & | GetRandom () |
Return a reference to the random number generator currently being used by world. More... | |
void | SetRandom (Random &r) |
Setup a new random number generator created elsewhere. More... | |
void | NewRandom (int seed=-1) |
Create a new random number generator (that World will manage) More... | |
size_t | GetRandomCellID () |
Get the position a cell, at random. More... | |
size_t | GetRandomCellID (size_t min_id, size_t max_id) |
Get the position a cell in a range, at random. More... | |
WorldPosition | GetRandomNeighborPos (WorldPosition pos) |
Use the specified function to get a neighbor (if not set, assume well mixed). More... | |
size_t | GetRandomOrgID () |
Get the id of a random occupied cell. More... | |
ORG & | GetRandomOrg () |
Get an organism from a random occupied cell. More... | |
emp::vector< size_t > | FindCellIDs (const std::function< bool(ORG *)> &filter) |
Find ALL cell IDs that return true in the provided filter. More... | |
emp::vector< size_t > | GetValidOrgIDs () |
Return IDs of all occupied cells in the population. More... | |
emp::vector< size_t > | GetEmptyPopIDs () |
Return IDs of all empty cells in the population. More... | |
void | DoBottleneck (const size_t new_size, bool choose_random=true) |
Run population through a bottleneck to (potentially) shrink it. More... | |
void | SerialTransfer (const double keep_frac) |
Perform a Serial Transfer where a fixed percentage of current organisms are maintained. More... | |
void | Print (std::ostream &os=std::cout, const std::string &empty="-", const std::string &spacer=" ") |
Print all organisms in the population using previously provided print function. More... | |
void | PrintOrgCounts (std::ostream &os=std::cout) |
Print unique organisms and the number of copies of each that exist. More... | |
void | PrintGrid (std::ostream &os=std::cout, const std::string &empty="-", const std::string &spacer=" ") |
Print the organisms layed out in a grid structure (assumes a grid population.) More... | |
size_t | size () const |
[std::vector compatibility] How big is the world? More... | |
void | resize (size_t new_size) |
[std::vector compatibility] Update world size. More... | |
void | clear () |
[std::vector compatibility] Remove all organisms. More... | |
iterator_t | begin () |
[std::vector compatibility] Return iterator to first organism. More... | |
iterator_t | end () |
[std::vector compatibility] Return iterator just past last organism. More... | |
Protected Member Functions | |
double | GetCache (size_t id) const |
Get the current cached value for the organism at the specified position. More... | |
void | ClearCache (size_t id) |
Clear the cache value at the specified position. More... | |
Protected Attributes | |
size_t | update |
How many times has Update() been called? More... | |
Ptr< Random > | random_ptr |
Random object to use. More... | |
bool | random_owner |
Did we create our own random number generator? More... | |
WorldVector< Ptr< ORG > > | pops |
The set of active [0] and "next" [1] organisms in population. More... | |
pop_t & | pop |
A shortcut to pops[0]. More... | |
size_t | num_orgs |
How many organisms are actually in the population. More... | |
fit_cache_t | fit_cache |
vector size == 0 when not caching; uncached values == 0. More... | |
std::string | name |
Name of this world (for use in configuration.) More... | |
bool | cache_on |
Should we be caching fitness values? More... | |
std::vector< size_t > | pop_sizes |
Sizes of population dimensions (eg, 2 vals for grid) More... | |
emp::TraitSet< ORG > | phenotypes |
What phenotypes are we tracking? More... | |
emp::vector< emp::Ptr< DataFile > > | files |
Output files. More... | |
bool | is_synchronous |
Does this world have synchronous generations? More... | |
bool | is_space_structured |
Do we have a spatially structured population? More... | |
bool | is_pheno_structured |
Do we have a phenotypically structured population? More... | |
DataManager< double, data::Current, data::Info, data::Range, data::Stats > | data_nodes |
Potential data nodes – these should be activated only if in use. More... | |
fun_calc_fitness_t | fun_calc_fitness |
...evaluate fitness for provided organism. More... | |
fun_do_mutations_t | fun_do_mutations |
...mutate an organism. More... | |
fun_print_org_t | fun_print_org |
...print an organism. More... | |
fun_get_genome_t | fun_get_genome |
...determine the genome object of an organism. More... | |
fun_find_inject_pos_t | fun_find_inject_pos |
...find where to inject a new, external organism. More... | |
fun_find_birth_pos_t | fun_find_birth_pos |
...find where to add a new offspring organism. More... | |
fun_kill_org_t | fun_kill_org |
...kill an organism. More... | |
fun_get_neighbor_t | fun_get_neighbor |
...choose a random neighbor "near" specified id. More... | |
std::map< std::string, std::string > | attributes |
Attributes are a dynamic way to track extra characteristics about a world. More... | |
emp::vector< Ptr< SystematicsBase< ORG > > > | systematics |
Phylogeny and line-of-descent data collection. More... | |
std::unordered_map< std::string, int > | systematics_labels |
SignalControl | control |
Signal< void(size_t)> | before_repro_sig |
...before organism gives birth w/parent position. More... | |
Signal< void(ORG &)> | offspring_ready_sig |
...when offspring organism is built. More... | |
Signal< void(ORG &)> | inject_ready_sig |
...when outside organism is ready to inject. More... | |
Signal< void(ORG &, size_t)> | before_placement_sig |
...before placing any organism into target cell. More... | |
Signal< void(size_t)> | on_placement_sig |
...after any organism is placed into world. More... | |
Signal< void(size_t)> | on_update_sig |
...at the beginning of Update() More... | |
Signal< void(size_t)> | on_death_sig |
...immediately before any organism dies. More... | |
Signal< void(WorldPosition, WorldPosition)> | on_swap_sig |
...after org positions are swapped More... | |
Signal< void()> | world_destruct_sig |
...in the World destructor. More... | |
Friends | |
class | World_iterator< World< ORG > > |
Setup a World with a population of organisms that can evolve or deal with ecological effects.
There are three ways that organisms can enter the population:
If the population is in EA mode (with synchronous generations), DoBirth will place offspring in a "next generation" placeholder population. Update() will move orgs into primary population.
Organisms have a series of functions that are called on them that are chosen:
FITNESS: Most selection methods require a fitness function to help determine who should be replicated. Other systems merely use fitness as a measured output. 0. If you explicitly set the fitness function using SetFitFun(), it will have priority.
MUTATIONS: The mutation function deteramines a main source of variation for most evolving systems. 0. If you set the mutation function using SetMutFun(), it will have priority.
PRINTING: How should organisms be printed to the command line? 0. Setting the print function with SetPrintFun() member function.
GENOMES: Do organisms have a genome separate from their instantiation? By default, the full organism is returned when a genome is requested, but a GetGenome() member function in the organism type will override this behavior.
using emp::World< ORG >::fit_cache_t = emp::vector<double> |
Type for fitness caches for pops.
using emp::World< ORG >::fun_calc_dist_t = std::function<double(ORG&,ORG&)> |
Function type for calculating the distance between two organisms.
using emp::World< ORG >::fun_calc_fitness_t = std::function<double(ORG&)> |
Function type for calculating fitness.
using emp::World< ORG >::fun_do_mutations_t = std::function<size_t(ORG&,Random&)> |
Function type for a mutation operator on an organism.
using emp::World< ORG >::fun_find_birth_pos_t = std::function<WorldPosition(Ptr<ORG>, WorldPosition)> |
Function type for adding a newly born organism into a world (returns birth position)
using emp::World< ORG >::fun_find_inject_pos_t = std::function<WorldPosition(Ptr<ORG>)> |
Function type for injecting organisms into a world (returns inject position)
using emp::World< ORG >::fun_get_genome_t = std::function<const genome_t & (ORG &)> |
Function type for retrieving a genome from an organism.
using emp::World< ORG >::fun_get_neighbor_t = std::function<WorldPosition(WorldPosition)> |
Function type for identifying an organism's random neighbor.
using emp::World< ORG >::fun_kill_org_t = std::function<WorldPosition()> |
Function type for determining picking and killing an organism (returns newly empty position)
using emp::World< ORG >::fun_print_org_t = std::function<void(ORG&,std::ostream &)> |
Function type for printing an organism's info to an output stream.
using emp::World< ORG >::genome_t = typename emp::find_genome_t<ORG> |
Type of underlying genomes.
using emp::World< ORG >::iterator_t = World_iterator<this_t> |
Type for this world's iterators.
using emp::World< ORG >::org_t = ORG |
Type of organisms in this world.
using emp::World< ORG >::pop_t = emp::vector<Ptr<ORG>> |
Type for whole populations.
using emp::World< ORG >::this_t = World<ORG> |
Resolved type of this templated class.
using emp::World< ORG >::value_type = org_t |
Identical to org_t; vector compatibility.
|
inline |
The World constructor can take two arguments, both optional:
|
inline |
|
inline |
DataFile & emp::World< ORG >::AddDataFile | ( | emp::Ptr< DataFile > | file | ) |
Add an already-constructed datafile.
|
inline |
void emp::World< ORG >::AddOrgAt | ( | Ptr< ORG > | new_org, |
WorldPosition | pos, | ||
WorldPosition | p_pos = WorldPosition() |
||
) |
AddOrgAt is the core function to add organisms to the population (others must go through here) Note: This function ignores population structure, so requires you to manage your own structure.
|
inline |
Add a new phenotype measuring function.
|
inline |
|
inline |
[std::vector compatibility] Return iterator to first organism.
|
inline |
Calculate the fitness of all organisms, storing the results in the cache.
double emp::World< ORG >::CalcFitnessID | ( | size_t | id | ) |
Use the configured fitness function on the organism at the specified position.
double emp::World< ORG >::CalcFitnessOrg | ( | ORG & | org | ) |
Use the configured fitness function on the specified organism.
void emp::World< ORG >::Clear | ( | ) |
Remove all organisms from the world.
|
inline |
[std::vector compatibility] Remove all organisms.
|
inlineprotected |
Clear the cache value at the specified position.
|
inline |
Remove all currently cached fitness values (useful with changing environments, etc.)
WorldPosition emp::World< ORG >::DoBirth | ( | const genome_t & | mem, |
size_t | parent_pos, | ||
size_t | copy_count = 1 |
||
) |
Place one or more copies of an offspring into population; return position of last placed.
void emp::World< ORG >::DoBottleneck | ( | const size_t | new_size, |
bool | choose_random = true |
||
) |
Run population through a bottleneck to (potentially) shrink it.
|
inline |
|
inline |
|
inline |
Use mutation function on ALL organisms in the population.
|
inline |
Use mutation function on the organism at the specified position in the population.
|
inline |
Use mutation function on a single, specified organism.
|
inline |
[std::vector compatibility] Return iterator just past last organism.
emp::vector< size_t > emp::World< ORG >::FindCellIDs | ( | const std::function< bool(ORG *)> & | filter | ) |
Find ALL cell IDs that return true in the provided filter.
|
inline |
Get the value for an attribute that you know exists.
|
inlineprotected |
Get the current cached value for the organism at the specified position.
|
inline |
|
inline |
Return IDs of all empty cells in the population.
|
inline |
Lookup a file by name.
|
inline |
Get the fitness function currently in use.
|
inline |
Access a data node that tracks fitness information in the population. The fitness will not be collected until the first Update() after this function is initially called, signaling the need for this information.
|
inline |
Get the full population to analyze externally.
|
inline |
Retrieve the genome corresponding to a specified organism.
|
inline |
Retrive the genome corresponding to the organism at the specified position.
|
inline |
How many cells tall is the world? (assumes grids are active.)
|
inline |
Retrieve a reference to the organsim as the specified position in the NEXT population. Will trip assert if cell is not occupied.
|
inline |
How many organisms are currently in the world?
|
inline |
Retrieve a reference to the organsim as the specified position. Same as operator[]; will trip assert if cell is not occupied.
|
inline |
Retrieve a const reference to the organsim as the specified x,y coordinates. : Technically, we should set this up with any number of coordinates.
|
inline |
Retrive a pointer to the contents of a speciefied cell; will be nullptr if the cell is not occupied.
|
inline |
What phenotypic traits is the population tracking?
|
inline |
Return a reference to the random number generator currently being used by world.
|
inline |
Get the position a cell, at random.
|
inline |
Get the position a cell in a range, at random.
|
inline |
Use the specified function to get a neighbor (if not set, assume well mixed).
|
inline |
Get an organism from a random occupied cell.
size_t emp::World< ORG >::GetRandomOrgID | ( | ) |
Get the id of a random occupied cell.
|
inline |
Access signal controller used for this world directly.
|
inline |
How many organisms can fit in the world?
|
inline |
Get a systematics manager (which is tracking lineages in the population.)
id | - which systematics manager to return? Systematics managers are stored in the order they are added to the world. |
|
inline |
Get a systematics manager (which is tracking lineages in the population.)
id | - which systematics manager to return? Systematics managers are stored in the order they are added to the world. |
|
inline |
What update number is the world currently on? (assumes Update() is being used)
|
inline |
Return IDs of all occupied cells in the population.
|
inline |
How many cells wide is the world? (assumes grids are active.)
|
inline |
Worlds can have arbitrary attributes that can be set and changed dynamically. This function determines if an attribute exists, regardless of its value.
void emp::World< ORG >::Inject | ( | const genome_t & | mem, |
size_t | copy_count = 1 |
||
) |
Inject an organism using the default injection scheme.
void emp::World< ORG >::InjectAt | ( | const genome_t & | mem, |
const WorldPosition | pos | ||
) |
Inject an organism at a specific position.
void emp::World< ORG >::InjectRandomOrg | ( | ARGS &&... | args | ) |
Inject a random organism (constructor must facilitate!)
|
inline |
Are we currently caching fitness values?
|
inline |
Does the specified cell ID have an organism in it?
|
inline |
Is there some sort of structure to the population based on phenotype? (i.e., are phenotypically-similar organisms forced to be closer together?)
|
inline |
Is there some sort of spatial structure to the population? (i.e., are some organisms closer together than others.)
|
inline |
Are generations being evaluated synchronously? (i.e., Update() places all births into the population after removing all current organisms.)
|
inline |
Denote that the World will have organisms structured based on phenotype. (Note: this function does not change functionality, just indicates what's happening!)
|
inline |
Denote that the World will have a spatial structure to the organisms. (Note: this function does not change functionality, just indicates what's happening!)
|
inline |
Denote that this World will be treated as having synchronous generations. (Note: this function does not change functionality, just indicates what's happening!)
void emp::World< ORG >::NewRandom | ( | int | seed = -1 | ) |
Create a new random number generator (that World will manage)
|
inline |
Provide a function for World to call before an organism is added to the active population, but after position is found. With synchonous generations, this occurs during Update(). Trigger: Organism is about to be added to population; position is known (either born or injected) Args: (1) Reference to organism about to be placed; (2) Position organism will be placed. Return: Key value needed to make future modifications.
|
inline |
|
inline |
|
inline |
|
inline |
Provide a function for World to call each time an organism is about to die. Trigger: Organism is about to be killed Argument: Position of organism about to die Return: Key value needed to make future modifications.
|
inline |
Provide a function for World to call immediately after any organism has been added to the active population. With synchonous generations, this occurs during Update(). Trigger: Organism has been added to population (either born or injected) Argument: Position of organism placed in the population. Return: Key value needed to make future modifications.
|
inline |
Provide a function for World to call each time two organisms swap positions in world. Trigger: Organisms have just swapped positions. Arguments: Positions of the two organisms. Return: Key value needed to make future modifications.
|
inline |
|
inline |
Provide a function for World to call at the start of its destructor (for additional cleanup). Trigger: Destructor has begun to execture Argument: None Return: Key value needed to make future modifications.
|
inline |
Index into a world to obtain a const reference to an organism. Any manipulations to organisms should go through other functions to be tracked appropriately. Will trip assert if cell is not occupied.
void emp::World< ORG >::Print | ( | std::ostream & | os = std::cout , |
const std::string & | empty = "-" , |
||
const std::string & | spacer = " " |
||
) |
Print all organisms in the population using previously provided print function.
void emp::World< ORG >::PrintGrid | ( | std::ostream & | os = std::cout , |
const std::string & | empty = "-" , |
||
const std::string & | spacer = " " |
||
) |
Print the organisms layed out in a grid structure (assumes a grid population.)
void emp::World< ORG >::PrintOrgCounts | ( | std::ostream & | os = std::cout | ) |
Print unique organisms and the number of copies of each that exist.
|
inline |
Run the Process member function on all organisms in the population; forward any args passed into this function.
|
inline |
Run the Process member function on a single, specified organism in the population; forward any args passed into this function.
void emp::World< ORG >::RemoveOrgAt | ( | WorldPosition | pos | ) |
RemoveOrgAt is the core function to remove organisms from the population. Note: This function ignores population structure, so requires you to manage your own structure.
|
inline |
|
inline |
|
inline |
Clear all of the orgs and reset stats.
|
inline |
Reset the hardware for all organisms.
|
inline |
Change the size of the world. If the new size is smaller than the old, remove any organisms outside the new range. If larger, new positions are empty.
|
inline |
Change the size of the world based on width and height.
|
inline |
Change the size of the world based on a vector of dimensions.
|
inline |
[std::vector compatibility] Update world size.
void emp::World< ORG >::SerialTransfer | ( | const double | keep_frac | ) |
Perform a Serial Transfer where a fixed percentage of current organisms are maintained.
|
inline |
Setup the function to place a newly born organism into the population. It should take a pointer to the new organism and the position of the parent, returning a WorldPosition indicating where it was placed.
|
inline |
Setup the function to inject an organism into the population. It should take a pointer to the organism to be injected and return a WorldPosition indicating where it was placed.
|
inline |
Set the value of a new attribute on this world. If the attribute already exists, it will be updated. If it doesn't exist, it will be added.
|
inline |
Setup the population to automatically test for and trigger mutations. By default, this occurs before deciding where an offspring should be placed. Note that this pre-placement timing may be needed if fitness or other phenotypic traits are required to determine placement.
|
inline |
Setup the population to automatically test for and trigger mutations based on a provided test function that takes the position where the offspring will be placed and indicates (true/false) whether mutations should be processed. This timing allows position to influence mutations.
|
inline |
Turn on (or off) fitness caching for individual organisms.
|
inline |
Setup the function to be used when fitness needs to be calculated. The provided function should take a reference to an organism and return a fitness value of type double.
|
inline |
Setup the function to extract or convert an organism to a genome. It should take an organism reference and return a const genome reference.
|
inline |
Setup the function to take an organism position id and return a random neighbor id from the population.
|
inline |
Setup the function to kill an organism. It should return a WorldPosition indicating the newly empty cell, which is not necessarily where the kill occurred.
|
inline |
Setup the function to be used to mutate an organism. It should take a reference to an organism and return the number of mutations that occurred.
void emp::World< ORG >::SetPopStruct_Grid | ( | size_t | width, |
size_t | height, | ||
bool | synchronous_gen = false |
||
) |
Set the population to be a grid of cells using the specified dimensions. The third argument determines if the generations should be synchronous (true) or not (false, default)
void emp::World< ORG >::SetPopStruct_Grow | ( | bool | synchronous_gen = false | ) |
Set the population to always append new organisms on the end. Argument determines if the generations should be synchronous (true) or not (false, default)
void emp::World< ORG >::SetPopStruct_Mixed | ( | bool | synchronous_gen = false | ) |
Set the population to be well-mixed (with all organisms counting as neighbors.) Argument determines if the generations should be synchronous (true) or not (false, default)
|
inline |
Setup the function to be used to print an organism. It should take a reference to an organism and an std::ostream, with a void return. The organism should get printed to the provided ostream.
void emp::World< ORG >::SetRandom | ( | Random & | r | ) |
Setup a new random number generator created elsewhere.
void emp::World< ORG >::SetSharedFitFun | ( | const fun_calc_fitness_t & | fit_fun, |
const fun_calc_dist_t & | dist_fun, | ||
double | sharing_threshold, | ||
double | alpha | ||
) |
Same as setting a fitness function, but uses Goldberg and Richardson's fitness sharing function (1987) to make similar organisms detract from each other's fitness and prevent the population from clustering around a single peak. In addition to the base fitness function, a shared fitness function also requires:
|
inline |
Tell systematics managers that this world has synchronous generations.
DataFile & emp::World< ORG >::SetupFile | ( | const std::string & | filename | ) |
Setup an arbitrary file; no default filename available.
DataFile & emp::World< ORG >::SetupFitnessFile | ( | const std::string & | filename = "fitness.csv" , |
const bool & | print_header = true |
||
) |
Setup a file to be printed that collects fitness information over time.
DataFile & emp::World< ORG >::SetupPopulationFile | ( | const std::string & | filename = "population.csv" , |
const bool & | print_header = true |
||
) |
Setup a file to be printed that collects population information over time.
DataFile & emp::World< ORG >::SetupSystematicsFile | ( | std::string | label, |
const std::string & | filename = "systematics.csv" , |
||
const bool & | print_header = true |
||
) |
Setup a file (by label) to be printed that collects systematics information over time.
DataFile & emp::World< ORG >::SetupSystematicsFile | ( | size_t | id = 0 , |
const std::string & | filename = "systematics.csv" , |
||
const bool & | print_header = true |
||
) |
Setup a file (by id) to be printed that collects systematics information over time.
|
inline |
[std::vector compatibility] How big is the world?
|
inline |
Swap the positions of two organisms.
void emp::World< ORG >::Update | ( | ) |
Update the world:
|
friend |
|
protected |
Attributes are a dynamic way to track extra characteristics about a world.
|
protected |
...before placing any organism into target cell.
|
protected |
...before organism gives birth w/parent position.
|
protected |
Should we be caching fitness values?
|
protected |
|
protected |
Potential data nodes – these should be activated only if in use.
|
protected |
Output files.
|
protected |
vector size == 0 when not caching; uncached values == 0.
|
protected |
...evaluate fitness for provided organism.
|
protected |
...mutate an organism.
|
protected |
...find where to add a new offspring organism.
|
protected |
...find where to inject a new, external organism.
|
protected |
...determine the genome object of an organism.
|
protected |
...choose a random neighbor "near" specified id.
|
protected |
...kill an organism.
|
protected |
...print an organism.
|
protected |
...when outside organism is ready to inject.
|
protected |
Do we have a phenotypically structured population?
|
protected |
Do we have a spatially structured population?
|
protected |
Does this world have synchronous generations?
|
protected |
Name of this world (for use in configuration.)
|
protected |
How many organisms are actually in the population.
|
protected |
...when offspring organism is built.
|
protected |
...immediately before any organism dies.
|
protected |
...after any organism is placed into world.
|
protected |
...after org positions are swapped
|
protected |
...at the beginning of Update()
|
protected |
What phenotypes are we tracking?
|
protected |
A shortcut to pops[0].
|
protected |
Sizes of population dimensions (eg, 2 vals for grid)
|
protected |
The set of active [0] and "next" [1] organisms in population.
|
protected |
Did we create our own random number generator?
|
protected |
Random object to use.
|
protected |
Phylogeny and line-of-descent data collection.
|
protected |
|
protected |
How many times has Update() been called?
|
protected |
...in the World destructor.