Commit 88146714 authored by Alexis Lebis's avatar Alexis Lebis

add _course sorted by TF in CSDVP

parent 200848c8
...@@ -211,5 +211,14 @@ int main(int argc, char* argv[]) ...@@ -211,5 +211,14 @@ int main(int argc, char* argv[])
std::cout << "CSDVP HAS BEEN CORRECTLY GENERATED!" << std::endl; std::cout << "CSDVP HAS BEEN CORRECTLY GENERATED!" << std::endl;
for(int i = 0 ; i < pb.coursesSortedByTF().size(); i++)
{
std::cout << "TF#" << std::to_string(i) << std::endl;
for(int j = 0; j < pb.coursesSortedByTF().at(i).size(); j++)
{
std::cout << pb.coursesSortedByTF().at(i).at(j) << std::endl;
}
}
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
\ No newline at end of file
...@@ -162,6 +162,23 @@ int CSDVP::CSDVP_COUNTER = 0; ...@@ -162,6 +162,23 @@ int CSDVP::CSDVP_COUNTER = 0;
this->_isConfig = true; this->_isConfig = true;
return this->_isConfig; return this->_isConfig;
} }
void CSDVP::_makeCoursesSortedByTF()
{
//Init the vector of the size of the time frames
for(int i = 0; i < this->_timeFrames.size(); i++)
this->_coursesSortedByTF.push_back(std::vector<Course>());
int tmpIdx;
for(int i = 0; i < this->_availableCourses.size(); i++)
{
for(int j = 0; j < this->_availableCourses.at(i).timeFrame().size(); j++)
{
tmpIdx = this->_availableCourses.at(i).timeFrame().at(j) - this->_minimalTimeFrame;
this->_coursesSortedByTF.at(tmpIdx).push_back(this->_availableCourses.at(i));
}
}
}
// === END FUNC // === END FUNC
// === STATIC // === STATIC
...@@ -299,6 +316,7 @@ int CSDVP::CSDVP_COUNTER = 0; ...@@ -299,6 +316,7 @@ int CSDVP::CSDVP_COUNTER = 0;
pb.addCourseToCatalogue(tmpCourses.at(i)); pb.addCourseToCatalogue(tmpCourses.at(i));
//From here, coursesCatalogue can still be < to minCourseTF * nbTF (due to the fact that a same course can belongs to ) //From here, coursesCatalogue can still be < to minCourseTF * nbTF (due to the fact that a same course can belongs to )
pb._makeCoursesSortedByTF();
/* COMPETENCY CREATION /* COMPETENCY CREATION
* We create _quantityAvailableCompetency competencies. For each comp, we randomly define it's magnitude. * We create _quantityAvailableCompetency competencies. For each comp, we randomly define it's magnitude.
......
...@@ -52,8 +52,9 @@ class CSDVP ...@@ -52,8 +52,9 @@ class CSDVP
// ---------- PROBLEM SPECIFIC ATTRIBUTES ---------- // ---------- PROBLEM SPECIFIC ATTRIBUTES ----------
// Theses attributes represent the CSDVP // Theses attributes represent the CSDVP
std::vector<int> _timeFrames; std::vector<int> _timeFrames; // Time frames stocks the VALUE, not the index
std::vector<Course> _availableCourses; std::vector<Course> _availableCourses;
std::vector<std::vector<Course>> _coursesSortedByTF; //sorted by standard index. e.g. TF[4;6] -> [0]=4; [1]=5 ; [2] = 6
std::vector<Competency> _availableCompentecies; std::vector<Competency> _availableCompentecies;
///@todo implements a decay politics ///@todo implements a decay politics
...@@ -77,6 +78,8 @@ class CSDVP ...@@ -77,6 +78,8 @@ class CSDVP
static double _randomizeIn(const double min, const double max); static double _randomizeIn(const double min, const double max);
// --------- END GENERATION RELATED FUNCTION --------- // --------- END GENERATION RELATED FUNCTION ---------
void _makeCoursesSortedByTF();
public: public:
// --------- GENERATION RELATED FUNCTION --------- // --------- GENERATION RELATED FUNCTION ---------
/// allows a random attribution of pb's attributes /// allows a random attribution of pb's attributes
...@@ -117,6 +120,7 @@ class CSDVP ...@@ -117,6 +120,7 @@ class CSDVP
const std::vector<int> & timeFrames() const{return this->_timeFrames;} const std::vector<int> & timeFrames() const{return this->_timeFrames;}
const std::vector<Course> & coursesCatalogue() const{return this->_availableCourses;} const std::vector<Course> & coursesCatalogue() const{return this->_availableCourses;}
const std::vector<Competency> & competencyCatalogue() const{return this->_availableCompentecies;} const std::vector<Competency> & competencyCatalogue() const{return this->_availableCompentecies;}
const std::vector<std::vector<Course>> & coursesSortedByTF() const {return this->_coursesSortedByTF;}
std::vector<int> & unlocked_timeFrames(){return this->_timeFrames;} std::vector<int> & unlocked_timeFrames(){return this->_timeFrames;}
std::vector<Course> & unlocked_coursesCatalogue(){return this->_availableCourses;} std::vector<Course> & unlocked_coursesCatalogue(){return this->_availableCourses;}
std::vector<Competency> & unlocked_competenciesCatalogue(){return this->_availableCompentecies;} std::vector<Competency> & unlocked_competenciesCatalogue(){return this->_availableCompentecies;}
......
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