World_structure.hpp
Functions for popular world structure methods.
Functions
-
template<typename ORG>
void SetPools(World<ORG> &world, size_t num_pools, size_t pool_size, bool synchronous_gen = false) Set the population to be a set of pools that are individually well mixed, but with limited migration. Arguments are the number of pools, the size of each pool, and whether the generations should be synchronous (true) or not (false, default).
-
template<typename ORG>
void SetMapElites(World<ORG> &world, TraitSet<ORG> traits, const vector<size_t> &trait_counts) Set the population to use a MapElites structure. This means that organism placement has two key components: 1: Organism position is based on their phenotypic traits. 2: Organisms must have a higher fitness than the current resident of a position to steal it.
Note: Since organisms compete with their predecessors for space in the populations, synchronous generations do not make sense.
This for version will setup a MAP-Elites world; traits to use an how many bins for each (trait counts) must be provided.
-
template<typename ORG>
void SetMapElites(World<ORG> &world, TraitSet<ORG> traits) Setup a MAP-Elites world, given the provided set of traits. Requires world to already have a size; that size is respected when deciding trait bins.
-
template<typename ORG>
void SetMapElites(World<ORG> &world, const vector<size_t> &trait_counts) Setup a MAP-Elites world, given the provided trait counts (number of bins). Requires world to already have a phenotypes that those counts are applied to.
-
template<typename ORG>
void SetMapElites(World<ORG> &world) Setup a MAP-Elites world, given the provided worlds already has size AND set of phenotypes. Requires world to already have a size; that size is respected when deciding trait bins.
-
class WorldPosition
- #include <World_structure.hpp>
A class to track positions in World. For the moment, the only informaiton beyond index is active (vs. next) population when using synchronous generations.
Public Functions
-
inline WorldPosition()
-
inline WorldPosition(size_t _id, size_t _pop_id = 0)
-
WorldPosition(const WorldPosition&) = default
-
WorldPosition &operator=(const WorldPosition&) = default
-
inline uint32_t GetIndex() const
-
inline uint32_t GetPopID() const
-
inline bool IsActive() const
-
inline bool IsValid() const
-
inline WorldPosition &SetActive(bool = true)
-
inline WorldPosition &SetPopID(size_t _id)
-
inline WorldPosition &SetIndex(size_t _id)
-
inline WorldPosition &MarkInvalid()
Public Static Attributes
-
static constexpr size_t invalid_id = (uint32_t)-1
-
inline WorldPosition()
-
template<typename T>
class WorldVector : public array<vector<T>, 2> - #include <World_structure.hpp>
A vector that can be indexed with a WorldPosition.
Public Functions
-
inline bool IsValid(WorldPosition pos) const
Test if a position is currently valid.
-
inline void MakeValid(WorldPosition pos)
Make sure position is valid; if not expand relevant vector.
-
inline T &operator()(WorldPosition pos)
-
inline const T &operator()(WorldPosition pos) const
-
inline bool IsValid(WorldPosition pos) const
-
template<typename ORG>
struct World_MinDistInfo - #include <World_structure.hpp>
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.
Public Functions
-
inline double CalcDist(size_t id1, size_t id2)
-
inline void Refresh_AgainstBin(size_t refresh_id, size_t target_bin)
-
inline void Refresh(size_t refresh_id, size_t start_id = 0)
-
inline size_t CalcBin(size_t id)
Calculate which bin an organism should be in.
-
inline void ResetBins()
Reset all of the bins in the multidimensional grid for nearest-neighbor analysis.
-
inline void Setup()
-
inline void Clear()
-
inline size_t FindKill()
Find the best organism to kill in the population. In this case, find the two closest organisms and kill the one with the lower fitness.
-
inline 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.
-
inline void Update(size_t pos)
Assume a position has changed; refresh it AND everything that had it as a closest connection.
-
inline bool OK()
A debug function to make sure the internal state is all valid.
Public Members
-
bool is_setup
Have we initialized the internal data stucture?
-
size_t num_trait_bins
How many bins should we use for each trait?
-
size_t num_total_bins
How many bins are there overall?
Public Static Attributes
-
static constexpr size_t ID_NONE = (size_t)-1
ID for organism does not exist.
-
inline double CalcDist(size_t id1, size_t id2)