Empirical
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
emp::World_MinDistInfo< ORG > Struct Template Reference

Build a class to track distances between organisms. More...

#include <World_structure.h>

Public Member Functions

 World_MinDistInfo (World< ORG > &in_world, const TraitSet< ORG > &in_traits)
 
double CalcDist (size_t id1, size_t id2)
 
void Refresh_AgainstBin (size_t refresh_id, size_t target_bin)
 
void Refresh (size_t refresh_id, size_t start_id=0)
 
size_t CalcBin (size_t id)
 Calculate which bin an organism should be in. More...
 
void ResetBins ()
 Reset all of the bins in the multidimensional grid for nearest-neighbor analysis. More...
 
void Setup ()
 
void Clear ()
 
size_t FindKill ()
 
size_t GetBirthPos (size_t world_size)
 Return an empty world position. If none are available, return the position of an org to be killed. More...
 
void Update (size_t pos)
 Assume a position has changed; refresh it AND everything that had it as a closest connection. More...
 
bool OK ()
 A debug function to make sure the internal state is all valid. More...
 

Public Attributes

emp::vector< size_t > nearest_id
 For each individual, whom are they closest to? More...
 
emp::vector< double > distance
 And what is their distance? More...
 
World< ORG > & world
 World object being tracked. More...
 
TraitSet< ORG > traits
 Traits we are tryng to spread. More...
 
emp::vector< double > min_vals
 Smallest value found for each trait. More...
 
emp::vector< double > max_vals
 Largest value found for each trait. More...
 
emp::vector< double > bin_width
 Largest value found for each trait. More...
 
bool is_setup
 Have we initialized the internal data stucture? More...
 
size_t num_trait_bins
 How many bins should we use for each trait? More...
 
size_t num_total_bins
 How many bins are there overall? More...
 
emp::vector< std::set< size_t > > bin_ids
 Which org ids fall into each bin? More...
 
emp::vector< size_t > org_bins
 Which bin is each org currently in? More...
 

Static Public Attributes

static constexpr size_t ID_NONE = (size_t) -1
 ID for organism does not exist. More...
 

Detailed Description

template<typename ORG>
struct emp::World_MinDistInfo< ORG >

Build a class to track distances between organisms.

DiverseElites is similar to MAP-Elites, but rather than merely keep the elites on a pre-defined grid, it merely tries to maintain maximal distance between elites in trait space. The main advantages to this technique are (1) It's easy to build up an inital population that grows in diversity over time, and (2) You don't need to predefine box sizes or even limits to trait values. Set the population to use a DiverseElites structure. This means that organism placement has two key components: 1: Organism position is in continuous space based on phenotypic traits. 2: When the population is full, nearby organisms must battle to keep their position.

Note: Since organisms compete with their predecessors for space in the populations, synchronous generations do not make sense.

Constructor & Destructor Documentation

template<typename ORG >
emp::World_MinDistInfo< ORG >::World_MinDistInfo ( World< ORG > &  in_world,
const TraitSet< ORG > &  in_traits 
)
inline

Member Function Documentation

template<typename ORG >
size_t emp::World_MinDistInfo< ORG >::CalcBin ( size_t  id)
inline

Calculate which bin an organism should be in.

template<typename ORG >
double emp::World_MinDistInfo< ORG >::CalcDist ( size_t  id1,
size_t  id2 
)
inline
template<typename ORG >
void emp::World_MinDistInfo< ORG >::Clear ( )
inline
template<typename ORG >
size_t emp::World_MinDistInfo< ORG >::FindKill ( )
inline

Find the best organism to kill in the popualtion. In this case, find the two closest organisms and kill the one with the lower fitness.

template<typename ORG >
size_t emp::World_MinDistInfo< ORG >::GetBirthPos ( size_t  world_size)
inline

Return an empty world position. If none are available, return the position of an org to be killed.

template<typename ORG >
bool emp::World_MinDistInfo< ORG >::OK ( )
inline

A debug function to make sure the internal state is all valid.

template<typename ORG >
void emp::World_MinDistInfo< ORG >::Refresh ( size_t  refresh_id,
size_t  start_id = 0 
)
inline
template<typename ORG >
void emp::World_MinDistInfo< ORG >::Refresh_AgainstBin ( size_t  refresh_id,
size_t  target_bin 
)
inline
template<typename ORG >
void emp::World_MinDistInfo< ORG >::ResetBins ( )
inline

Reset all of the bins in the multidimensional grid for nearest-neighbor analysis.

template<typename ORG >
void emp::World_MinDistInfo< ORG >::Setup ( )
inline
template<typename ORG >
void emp::World_MinDistInfo< ORG >::Update ( size_t  pos)
inline

Assume a position has changed; refresh it AND everything that had it as a closest connection.

Determine if this new point extends the range of any phenotypes.

Remove org if from the bin we currently have it in.

Determine if we need to re-place all orgs in the structure

Otherwise just update closest connections to this org.

Member Data Documentation

template<typename ORG >
emp::vector<std::set<size_t> > emp::World_MinDistInfo< ORG >::bin_ids

Which org ids fall into each bin?

template<typename ORG >
emp::vector<double> emp::World_MinDistInfo< ORG >::bin_width

Largest value found for each trait.

template<typename ORG >
emp::vector<double> emp::World_MinDistInfo< ORG >::distance

And what is their distance?

template<typename ORG >
constexpr size_t emp::World_MinDistInfo< ORG >::ID_NONE = (size_t) -1
static

ID for organism does not exist.

template<typename ORG >
bool emp::World_MinDistInfo< ORG >::is_setup

Have we initialized the internal data stucture?

template<typename ORG >
emp::vector<double> emp::World_MinDistInfo< ORG >::max_vals

Largest value found for each trait.

template<typename ORG >
emp::vector<double> emp::World_MinDistInfo< ORG >::min_vals

Smallest value found for each trait.

template<typename ORG >
emp::vector<size_t> emp::World_MinDistInfo< ORG >::nearest_id

For each individual, whom are they closest to?

template<typename ORG >
size_t emp::World_MinDistInfo< ORG >::num_total_bins

How many bins are there overall?

template<typename ORG >
size_t emp::World_MinDistInfo< ORG >::num_trait_bins

How many bins should we use for each trait?

template<typename ORG >
emp::vector<size_t> emp::World_MinDistInfo< ORG >::org_bins

Which bin is each org currently in?

template<typename ORG >
TraitSet<ORG> emp::World_MinDistInfo< ORG >::traits

Traits we are tryng to spread.

template<typename ORG >
World<ORG>& emp::World_MinDistInfo< ORG >::world

World object being tracked.


The documentation for this struct was generated from the following file: