AntHocNet 2.0.0
Paper-faithful ant-colony ad hoc routing: the shared core and its adapters
Loading...
Searching...
No Matches
link_metric.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 * ILinkMetric: the strategy that turns a backward ant's path observation into a
6 * pheromone value (Eq.2). Extracting it from advanceBackAnt makes the pure core
7 * the natural home for both the canonical metric and pluggable research metrics
8 * (fuzzy / energy / QoS), selected by config, without touching the state machine
9 * (item 16, ADR-0003).
10 *
11 * The metric must be pure: it reads only the observation, never the simulator,
12 * clock, or RNG. Adapter-supplied signals (energy, SNR, queue occupancy) enter
13 * through LinkObservation, keeping the core free of simulator dependencies.
14 */
15#ifndef ANTHOCNET_CORE_LINK_METRIC_H
16#define ANTHOCNET_CORE_LINK_METRIC_H
17
18#include <cmath>
19
20namespace anthocnet {
21namespace core {
22
23/// What a backward ant knows about the path from this node to the destination.
24/// Carries path aggregates and node-local signals only — never per-hop
25/// downstream vectors (the wire carries one scalar cost per hop, ADR-0009).
27 double hops = 0.0; ///< hops to the destination; fractional once smoothed (#185).
28 double pathTime = 0.0; ///< accumulated time estimate (seconds, item 02).
29 double hopTime = 0.0; ///< config T_hop (seconds).
30};
31
32/// Maps an observation to a pheromone (goodness; higher == better).
34 virtual ~ILinkMetric() = default;
35 virtual double pheromone(const LinkObservation& obs) const = 0;
36};
37
38/// The canonical AntHocNet metric (Eq.2): blend the path-time estimate with the
39/// hop-count estimate and invert. Identical to the post-item-02 inline formula.
41 double pheromone(const LinkObservation& o) const override {
42 return std::pow((o.pathTime + o.hops * o.hopTime) / 2.0, -1.0);
43 }
44};
45
46} // namespace core
47} // namespace anthocnet
48
49#endif // ANTHOCNET_CORE_LINK_METRIC_H
AntHistoryTracker: (src, seqNum) duplicate detection.
Definition ant_history.h:24
The canonical AntHocNet metric (Eq.2): blend the path-time estimate with the hop-count estimate and i...
Definition link_metric.h:40
double pheromone(const LinkObservation &o) const override
Definition link_metric.h:41
Maps an observation to a pheromone (goodness; higher == better).
Definition link_metric.h:33
virtual ~ILinkMetric()=default
virtual double pheromone(const LinkObservation &obs) const =0
What a backward ant knows about the path from this node to the destination.
Definition link_metric.h:26
double hops
hops to the destination; fractional once smoothed (#185).
Definition link_metric.h:27
double pathTime
accumulated time estimate (seconds, item 02).
Definition link_metric.h:28
double hopTime
config T_hop (seconds).
Definition link_metric.h:29