-
Notifications
You must be signed in to change notification settings - Fork 0
/
ert-method
213 lines (166 loc) · 3.44 KB
/
ert-method
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#include <iostream>
#include <math.h>
using namespace std;
double silnia(int value)
{
if(value==0) return 1;
else return value*silnia(value-1);
}
double suma(double A,double V)
{
int i=0;
double result=0;
while(i<=V)
{
result+=pow(A,i)/silnia(i);
i++;
}
return result;
}
double Erlang(double A,double V)
{
return ((pow(A,V)/silnia(V))/suma(A,V));
}
class Primary_Bundle
{
double A,V;
double R,D;
public:
Primary_Bundle(double a,double v):A(a),V(v)
{
R=A*Erlang(A,V);
D=R*((A/(V+1-A+R))-R);
}
double getA()
{
return A;
}
double getV()
{
return V;
}
double getR()
{
return R;
}
double getD()
{
return D;
}
};
class Secondary_Bundle
{
private:
double A,V,V_ob_0,V_ob_1;
double R,D,Z,B,B_ob;
double sigma2;
public:
Secondary_Bundle(double R_sum,double D_sum):R(R_sum),D(D_sum)
{
find_parameters();
}
double getA()
{
return A;
}
double getV()
{
return V;
}
double getR()
{
return R;
}
double getD()
{
return D;
}
double getZ()
{
return Z;
}
double getB()
{
return B;
}
double find_parameters()
{
double A_acc=0.01;
cout<<endl<<"PROCESSING..."<<endl<<endl;
double Vt=0,At=A_acc;
while(calc_D(At,Vt)<=getD())
{
Vt++;
At=A_acc;
while(calc_R(At,Vt)<=getR())
{
At+=A_acc;
}
}
A=At;
V=Vt;
sigma2=getR()*((getA()/(getV()+1-getA()+getR()))+1-getR());
Z=sigma2/getR();
B=0.001;
B_ob=0.001;
V_ob_0=find_V(A,B,1)-getV();
V_ob_1=find_V(A,B*R/A,1)-getV();
}
double find_V(double At,double Et,double Vt)
{
if(Erlang(At,Vt)-Et<=0.00000001) return Vt;
if(Vt<=0) return 0;
if(Erlang(At,Vt)>Et) return find_V(At,Et,++Vt);
else return find_V(At,Et,--Vt);
}
double calc_D(double A,double V)
{
return getR()*((A/(V+1-A+getR()))-getR());
}
double calc_R(double A,double V)
{
return A*Erlang(A,V);
}
void disp_parameters()
{
cout<<"R: "<<getR()<<endl;
cout<<"D: "<<getD()<<endl;
cout<<"Z: "<<getZ()<<endl;
cout<<"A: "<<getA()<<endl;
cout<<"V: "<<getV()<<endl;
cout<<"B: "<<getB()<<endl;
cout<<"V_ob by B (whole network): "<<V_ob_0<<endl;
cout<<"V_ob by B_ob (sec bundle only): "<<V_ob_1<<endl;
}
};
int main()
{
cout<<"MONITOROWANIE I OCENA WYDAJNOSCI SIECI PAKIETOWYCH"<<endl;
cout << "---------------METODA ERT---------------" << endl;
cout<<"LUKASZ CIESIELSKI"<<endl;
cout<<"POLITECHNIKA POZNANSKA V SEMESTR"<<endl<<endl;
double A,V,R_sum,D_sum=0,A_sec;
int k;
cout<<"Primary bundles: ";
cin>>k;
cout<<endl<<"Secondary offered traffic: ";
cin>>A_sec;
cout<<endl;
R_sum=A_sec;
Primary_Bundle *s[k];
for(int i=0;i<k;i++)
{
cout<<"A"<<i+1<<": ";
cin>>A;
cout<<"V"<<i+1<<": ";
cin>>V;
s[i]=new Primary_Bundle(A,V);
R_sum+=s[i]->getR();
D_sum+=s[i]->getD();
}
Secondary_Bundle *sec_b=new Secondary_Bundle(R_sum,D_sum);
sec_b->disp_parameters();
delete sec_b;
delete [] s;
return 0;
}