school project part2

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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
#include <iostream>
#include <string>
#include "User.h"

using namespace std;
using std::cout;
using std::endl;

User::User()
{
    for (int user=0; user<50; user++)
    
    {
        User_Channel_Conditions[user]=0;
        User_Packet_Delays[user]=0;
        User_GBR[user]=0;
        Final_Allocation_List[user]=-1;
        Users_Black_List[user]=false;

    }
    
}


void User::SetUserChannelConditions(float UserValue, int index)
{
    User_Channel_Conditions[index]=UserValue;
    
}

float User::GetUserChannelConditions(int index)
{
    return User_Channel_Conditions[index];
}

void User::SetUserPacketDelays(float UserValue, int index)
{
    User_Packet_Delays[index]=UserValue;
   
}

float User::GetUserPacketDelays(int index)
{
    return User_Packet_Delays[index];

}

void User::SetUserGBR(bool UserValue, int index)
{
    User_GBR[index]=UserValue;
}

bool User::GetUserGBR(int index)
{
    return    User_GBR[index];
}

void User::Print_Values()
{
    cout<<"TOTAL VALUES"<<endl;
    
    for (int user=0; user<50; user++)
    {
        cout<<"User :"<<user<<" CH : "<<User_Channel_Conditions[user]<<" PD : "<<User_Packet_Delays[user]<<" GBR : "<<User_GBR[user]<< endl;
    }
}

int User::ComputeMaxVal_User_Channel_Conditions()
{
    float aux=0;
    int index=0;

    
    for (int user=0; user<50; user++)
    {
        if(User_Channel_Conditions[user]>aux)
        {
            aux = User_Channel_Conditions[user]; //the value
            index = user; // the user
        }
        else
        {}
    }
    
    return index;
}
int User::ComputeMaxVal_User_Packet_Delays()
{
    float aux=0;
    int index=0;
    
    for (int user=0; user<50; user++)
    {
        if(User_Packet_Delays[user]>aux)
        {
            aux = User_Packet_Delays[user]; //the value
            index = user; // the user
        }
        else
        {}
    }
    
    return index;
}

int User::SelectUser1()
{
    // MAYOR VALOR DE CH Y ES GBR
    
    float aux_ch=0, aux_pd=0;
    int index=0;
    
    
    for (int user=0; user<50; user++)
    {
        if(Users_Black_List[user]==false)
        {
        if( User_Channel_Conditions[user]>aux_ch && User_GBR[user] == true )
        {
            aux_ch = User_Channel_Conditions[user]; //the value
           // aux_pd = User_Packet_Delays[user]; //the value

            index = user; // the user
            Users_Black_List[user]=true;
        }
        else
        {}
        }
    }
    
    return index;
}


int User::SelectUser2()
{
    // MAYOR VALOR DE CH Y NO ES GBR
    
    float aux_ch=0, aux_pd=0;
    int index=0;
    
    
    for (int user=0; user<50; user++)
    {
        if(Users_Black_List[user]==false)
        {
        if( User_Channel_Conditions[user]>aux_ch /*&& User_GBR[user] == false */)
        {
            aux_ch = User_Channel_Conditions[user]; //the value
            //aux_pd = User_Packet_Delays[user]; //the value
            
            index = user; // the user
            Users_Black_List[user]=true;
        }
        else
        {}
        }
    }
    
    return index;
}

int User::SelectUser3()
{
    // MAYOR VALOR DE PD Y ES GBR
    
    float aux_ch=0, aux_pd=0;
    int index=0;
    
    
    for (int user=0; user<50; user++)
    {
        if(Users_Black_List[user]==false)
        {
        if( User_Packet_Delays[user]>aux_pd && User_GBR[user] == true )
        {
            aux_pd = User_Packet_Delays[user]; //the value
            index = user; // the user
            Users_Black_List[user]=true;
        }
        else
        {}
        }
    }
    
    return index;
}

