4 #include "../couples/couple.h" 5 #include "../boys/allboys.h" 6 #include "../girls/allgirls.h" 15 std::vector<Girl*> girls,
Logger *logger)
17 std::vector<Couple> couples;
20 for (i = 0; i < (int)girls.size(); i++) {
21 if (girls[i]->committed)
continue;
24 switch (girls[i]->boy_type) {
37 for (j = 0; j < (int)boys.size(); j++) {
38 if (boys[j]->committed)
continue;
39 logger->
log(
"Match",
"Checking compatibility of "+boys[j]->name+
" and "+girls[i]->name,
false);
40 if (boys[j]->isCompatible( girls[i] ) &&
41 girls[i]->isCompatible( boys[j] ) ) {
43 couples.push_back(
Couple((boys)[j], girls[i]) );
44 boys[j]->committed =
true;
45 girls[i]->committed =
true;
46 logger->
log(
"Committed", boys[j]->name+
" and "+girls[i]->name +
" committed",
false);
59 std::vector<Girl*> girls,
Logger *logger)
63 std::vector<Girl*> girlsCopy = girls;
64 std::vector<Boy*> boysCopy = boys;
65 std::vector<Couple> couples;
68 for (i = 0; i < (int)girls.size(); i++) {
69 if (girls[i]->committed)
continue;
75 switch (girls[i]->boy_type) {
88 for (j = 0; j < (int)boysCopy.size(); j++) {
89 if (boysCopy[j]->committed)
continue;
90 logger->
log(
"Match",
"Checking compatibility of "+boysCopy[j]->name+
" and "+girls[i]->name,
false);
91 if (boysCopy[j]->isCompatible( girls[i] ) &&
92 girls[i]->isCompatible( boys[j] ) ) {
94 couples.push_back(
Couple((boysCopy)[j], girls[i]) );
95 boysCopy[j]->committed =
true;
96 girls[i]->committed =
true;
97 logger->
log(
"Committed", boysCopy[j]->name+
" and "+girls[i]->name +
" committed",
false);
105 Boy *singleBoy = boys[0];
106 for (
int i = 0; i < (int)boys.size() && boys[i]->committed; i++)
112 for (
auto it = girlsCopy.begin(); it != girlsCopy.end(); it++) {
113 if ((*it)->committed)
continue;
114 couples.push_back(
Couple(singleBoy, *it) );
116 (*it)->committed =
true;
117 logger->
log(
"Committed", singleBoy->
name+
" and "+(*it)->name+
" committed",
false);
131 for (
auto it = couples->begin(); it != couples->end(); it++)
132 it->makeGiftBasket(*giftlist, logger);
140 for (
auto it = couples->begin(); it != couples->end(); it++)
141 it->makeGiftBasket2(*giftlist, logger);
150 std::vector<Couple> happyCouples (couples.begin(), couples.begin() + k);
160 std::vector<Couple> happyCouples (couples.begin(), couples.begin() + k);
170 std::vector<Couple> unhappyCouples (couples.begin(), couples.begin() + k);
171 return unhappyCouples;
180 std::vector<Couple> retvalue;
182 for (
auto it = couples.begin(); it != couples.end(); it++) {
183 if (it->findHappiness() < t)
184 retvalue.push_back(*it);
194 std::vector<Couple> *couples,
195 std::vector<Boy*> *boys,
196 std::vector<Girl*> *girls,
199 std::vector<Couple> newCouples;
201 for (std::vector<Couple>::iterator it = happyCouples.begin(); it != happyCouples.end(); it++) {
202 auto girl = it->girl;
206 switch (girl->boy_type) {
219 for (
int j = 0; j < (int)boys->size(); j++) {
220 if ((*boys)[j]->committed ||
221 (*boys)[j]->name == boy->name)
223 logger->
log(
"Match",
"Checking compatibility of "+(*boys)[j]->name+
" and "+(*boys)[j]->name,
false);
224 if ((*boys)[j]->isCompatible( girl ) &&
225 girl->isCompatible( (*boys)[j] ) ) {
227 newCouples.push_back(
Couple((*boys)[j], girl) );
228 (*boys)[j]->committed =
true;
229 girl->committed =
true;
230 logger->
log(
"Committed", (*boys)[j]->name+
" and "+girl->name +
" committed",
false);
236 auto newCouplesItr = newCouples.begin();
237 for (
auto it = happyCouples.begin(); it != happyCouples.end(); it++) {
238 for (
auto jt = couples->begin(); jt != couples->end() && newCouplesItr != newCouples.end(); jt++) {
239 if (it->boy->name == jt->boy->name) {
241 couples->push_back(*newCouplesItr);
253 std::vector<Couple> *couples,
254 std::vector<Boy*> *boys,
255 std::vector<Girl*> *girls,
259 std::vector<Couple> newCouples;
261 for (std::vector<Couple>::iterator it = sadCouples.begin(); it != sadCouples.end(); it++) {
262 auto girl = it->girl;
266 switch (girl->boy_type) {
279 for (
int j = 0; j < (int)boys->size(); j++) {
280 if ((*boys)[j]->committed ||
281 (*boys)[j]->name == boy->name)
283 logger->
log(
"Match",
"Checking compatibility of "+(*boys)[j]->name+
" and "+(*boys)[j]->name,
false);
284 if ((*boys)[j]->isCompatible( girl ) &&
285 girl->isCompatible( (*boys)[j] ) ) {
287 newCouples.push_back(
Couple((*boys)[j], girl) );
288 (*boys)[j]->committed =
true;
289 girl->committed =
true;
290 logger->
log(
"Committed", (*boys)[j]->name+
" and "+girl->name +
" committed",
false);
296 auto newCouplesItr = newCouples.begin();
297 for (
auto it = sadCouples.begin(); it != sadCouples.end(); it++) {
298 for (
auto jt = couples->begin(); jt != couples->end() && newCouplesItr != newCouples.end(); jt++) {
299 if (it->boy->name == jt->boy->name) {
301 couples->push_back(*newCouplesItr);
void log(const std::string type, const std::string msg, bool print=false)
std::vector< Couple > getKCompatibleCouples(std::vector< Couple > couples, int k)
bool compareOnIntelligence(Boy *b1, Boy *b2)
std::vector< Couple > makeCouplesAlternatively(std::vector< Boy * > boys, std::vector< Girl * > girls, Logger *logger)
void performBreakupOnHappinessAndPairAgain(std::vector< Couple > sadCouples, std::vector< Couple > *couples, std::vector< Boy * > *boys, std::vector< Girl * > *girls, int t, Logger *logger)
void performGifting(std::vector< Couple > *couples, std::vector< Gift > *giftlist, Logger *logger)
std::vector< Couple > getKHappiestCouples(std::vector< Couple > couples, int k)
std::vector< Couple > getKUnhappiestCouples(std::vector< Couple > couples, int k)
std::vector< Couple > makeCouples(std::vector< Boy * > boys, std::vector< Girl * > girls, Logger *logger)
bool compareOnAttractiveness(Boy *b1, Boy *b2)
bool compareOnMaintenanceCost(Girl *g1, Girl *g2)
void performBreakupAndPairAgain(std::vector< Couple >happyCouples, std::vector< Couple > *couples, std::vector< Boy * > *boys, std::vector< Girl * > *girls, Logger *logger)
void performGifting2(std::vector< Couple > *couples, std::vector< Gift > *giftlist, Logger *logger)
bool compareOnRichness(Boy *b1, Boy *b2)
bool compareOnHappiness(Couple c1, Couple c2)
std::vector< Couple > getCouplesWithHappinessLessThan(std::vector< Couple >couples, int t)
bool compareOnCompatibility(Couple c1, Couple c2)