-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClasses_Final.cpp
More file actions
869 lines (768 loc) · 25.3 KB
/
Classes_Final.cpp
File metadata and controls
869 lines (768 loc) · 25.3 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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
#define SPEED 40
#include <iostream>
#include <cstring>
#include <ctime>
#include <queue>
#include <list>
#include <unordered_map>
#include <utility>
#include <vector>
#include <string>
#include <unordered_set>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <cctype>
using namespace std;
enum class CabSize:int {
Small = 4,
Large = 7
};
string changeUppercase(const string &str) {
string str1=str;
for (char &c : str1) {
c = toupper(c);
}
return str1;
}
bool ifpairExists(pair<string, int> p, list<pair<string, int>>& l) {
for (const auto& item : l) {
if (item == p) {
return true;
}
}
return false;
}
class Graph {
private:
int V;
unordered_map<string, unordered_map<string, float>> adj;
public:
Graph(int V) : V(V) {}
void addEdge(string u, string v, float weight) {
adj[u][v] = weight;
adj[v][u] = weight;
}
vector<pair<string, float>> dijkstra(string src, string dest) {
unordered_map<string, float> dist;
unordered_map<string, string> prev;
//To 'explore' nodes in order of distance from source
priority_queue<pair<float, string>, vector<pair<float, string>>, greater<pair<float, string>>> pq;
for (auto it = adj.begin(); it != adj.end(); ++it) {
const auto& u = *it;
dist[u.first] = 9999999999;
}
dist[src] = 0;
pq.push(make_pair(0, src));
while (!pq.empty()) {
//Pop node with minimum distance from pq
float u_dist = pq.top().first;
string u = pq.top().second;
pq.pop();
if (u == dest) {
break;
}
//Explore neighbours of current node
for (auto it = adj[u].begin(); it != adj[u].end(); ++it) {
string v = it->first;
float v_dist = it->second;
float alt = u_dist + v_dist; //alt is tentative distance to neighbour
if (alt < dist[v]) {
//Update distance from previous node for neighbour
dist[v] = alt;
prev[v] = u;
pq.push(make_pair(alt, v));
}
}
}
//Reconstruct path
vector<pair<string, float>> path;
string u = dest;
while (prev.count(u)) {
path.emplace_back(u, dist[u]);
u = prev[u];
}
path.emplace_back(src, 0);
reverse(path.begin(), path.end());
return path;
}
vector<vector<pair<string, float>>> yenKSP(string src, string dest, int K) {
//List of kth shortest paths
vector<vector<pair<string, float>>> paths;
//First shortest path
vector<pair<string, float>> shortestPath = dijkstra(src, dest);
paths.push_back(shortestPath);
//Find (K-1) more paths
for (int k = 1; k < K; k++) {
vector<vector<pair<string, float>>> candidates;
for (int i = 0; i < paths[k - 1].size() - 1; i++) {
string u = paths[k - 1][i].first;
string v = paths[k - 1][i + 1].first;
//Copy current graph
Graph g = *this;
//Remove edge from previous path
g.removeEdge(u, v);
//Calculate new path after removing edge
vector<pair<string, float>> path = g.dijkstra(src, dest);
if (!path.empty()) {
path.insert(path.begin(), paths[k - 1].begin(), paths[k - 1].begin() + i + 1); //combine paths
candidates.push_back(path);
}
}
if (candidates.empty()) {
break;
}
//Sort candidates by distance
for (int i = 0; i < candidates.size() - 1; i++) {
for (int j = 0; j < candidates.size() - i - 1; j++) {
float aDist = 0.0, bDist = 0.0;
for (const auto& p : candidates[j]) {
aDist += p.second;
}
for (const auto& p : candidates[j + 1]) {
bDist += p.second;
}
if (aDist > bDist) {
swap(candidates[j], candidates[j + 1]);
}
}
}
//Add new path if unique
bool foundNewPath = true;
for (const auto& path : paths) {
if (path == candidates[0]) {
foundNewPath = false;
break;
}
}
if (foundNewPath) {
paths.push_back(candidates[0]);
}
}
return paths;
}
private:
void removeEdge(string u, string v) {
adj[u].erase(v); //remove u-v
adj[v].erase(u); //remove v-u
}
};
// CLASS TIME
class Time{
public:
int hour;
int minute;
int second;
Time();
Time(int h, int m, int s);
Time(const Time& T);
~Time();
void displayTime() const;
Time currDifference()const;
Time operator+(const Time T2) const;
Time operator-(const Time T2) const;
Time addTime(int h,int m,int s);
Time subtractTime(int h, int m, int s);
bool operator<(const Time& other) const;
bool isValidTime() const;
};
// Default Constructor
Time::Time(){
hour=0;
minute=0;
second=0;
}
// Parameterised Constructor
Time :: Time(int h, int m, int s){
if ((h>=0 && h<=23) && (m>=0 && m <=59) && (s>=0&&s<=59)){
hour=h;
minute=m;
second=s;
}
else {
cout << "Invalid time arguments." << endl;
}
}
// Copy Constructor
Time:: Time(const Time &T){
hour=T.hour;
minute=T.minute;
second=T.second;
}
// Destructor
Time:: ~Time(){
}
// Function to display time format
void Time::displayTime() const{
int arr[3]={hour,minute,second};
for(int i=0;i<3;++i){
if( i==0){
if (arr[i]==24){
cout << "00" << ":";
}
}
if (arr[i]<10){
if( i==2){
cout << "0" << arr[i];
}
else{
cout << "0" << arr[i] << ":";
}
}
else {
if( i==2){
cout << arr[i];
}
else{
cout << arr[i] << ":";
}
}
}
}
//Function to calculate the time difference with the current time
Time Time::currDifference() const {
time_t currentTime = time(nullptr);
tm* localTime = localtime(¤tTime);
int currentTotalSeconds = localTime->tm_hour * 3600 + localTime->tm_min * 60 + localTime->tm_sec;
int storedTotalSeconds = hour * 3600 + minute * 60 + second;
int differenceSeconds = storedTotalSeconds-currentTotalSeconds;
Time diff;
diff.hour = differenceSeconds / 3600;
differenceSeconds %= 3600;
diff.minute = differenceSeconds / 60;
diff.second = differenceSeconds % 60;
return diff;
}
// Operator '+' Overloading
Time Time::operator+(const Time T2) const{
Time sum;
int s,m,h;
s=T2.second+this->second;
if (s<60){
sum.second=s;
}
else{
int n=s-60;
sum.minute+=(n/60);
sum.second=59;
}
m=T2.minute+this->minute;
if (m<60){
sum.minute=m;
}
else{
int q=m-60;
sum.hour+=(q/60);
sum.minute=59;
}
h=T2.hour+this->hour;
if(h>24){
int t=h-24;
h=t;
}
sum.hour=h;
return sum;
}
//Overator '-' overloading
Time Time::operator-(const Time T2) const{
int totalSeconds1 = hour * 3600 + minute * 60 + second;
int totalSeconds2 = T2.hour * 3600 + T2.minute * 60 + T2.second;
int differenceSeconds = totalSeconds1 - totalSeconds2;
if (differenceSeconds < 0) {
differenceSeconds += 24 * 3600;
}
Time diff;
diff.hour = differenceSeconds / 3600;
differenceSeconds %= 3600;
diff.minute = differenceSeconds / 60;
diff.second = differenceSeconds % 60;
return diff;
}
// Function to add time to the current time
Time Time:: addTime(int h,int m, int s){
this->second+=s;
this->minute=this->minute+m+second/60;
this->hour=this->hour+h+minute/60;
second %= 60;
minute %= 60;
hour %= 24;
return *this;
}
// Function to do subtract time from the current time
Time Time:: subtractTime(int h, int m, int s) {
second -= s;
minute -= m;
hour -= h;
while (second < 0) {
second += 60;
minute--;
}
while (minute < 0) {
minute += 60;
hour--;
}
while (hour < 0) {
hour+= 24;
}
return *this;
}
// Operator '<' Overloading
bool Time ::operator<( const Time& other) const {
int h1=this->hour;
int h2=other.hour;
if (this->hour == 0 && other.hour<10){
h1=this->hour;
}
else if (this->hour==0 && other.hour > 10){
h1=24;
}
else if (other.hour==0 && this->hour<10){
h2=other.hour;
}
else if(other.hour==0 && this->hour>10){
h2=24;
}
int totalSecondsThis = h1 * 3600 + minute * 60 + second;
int totalSecondsOther = h2 * 3600 + other.minute * 60 + other.second;
return totalSecondsThis < totalSecondsOther;
}
// Function to check whether the entered time is valid or not
bool Time:: isValidTime() const{
time_t currentTime = time(nullptr);
tm* localTime = localtime(¤tTime);
Time compare_t(localTime->tm_hour,localTime->tm_min,localTime->tm_sec);
if (compare_t < (*this) && this->hour <=23 && this->minute <=59 && this->second<=59 && this->hour>=0 && this->minute>=0 && this->second>=0){
return true;
}
else {
return false;
}
}
class User;
class Request{
public:
string name;
string user;
string location;
Time reporting_time;
CabSize cab_size;
Request();
~Request();
Request(const string& n, const string& u, const string& l, Time t, CabSize c);
void displayRequest();
friend User;
};
Request :: Request(){}
Request :: Request(const string& n, const string& u, const string& l, Time t, CabSize c){
name=n;
user=u;
location=l;
reporting_time=t;
cab_size=c;
}
Request :: ~Request(){}
void Request::displayRequest() {
cout << "Name: " << name << endl;
cout << "User: " << user << endl;
cout << "Location: " << location << endl;
cout << "Reporting Time: ";
reporting_time.displayTime();
cout << "Cab Size: ";
switch (cab_size) {
case CabSize::Small:
cout << "Small" << endl;
break;
case CabSize::Large:
cout << "Large" << endl;
break;
}
}
bool checkLocation(const string& s, const string& filename) {
ifstream file(filename);
if (!file.is_open()) {
cerr << "Could not open the file!" << endl;
return false;
}
string line;
while (getline(file, line)) {
stringstream ss(line);
string cell;
while (getline(ss, cell, ',')) {
if (cell == s) {
file.close();
return true;
}
}
}
file.close();
return false;
}
class User {
friend Request;
private:
string name;
string Id;
public:
User(){
setName();
setId();
}
User(string& newName, string& newId):name(newName), Id(newId) {}
// Getters (Accessors)
string getName() {
return name;
}
string getId(){
return Id;
}
// Setters (Mutators)
void setName() {
cout << "Enter name: ";
cin.ignore();
getline(cin,name);
}
void setId() {
cout << "Enter ID: ";
cin.ignore();
getline(cin,Id);
}
// Function to book a ride request
Request bookRequest() {
string loc;
string l;
bool ans1=false;
while (ans1==false){
cout << "Enter valid destination: " ;
getline(cin,loc);
l=changeUppercase(loc);
ans1=checkLocation(l,"places_and_connections-2.csv");
}
int h,m;
bool ans=false;
Time t;
while ( ans==false){
cout << "Enter hour: " ;
cin >> h;
if (h==0){
h+=24;
}
cout << "Enter minutes: " ;
cin >> m;
Time check_t(h,m,0);
t=check_t;
ans=check_t.isValidTime();
}
int cabSizeInt;
cout << "Enter preferred cab size (4 for Small, 7 for Large): ";
cin >> cabSizeInt;
cin.ignore();
CabSize cabSize;
if (cabSizeInt == 4) {
cabSize = CabSize::Small;
}
else if (cabSizeInt == 7) {
cabSize = CabSize::Large;
}
else {
cout << "Invalid input. ";
return Request();
}
string location=changeUppercase(l);
string n=changeUppercase(getName());
string i=changeUppercase(getId());
Request r(n, i, location, t, cabSize);
this->writeRequestToCSV("requests-1.csv",r);
return r;
}
// Function to transfer the ride request to the CSV file
void writeRequestToCSV(const string& filename, const Request& request) {
ofstream file(filename, ios::app);
if (file.is_open()) {
file << request.name << "," << request.user << "," << request.location << ","
<< request.reporting_time.hour << ":" << request.reporting_time.minute << ","
<< static_cast<int>(request.cab_size) << "\n";
file.close();
} else {
cout << "Unable to open the file." << endl;
}
}
// Function to check whether the request exists in the CSV file
bool isRequest(const string& name) {
string s=changeUppercase(name);
ifstream file("requests-1.csv");
if (!file.is_open()) {
cout << "Unable to open the file." << endl;
return false;
}
string line;
while (getline(file, line)) {
stringstream ss(line);
string requestName;
getline(ss, requestName, ',');
requestName.erase(0, requestName.find_first_not_of(" \t\r\n"));
requestName.erase(requestName.find_last_not_of(" \t\r\n") + 1);
if (requestName == s) {
file.close();
return true;
}
}
file.close();
return false;
}
// Function to find the ride request in the CSV file
static Request findRequest(const string &name) {
string s=changeUppercase(name);
ifstream file("requests-1.csv");
if (!file.is_open()) {
cout << "Unable to open the file." << endl;
return Request();
}
string line;
while (getline(file, line)) {
stringstream ss(line);
string requestName;
getline(ss, requestName, ',');
requestName.erase(0, requestName.find_first_not_of(" \t\r\n"));
requestName.erase(requestName.find_last_not_of(" \t\r\n") + 1);
if (requestName == s) {
string user, location, timeStr;
int cabSizeInt, hour, minute;
char comma;
getline(ss, user, ',');
getline(ss, location, ',');
getline(ss, timeStr, ',');
ss >> cabSizeInt;
ss.ignore();
sscanf(timeStr.c_str(), "%d:%d", &hour, &minute);
Time reportingTime(hour, minute, 0);
CabSize cabSize = (cabSizeInt == 4) ? CabSize::Small : CabSize::Large;
file.close();
return Request(name, user, location, reportingTime, cabSize);
}
}
file.close();
return Request();
}
};
// Class UserGroup
class UserGroup{
public:
CabSize cab_size;
Time time_slot;
vector <pair < Time, Request > > v;
UserGroup();
UserGroup(CabSize c,Time t);
~UserGroup();
void displayUserGroup();
void addToGroup(const pair<Time, Request>& newPair);
bool isGroupFull();
const string& findUser(const string& name);
bool checkOne() const;
};
UserGroup::UserGroup(){}
UserGroup::UserGroup(CabSize c,Time t):time_slot(t),cab_size(c){}
UserGroup::~UserGroup(){}
// Function to display the details of UserGroup class
void UserGroup::displayUserGroup() {
cout << "Cab Size: " << static_cast<int>(cab_size) << endl;
cout << "Time Slot: From ";
Time upper=time_slot.addTime(0,20,0);
Time lower=time_slot.subtractTime(0,40,0);
lower.displayTime();
cout << " to " ;
upper.displayTime();
cout << "\n";
cout << "\n Users: " << endl;
cout << endl;
for (const auto& pair : v) {
cout << "Name: " << pair.second.name << " | " ;
cout << "UserId: " << pair.second.user << " | ";
cout << "Location: " << pair.second.location << " | ";
cout << "Time: " ;
pair.first.displayTime();
cout << " | \n";
cout << endl;
}
}
// Function to add ride requests to the group
void UserGroup::addToGroup(const pair<Time, Request>& newPair) {
v.push_back(newPair);
}
// Function to find users in the group
const string& UserGroup::findUser(const string& name) {
static const string empty_location = "";
for (const auto& pair : v) {
if (pair.second.user == name) {
return pair.second.location;
}
}
return empty_location;
}
// Function to validate whether the group is full or not
bool UserGroup::isGroupFull() {
return v.size() == static_cast<size_t>(cab_size);
}
bool UserGroup::checkOne() const{
return v.size() <= 1;
}
struct CompareTime {
bool operator()(const pair<Time, Request>& p1, const pair<Time, Request>& p2) const {
return p2.first < p1.first;
}
};
// Function to read requests from file
void readRequestsFromFile(const string& filename, priority_queue<pair<Time, Request>, vector<pair<Time, Request>>, CompareTime>& pq) {
ifstream file(filename);
if (!file.is_open()) {
cout << "Error opening file: " << filename << endl;
return;
}
string line;
getline(file, line);
while (getline(file, line)) {
stringstream ss(line);
string name, user, location;
int hour, minute;
int cabSizeInt;
getline(ss, name, ',');
getline(ss, user, ',');
getline(ss, location, ',');
ss >> hour;
ss.ignore();
ss >> minute;
ss.ignore();
ss >> cabSizeInt;
CabSize cabSize;
if (cabSizeInt == 4) {
cabSize = CabSize::Small;
} else if (cabSizeInt == 7) {
cabSize = CabSize::Large;
} else {
cout << "Invalid cab size: " << cabSizeInt << endl;
continue;
}
Time reportingTime(hour, minute, 0);
Request request(name, user, location, reportingTime, cabSize);
pq.push(make_pair(reportingTime, request));
}
file.close();
}
// User-Grouping Algorithm
list <pair<list<pair<string,int> >, UserGroup > > UserGroupingAlgorithm(priority_queue<pair<Time, Request>, vector<pair<Time, Request>>, CompareTime> pq, Request &r, Graph &g){
Time c_time=r.reporting_time;
Time upper=c_time.addTime(0,20,0);
Time lower=c_time.subtractTime(0,40,0);
list < pair<list<pair<string, int> >,UserGroup > > path_list;
list <pair <Time,Request> > temp_list;
list <pair<Time,Request> > new_list;
while(!pq.empty()){
new_list.push_back(pq.top());
pq.pop();
}
list <pair <Time,Request> > :: iterator new_it=new_list.begin();
pair <Time,Request> pair1=make_pair(r.reporting_time,r);
while(new_it!=new_list.end()){
if (new_it->first < upper && lower < new_it->first){
temp_list.push_back(*new_it);
}
new_it++;
}
string desired_dest=r.location;
vector <vector <pair <string,float> > > paths=g.yenKSP("PLAKSHA", desired_dest, 2);
vector <vector <pair <string, float > > > :: iterator v_main=paths.begin();
while(v_main!=paths.end()){
vector < pair < string, float > > :: iterator v_mini=v_main->begin();
list <pair<string,int> > l;
UserGroup g(r.cab_size, r.reporting_time);
while(v_mini!=v_main->end()){
list <pair<Time, Request> >:: iterator lit = temp_list.begin();
while(lit!=temp_list.end()){
if (lit->second.location==v_mini->first){
float time=(v_mini->second/SPEED);
int m=static_cast<int>(time*60);
if (g.isGroupFull()==false){
g.addToGroup(*lit);
}
pair <string,int> p=make_pair(lit->second.location,m);
if ( ifpairExists(p,l)==false){
l.push_back(p);
}
}
lit++;
}
v_mini++;
}
pair <list<pair<string,int> > , UserGroup > p_main=make_pair(l,g);
path_list.push_back(p_main);
v_main++;
}
return path_list;
}
// Display Function
void displayOptions(list < pair<list<pair<string, int> >,UserGroup > > path_list,Request &r){
list < pair <list<pair<string, int> >,UserGroup> > :: iterator main_it=path_list.begin();
int count=1;
while(main_it!=path_list.end()){
cout << "\nOPTION " << count << " : " << endl;
if (main_it->second.checkOne() == true) {
cout << "\nNo carpoolers found, you have an option to travel alone :(." << endl;
cout << "\nYour cab details are as follows. \n" << endl;
main_it->second.displayUserGroup();
}
else {
cout << "Carpoolers found !\n " << endl;
main_it->second.displayUserGroup();
}
list <pair<string,int>> ::iterator s_it=main_it->first.begin();
cout << "The path of the cab:" << endl;
cout << "\nPlaksha->" ;
while(s_it!=main_it->first.end()){
cout << s_it->first << "(" << s_it->second << " minutes to reach) ->";
s_it++;
}
cout << "\n" ;
main_it++;
count++;
}
}
// Function to determine the most optimised route choice
void mostOptimisedChoice(list < pair<list<pair<string, int> >,UserGroup > > path_list,Request &r){
list < pair<list<pair<string, int> >, UserGroup> > :: iterator main_it2=path_list.begin();
int min_t=10000;
while(main_it2!=path_list.end()){
list <pair<string,int> > ::iterator s_it2=main_it2->first.begin();
while(s_it2!=main_it2->first.end()){
if (s_it2->first ==r.location){
if(min_t > s_it2->second){
min_t=s_it2->second;
}
}
s_it2++;
}
main_it2++;
}
list < pair<list<pair<string, int> >, UserGroup> > :: iterator main_it3=path_list.begin();
while(main_it3!=path_list.end()){
list <pair<string,int> > ::iterator s_it3=main_it3->first.begin();
while(s_it3!=main_it3->first.end()){
if (s_it3->first ==r.location){
if(min_t==s_it3->second){
cout << "THE MOST OPTIMISING CHOICE: " << endl;
cout << "\n You will reach in " << min_t << " minutes!" << endl;
if (main_it3->second.checkOne() == true){
cout << "\nIn this option, you will unfortunately not have any carpoolers. :( " << endl;
cout << "\nYour cab details are as follows.\n " << endl;
main_it3->second.displayUserGroup();
}
else{
cout << "\nYour carpooling details are...\n " << endl;
main_it3->second.displayUserGroup();
}
break;
}
}
s_it3++;
}
main_it3++;
}
}