AntHocNet 2.0.0
Paper-faithful ant-colony ad hoc routing: the shared core and its adapters
Loading...
Searching...
No Matches
anthocnet::core::PheromoneTable Class Reference

#include <anthocnet/core/pheromone_table.h>

Public Types

using Key = std::pair< NodeAddress, NodeAddress >
 
using PheromoneMap = std::map< Key, double >
 
using NeighborSet = std::set< NodeAddress >
 
using DestinationSet = std::set< NodeAddress >
 

Public Member Functions

void addPheromoneRegular (NodeAddress dest, NodeAddress neighbor, double value)
 
void addPheromoneVirtual (NodeAddress dest, NodeAddress neighbor, double value)
 
void removePheromoneRegular (NodeAddress dest, NodeAddress neighbor)
 
void removePheromoneVirtual (NodeAddress dest, NodeAddress neighbor)
 
double getPheromoneRegular (NodeAddress dest, NodeAddress neighbor) const
 
double getPheromoneVirtual (NodeAddress dest, NodeAddress neighbor) const
 
double bestRegular (NodeAddress dest) const
 Best (largest) regular pheromone any neighbour holds for dest, or 0 if none.
 
double bestVirtual (NodeAddress dest) const
 Best (largest) virtual pheromone any neighbour holds for dest, or 0 if none.
 
void setPheromoneRegular (NodeAddress dest, NodeAddress neighbor, double value)
 
void setPheromoneVirtual (NodeAddress dest, NodeAddress neighbor, double value)
 
bool isEmptyRegular () const
 
bool isEmptyVirtual () const
 
