![]() |
5G-LENA nr-v3.3-159-ga6832aa7
The 5G/NR module for the ns-3 simulator
|
UE representation for a AI-based scheduler. More...
#include "nr-mac-scheduler-ue-info-ai.h"
Classes | |
struct | LcObservation |
A struct for an observation of a flow. More... | |
Public Types | |
typedef Callback< void, const std::vector< LcObservation > &, bool, float, const std::string &, const UpdateAllUeWeightsFn & > | NotifyCb |
A callback type for notifying with specific parameters. | |
typedef std::unordered_map< uint8_t, Weights > | UeWeightsMap |
A hash map for UE weights. | |
typedef std::function< void(const UeWeightsMap &)> | UpdateAllUeWeightsFn |
A function type for updating the weights of all UEs. | |
typedef std::unordered_map< uint8_t, double > | Weights |
A hash map for weights. | |
![]() | |
typedef std::function< NrMacHarqVector &(const UePtr &ue)> | GetHarqVectorFn |
typedef std::function< std::unordered_map< uint8_t, LCGPtr > &(const UePtr &ue)> | GetLCGFn |
typedef std::function< uint32_t()> | GetRbPerRbgFn |
enum class | McsCsiSource { AVG_MCS , AVG_SPEC_EFF , AVG_SINR , WIDEBAND_MCS } |
Public Member Functions | |
NrMacSchedulerUeInfoAi (float alpha, uint16_t rnti, BeamId beamId, const GetRbPerRbgFn &fn) | |
NrMacSchedulerUeInfoAi constructor. | |
std::vector< LcObservation > | GetDlObservation () |
Get the current observation for downlink. | |
float | GetDlReward () |
Get the reward for downlink. | |
std::vector< LcObservation > | GetUlObservation () |
Get the current observation for uplink. | |
float | GetUlReward () |
Get the reward for uplink. | |
void | ResetDlSchedInfo () override |
Reset DL AI scheduler info. | |
void | ResetUlSchedInfo () override |
Reset UL AI scheduler info. | |
void | UpdateDlWeights (Weights &weights) |
Update the weights for downlink. | |
void | UpdateUlWeights (Weights &weights) |
Update the weights for uplink. | |
![]() | |
NrMacSchedulerUeInfoQos (float alpha, uint16_t rnti, BeamId beamId, const GetRbPerRbgFn &fn) | |
NrMacSchedulerUeInfoQos constructor. | |
void | CalculatePotentialTPutDl (const NrMacSchedulerNs3::FTResources &assignableInIteration) |
Calculate the Potential throughput for downlink. | |
void | CalculatePotentialTPutUl (const NrMacSchedulerNs3::FTResources &assignableInIteration) |
Calculate the Potential throughput for uplink. | |
void | ResetDlMetric () override |
Reset the DL avg Th to the last value. | |
void | ResetDlSchedInfo () override |
Reset DL QoS scheduler info. | |
void | ResetUlMetric () override |
Reset the UL avg Th to the last value. | |
void | ResetUlSchedInfo () override |
Reset UL QoS scheduler info. | |
void | UpdateDlQosMetric (const NrMacSchedulerNs3::FTResources &totAssigned, double timeWindow) |
Update the QoS metric for downlink. | |
void | UpdateUlQosMetric (const NrMacSchedulerNs3::FTResources &totAssigned, double timeWindow) |
Update the QoS metric for uplink. | |
![]() | |
NrMacSchedulerUeInfo ()=delete | |
Default Constructor (deleted) | |
NrMacSchedulerUeInfo (uint16_t rnti, BeamId beamId, const GetRbPerRbgFn &fn) | |
Create a new UE representation. | |
virtual | ~NrMacSchedulerUeInfo () |
~NrMacSchedulerUeInfo deconstructor | |
uint8_t | GetDlMcs () const |
Get the downlink MCS, given by the wideband CQI, or the sub-band CQIs of the currently allocated RBGs, if available. | |
uint32_t | GetTotalDlBuffer () const |
void | ReleaseLC (uint8_t lcid) |
virtual void | UpdateDlMetric () |
Update DL metrics after resources have been assigned. | |
virtual void | UpdateUlMetric () |
Update UL metrics after resources have been assigned. | |
Static Public Member Functions | |
static double | CalculateDlWeight (const NrMacSchedulerNs3::UePtrAndBufferReq &ue) |
Calculate the weight of a UE in the downlink. | |
static double | CalculateUlWeight (const NrMacSchedulerNs3::UePtrAndBufferReq &ue) |
Calculate the weight of a UE in the uplink. | |
static bool | CompareUeWeightsDl (const NrMacSchedulerNs3::UePtrAndBufferReq &lue, const NrMacSchedulerNs3::UePtrAndBufferReq &rue) |
comparison function object (i.e. an object that satisfies the requirements of Compare) which returns true if the first argument is less than (i.e. is ordered before) the second. | |
static bool | CompareUeWeightsUl (const NrMacSchedulerNs3::UePtrAndBufferReq &lue, const NrMacSchedulerNs3::UePtrAndBufferReq &rue) |
comparison function object (i.e. an object that satisfies the requirements of Compare) which returns true if the first argument is less than (i.e. is ordered before) the second. | |
![]() | |
static double | CalculateDelayBudgetFactor (uint64_t pdb, uint16_t hol) |
This function calculates the Delay Budget Factor for the case of DC-GBR LC. This value will then be used for the calculation of the QoS metric (weight). Notice that in order to avoid the case that a packet has not been dropped when HOL >= PDB, even though it is in this state (currently our code does not implement packet drop by default), we give very high priority to this packet. We do this by considering a very small value for the denominator (i.e. (PDB - HOL) = 0.1). | |
static uint8_t | CalculateDlMinPriority (const NrMacSchedulerNs3::UePtrAndBufferReq &ue) |
This function calculates the min Priority for the DL. | |
static double | CalculateDlWeight (const NrMacSchedulerNs3::UePtrAndBufferReq &ue) |
comparison function object (i.e. an object that satisfies the requirements of Compare) which returns true if the first argument is less than (i.e. is ordered before) the second. | |
static uint8_t | CalculateUlMinPriority (const NrMacSchedulerNs3::UePtrAndBufferReq &ue) |
This function calculates the min Priority for the UL. | |
static bool | CompareUeWeightsDl (const NrMacSchedulerNs3::UePtrAndBufferReq &lue, const NrMacSchedulerNs3::UePtrAndBufferReq &rue) |
comparison function object (i.e. an object that satisfies the requirements of Compare) which returns true if the first argument is less than (i.e. is ordered before) the second. | |
static bool | CompareUeWeightsUl (const NrMacSchedulerNs3::UePtrAndBufferReq &lue, const NrMacSchedulerNs3::UePtrAndBufferReq &rue) |
comparison function object (i.e. an object that satisfies the requirements of Compare) which returns true if the first argument is less than (i.e. is ordered before) the second. | |
![]() | |
static NrMacHarqVector & | GetDlHarqVector (const UePtr &ue) |
GetDlHarqVector. | |
static std::unordered_map< uint8_t, LCGPtr > & | GetDlLCG (const UePtr &ue) |
GetDlLCG. | |
static uint8_t & | GetDlMcs (const UePtr &ue) |
GetDlMcs. | |
static std::vector< uint16_t > & | GetDlRBG (const UePtr &ue) |
GetDlRBG. | |
static std::vector< uint8_t > & | GetDlSym (const UePtr &ue) |
GetDlSym. | |
static uint32_t & | GetDlTBS (const UePtr &ue) |
GetDlTBS. | |
static NrMacHarqVector & | GetUlHarqVector (const UePtr &ue) |
GetUlHarqVector. | |
static std::unordered_map< uint8_t, LCGPtr > & | GetUlLCG (const UePtr &ue) |
GetUlLCG. | |
static uint8_t & | GetUlMcs (const UePtr &ue) |
GetUlMcs. | |
static std::vector< uint16_t > & | GetUlRBG (const UePtr &ue) |
GetUlRBG. | |
static std::vector< uint8_t > & | GetUlSym (const UePtr &ue) |
GetUlSym. | |
static uint32_t & | GetUlTBS (const UePtr &ue) |
GetUlTBS. | |
static void | PrintLcInfo (uint16_t ue, uint8_t lcgId, uint8_t lcId, uint8_t cqi, uint8_t P, uint8_t minP) |
Prints information related to the QCI of a UEs LC. | |
Public Attributes | |
Weights | m_weightsDl |
Weights assigned to each flow for a UE in the downlink. | |
Weights | m_weightsUl |
Weights assigned to each flow for a UE in the uplink. | |
![]() | |
float | m_alpha {0.0} |
PF fairness metric. | |
double | m_avgTputDl {0.0} |
Average throughput in downlink during all the slots. | |
double | m_avgTputUl {0.0} |
Average throughput in uplink during all the slots. | |
double | m_currTputDl {0.0} |
Current slot throughput in downlink. | |
double | m_currTputUl {0.0} |
Current slot throughput in uplink. | |
double | m_lastAvgTputDl {0.0} |
Last average throughput in downlink. | |
double | m_lastAvgTputUl {0.0} |
Last average throughput in uplink. | |
double | m_potentialTputDl {0.0} |
double | m_potentialTputUl {0.0} |
![]() | |
BeamId | m_beamId |
Beam ID of the UE (kept updated as much as possible by MAC) | |
Ptr< NrAmc > | m_dlAmc |
AMC instance of scheduler associated with DL. | |
CqiInfo | m_dlCqi |
DL CQI information. | |
NrMacHarqVector | m_dlHarq |
HARQ process vector for DL. | |
std::unordered_map< uint8_t, LCGPtr > | m_dlLCG |
DL LCG. | |
uint8_t | m_dlMcs {0} |
DL MCS. | |
uint32_t | m_dlMRBRetx {0} |
Ptr< const ComplexMatrixArray > | m_dlPrecMats {nullptr} |
DL Precoding matrices. | |
uint8_t | m_dlRank {1} |
DL rank (number of MIMO layers) | |
std::vector< uint16_t > | m_dlRBG |
DL Resource Block Group assigned in this slot. | |
std::vector< SbMcsInfo > | m_dlSbMcsInfo |
std::vector< uint8_t > | m_dlSym |
Corresponding symbol of m_dlRBG in this slot. | |
uint32_t | m_dlTbSize {0} |
std::optional< uint8_t > | m_fhMaxMcsAssignable |
Maximum DL MCS assignable due to FH limitations. | |
McsCsiSource | m_mcsCsiSource |
Source of MCS computation based on CSI feedback. | |
std::vector< uint8_t > | m_rbgToSb |
Precomputed RBG to SB mapping. | |
uint16_t | m_rnti {0} |
RNTI of the UE. | |
uint32_t | m_srsOffset {0} |
SRS offset. | |
uint32_t | m_srsPeriodicity {0} |
SRS periodicity. | |
uint8_t | m_startMcsDlUe {0} |
Starting DL MCS to be used. | |
Ptr< NrAmc > | m_ulAmc |
AMC instance of scheduler associated with UL. | |
CqiInfo | m_ulCqi |
UL CQI information. | |
NrMacHarqVector | m_ulHarq |
HARQ process vector for UL. | |
std::unordered_map< uint8_t, LCGPtr > | m_ulLCG |
UL LCG. | |
uint8_t | m_ulMcs {0} |
UL MCS. | |
uint32_t | m_ulMRBRetx {0} |
Ptr< const ComplexMatrixArray > | m_ulPrecMats {nullptr} |
UL Precoding matrices. | |
uint8_t | m_ulRank {1} |
UL rank (number of MIMO layers) | |
std::vector< uint16_t > | m_ulRBG |
UL Resource Block Group assigned in this slot. | |
std::vector< uint8_t > | m_ulSym |
Corresponding symbol of m_ulRBG in this slot. | |
uint32_t | m_ulTbSize {0} |
Additional Inherited Members | |
![]() | |
uint32_t | GetNumRbPerRbg () const |
Retrieve the number of RB per RBG. | |
UE representation for a AI-based scheduler.
The representation stores the weights of a UE, which are also referred to as actions in the RL model, in response to sending the predefined observation. The observation is a vector of LcObservation, each representing an observation of a flow. In addition to RL-related operations, it updates the metrics in NrMacSchedulerUeInfoQos by inheriting from the NrMacSchedulerUeInfoQos class. In resource allocation per symbol, we can design the reward function of a UE using the QoS metrics.
Definition at line 27 of file nr-mac-scheduler-ue-info-ai.h.
A callback type for notifying with specific parameters.
This callback takes the following parameters:
Definition at line 97 of file nr-mac-scheduler-ue-info-ai.h.
A hash map for UE weights.
A hash map for UE weights that maps a uint8_t to a Weights. The key is the RNTI, and the value is the Weights of the UE.
Definition at line 57 of file nr-mac-scheduler-ue-info-ai.h.
A function type for updating the weights of all UEs.
Definition at line 79 of file nr-mac-scheduler-ue-info-ai.h.
A hash map for weights.
A hash map for weights that maps a pair of uint8_t to a double. The key is the LC ID, and the value is the weight of the LC as a double.
Definition at line 49 of file nr-mac-scheduler-ue-info-ai.h.
|
inline |
NrMacSchedulerUeInfoAi constructor.
alpha | The fairness metric |
rnti | RNTI of the UE |
beamId | BeamId of the UE |
fn | A function that tells how many RB per RBG |
Definition at line 37 of file nr-mac-scheduler-ue-info-ai.h.
|
inlinestatic |
Calculate the weight of a UE in the downlink.
ue | the UE |
Calculate the weight of a UE in the downlink by iterating over the active LCs of the UE. The weight is calculated as the sum of the weights of the active LCs. The weight of an LC is retrieved from the m_weightsDl map.
Definition at line 227 of file nr-mac-scheduler-ue-info-ai.h.
References m_weightsDl.
Referenced by CompareUeWeightsDl().
|
inlinestatic |
Calculate the weight of a UE in the uplink.
ue | the UE |
Calculate the weight of a UE in the uplink by iterating over the active LCs of the UE. The weight is calculated as the sum of the weights of the active LCs. The weight of an LC is retrieved from the m_weightsUl map.
Definition at line 275 of file nr-mac-scheduler-ue-info-ai.h.
References m_weightsUl.
Referenced by CompareUeWeightsUl().
|
inlinestatic |
comparison function object (i.e. an object that satisfies the requirements of Compare) which returns true if the first argument is less than (i.e. is ordered before) the second.
lue | Left UE |
rue | Right UE |
The AI metric is calculated in CalculateDlWeight()
Definition at line 209 of file nr-mac-scheduler-ue-info-ai.h.
References CalculateDlWeight().
Referenced by ns3::NrMacSchedulerOfdmaAi::GetUeCompareDlFn(), and ns3::NrMacSchedulerTdmaAi::GetUeCompareDlFn().
|
inlinestatic |
comparison function object (i.e. an object that satisfies the requirements of Compare) which returns true if the first argument is less than (i.e. is ordered before) the second.
lue | Left UE |
rue | Right UE |
The AI metric is calculated in CalculateUlWeight()
Definition at line 257 of file nr-mac-scheduler-ue-info-ai.h.
References CalculateUlWeight().
Referenced by ns3::NrMacSchedulerOfdmaAi::GetUeCompareUlFn(), and ns3::NrMacSchedulerTdmaAi::GetUeCompareUlFn().
std::vector< NrMacSchedulerUeInfoAi::LcObservation > ns3::NrMacSchedulerUeInfoAi::GetDlObservation | ( | ) |
Get the current observation for downlink.
ue | the UE |
Get the current observation for downlink by iterating over the active LCs of the UE. The observation is stored in a vector of LcObservation and each consists of the RNTI, LCG ID, LC ID, QCI, priority, and head-of-line delay of the flow.
Definition at line 16 of file nr-mac-scheduler-ue-info-ai.cc.
References ns3::NrMacSchedulerUeInfo::m_dlLCG, and ns3::NrMacSchedulerUeInfo::m_rnti.
float ns3::NrMacSchedulerUeInfoAi::GetDlReward | ( | ) |
Get the reward for downlink.
Calculate the reward for the downlink based on the latest observation and the given weights. The reward is calculated as the sum of the rewards of the active LCs. The reward for an LC ( i ) is calculated as .
@alpha is a fairness metric. ( P ) is the priority associated with the QCI. HOL is the head-of-line delay of the LC. Please note that the throughput is calculated in bit/symbol.
Definition at line 80 of file nr-mac-scheduler-ue-info-ai.cc.
References ns3::NrMacSchedulerUeInfoQos::m_alpha, ns3::NrMacSchedulerUeInfoQos::m_avgTputDl, ns3::NrMacSchedulerUeInfo::m_dlLCG, and ns3::NrMacSchedulerUeInfoQos::m_potentialTputDl.
std::vector< NrMacSchedulerUeInfoAi::LcObservation > ns3::NrMacSchedulerUeInfoAi::GetUlObservation | ( | ) |
Get the current observation for uplink.
ue | the UE |
Get the current observation for uplink by iterating over the active LCs of the UE. The observation is stored in a vector of LcObservation and each consists of the RNTI, LCG ID, LC ID, QCI, priority, and head-of-line delay of the flow.
Definition at line 42 of file nr-mac-scheduler-ue-info-ai.cc.
References ns3::NrMacSchedulerUeInfo::m_rnti, and ns3::NrMacSchedulerUeInfo::m_ulLCG.
float ns3::NrMacSchedulerUeInfoAi::GetUlReward | ( | ) |
Get the reward for uplink.
Calculate the reward for the uplink based on the latest observation and the given weights. The reward is calculated as the sum of the rewards of the active LCs. The reward for an LC ( i ) is calculated as .
@alpha is a fairness metric. ( P ) is the priority associated with the QCI. HOL is the head-of-line delay of the LC. Please note that the throughput is calculated in bit/symbol.
Definition at line 104 of file nr-mac-scheduler-ue-info-ai.cc.
References ns3::NrMacSchedulerUeInfoQos::m_alpha, ns3::NrMacSchedulerUeInfoQos::m_avgTputUl, ns3::NrMacSchedulerUeInfoQos::m_potentialTputUl, and ns3::NrMacSchedulerUeInfo::m_ulLCG.
|
inlineoverridevirtual |
Reset DL AI scheduler info.
Clear the weights for the downlink. It calls also NrMacSchedulerUeInfoQos::ResetDlSchedInfo.
Reimplemented from ns3::NrMacSchedulerUeInfo.
Definition at line 105 of file nr-mac-scheduler-ue-info-ai.h.
References m_weightsDl, and ns3::NrMacSchedulerUeInfoQos::ResetDlSchedInfo().
|
inlineoverridevirtual |
Reset UL AI scheduler info.
Clear the weights for the uplink. It also calls NrMacSchedulerUeInfoQos::ResetUlSchedInfo.
Reimplemented from ns3::NrMacSchedulerUeInfo.
Definition at line 117 of file nr-mac-scheduler-ue-info-ai.h.
References m_weightsUl, and ns3::NrMacSchedulerUeInfoQos::ResetUlSchedInfo().
void ns3::NrMacSchedulerUeInfoAi::UpdateDlWeights | ( | NrMacSchedulerUeInfoAi::Weights & | weights | ) |
Update the weights for downlink.
weights | The weights assigned to a UE |
Update m_weights by copying the weights assigned to a UE. The weights consist of an unordered_map of (key, value) pairs where the lcId is the key, and the weight of the lcId is the value. The higher the weight, the higher the priority of the flow in scheduling.
Definition at line 68 of file nr-mac-scheduler-ue-info-ai.cc.
References m_weightsDl.
void ns3::NrMacSchedulerUeInfoAi::UpdateUlWeights | ( | NrMacSchedulerUeInfoAi::Weights & | weights | ) |
Update the weights for uplink.
weights | the weights assigned to a UE |
Update m_weights by copying the weights assigned to a UE. The weights consist of an unordered_map of (key, value) pairs where the combination of lcgId and lcId is the key, and the weight of the lcId is the value. The higher the weight, the higher the priority of the flow in scheduling.
Definition at line 74 of file nr-mac-scheduler-ue-info-ai.cc.
References m_weightsUl.
Weights ns3::NrMacSchedulerUeInfoAi::m_weightsDl |
Weights assigned to each flow for a UE in the downlink.
Definition at line 295 of file nr-mac-scheduler-ue-info-ai.h.
Referenced by CalculateDlWeight(), ResetDlSchedInfo(), and UpdateDlWeights().
Weights ns3::NrMacSchedulerUeInfoAi::m_weightsUl |
Weights assigned to each flow for a UE in the uplink.
Definition at line 296 of file nr-mac-scheduler-ue-info-ai.h.
Referenced by CalculateUlWeight(), ResetUlSchedInfo(), and UpdateUlWeights().