-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathI.h
More file actions
326 lines (310 loc) · 6.41 KB
/
I.h
File metadata and controls
326 lines (310 loc) · 6.41 KB
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
325
326
/*
* I.h
*
* Created on: 10-Oct-2013
* Author: 123
*/
/**<
I.h is the header file which parse the details of universities structure and store the details in their respective structures
*/
#ifndef I_H_
#define I_H_
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <sstream>
#include <omp.h>
#include <map>
#include <queue>
#include <random>
using namespace std;
struct Student;
struct Faculty;
struct Department;
/**<
Structure to store students of a particular interest
*/
struct globalInterest{
vector<Student*> glo_in;
globalInterest(){}
};
/**<
Structure storing different randomseed
*/
struct Randomseed
{
public:
float faculty_random;
float student_random;
float course_random;
float friend_random;
Randomseed(){}
Randomseed(float a,float b,float c,float d)
{
this->faculty_random = a;
this->student_random = b;
this->course_random = c;
this->friend_random = d;
}
};
/**<
Structure storing students of a Hostel
*/
struct HOSTEL
{
string name;
vector<Student*> stu_hostel;
HOSTEL(string n)
{
this->name = n;
}
};
/**<
Structure representing Courses having specifications
*/
struct Courses
{
public :
string name;
string dep_offer;
Department* depp_offer;
float freq_peryr;
Faculty* prof;
vector<Student*> students;
Courses(){}
Courses(string n,string d,float f)
{
this->name = n;
this->freq_peryr = f;
this->dep_offer = d;
}
};
/**<
Structure storing Interest with its name and popularity
*/
struct Interest
{
public:
string name;
float popularity;
//vector<Student*> interest_student;
//vector<Faculty*> interest_faculty;
Interest(string a,float b)
{
this->name = a;
this->popularity = b;
}
};
/**<
Structure of Department storing its name, number of faculty, number of students per year , Courses under the department and faculty under the department
*/
struct Department
{
public:
string name;
int num_faculty;
int num_student_peryr;
float sem_deptc;
float sem_nondeptc;
vector<Courses*> floatedCourses;
vector<Faculty*> dep_faculty;
Department(){}
Department(string v,int n_f,int n_s,float s_d,float s_n)
{
this->name = v;
this->num_faculty = n_f;
this->num_student_peryr = n_s;
this->sem_deptc = s_d;
this->sem_nondeptc = s_n;
}
};
/**<
Class of university having objects Courses,departments,Hostels,Houselocality,Students,Interest
*/
class University
{
public:
vector<Courses*> Course;
vector<Department*> dept;
vector<string> Hostel;
vector<HOSTEL*> hostels_univ;
vector<string> HouseLocality;
vector<Student*> students;
vector<Faculty*> profs;
vector<Interest> Interests_univ;
string name;
float openness;
float friendliness;
float friendshiprate;
University(string a){
this->name = a;
}
};
/**<
Structure of node to define general charachteristic of student and faculty
*/
struct node
{
public:
string name;
Department* dept;
string home;
vector<Interest> interest;
vector<string> friends;
vector<Courses*> courses;
University* univ;
node(){}
node(string n,Department* d,string h,vector<Interest> i,University* u)
{
this->univ= u;
this->dept = d;
this->name = n;
this->home = h;
this->interest = i;
}
};
/**<
Structure of faculty
*/
struct Faculty
{
public:
string employecode;
node* info;
Faculty(){}
Faculty(string e,node* p)
{
this->employecode = e;
this->info = p;
}
};
/**<
Structure of Student
*/
struct Student
{
public:
string entrynumber;
HOSTEL* home;
char floorno;
int room;
node* info;
Student(){}
Student(string e,node* p,HOSTEL* h,char a,int b){
this->entrynumber = e;
this->info = p;
this-> home = h;
this->floorno = a;
this->room = b;
}
};
/**<
Function to parse input file and storing data
*/
void create(map<int,University*> *Univs,Randomseed *randomseed,map<string,globalInterest*> *In)
{
string line;
int i=-1;
ifstream input ("input.txt");
if (input.is_open())
{
while (input.good())
{
getline(input,line);
string x;
stringstream s(line);
while (s >> x){
if(x == "UNIVERSITY")
{
i++;
s >> x;
University *U1 = new University(x);
(*Univs)[i] = U1;
}
else if(x == "DEPARTMENT")
{
s>>x;
string a = x;
s>>x;
float b = atof(x.c_str());
s>>x;
float c = atof(x.c_str());
s>>x;
float d = atof(x.c_str());
s>>x;
float e = atof(x.c_str());
//cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;
Department *d1 = new Department(a,b,c,d,e);
Univs->at(i)->dept.push_back(d1);
}
else if(x == "COURSE")
{
s>>x;
string a = x;
s>>x;
string b = x;
s>>x;
float c = atof(x.c_str());
Courses *c1 = new Courses(a,b,c);
Univs->at(i)->Course.push_back(c1);
}
else if(x == "INTEREST")
{
s >> x;
string tempname = x;
s >> x;
Interest in = Interest(tempname,atof(x.c_str()));
Univs->at(i)->Interests_univ.push_back(in);
if(In->find(tempname) == In->end()){
globalInterest *g = new globalInterest();
(*In)[tempname] = g;
// cout << "\n inserted " << tempname;
}
}
else if(x == "HOSTEL")
{
s>>x;
Univs->at(i)->Hostel.push_back(x);
HOSTEL* h = new HOSTEL(x);
Univs->at(i)->hostels_univ.push_back(h);
}
else if(x == "HOUSELOCALITY")
{
s>>x;
Univs->at(i)->HouseLocality.push_back(x);
}
else if(x == "FRIENDSHIPRATE")
{
s>>x;
Univs->at(i)->friendshiprate = atof(x.c_str());
}
else if(x == "OPENNESS")
{
s>>x;
Univs->at(i)->openness = atof(x.c_str());
}
else if(x == "FRIENDLINESS")
{
s>>x;
Univs->at(i)->friendliness = atof(x.c_str());
}
else if(x == "RANDOMSEED")
{
s>>x;
float a = atof(x.c_str());
s>>x;
float b = atof(x.c_str());
s>>x;
float c = atof(x.c_str());
s>>x;
float d = atof(x.c_str());
(*randomseed) = Randomseed(a,b,c,d);
}
}
}
input.close();
}
}
#endif /* I_H_ */