int User::SelectUser4()
{
    // MAYOR VALOR DE PD Y NO ES GBR
    
    float aux_ch=0, aux_pd=0;
    int index=0;
    
    
    for (int user=0; user<50; user++)
    {
        if(Users_Black_List[user]==false)
        {
        if( User_Packet_Delays[user]>aux_pd /*&& User_GBR[user] == false*/)
        {
            aux_pd = User_Packet_Delays[user]; //the value
            
            index = user; // the user
            Users_Black_List[user]=true;
        }
        else
        {}
        }
    }
    
    return index;
}

int User::SelectUser5()
{
    // MAYOR VALOR DE CH, PD Y ES GBR
    
    float aux_ch=0, aux_pd=0;
    int index=0;
    
    
    for (int user=0; user<50; user++)
    {
        if( Users_Black_List[user]==false)
        {
        if( User_Channel_Conditions[user]>aux_ch && User_Packet_Delays[user]>aux_pd && User_GBR[user] == true )
        {
            aux_pd = User_Packet_Delays[user]; //the value
            aux_ch = User_Channel_Conditions[user]; //the value

            index = user; // the user
            Users_Black_List[user]=true;
        }
        else
        {}
        }
    }
    
    return index;
}
int User::SelectUser6()
{
    // MAYOR VALOR DE CH PD Y NO ES GBR
    
    float aux_ch=0, aux_pd=0;
    int index=0;
    
    
    for (int user=0; user<50; user++)
    {
        if(Users_Black_List[user]==false)
        {
        if( User_Channel_Conditions[user]>aux_ch && User_Packet_Delays[user]>aux_pd /*&& User_GBR[user] == false*/)
        {
            aux_pd = User_Packet_Delays[user]; //the value
            aux_ch = User_Channel_Conditions[user]; //the value
            
            index = user; // the user
            Users_Black_List[user]=true;
        }
        else
        {}
        }
    }
    
    return index;
}
    
    for (int index = 0; index <50; index++)
    {
        cout<< "User : "<<index<< " : "<<Final_Allocation_List[index]<<endl;
    }
    
    cout<< "BLACK LIST"<<endl;
    
    for (int index = 0; index <50; index++)
    {
        cout<< "User : "<<index<< " : "<<Users_Black_List[index]<<endl;
    }
    
}
*/
void User::Print_Selected_Users()
{
    
    cout<<"1st Selected User : "<<SelectUser1()
    <<"  CH : "<< User_Channel_Conditions[SelectUser1()]
    <<"  PD : "<< User_Packet_Delays[SelectUser1()]
    <<"  GBR : "<< User_GBR[SelectUser1()]
    <<endl;
    
    cout<<"2nd Selected User : "<<SelectUser2()
    <<"  CH : "<< User_Channel_Conditions[SelectUser2()]
    <<"  PD : "<< User_Packet_Delays[SelectUser2()]
    <<"  GBR : "<< User_GBR[SelectUser2()]
    <<endl;
    
    cout<<"3rd Selected User : "<<SelectUser3()
    <<"  CH : "<< User_Channel_Conditions[SelectUser3()]
    <<"  PD : "<< User_Packet_Delays[SelectUser3()]
    <<"  GBR : "<< User_GBR[SelectUser3()]
    <<endl;
    
    cout<<"4th Selected User : "<<SelectUser4()
    <<"  CH : "<< User_Channel_Conditions[SelectUser4()]
    <<"  PD : "<< User_Packet_Delays[SelectUser4()]
    <<"  GBR : "<< User_GBR[SelectUser4()]
    <<endl;
    
    cout<<"5th Selected User : "<<SelectUser5()
    <<"  CH : "<< User_Channel_Conditions[SelectUser5()]
    <<"  PD : "<< User_Packet_Delays[SelectUser5()]
    <<"  GBR : "<< User_GBR[SelectUser5()]
    <<endl;
    
    cout<<"6th Selected User : "<<SelectUser6()
    <<"  CH : "<< User_Channel_Conditions[SelectUser6()]
    <<"  PD : "<< User_Packet_Delays[SelectUser6()]
    <<"  GBR : "<< User_GBR[SelectUser6()]
    <<endl;
     
}
Last edited on
and the las part is the main.cpp
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
#include <iostream>
#include <string>
#include "User.cpp"

using namespace std;

