-
Notifications
You must be signed in to change notification settings - Fork 2
/
BaseStation.hpp
executable file
·161 lines (131 loc) · 4.54 KB
/
BaseStation.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//
// BaseStation.hpp
// AggregationNS3
//
// Created by Alper Sinan Akyurek on 8/21/16.
// Copyright © 2016 Alper Sinan Akyurek. All rights reserved.
//
#ifndef BaseStation_hpp
#define BaseStation_hpp
#include "GainFunction.hpp"
#include <vector>
/**
Implements the smart Base Station for the 5G case with the capability of
negotiating the C values.
**/
class BaseStation
{
public:
/** C Value type **/
typedef GainFunction::TGain TCValue;
/** Gain value type **/
typedef GainFunction::TGain TResponse;
/** Number of nodes in the network **/
typedef unsigned int TNumberOfNodes;
/** The C Values used during negotiations in a vector **/
typedef std::vector<TCValue> TCValueVector;
/** The response vector for each C Values **/
typedef std::vector<TResponse> TResponseVector;
/** Number type for iteration statistics. **/
typedef unsigned int TIterationNumber;
private:
/** Minimum C Value for the iterations. **/
TCValue m_CValueMinimum;
/** Maximum C Values for the iterations. **/
TCValue m_CValueMaximum = 100;
/** Resolution for the iterations. **/
TCValue m_CValueResolution = 0.1;
/** The response vector from all nodes to the C values **/
TResponseVector m_responseVector;
/** Current Optimal C Value as a result of negotiations. **/
TCValue m_optimalCValue;
/** Number of Nodes in the Network **/
TNumberOfNodes m_numberOfNodes;
/** Alpha parameter in the algorithm **/
TResponse m_alpha;
/** Determines whether a static or dynamic Alpha value is used. **/
bool m_useDynamicAlpha;
/** Number of update broadcasts. **/
TIterationNumber m_numberOfBroadcasts = 0;
/** Number of updated responses. **/
TIterationNumber m_numberOfUpdates = 0;
/** Indicates whether updates from nodes have an effect. **/
bool m_updateEnabled = true;
public:
/**
C Value vector used for negotiations. This would normally be sent OTA
to the negotiating nodes. Used a public variable for simple
implementation.
**/
TCValueVector cVector;
private:
/**
Creates the initial C Value vector
**/
BaseStation( void );
/**
Reads the configuration of C values from "baseStation.txt" file.
**/
void
ReadConfiguration ( void );
/**
For a C Value vector index, get the gain value response from the
negotiating node.
\param index C Value vector index to be used for Gain value calculation
by the node.
\return The gain value response of the node.
**/
TResponse
GetError( const TResponseVector::size_type index ) const;
public:
/**
Returns the single instance of the BaseStation class.
\return Single instance of BaseStation.
**/
static
BaseStation &
GetBaseStation( void );
/**
Used to register a new incoming node. The node published its gain value
responses and optains the result of the negotiation C Value.
\param responses Gain value vector response to the C Values.
\return Optimal C Value of the negotiation.
**/
TCValue &
RegisterMe( const TResponseVector & responses );
/**
Returns the Optimal C Value.
\return Optimal C Value.
**/
TCValue &
GetOptimalCValue( void )
{
return ( this->m_optimalCValue );
}
/**
Updates responses so the the base station can calculate optimal
solution.
\param deltaResponses New Responses - OldResponses
**/
void
UpdateResponses( const TResponseVector & deltaResponses );
/**
Returns the number of update broadcasts.
\return Number of broadcasts of C values.
**/
TIterationNumber
GetNumberOfBroadcasts( void ) const
{
return ( this->m_numberOfBroadcasts );
}
/**
Returns the number of update requests for C values.
\return Number of C value update requests.
**/
TIterationNumber
GetNumberOfUpdateRequests( void ) const
{
return ( this->m_numberOfUpdates );
}
};
#endif /* BaseStation_hpp */