|
AntHocNet 2.0.0
Paper-faithful ant-colony ad hoc routing: the shared core and its adapters
|
#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. | |
Definition at line 29 of file pheromone_table.h.
| using anthocnet::core::PheromoneTable::Key = std::pair<NodeAddress, NodeAddress> |
Definition at line 31 of file pheromone_table.h.
| using anthocnet::core::PheromoneTable::PheromoneMap = std::map<Key, double> |
Definition at line 32 of file pheromone_table.h.
| using anthocnet::core::PheromoneTable::NeighborSet = std::set<NodeAddress> |
Definition at line 33 of file pheromone_table.h.
| using anthocnet::core::PheromoneTable::DestinationSet = std::set<NodeAddress> |
Definition at line 34 of file pheromone_table.h.
| void anthocnet::core::PheromoneTable::addPheromoneRegular | ( | NodeAddress | dest, |
| NodeAddress | neighbor, | ||
| double | value | ||
| ) |
| void anthocnet::core::PheromoneTable::addPheromoneVirtual | ( | NodeAddress | dest, |
| NodeAddress | neighbor, | ||
| double | value | ||
| ) |
| void anthocnet::core::PheromoneTable::removePheromoneRegular | ( | NodeAddress | dest, |
| NodeAddress | neighbor | ||
| ) |
| void anthocnet::core::PheromoneTable::removePheromoneVirtual | ( | NodeAddress | dest, |
| NodeAddress | neighbor | ||
| ) |
| double anthocnet::core::PheromoneTable::getPheromoneRegular | ( | NodeAddress | dest, |
| NodeAddress | neighbor | ||
| ) | const |
| double anthocnet::core::PheromoneTable::getPheromoneVirtual | ( | NodeAddress | dest, |
| NodeAddress | neighbor | ||
| ) | const |
| 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.
| 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).
| void anthocnet::core::PheromoneTable::setPheromoneRegular | ( | NodeAddress | dest, |
| NodeAddress | neighbor, | ||
| double | value | ||
| ) |
| void anthocnet::core::PheromoneTable::setPheromoneVirtual | ( | NodeAddress | dest, |
| NodeAddress | neighbor, | ||
| double | value | ||
| ) |
|
inline |
Definition at line 55 of file pheromone_table.h.
|
inline |
Definition at line 56 of file pheromone_table.h.
|
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.
|
inline |
Definition at line 63 of file pheromone_table.h.
|
inline |
Definition at line 64 of file pheromone_table.h.
| void anthocnet::core::PheromoneTable::addNeighbor | ( | NodeAddress | neighbor | ) |
| void anthocnet::core::PheromoneTable::removeNeighbor | ( | NodeAddress | neighbor | ) |
|
inline |
Definition at line 71 of file pheromone_table.h.
|
inline |
Definition at line 72 of file pheromone_table.h.
|
inline |
Definition at line 73 of file pheromone_table.h.
|
inline |
Definition at line 75 of file pheromone_table.h.
|
inline |
Definition at line 76 of file pheromone_table.h.
| 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.
| 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.
| NodeAddress anthocnet::core::PheromoneTable::lookup | ( | NodeAddress | dest, |
| double | beta, | ||
| IRng & | rng, | ||
| NodeAddress | exclude = kInvalidAddress |
||
| ) | const |
Reactive lookup == nextNeighborNode(dest, false, beta).
| NodeAddress anthocnet::core::PheromoneTable::randomDestination | ( | IRng & | rng | ) | const |
Uniformly pick a known regular destination, or kInvalidAddress if none.