int main()
{

	User varUser;
//Channel Conditions del 1 al 100 - 100 la mejor - 1 a peor-
    varUser.SetUserChannelConditions(40,0); varUser.SetUserChannelConditions(78,1);
    varUser.SetUserChannelConditions(70,2); varUser.SetUserChannelConditions(5,3);
    varUser.SetUserChannelConditions(90,4); varUser.SetUserChannelConditions(7,5);
    varUser.SetUserChannelConditions(10,6); varUser.SetUserChannelConditions(46,7);
    varUser.SetUserChannelConditions(0.1,8); varUser.SetUserChannelConditions(48,9);
    varUser.SetUserChannelConditions(80.4,10); varUser.SetUserChannelConditions(43,11);
    varUser.SetUserChannelConditions(40.56,12); varUser.SetUserChannelConditions(44,13);
    varUser.SetUserChannelConditions(13,14); varUser.SetUserChannelConditions(74,15);
    varUser.SetUserChannelConditions(15,16); varUser.SetUserChannelConditions(79,17);
    varUser.SetUserChannelConditions(99,18); varUser.SetUserChannelConditions(53,19);
    varUser.SetUserChannelConditions(76,20); varUser.SetUserChannelConditions(35,21);
    varUser.SetUserChannelConditions(23,22); varUser.SetUserChannelConditions(32,23);
    varUser.SetUserChannelConditions(87,24); varUser.SetUserChannelConditions(84,25);
    varUser.SetUserChannelConditions(91,26); varUser.SetUserChannelConditions(85,27);
    varUser.SetUserChannelConditions(68,28); varUser.SetUserChannelConditions(6,29);
    varUser.SetUserChannelConditions(55,30); varUser.SetUserChannelConditions(71,31);
    varUser.SetUserChannelConditions(29,32); varUser.SetUserChannelConditions(64,33);
    varUser.SetUserChannelConditions(56,34); varUser.SetUserChannelConditions(69,35);
    varUser.SetUserChannelConditions(73,36); varUser.SetUserChannelConditions(1,37);
    varUser.SetUserChannelConditions(74,38); varUser.SetUserChannelConditions(83,39);
    varUser.SetUserChannelConditions(4,40); varUser.SetUserChannelConditions(96,41);
    varUser.SetUserChannelConditions(38,42); varUser.SetUserChannelConditions(63,43);
    varUser.SetUserChannelConditions(97,44); varUser.SetUserChannelConditions(38,45);
    varUser.SetUserChannelConditions(88,46); varUser.SetUserChannelConditions(32,47);
    varUser.SetUserChannelConditions(9,48); varUser.SetUserChannelConditions(93,49);

    
//Packet Delays del 0.01 al 1 Segundo - 1 el mayor tiempo - 0.1 el menor-

    varUser.SetUserPacketDelays(0.03,0); varUser.SetUserPacketDelays(0.45,1);
    varUser.SetUserPacketDelays(0.4,2); varUser.SetUserPacketDelays(0.04,3);
    varUser.SetUserPacketDelays(0.05,4); varUser.SetUserPacketDelays(0.67,5);
    varUser.SetUserPacketDelays(0.01,6); varUser.SetUserPacketDelays(0.69,7);
    varUser.SetUserPacketDelays(0.9,8); varUser.SetUserPacketDelays(0.80,9);
    varUser.SetUserPacketDelays(0.94,10); varUser.SetUserPacketDelays(0.93,11);
    varUser.SetUserPacketDelays(0.02,12); varUser.SetUserPacketDelays(0.45,3);
    varUser.SetUserPacketDelays(0.92,14); varUser.SetUserPacketDelays(0.56,15);
    varUser.SetUserPacketDelays(0.015,16); varUser.SetUserPacketDelays(0.69,17);
    varUser.SetUserPacketDelays(0.038,18); varUser.SetUserPacketDelays(0.93,19);
    varUser.SetUserPacketDelays(0.076,20); varUser.SetUserPacketDelays(0.47,21);
    varUser.SetUserPacketDelays(0.36,22); varUser.SetUserPacketDelays(0.06,23);
    varUser.SetUserPacketDelays(0.39,24); varUser.SetUserPacketDelays(0.07,25);
    varUser.SetUserPacketDelays(0.8,26); varUser.SetUserPacketDelays(0.02,27);
    varUser.SetUserPacketDelays(0.056,28); varUser.SetUserPacketDelays(0.51,29);
    varUser.SetUserPacketDelays(0.91,30); varUser.SetUserPacketDelays(0.78,31);
    varUser.SetUserPacketDelays(0.86,32); varUser.SetUserPacketDelays(0.34,33);
    varUser.SetUserPacketDelays(0.45,34); varUser.SetUserPacketDelays(0.57,35);
    varUser.SetUserPacketDelays(0.066,36); varUser.SetUserPacketDelays(0.7,37);
    varUser.SetUserPacketDelays(0.62,38); varUser.SetUserPacketDelays(0.44,39);
    varUser.SetUserPacketDelays(0.59,40); varUser.SetUserPacketDelays(0.68,41);
    varUser.SetUserPacketDelays(0.24,42); varUser.SetUserPacketDelays(0.29,43);
    varUser.SetUserPacketDelays(0.32,44); varUser.SetUserPacketDelays(0.02,45);
    varUser.SetUserPacketDelays(0.58,46); varUser.SetUserPacketDelays(0.05,47);
    varUser.SetUserPacketDelays(0.68,48); varUser.SetUserPacketDelays(0.07,49);
    
   
//GBR Si GBR = true - No GBR = false

    
    varUser.SetUserGBR(false,0); varUser.SetUserGBR(true,1);
     varUser.SetUserGBR(true,2); varUser.SetUserGBR(false,3);
     varUser.SetUserGBR(false,4); varUser.SetUserGBR(true,5);
     varUser.SetUserGBR(false,6); varUser.SetUserGBR(false,7);
     varUser.SetUserGBR(true,8); varUser.SetUserGBR(false,9);
     varUser.SetUserGBR(true,10); varUser.SetUserGBR(true,11);
     varUser.SetUserGBR(true,12); varUser.SetUserGBR(false,13);
     varUser.SetUserGBR(false,14); varUser.SetUserGBR(false,15);
     varUser.SetUserGBR(false,16); varUser.SetUserGBR(true,17);
     varUser.SetUserGBR(true,18); varUser.SetUserGBR(false,19);
     varUser.SetUserGBR(false,20); varUser.SetUserGBR(true,21);
     varUser.SetUserGBR(false,22); varUser.SetUserGBR(false,23);
     varUser.SetUserGBR(true,24); varUser.SetUserGBR(false,25);
     varUser.SetUserGBR(false,26); varUser.SetUserGBR(true,27);
     varUser.SetUserGBR(true,28); varUser.SetUserGBR(true,29);
     varUser.SetUserGBR(true,30); varUser.SetUserGBR(true,31);
     varUser.SetUserGBR(true,32); varUser.SetUserGBR(true,33);
     varUser.SetUserGBR(false,34); varUser.SetUserGBR(true,35);
     varUser.SetUserGBR(false,36); varUser.SetUserGBR(true,37);
     varUser.SetUserGBR(true,38); varUser.SetUserGBR(true,39);
     varUser.SetUserGBR(false,40); varUser.SetUserGBR(true,41);
     varUser.SetUserGBR(false,42); varUser.SetUserGBR(false,43);
     varUser.SetUserGBR(false,44); varUser.SetUserGBR(false,45);
     varUser.SetUserGBR(false,46); varUser.SetUserGBR(false,47);
     varUser.SetUserGBR(false,48); varUser.SetUserGBR(true,49);
    
    varUser.Print_Values();
    //cout<< "MAX CH "<<varUser.ComputeMaxVal_User_Channel_Conditions()<<endl;
    //cout<< "MAX PD "<<varUser.ComputeMaxVal_User_Packet_Delays()<<endl;
    
    varUser.Print_Selected_Users();
    //varUser.Select_Final_Allocation_List();
   // varUser.Print_Final_Allocation_List();

    

		
	return 0;
}
Last edited on
Seriously? You're splitting your code over several different forum threads? That's going to make it a nightmare to try and have any kind of coherent discussion - or even to read and understand the entirety of your project.

Please consolidate this into a single thread, so that we can make sense of it.
Topic archived. No new replies allowed.