Commit 29876b60 authored by Alexis Lebis's avatar Alexis Lebis

New INIT - does not work

parent 8c445303
......@@ -5,8 +5,8 @@
#include <queenCrossover.h>
#include <queenEval.h>
#include <model/problem.h>
#include <model/magnitude.h>
#include <model/competency.h>
#include <model/ea/cursus.h>
#include <model/ea/initializer.h>
......@@ -57,10 +57,32 @@ int main(int argc, char* argv[]){
// ================================= END TEST ZONE =====================================
// ================================= CEAO ZONE ===================================
//CSDVP pb;
CSDVP pb;
// ===== PB CONFIG ZONE =====
pb.set_cfg_quantityCourses(15);
pb.set_cfg_quantityCompetencies(15);
pb.set_cfg_minimalTimeFrames(1);
pb.set_cfg_maximalTimeFrames(6); //Just "Licence"
pb.set_cfg_ectsMin(3);
pb.set_cfg_ectsMax(5);
pb.set_cfg_courseByTFMin(3);
pb.set_cfg_courseByTFMax(5);
pb.set_cfg_minimalMagnitude(0.2);
pb.set_cfg_maximalMagnitude(0.75);
pb.set_cfg_minimalCompetencyByCourse(1);
pb.set_cfg_maximalCompetencyByCourse(3);
pb.set_cfg_minimalPrerequisiteByCourse(0);
pb.set_cfg_maximalPrerequisiteByCourse(2);
pb.set_cfg_pickedCoursesByTimeFrame(2);
CSDVP::generateProblem(pb, CSDVP::GenerationType::RANDOM, 7777);
assert(pb.checkConfig());
// ===== END PB CONFIG =====
Cursus c1;
CursusInit init(8,1); //init(pb.getQuantityCoursesToPick(),1);
CursusInit init(pb.getQuantityCoursesToPick(),pb.cfg_quantityCourses(), pb.seed());
CursusEval eval;
CursusMutation mut;
CursusCrossover xOver;
......
......@@ -8,7 +8,7 @@
/**
* Represents a cursus of a student. It is equivalent to an individu in a EA.
* Here, it is defined as an eoVector of int: eoInt with a "eoMinimizingFitness" template. Each int represents a course.
* In version 1, the representation is based on the course's ID. In further version, this could become deprecated and be based on the course's position inside the problem's vector.
* In version 1.1, the representation is based on the course's position in the vector. Older version dealing with the course's ID **IS** deprecated
* @version 1
*/
......
#ifndef SRC_MODEL_EA_INITIALIZER_H_
#define SRC_MODEL_EA_INITIALIZER_H_
#include<queue>
#include<vector>
#include<cassert>
#include<algorithm>
#include<random>
#include<functional>
#include <eoInit.h>
#include "model/problem.h"
#include "cursus.h"
typedef eoInitPermutation<Cursus> CursusInit;
template <class EOT>
class eoInitCSDVP: public eoInit<EOT>
{
public:
typedef typename EOT::AtomType AtomType;
eoInitCSDVP(unsigned chromSize, unsigned maxVal, int _seed)
: _chromSize(chromSize), _maxVal(maxVal)
{}
virtual void operator()(EOT& chrom)
{
chrom.resize(_chromSize);
std::vector<int> rdVec;
for(int i = 0; i < this->_maxVal; i++)
rdVec.push_back(i);
std::random_shuffle(rdVec.begin(), rdVec.end());
std::vector<int> r2; //trying tmp struct
for(int i = 0; i < rdVec.size(); i++)
r2.push_back(rdVec.at(i));
for(unsigned idx=0;idx <chrom.size();idx++)
{
unsigned int tmp = r2.at(idx);
// chrom[idx]=tmp; // DOES NOT WORK
chrom[idx] = idx; //DOES WORK;
}
//std::random_shuffle(chrom.begin(), chrom.end(),gen);
chrom.invalidate();
}
private :
unsigned _chromSize;
unsigned _maxVal;
UF_random_generator<unsigned int> gen;
int _seed;
};
typedef eoInitCSDVP<Cursus> CursusInit;
#endif // SRC_MODEL_EA_INITIALIZER_H_
\ No newline at end of file
......@@ -158,7 +158,7 @@ int CSDVP::CSDVP_COUNTER = 0;
throw CSDVPBadlyConfiguratedException("this->_quantityAvailableCompetencies < this->_maximalCompetencyByCourse");
if(this->_pickedCoursesByTimeFrame > this->_minimalCoursesByTimeFrame)
throw CSDVPBadlyConfiguratedException("this->_pickedCoursesByTimeFrame > this->_minimalCoursesByTimeFrame");
this->_isConfig = true;
return this->_isConfig;
}
......
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