Skip to main content

Tutorial 3 — Routing Strategy Comparison

Objective: Run the same topology under three routing strategies to see how strategy choice affects latency vs fidelity trade-offs.

qnet-core supports three routing strategies that prioritize different aspects of network performance. Each strategy makes different trade-offs between speed and quality of the established entanglement.

Define an Asymmetric Network

from qnet_core import QNetEngine, NodeDefinition, LinkDefinition, StrategyType

engine = QNetEngine()

nodes = [
NodeDefinition(id="Alice", memory_lifetime_t2=1.0),
NodeDefinition(id="R1", memory_lifetime_t2=0.8),
NodeDefinition(id="R2", memory_lifetime_t2=0.6),
NodeDefinition(id="Bob", memory_lifetime_t2=1.0),
]

links = [
# Short but noisy link (high fidelity, fast generation)
LinkDefinition("Alice", "R1", distance_km=5.0, base_fidelity=0.97, generation_rate_hz=2_000.0),
# Long but clean link (lower fidelity, slower generation)
LinkDefinition("R1", "R2", distance_km=30.0, base_fidelity=0.80, generation_rate_hz=200.0),
# Medium link
LinkDefinition("R2", "Bob", distance_km=15.0, base_fidelity=0.90, generation_rate_hz=800.0),
]

engine.define_network(nodes, links)

Run Under Each Strategy

strategies = [
StrategyType.LowestLatency,
StrategyType.HighestFidelity,
StrategyType.HighestSuccess,
]

for strategy in strategies:
stats = engine.simulate(
from_node="Alice",
to="Bob",
fidelity_target=0.75,
max_latency_ms=10_000.0,
runs=500,
strategy=strategy,
seed=42,
)

print(f"{strategy:<20} {stats.empirical_success_rate:>7.1%} "
f"{stats.mean_latency_ms:>9.1f} ms {stats.mean_fidelity:>9.4f}")

Strategy Reference

StrategyPriorityHow It Works
LowestLatencySpeedMinimizes total hop distance; fastest route even with lower per-link fidelity
HighestFidelityQualityMaximizes end-to-end fidelity via purification; may take longer but ensures quality
HighestSuccessReliabilityPrefers links/paths with higher generation success rates (stochastic optimization)

Typical Results

On an asymmetric network like the one above, you'll typically see:

  • LowestLatency: Shortest total path, lowest latency, but possibly lower final fidelity
  • HighestFidelity: May take a longer route with more purification hops; highest fidelity at cost of latency
  • HighestSuccess: Balances both by preferring high-rate links with good fidelity — often the best all-around choice

What's next