Q2NS dev
ns-3 module
Loading...
Searching...
No Matches
q2ns::QMap Class Referenceabstract

Abstract base class for channel map models. More...

#include <q2ns-qmap.h>

Inheritance diagram for q2ns::QMap:
Collaboration diagram for q2ns::QMap:

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< QMapCompose (const ns3::Ptr< QMap > &a, const ns3::Ptr< QMap > &b)
 Compose two QMaps into one sequential composite QMap.
 
static ns3::Ptr< QMapCompose (const std::vector< ns3::Ptr< QMap > > &maps)
 Compose a sequence of QMaps into one sequential composite QMap.
 
static ns3::Ptr< QMapFromLambda (std::function< void(QNode &, std::shared_ptr< Qubit > &)> f)
 Build a QMap from a simple lambda.
 
static ns3::Ptr< QMapFromLambda (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.
 

Detailed Description

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:

  • Probability: direct per-transmission application probability
  • Rate: Poisson event rate in 1/s, converted to a per-flight probability

If Rate is greater than zero, it overrides Probability using the current flight time in the provided QMapContext.

See also
QMapInstance
QNode

Definition at line 65 of file q2ns-qmap.h.

Constructor & Destructor Documentation

◆ ~QMap()

q2ns::QMap::~QMap ( )
overridedefault

Virtual destructor.

Member Function Documentation

◆ Bernoulli_()

bool q2ns::QMap::Bernoulli_ ( ns3::Ptr< ns3::UniformRandomVariable >  u,
const QMapContext ctx 
) const
inlineprotected

Perform one Bernoulli trial using the effective probability.

Parameters
uUniform random source.
ctxPer-transmission context.
Returns
True if the event occurs, false otherwise.

Definition at line 183 of file q2ns-qmap.h.

References GetProb_().

Referenced by q2ns::DephasingQMap::Sample(), q2ns::DepolarizingQMap::Sample(), and q2ns::LossQMap::Sample().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Compose() [1/2]

ns3::Ptr< QMap > q2ns::QMap::Compose ( const ns3::Ptr< QMap > &  a,
const ns3::Ptr< QMap > &  b 
)
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.

Parameters
aFirst QMap in the sequence.
bSecond QMap in the sequence.
Returns
Composite QMap object.
See also
Compose(const std::vector<ns3::Ptr<QMap>>&)

Definition at line 122 of file q2ns-qmap.cc.

References Compose().

Referenced by Compose(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Compose() [2/2]

ns3::Ptr< QMap > q2ns::QMap::Compose ( const std::vector< ns3::Ptr< QMap > > &  maps)
static

Compose a sequence of QMaps into one sequential composite QMap.

Maps are applied left to right in the order provided.

Parameters
mapsSequence of maps to compose.
Returns
Composite QMap object.
See also
Compose(const ns3::Ptr<QMap>&, const ns3::Ptr<QMap>&)

Definition at line 132 of file q2ns-qmap.cc.

◆ FromLambda() [1/2]

ns3::Ptr< QMap > q2ns::QMap::FromLambda ( std::function< void(QNode &, std::shared_ptr< Qubit > &)>  f)
static

Build a QMap from a simple lambda.

The lambda is executed at the receiving node and receives only the node and qubit handle.

Parameters
fUser-provided callable.
Returns
QMap wrapping the callable.
See also
FromLambda(std::function<void(QNode&, std::shared_ptr<Qubit>&, ns3::Ptr<ns3::UniformRandomVariable>, const QMapContext&)>)

Definition at line 140 of file q2ns-qmap.cc.

Referenced by main().

Here is the caller graph for this function:

◆ FromLambda() [2/2]

ns3::Ptr< QMap > q2ns::QMap::FromLambda ( std::function< void(QNode &, std::shared_ptr< Qubit > &, ns3::Ptr< ns3::UniformRandomVariable >, const QMapContext &)>  f)
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.

Parameters
fUser-provided callable.
Returns
QMap wrapping the callable.
See also
FromLambda(std::function<void(QNode&, std::shared_ptr<Qubit>&)>)

Definition at line 147 of file q2ns-qmap.cc.

◆ GetProb_()

double q2ns::QMap::GetProb_ ( const QMapContext ctx) const
inlineprotected

Return the effective application probability for this transmission.

Parameters
ctxPer-transmission context.
Returns
Probability in [0, 1].

Definition at line 173 of file q2ns-qmap.h.

References q2ns::QMapContext::elapsedTime, p_, rate_, and RateToProb().

Referenced by Bernoulli_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTypeId()

ns3::TypeId q2ns::QMap::GetTypeId ( )
static

Get the ns-3 TypeId.

Returns
TypeId for q2ns::QMap.

Definition at line 35 of file q2ns-qmap.cc.

References p_, and rate_.

◆ RateToProb()

static double q2ns::QMap::RateToProb ( double  rate_per_s,
const ns3::Time &  t 
)
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.

Parameters
rate_per_sEvent rate in 1/s.
tElapsed time.
Returns
Probability in [0, 1].

Definition at line 158 of file q2ns-qmap.h.

Referenced by GetProb_(), and main().

Here is the caller graph for this function:

◆ Sample()

virtual QMapInstance q2ns::QMap::Sample ( ns3::Ptr< ns3::UniformRandomVariable >  u,
const QMapContext ctx = QMapContext{} 
) const
pure virtual

Sample a per-transmission QMapInstance.

The returned callable is later executed at the receiving node after the qubit has become local there.

Parameters
uUniform random source to use for sampling.
ctxOptional per-transmission context.
Returns
Per-transmission QMapInstance. An empty callable represents the identity map.

Implemented in q2ns::anonymous_namespace{q2ns-qmap.cc}::CompositeQMap, q2ns::LambdaQMap, q2ns::ConditionalQMap, q2ns::DephasingQMap, q2ns::DepolarizingQMap, q2ns::LossQMap, q2ns::RandomGateQMap, and q2ns::RandomUnitaryQMap.

◆ SetLost_()

void q2ns::QMap::SetLost_ ( Qubit q)
staticprotected

Mark a qubit lost through the standard registry-backed location path.

Parameters
qQubit handle.

Definition at line 55 of file q2ns-qmap.cc.

References q2ns::Qubit::SetLocationLost().

Referenced by q2ns::LossQMap::Sample().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ p_

double q2ns::QMap::p_ = 0.0
protected

Direct per-transmission probability.

Definition at line 200 of file q2ns-qmap.h.

Referenced by GetProb_(), and GetTypeId().

◆ rate_

double q2ns::QMap::rate_ = 0.0
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().


The documentation for this class was generated from the following files: