Commit e5265b0e authored by Alexis Lebis's avatar Alexis Lebis

prerequisitesConstraints ok

parent ee30dd60
...@@ -66,8 +66,8 @@ int main(int argc, char* argv[]){ ...@@ -66,8 +66,8 @@ int main(int argc, char* argv[]){
CSDVP pb; CSDVP pb;
Profession job; Profession job;
// ===== PB CONFIG ZONE ===== // ===== PB CONFIG ZONE =====
pb.set_cfg_quantityCourses(15); pb.set_cfg_quantityCourses(10);
pb.set_cfg_quantityCompetencies(15); pb.set_cfg_quantityCompetencies(5);
pb.set_cfg_minimalTimeFrames(1); pb.set_cfg_minimalTimeFrames(1);
pb.set_cfg_maximalTimeFrames(6); //Just "Licence" pb.set_cfg_maximalTimeFrames(6); //Just "Licence"
pb.set_cfg_ectsMin(1); pb.set_cfg_ectsMin(1);
...@@ -79,11 +79,11 @@ int main(int argc, char* argv[]){ ...@@ -79,11 +79,11 @@ int main(int argc, char* argv[]){
pb.set_cfg_minimalCompetencyByCourse(1); pb.set_cfg_minimalCompetencyByCourse(1);
pb.set_cfg_maximalCompetencyByCourse(3); pb.set_cfg_maximalCompetencyByCourse(3);
pb.set_cfg_minimalPrerequisiteByCourse(0); pb.set_cfg_minimalPrerequisiteByCourse(0);
pb.set_cfg_maximalPrerequisiteByCourse(2); pb.set_cfg_maximalPrerequisiteByCourse(1);
pb.set_cfg_pickedCoursesByTimeFrame(2); pb.set_cfg_pickedCoursesByTimeFrame(2);
CSDVP::generateProblem(pb, CSDVP::GenerationType::RANDOM, 7777); CSDVP::generateProblem(pb, CSDVP::GenerationType::RANDOM, 11);
assert(pb.checkConfig()); assert(pb.checkConfig());
job.setRequiredECTS(4 * 6); job.setRequiredECTS(4 * 6);
...@@ -93,8 +93,8 @@ int main(int argc, char* argv[]){ ...@@ -93,8 +93,8 @@ int main(int argc, char* argv[]){
job.addPrerequisite(tmpC); job.addPrerequisite(tmpC);
tmpC = Competency::build(0.5,"Wesh"); tmpC = Competency::build(0.5,"Wesh");
job.addPrerequisite(tmpC); job.addPrerequisite(tmpC);
tmpC = pb.competencyCatalogue().at(8); // tmpC = pb.competencyCatalogue().at(8);
job.addPrerequisite(tmpC); // job.addPrerequisite(tmpC);
// ===== END PB CONFIG ===== // ===== END PB CONFIG =====
Cursus c1; Cursus c1;
...@@ -103,7 +103,7 @@ int main(int argc, char* argv[]){ ...@@ -103,7 +103,7 @@ int main(int argc, char* argv[]){
std::cout << "cfg_quantityCourses() : " << std::to_string(pb.cfg_quantityCourses()) << std::endl; std::cout << "cfg_quantityCourses() : " << std::to_string(pb.cfg_quantityCourses()) << std::endl;
/**@todo make size of the pb accessible as well as size of an individu*/ /**@todo make size of the pb accessible as well as size of an individu*/
int size_of_the_pb = 30; int size_of_the_pb = 3;
ConstraintsECTS ctrECTS(pb, job); ConstraintsECTS ctrECTS(pb, job);
ConstraintsRepetition ctrRep(pb, job); ConstraintsRepetition ctrRep(pb, job);
...@@ -112,7 +112,7 @@ int main(int argc, char* argv[]){ ...@@ -112,7 +112,7 @@ int main(int argc, char* argv[]){
std::pair<bool,double> res; std::pair<bool,double> res;
//CursusInit init(pb.getQuantityCoursesToPick()-5,0); //CursusInit init(pb.getQuantityCoursesToPick()-5,0);
CursusInit init(pb.getQuantityCoursesToPick(),pb.coursesCatalogue().size(),pb.seed()); CursusInit init(pb.getQuantityCoursesToPick()-6,pb.coursesCatalogue().size(),pb.seed());
//pb.cfg_quantityCourses());//pb.getQuantityCoursesToPick(),pb.cfg_quantityCourses(), pb.seed()); //pb.cfg_quantityCourses());//pb.getQuantityCoursesToPick(),pb.cfg_quantityCourses(), pb.seed());
CursusEval eval; CursusEval eval;
...@@ -139,6 +139,19 @@ int main(int argc, char* argv[]){ ...@@ -139,6 +139,19 @@ int main(int argc, char* argv[]){
//res = ctrJob.integrityCheck(c1); //res = ctrJob.integrityCheck(c1);
res = ctrPrq.integrityCheck(c1); res = ctrPrq.integrityCheck(c1);
std::cout << "IND#" << std::to_string(i) << "\nFirst: " << res.first << "\nSecond: " << std::to_string((double)res.second) << std::endl; std::cout << "IND#" << std::to_string(i) << "\nFirst: " << res.first << "\nSecond: " << std::to_string((double)res.second) << std::endl;
if(res.first)
{
std::cout << "*************** OK PREREQ !! ***********" << std::endl;
}
else
{
std::cout << "$$$$$$$$$$$$$$$$ NON OK PREREQ !! $$$$$$$$$$$$$$$$$$$" << std::endl;
}
for(int i = 0 ; i < c1.size(); i++)
{
std::cout << pb.coursesCatalogue().at(c1.at(i)) << std::endl;
}
pop.push_back(c1); pop.push_back(c1);
} }
//MUTATION TEST //MUTATION TEST
......
...@@ -55,6 +55,22 @@ std::pair<bool, double> ConstraintsPrerequisites::integrityCheck(Cursus indiv) ...@@ -55,6 +55,22 @@ std::pair<bool, double> ConstraintsPrerequisites::integrityCheck(Cursus indiv)
//std::cout << "\tPrereq: " << std::to_string(currentCourse.prerequisites().size()) << std::endl; //std::cout << "\tPrereq: " << std::to_string(currentCourse.prerequisites().size()) << std::endl;
nbPrereq += currentCourse.prerequisites().size(); nbPrereq += currentCourse.prerequisites().size();
//Handling prereq
// Check if prerequisites exists in TF-1
if(currentTF > 0)
{
prereqFound = this->_prereqsInPreviousTF(compByTF.at(currentTF-1), currentCourse.prerequisites());
}
else
{
prereqFound = this->_prereqsInPreviousTF(std::vector<Competency>(0), currentCourse.prerequisites());
}
notFound += prereqFound.first;
notRespected += prereqFound.second;
// Handling teached comp
for(int j = 0; j < currentCourse.teachedCompetenciesWeighted().size() ; j++) for(int j = 0; j < currentCourse.teachedCompetenciesWeighted().size() ; j++)
{ {
currentCompetency = currentCourse.teachedCompetenciesWeighted().at(j).first; currentCompetency = currentCourse.teachedCompetenciesWeighted().at(j).first;
...@@ -75,24 +91,11 @@ std::pair<bool, double> ConstraintsPrerequisites::integrityCheck(Cursus indiv) ...@@ -75,24 +91,11 @@ std::pair<bool, double> ConstraintsPrerequisites::integrityCheck(Cursus indiv)
//compToAnswer.at(posFound.first) = e.getCompetency(); //compToAnswer.at(posFound.first) = e.getCompetency();
//std::cout << "INFO:\n(during ConstraintsProfession)\n\n Compentecy evolution throw an exception. Auto rebase. New value is " << e.getCompetency() << std::endl; //std::cout << "INFO:\n(during ConstraintsProfession)\n\n Compentecy evolution throw an exception. Auto rebase. New value is " << e.getCompetency() << std::endl;
//std::cout << "Comp rebased val is" << compByTF.at(currentTF).at(alreadyExists.first) << std::endl; //std::cout << "Comp rebased val is" << compByTF.at(currentTF).at(alreadyExists.first) << std::endl;
std::cout << "exception.Rebased"; std::cout << currentCompetency.c_name() << "exception.Rebased" << std::endl;
} }
} }
else else
{ {
// Check if prerequisites exists in TF-1
if(currentTF > 0)
{
prereqFound = this->_prereqsInPreviousTF(compByTF.at(currentTF-1), currentCourse.prerequisites());
}
else
{
prereqFound = this->_prereqsInPreviousTF(std::vector<Competency>(0), currentCourse.prerequisites());
}
notFound += prereqFound.first;
notRespected += prereqFound.second;
compByTF.at(currentTF).push_back(Competency::build(currentCompetency.c_magnitude().value(), currentCompetency.c_name())); compByTF.at(currentTF).push_back(Competency::build(currentCompetency.c_magnitude().value(), currentCompetency.c_name()));
} }
} }
...@@ -109,11 +112,24 @@ std::pair<bool, double> ConstraintsPrerequisites::integrityCheck(Cursus indiv) ...@@ -109,11 +112,24 @@ std::pair<bool, double> ConstraintsPrerequisites::integrityCheck(Cursus indiv)
} }
bool isOK = ((notFound == 0) && (notRespected == 0)); bool isOK = ((notFound == 0) && (notRespected == 0));
std::cout << "========== PREREQ CSTR RES ==========" << std::endl;
std::cout << "Not Found: " << std::to_string(notFound) << std::endl; std::cout << "Not Found: " << std::to_string(notFound) << std::endl;
std::cout << "Not Respected: " << std::to_string(notRespected) << std::endl; std::cout << "Not Respected: " << std::to_string(notRespected) << std::endl;
std::cout << "Nb Prereq: " << std::to_string(nbPrereq) << std::endl; std::cout << "Nb Prereq: " << std::to_string(nbPrereq) << std::endl;
double metric = 1.0 - ( (((double)2 * (double)notFound) + (double)notRespected ) / (2 * (double) nbPrereq) ); double metric = 0;
if(nbPrereq > 0)
{
metric = 1.0 - ( (((double)2 * (double)notFound) + (double)notRespected ) / (2 * (double) nbPrereq) );
}
else //can't divide by 0
{
if(isOK)
metric = 1;
else
metric = 0;
}
std::cout << "Metric: " << std::to_string(metric) << std::endl; std::cout << "Metric: " << std::to_string(metric) << std::endl;
std::cout << "====================" << std::endl;
return std::pair<bool, double>(isOK, metric); return std::pair<bool, double>(isOK, metric);
} }
...@@ -129,7 +145,6 @@ std::pair<int, int> ConstraintsPrerequisites::_prereqsInPreviousTF(std::vector<C ...@@ -129,7 +145,6 @@ std::pair<int, int> ConstraintsPrerequisites::_prereqsInPreviousTF(std::vector<C
for(int i = 0; i < prereqs.size(); i++) for(int i = 0; i < prereqs.size(); i++)
{ {
found = false; found = false;
std::cout << "Looking for " << prereqs.at(i) << std::endl;
for(int j = 0 ; j < cInTF.size() && !found; j++) for(int j = 0 ; j < cInTF.size() && !found; j++)
{ {
......
...@@ -245,13 +245,13 @@ std::ostream& operator<<(std::ostream& Stream, const Course & c) ...@@ -245,13 +245,13 @@ std::ostream& operator<<(std::ostream& Stream, const Course & c)
s+="\n\tRequirement: ["; s+="\n\tRequirement: [";
for(int i = 0; i < c.prerequisites().size(); i++) for(int i = 0; i < c.prerequisites().size(); i++)
{ {
s+="" + c.prerequisites().at(i).c_name() + " ; "; s+="" + c.prerequisites().at(i).c_name()+ "("+ std::to_string(c.prerequisites().at(i).c_magnitude().value()) + ") ; ";
} }
s+="]"; s+="]";
s+="\n\tTeaches: ["; s+="\n\tTeaches: [";
for(int i = 0 ; i < c.teachedCompetenciesWeighted().size(); i++) for(int i = 0 ; i < c.teachedCompetenciesWeighted().size(); i++)
{ {
s+= "" + std::to_string(c.teachedCompetenciesWeighted().at(i).second) + "." + c.teachedCompetenciesWeighted().at(i).first.c_name() + " ; "; s+= "" + c.teachedCompetenciesWeighted().at(i).first.c_name() + "("+ std::to_string(c.teachedCompetenciesWeighted().at(i).first.c_magnitude().value())+") ; ";
} }
s+="]"; s+="]";
Stream << s; Stream << s;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment