Class population_dynamics

Nested Relationships

Nested Types

Inheritance Relationships

Base Types

Derived Type

Class Documentation

class population_dynamics : public rer::client<population_dynamics>, public cosm::tv::metrics::population_dynamics_metrics

Orchestrates all applications of temporal variance all robots in the swarm as it relates to existence within the swarm. This includes:

  • Creating, initializing, and adding new robots to the swarm over time according to a pure birth process.

  • Permanently removing robots from the swarm over time according to a pure death process.

  • Temporarily removing robots from the swarm and then restoring them later, simulating a malfunction-repair cycle.

This class does not apply swarm population dynamics directly, as that possibly requires platform-specific knowledge. Instead it houses the data for all possible types of dynamics, and specifies the interface for application, which must be implemented by derived classes.

It also does not track the swarm size directly, as that may also require platform-specific knowledge.

Subclassed by cosm::argos::tv::pd_adaptor< TController >

Public Functions

population_dynamics(const config::population_dynamics_config *config, size_t total_pop, size_t active_pop, rmath::rng *rng)
population_dynamics(const population_dynamics&) = delete
~population_dynamics(void) override = default
virtual queue_status birth_queue_status(void) const override
virtual queue_status death_queue_status(void) const override
const population_dynamics &operator=(const population_dynamics&) = delete
virtual queue_status repair_queue_status(void) const override
inline void reset_metrics(void) final override
inline virtual size_t swarm_active_population(void) const override

Return the total number of robots in the arena that are active (i.e. in the arena and NOT being repaired).

inline virtual size_t swarm_max_population(void) const override

Return the maximum size of the swarm, which is assumed to be constant.

inline virtual size_t swarm_total_population(void) const override

Return the total number of robots in the arena, regardless of whether they are active or not (i.e. including ones being repaired).

void update(const rtypes::timestep &t)

Update the state of all processes. Should be called once per timestep.

Protected Functions

inline bool already_killed(const rtypes::type_uuid &id) const
inline bool currently_repairing(const rtypes::type_uuid &id) const
virtual op_result robot_add(int max_pop, const rtypes::type_uuid &id) = 0

Add a new robot to the swarm with the specified ID.

Parameters:
  • max_pop – Maximum swarm population (-1 indicates no limit)

  • id – The ID of the robot to add.

Returns:

The ID of the robot that was added (rtypes::constants::kNoUUID if the robot could not be added), along with the current swarm size.

virtual op_result robot_kill(void) = 0

Kill a random robot within the swarm.

Returns:

The ID of the robot that was added (rtypes::constants::kNoUUID if the robot could not be killed), along with the current swarm size.

virtual op_result robot_malfunction(void) = 0

Temporarily remove a robot from simulation/the swarm.

Returns:

The ID of the robot that was temporarily removed (rtypes::constants::kNoUUID if no robot could be removed), along with the current swarm size.

virtual op_result robot_repair(const rtypes::type_uuid &id) = 0

Restore a the specified robot which had been temporarily removed from the swarm/simulation.

Returns:

The ID of the robot that was restored (rtypes::constants::kNoUUID if no robot could be restored), along with the current swarm size.

struct op_result

Public Members

size_t active_pop
rtypes::type_uuid id
size_t total_pop