Commit 428f784e authored by Alexis Lebis's avatar Alexis Lebis

adding cstr over ects

parent 82f1bf8d
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/constraints)
include_directories(${PARADISEO_INCLUDE_DIR})
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
SET (EXERCICE_SOURCES
ectsConstraints.cpp
)
ADD_LIBRARY(lCstr STATIC ${EXERCICE_SOURCES})
\ No newline at end of file
#include "ectsConstraints.h"
#include "model/course.h"
std::pair<bool, double> ConstraintsECTS::integrityCheck(Cursus indiv)
{
std::vector<Course> courses = this->_pb.coursesCatalogue();
int tmpECTS = 0;
std::cout << "courses size : " << std::to_string(courses.size()) << std::endl;
std::cout << "courses catl : " << std::to_string(this->_pb.cfg_quantityCourses()) << std::endl;
for(int i = 0; i < indiv.size(); i++)
{
tmpECTS += courses.at(indiv[i]).ects();
std::cout << std::to_string(courses.at(indiv[i]).ects()) << " + ";
}
std::cout << " = " << std::to_string(tmpECTS) << std::endl;
bool isCheckOK = false;
if(tmpECTS >= this->_job.requiredECTS())
isCheckOK = true;
std::cout << "Required: " << std::to_string(this->_job.requiredECTS());
double metric = (double)tmpECTS / this->_job.requiredECTS();
return std::pair<bool, double>(isCheckOK, metric);
}
\ No newline at end of file
#ifndef SRC_MODEL_CONSTRAINTS_ECTS_CONSTRAINTS_H_
#define SRC_MODEL_CONSTRAINTS_ECTS_CONSTRAINTS_H_
#include <vector>
#include <utility>
#include <eo>
#include "model/problem.h"
#include "model/profession.h"
#include "model/ea/cursus.h"
/**
* This class is used to verify the constraints regarding ECTS
*/
class ConstraintsECTS
{
private:
CSDVP _pb; //Description of the pb
Profession _job;
public:
ConstraintsECTS(const CSDVP& csdvp, const Profession & p)
: _pb(csdvp), _job(p) {}
/** integrityCheck is used to investigate whether or not one individu (indiv) respects the constraints stated.
* Returns a std::pair. First is a boolean set to true when the individu passe the test and is ok with the constraints, false otherwise. Second is a metric inherent to the class caller which can be used during the fitness calcul.
* Metric here is : currentIndivECTS / expectedECTS
*/
std::pair<bool, double> integrityCheck(Cursus indiv);
};
#endif // SRC_MODEL_CONSTRAINTS_ECTS_CONSTRAINTS_H_
\ No newline at end of file
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