5G-LENA nr-v3.3-161-gad18933f
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-mac-scheduler-ue-info-ai.cc
1// Copyright (c) 2024 Seoul National University (SNU)
2// Copyright (c) 2024 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3//
4// SPDX-License-Identifier: GPL-2.0-only
5
6#include "nr-mac-scheduler-ue-info-ai.h"
7
8#include "ns3/log.h"
9
10namespace ns3
11{
12
13NS_LOG_COMPONENT_DEFINE("NrMacSchedulerUeInfoAi");
14
15std::vector<NrMacSchedulerUeInfoAi::LcObservation>
17{
18 NS_LOG_FUNCTION(this);
19 std::vector<NrMacSchedulerUeInfoAi::LcObservation> observations;
20 for (const auto& ueLcg : m_dlLCG)
21 {
22 std::vector<uint8_t> ueActiveLCs = ueLcg.second->GetActiveLCIds();
23
24 for (const auto lcId : ueActiveLCs)
25 {
26 std::unique_ptr<NrMacSchedulerLC>& LCPtr = ueLcg.second->GetLC(lcId);
27
29 m_rnti,
30 lcId,
31 LCPtr->m_qci,
32 LCPtr->m_priority,
33 LCPtr->m_rlcTransmissionQueueHolDelay};
34
35 observations.push_back(lcObservation);
36 }
37 }
38 return observations;
39}
40
41std::vector<NrMacSchedulerUeInfoAi::LcObservation>
43{
44 NS_LOG_FUNCTION(this);
45 std::vector<NrMacSchedulerUeInfoAi::LcObservation> observations;
46 for (const auto& ueLcg : m_ulLCG)
47 {
48 std::vector<uint8_t> ueActiveLCs = ueLcg.second->GetActiveLCIds();
49
50 for (const auto lcId : ueActiveLCs)
51 {
52 std::unique_ptr<NrMacSchedulerLC>& LCPtr = ueLcg.second->GetLC(lcId);
53
55 m_rnti,
56 lcId,
57 LCPtr->m_qci,
58 LCPtr->m_priority,
59 LCPtr->m_rlcTransmissionQueueHolDelay};
60
61 observations.push_back(lcObservation);
62 }
63 }
64 return observations;
65}
66
67void
72
73void
78
79float
81{
82 float reward = 0.0;
83 for (const auto& ueLcg : m_dlLCG)
84 {
85 std::vector<uint8_t> ueActiveLCs = ueLcg.second->GetActiveLCIds();
86
87 for (const auto lcId : ueActiveLCs)
88 {
89 std::unique_ptr<NrMacSchedulerLC>& LCPtr = ueLcg.second->GetLC(lcId);
90 if (m_avgTputDl == 0 || LCPtr->m_rlcTransmissionQueueHolDelay == 0)
91 {
92 continue;
93 }
94 reward += std::pow(m_potentialTputDl, m_alpha) /
95 (std::max(1E-9, m_avgTputDl) * LCPtr->m_priority *
96 LCPtr->m_rlcTransmissionQueueHolDelay);
97 }
98 }
99
100 return reward;
101}
102
103float
105{
106 float reward = 0.0;
107 for (const auto& ueLcg : m_ulLCG)
108 {
109 std::vector<uint8_t> ueActiveLCs = ueLcg.second->GetActiveLCIds();
110
111 for (const auto lcId : ueActiveLCs)
112 {
113 std::unique_ptr<NrMacSchedulerLC>& LCPtr = ueLcg.second->GetLC(lcId);
114 if (m_avgTputUl == 0 || LCPtr->m_rlcTransmissionQueueHolDelay == 0)
115 {
116 continue;
117 }
118 reward += std::pow(m_potentialTputUl, m_alpha) /
119 (std::max(1E-9, m_avgTputUl) * LCPtr->m_priority *
120 LCPtr->m_rlcTransmissionQueueHolDelay);
121 }
122 }
123
124 return reward;
125}
126
127} // namespace ns3
std::vector< LcObservation > GetUlObservation()
Get the current observation for uplink.
void UpdateUlWeights(Weights &weights)
Update the weights for uplink.
void UpdateDlWeights(Weights &weights)
Update the weights for downlink.
std::vector< LcObservation > GetDlObservation()
Get the current observation for downlink.
float GetDlReward()
Get the reward for downlink.
Weights m_weightsDl
Weights assigned to each flow for a UE in the downlink.
std::unordered_map< uint8_t, double > Weights
A hash map for weights.
float GetUlReward()
Get the reward for uplink.
Weights m_weightsUl
Weights assigned to each flow for a UE in the uplink.
std::unordered_map< uint8_t, LCGPtr > m_dlLCG
DL LCG.
std::unordered_map< uint8_t, LCGPtr > m_ulLCG
UL LCG.
double m_avgTputDl
Average throughput in downlink during all the slots.
double m_avgTputUl
Average throughput in uplink during all the slots.
std::unique_ptr< NrMacSchedulerLC > LCPtr
Unique pointer to an instance of NrMacSchedulerLC.