std::size_t numEntriesRegular () const
 Size gauge (issue #133): current (neighbor, dest) entry counts.
 
std::size_t numEntriesVirtual () const
 
std::size_t numEntries () const
 
void addNeighbor (NodeAddress neighbor)
 
void removeNeighbor (NodeAddress neighbor)
 
const NeighborSet & neighbors () const
 
std::size_t numNeighbors () const
 
bool hasNeighbor () const
 
const DestinationSet & regularDestinations () const
 
const DestinationSet & virtualDestinations () const
 
NodeAddress nextNeighborNode (NodeAddress dest, bool isProactiveAnt, double beta, IRng &rng, NodeAddress exclude=kInvalidAddress) const
 Stochastic next-hop choice.
 
std::vector< std::pair< NodeAddress, double > > nextHopDistribution (NodeAddress dest, bool isProactiveAnt, double beta, NodeAddress exclude=kInvalidAddress) const
 The probability distribution nextNeighborNode() samples from, for the same arguments: one (neighbour, probability) pair per candidate, in neighbour order, summing to 1 (empty when there is no route).
 
NodeAddress lookup (NodeAddress dest, double beta, IRng &rng, NodeAddress exclude=kInvalidAddress) const
 Reactive lookup == nextNeighborNode(dest, false, beta).
 
NodeAddress randomDestination (IRng &rng) const
 Uniformly pick a known regular destination, or kInvalidAddress if none.
 

Detailed Description

Definition at line 29 of file pheromone_table.h.

Member Typedef Documentation

◆ Key

Definition at line 31 of file pheromone_table.h.

◆ PheromoneMap

Definition at line 32 of file pheromone_table.h.

◆ NeighborSet

Definition at line 33 of file pheromone_table.h.

◆ DestinationSet

Member Function Documentation

◆ addPheromoneRegular()

void anthocnet::core::PheromoneTable::addPheromoneRegular ( NodeAddress  dest,
NodeAddress  neighbor,
double  value 
)

◆ addPheromoneVirtual()

void anthocnet::core::PheromoneTable::addPheromoneVirtual ( NodeAddress  dest,
NodeAddress  neighbor,
double  value 
)

◆ removePheromoneRegular()

void anthocnet::core::PheromoneTable::removePheromoneRegular ( NodeAddress  dest,
NodeAddress  neighbor 
)

◆ removePheromoneVirtual()

void anthocnet::core::PheromoneTable::removePheromoneVirtual ( NodeAddress  dest,
NodeAddress  neighbor 
)

◆ getPheromoneRegular()

double anthocnet::core::PheromoneTable::getPheromoneRegular ( NodeAddress  dest,
NodeAddress  neighbor 
) const

◆ getPheromoneVirtual()

double anthocnet::core::PheromoneTable::getPheromoneVirtual ( NodeAddress  dest,
NodeAddress  neighbor 
) const

◆ bestRegular()

double anthocnet::core::PheromoneTable::bestRegular ( NodeAddress  dest) const

Best (largest) regular pheromone any neighbour holds for dest, or 0 if none.

Used to advertise this node's path goodness in hello adverts.

◆ bestVirtual()

double anthocnet::core::PheromoneTable::bestVirtual ( NodeAddress  dest) const

Best (largest) virtual pheromone any neighbour holds for dest, or 0 if none.

Same units as bestRegular (the diffusion bootstrap re-inverts into regular units), so the two are directly comparable — that comparison is the proactive emission gate (#180).

◆ setPheromoneRegular()

void anthocnet::core::PheromoneTable::setPheromoneRegular ( NodeAddress  dest,
NodeAddress  neighbor,
double  value 
)

◆ setPheromoneVirtual()

void anthocnet::core::PheromoneTable::setPheromoneVirtual ( NodeAddress  dest,
NodeAddress  neighbor,
double  value 
)

◆ isEmptyRegular()

bool anthocnet::core::PheromoneTable::isEmptyRegular ( ) const
inline

Definition at line 55 of file pheromone_table.h.

◆ isEmptyVirtual()

bool anthocnet::core::PheromoneTable::isEmptyVirtual ( ) const
inline

Definition at line 56 of file pheromone_table.h.

◆ numEntriesRegular()

std::size_t anthocnet::core::PheromoneTable::numEntriesRegular ( ) const
inline

Size gauge (issue #133): current (neighbor, dest) entry counts.

The table grows with destinations x neighbours (regular + virtual) and only evaporation / link-failure removal shrink it, so adapters export these to observe growth over long runs. Read-only; no routing behaviour.

Definition at line 62 of file pheromone_table.h.

◆ numEntriesVirtual()

std::size_t anthocnet::core::PheromoneTable::numEntriesVirtual ( ) const
inline

Definition at line 63 of file pheromone_table.h.

◆ numEntries()

std::size_t anthocnet::core::PheromoneTable::numEntries ( ) const
inline

Definition at line 64 of file pheromone_table.h.

◆ addNeighbor()

void anthocnet::core::PheromoneTable::addNeighbor ( NodeAddress  neighbor)

◆ removeNeighbor()

void anthocnet::core::PheromoneTable::removeNeighbor ( NodeAddress  neighbor)

◆ neighbors()

const NeighborSet & anthocnet::core::PheromoneTable::neighbors ( ) const
inline

Definition at line 71 of file pheromone_table.h.

◆ numNeighbors()

std::size_t anthocnet::core::PheromoneTable::numNeighbors ( ) const
inline

Definition at line 72 of file pheromone_table.h.

◆ hasNeighbor()

bool anthocnet::core::PheromoneTable::hasNeighbor ( ) const
inline

Definition at line 73 of file pheromone_table.h.

◆ regularDestinations()

const DestinationSet & anthocnet::core::PheromoneTable::regularDestinations ( ) const
inline

Definition at line 75 of file pheromone_table.h.

◆ virtualDestinations()

const DestinationSet & anthocnet::core::PheromoneTable::virtualDestinations ( ) const
inline

Definition at line 76 of file pheromone_table.h.

◆ nextNeighborNode()

NodeAddress anthocnet::core::PheromoneTable::nextNeighborNode ( NodeAddress  dest,
bool  isProactiveAnt,
double  beta,
IRng &  rng,
NodeAddress  exclude = kInvalidAddress 
) const

Stochastic next-hop choice.

With isProactiveAnt the virtual table is blended in (max of regular/virtual); otherwise only regular is used. beta is the Eq.1 exponent (caller passes betaAnts or betaData). exclude (e.g. the previous hop for data) is skipped unless it is the only option, so a packet isn't sent back the way it came (A1). Returns kInvalidAddress when no route exists.

◆ nextHopDistribution()

std::vector< std::pair< NodeAddress, double > > anthocnet::core::PheromoneTable::nextHopDistribution ( NodeAddress  dest,
bool  isProactiveAnt,
double  beta,
NodeAddress  exclude = kInvalidAddress 
) const

The probability distribution nextNeighborNode() samples from, for the same arguments: one (neighbour, probability) pair per candidate, in neighbour order, summing to 1 (empty when there is no route).

Applies the same A1 fallback (the excluded hop is reconsidered when it is the only option). Read-only: for inspection and teaching (#546), never a second routing path – it consumes no randomness.

◆ lookup()

NodeAddress anthocnet::core::PheromoneTable::lookup ( NodeAddress  dest,
double  beta,
IRng &  rng,
NodeAddress  exclude = kInvalidAddress 
) const

Reactive lookup == nextNeighborNode(dest, false, beta).

◆ randomDestination()

NodeAddress anthocnet::core::PheromoneTable::randomDestination ( IRng &  rng) const

Uniformly pick a known regular destination, or kInvalidAddress if none.


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