![]() |
Q2NS dev
ns-3 module
|
Abstract base class for channel map models. More...
#include <q2ns-qmap.h>
Public Member Functions | |
| ~QMap () override=default | |
| Virtual destructor. | |
| virtual QMapInstance | Sample (ns3::Ptr< ns3::UniformRandomVariable > u, const QMapContext &ctx=QMapContext{}) const =0 |
| Sample a per-transmission QMapInstance. | |
Static Public Member Functions | |
| static ns3::TypeId | GetTypeId () |
| Get the ns-3 TypeId. | |
| static ns3::Ptr< QMap > | Compose (const ns3::Ptr< QMap > &a, const ns3::Ptr< QMap > &b) |
| Compose two QMaps into one sequential composite QMap. | |
| static ns3::Ptr< QMap > | Compose (const std::vector< ns3::Ptr< QMap > > &maps) |
| Compose a sequence of QMaps into one sequential composite QMap. | |
| static ns3::Ptr< QMap > | FromLambda (std::function< void(QNode &, std::shared_ptr< Qubit > &)> f) |
| Build a QMap from a simple lambda. | |
| static ns3::Ptr< QMap > | FromLambda (std::function< void(QNode &, std::shared_ptr< Qubit > &, ns3::Ptr< ns3::UniformRandomVariable >, const QMapContext &)> f) |
| Build a QMap from an advanced lambda. | |
| static double | RateToProb (double rate_per_s, const ns3::Time &t) |
| Convert a Poisson rate and elapsed time into an event probability. | |
Protected Member Functions | |
| double | GetProb_ (const QMapContext &ctx) const |
| Return the effective application probability for this transmission. | |
| bool | Bernoulli_ (ns3::Ptr< ns3::UniformRandomVariable > u, const QMapContext &ctx) const |
| Perform one Bernoulli trial using the effective probability. | |
Static Protected Member Functions | |
| static void | SetLost_ (Qubit &q) |
| Mark a qubit lost through the standard registry-backed location path. | |
Protected Attributes | |
| double | p_ = 0.0 |
| Direct per-transmission probability. | |
| double | rate_ = 0.0 |
| Poisson event rate in 1/s. Overrides p_ when positive. | |
Abstract base class for channel map models.
A QMap does not directly mutate a qubit when the channel is configured. Instead, it samples a per-transmission QMapInstance that is carried alongside the transmitted qubit and later executed by the receiving QNode after the qubit becomes local there.
Most probabilistic QMaps share two common knobs:
If Rate is greater than zero, it overrides Probability using the current flight time in the provided QMapContext.
Definition at line 65 of file q2ns-qmap.h.
|
overridedefault |
Virtual destructor.
|
inlineprotected |
Perform one Bernoulli trial using the effective probability.
| u | Uniform random source. |
| ctx | Per-transmission context. |
Definition at line 183 of file q2ns-qmap.h.
References GetProb_().
Referenced by q2ns::DephasingQMap::Sample(), q2ns::DepolarizingQMap::Sample(), and q2ns::LossQMap::Sample().
|
static |
Compose two QMaps into one sequential composite QMap.
The resulting map applies the sampled instance of a first, then the sampled instance of b. If either step marks the qubit lost, later steps are not run.
Definition at line 122 of file q2ns-qmap.cc.
References Compose().
Referenced by Compose(), and main().
Compose a sequence of QMaps into one sequential composite QMap.
Maps are applied left to right in the order provided.
| maps | Sequence of maps to compose. |
Definition at line 132 of file q2ns-qmap.cc.
|
static |
Build a QMap from a simple lambda.
The lambda is executed at the receiving node and receives only the node and qubit handle.
| f | User-provided callable. |
Definition at line 140 of file q2ns-qmap.cc.
Referenced by main().
|
static |
Build a QMap from an advanced lambda.
The lambda is executed at the receiving node and also receives the random source and sampled transmission context.
| f | User-provided callable. |
Definition at line 147 of file q2ns-qmap.cc.
|
inlineprotected |
Return the effective application probability for this transmission.
| ctx | Per-transmission context. |
Definition at line 173 of file q2ns-qmap.h.
References q2ns::QMapContext::elapsedTime, p_, rate_, and RateToProb().
Referenced by Bernoulli_().
|
static |
|
inlinestatic |
Convert a Poisson rate and elapsed time into an event probability.
This returns the probability of at least one event in time t under a Poisson process with rate rate_per_s.
| rate_per_s | Event rate in 1/s. |
| t | Elapsed time. |
Definition at line 158 of file q2ns-qmap.h.
Referenced by GetProb_(), and main().
|
pure virtual |
Sample a per-transmission QMapInstance.
The returned callable is later executed at the receiving node after the qubit has become local there.
| u | Uniform random source to use for sampling. |
| ctx | Optional per-transmission context. |
Implemented in q2ns::anonymous_namespace{q2ns-qmap.cc}::CompositeQMap, q2ns::LambdaQMap, q2ns::ConditionalQMap, q2ns::DephasingQMap, q2ns::DepolarizingQMap, q2ns::LossQMap, q2ns::RandomGateQMap, and q2ns::RandomUnitaryQMap.
|
staticprotected |
Mark a qubit lost through the standard registry-backed location path.
| q | Qubit handle. |
Definition at line 55 of file q2ns-qmap.cc.
References q2ns::Qubit::SetLocationLost().
Referenced by q2ns::LossQMap::Sample().
|
protected |
Direct per-transmission probability.
Definition at line 200 of file q2ns-qmap.h.
Referenced by GetProb_(), and GetTypeId().
|
protected |
Poisson event rate in 1/s. Overrides p_ when positive.
Definition at line 201 of file q2ns-qmap.h.
Referenced by GetProb_(), and GetTypeId().