Class pheromone_density

Inheritance Relationships

Base Types

  • public rmath::expression< double >

  • public rer::client< pheromone_density >

Class Documentation

class pheromone_density : public rmath::expression<double>, public rer::client<pheromone_density>

Calculates the pheromone density associated with something, which decays over time on its, but can be reinforced by additional entities other than the current one reporting the same thing and reinforcing the density/information relevance.

Depends on:

  • The pheromone decay parameter.

  • The previous value of the pheromone density.

Public Functions

inline explicit pheromone_density(double rho)
inline pheromone_density(void)
inline pheromone_density operator+(const pheromone_density &other) const

Add two pheromone density objects. Only adds the current values, ignoring the current deltas for each object.

inline pheromone_density &operator+=(const pheromone_density &other)

Add one pheromone density to another. Only adds the the current values, ignoring the current deltas for each object.

inline pheromone_density operator-(const pheromone_density &other) const

Subtract two pheromone density objects. Only subtracts the current values, ignoring the current deltas for each object.

inline pheromone_density &operator-=(const pheromone_density &other)

Subtract one pheromone density object from another. Only subtracts the the current values, ignoring the current deltas for each object.

inline pheromone_density operator/(double div) const

Divides a density by a constant factor, ignoring current deltas for the object.

inline void pheromone_add(double val)

Add a deposit of pheromone. Does not update the current value&#8212;that must be done separately, so that multiple deposits are batched together for a single value update.

Parameters:

val – The amount of the pheromone deposit. Should pretty much always be 1.0, unless there is a good reason not to do so.

inline void pheromone_set(double val)

Set the pheromone density to the specified value. This is useful when repeated pheromone deposits are not desired, but you want to have a way to reset the density of something to a maximum value (e.g. seeing the same block on subsequent timesteps).

Also sets the batched/pending updates to 0.

Parameters:

val – The value to set.

inline void reset(void)
inline void rho(double rho)
inline double update(void)

Calculates the new pheromone density based on:

  • The current density

  • How many unit deposits have been made since the last calculation

  • The decay rate.

Returns:

The new density.

Public Static Attributes

static constexpr const double kUNIT_QUANTITY = 1.0

Convenience constant for use it adding pheromones to a density.