AntHocNet 2.0.0
Paper-faithful ant-colony ad hoc routing: the shared core and its adapters
Loading...
Searching...
No Matches
pheromone_engine.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (C) 2026 Daniel Henrique Joppi
3
4/**
5 * PheromoneEngine: the reinforcement / evaporation math, lifted out of the
6 * NS-2 AntNest class so both simulators share identical routing dynamics.
7 *
8 * Operates on a PheromoneTable by reference; carries no simulator state.
9 */
10#ifndef ANTHOCNET_CORE_PHEROMONE_ENGINE_H
11#define ANTHOCNET_CORE_PHEROMONE_ENGINE_H
12
17
18namespace anthocnet {
19namespace core {
20
22public:
23 explicit PheromoneEngine(const Config& config) : config_(config) {}
24
25 /// phValue - (1 - alpha) * phValue
26 double evaporate(double phValue) const;
27 /// gamma * phValue + (1 - gamma) * phUpdate
28 double reinforce(double phValue, double phUpdate) const;
29
30 /// Reinforce the (dest, neighbor) regular link travelled by an ant. Aging
31 /// of other links is handled separately by evaporateAll (ADR-0012).
33 NodeAddress neighbor, double phUpdate) const;
34
35 /// Time-proportional aging of every regular AND virtual link by
36 /// alpha^(dt/interval), pruning links below minPheromone. Driven by the
37 /// maintenance tick. One clock for both tables (#262) keeps them
38 /// commensurable for virtual-vs-regular comparisons.
39 void evaporateAll(PheromoneTable& table, double dtSeconds) const;
40
41 /// Reinforce the virtual links advertised by a hello. Aging is handled by
42 /// evaporateAll, same as the regular table (#262).
43 void updateVirtual(PheromoneTable& table, const AntMessage& hello) const;
44
45 /// Prune a vanished neighbour from both tables.
46 void cleanNeighbor(PheromoneTable& table, NodeAddress neighbor) const;
47
48 /// True if any neighbour still holds usable pheromone for this dest.
49 bool hasRegularDestination(const PheromoneTable& table, NodeAddress dest) const;
50
51private:
52 void cleanNeighbor(PheromoneTable& table, NodeAddress neighbor, bool regular) const;
53
54 const Config config_;
55};
56
57} // namespace core
58} // namespace anthocnet
59
60#endif // ANTHOCNET_CORE_PHEROMONE_ENGINE_H
double reinforce(double phValue, double phUpdate) const
gamma * phValue + (1 - gamma) * phUpdate
void evaporateAll(PheromoneTable &table, double dtSeconds) const
Time-proportional aging of every regular AND virtual link by alpha^(dt/interval), pruning links below...
void updateRegular(PheromoneTable &table, NodeAddress dest, NodeAddress neighbor, double phUpdate) const
Reinforce the (dest, neighbor) regular link travelled by an ant.
double evaporate(double phValue) const
phValue - (1 - alpha) * phValue
void updateVirtual(PheromoneTable &table, const AntMessage &hello) const
Reinforce the virtual links advertised by a hello.
void cleanNeighbor(PheromoneTable &table, NodeAddress neighbor) const
Prune a vanished neighbour from both tables.
PheromoneEngine(const Config &config)
bool hasRegularDestination(const PheromoneTable &table, NodeAddress dest) const
True if any neighbour still holds usable pheromone for this dest.
std::int32_t NodeAddress
Network-layer node address.
Definition types.h:21
AntHistoryTracker: (src, seqNum) duplicate detection.
Definition ant_history.h:24
Complete, copyable description of an ant packet.
Definition ant_message.h:48