Commit 200848c8 authored by Alexis Lebis's avatar Alexis Lebis

Profession & co

parent 428f784e
......@@ -15,7 +15,7 @@ ADD_EXECUTABLE(tryMutation tryMutation.cpp)
ADD_EXECUTABLE(tryCrossover tryCrossover.cpp)
ADD_EXECUTABLE(tryEval tryEval.cpp)
ADD_DEPENDENCIES(ceao lQueen lModel)
ADD_DEPENDENCIES(ceao lQueen lModel lEA lCstr)
ADD_DEPENDENCIES(ceao_competency lQueen lModel)
ADD_DEPENDENCIES(ceao_course lQueen lModel)
ADD_DEPENDENCIES(ceao_profession lQueen lModel)
......@@ -28,7 +28,7 @@ ADD_DEPENDENCIES(tryEval lQueen)
# 3) Link the librairies for your executable
TARGET_LINK_LIBRARIES(ceao ${PARADISEO_LIBRARIES} lQueen lModel lEA)
TARGET_LINK_LIBRARIES(ceao ${PARADISEO_LIBRARIES} lQueen lModel lEA lCstr)
TARGET_LINK_LIBRARIES(ceao_competency ${PARADISEO_LIBRARIES} lQueen lModel)
TARGET_LINK_LIBRARIES(ceao_course ${PARADISEO_LIBRARIES} lQueen lModel)
TARGET_LINK_LIBRARIES(ceao_profession ${PARADISEO_LIBRARIES} lQueen lModel)
......
# File: FindParadiseo.cmake
# Version: 0.0.1
#
# The following variables are filled out:
# - PARADISEO_INCLUDE_DIR : EO, MO and MOEO source dir
# - EO_INCLUDE_DIR : EO source dir
# - MO_INCLUDE_DIR : MO source dir
# - MOEO_INCLUDE_DIR : MOEO source dir. WARNING : You have ton include MO before !
# - PARADISEO_LIBRARIES : the list of all required modules
# - PARADISEO_XXX_LIBRARY : the name of the library to link for the required module
# - PARADISEO_XXX_FOUND : true if the required module is found
# - PARADISEO_FOUND : true if all required modules are found
#
# Here are the components:
# - eo
# - PyEO
# - es
# - ga
# - cma
# - flowshop
# - moeo
# - smp
# - peo
# You can use find_package(Paradiseo COMPONENTS ... ) to enable one or several components. If you not specifie component, all components will be load except SMP for compatibility reasons.
#
# Output
# ------
#
# example:
# find_package(Paradiseo COMPONENTS eo eoutils cma es flowshop ga moeo REQUIRED)
# include_directories(${PARADISEO_INCLUDE_DIR})
# add_executable(example ...)
# target_link_libraries(examplep ${PARADISEO_LIBRARIES})
if(UNIX)
set(INSTALL_SUB_DIR /paradiseo)
endif()
# enabled components
if ("${Paradiseo_FIND_COMPONENTS}" STREQUAL "")
set(PARADISEO_LIBRARIES_TO_FIND eo eoutils cma es flowshop ga moeo)
else()
set(PARADISEO_LIBRARIES_TO_FIND ${Paradiseo_FIND_COMPONENTS})
endif()
#set the build directory
set(BUILD_DIR build)
# Path
set(PARADISEO_SRC_PATHS
${PARADISEO_ROOT}
$ENV{PARADISEO_ROOT}
/usr/local/
/usr/
/sw # Fink
/opt/local/ # DarwinPorts
/opt/csw/ # Blastwave
/opt/
[KEY_CURRENT_USER\\Software\\Inria\\ParadisEO]/local
[HKEY_LOCAL_MACHINE\\Software\\Inria\\ParadisEO]/local
)
find_path(EO_INCLUDE_DIR eo
PATH_SUFFIXES include${INSTALL_SUB_DIR}/eo eo/src
PATHS ${PARADISEO_SRC_PATHS})
find_path(MO_INCLUDE_DIR mo
PATH_SUFFIXES include${INSTALL_SUB_DIR}/mo mo/src
PATHS ${PARADISEO_SRC_PATHS})
find_path(MOEO_INCLUDE_DIR moeo
PATH_SUFFIXES include${INSTALL_SUB_DIR}/moeo moeo/src
PATHS ${PARADISEO_SRC_PATHS})
# Specific for SMP and PEO
foreach(COMP ${PARADISEO_LIBRARIES_TO_FIND})
if(${COMP} STREQUAL "smp")
set(SMP_FOUND true)
find_path(SMP_INCLUDE_DIR smp
PATH_SUFFIXES include${INSTALL_SUB_DIR}/smp smp/src
PATHS ${PARADISEO_SRC_PATHS})
elseif(${COMP} STREQUAL "peo")
set(PEO_FOUND true)
find_path(PEO_INCLUDE_DIR peo
PATH_SUFFIXES include${INSTALL_SUB_DIR}/peo peo/src
PATHS ${PARADISEO_SRC_PATHS})
endif()
endforeach()
set(PARADISEO_INCLUDE_DIR ${EO_INCLUDE_DIR} ${MO_INCLUDE_DIR} ${MOEO_INCLUDE_DIR})
if(SMP_FOUND)
set(PARADISEO_INCLUDE_DIR ${PARADISEO_INCLUDE_DIR} ${SMP_INCLUDE_DIR})
endif()
if(PEO_FOUND)
set(PARADISEO_INCLUDE_DIR ${PARADISEO_INCLUDE_DIR} ${PEO_INCLUDE_DIR})
endif()
# find the requested modules
set(PARADISEO_FOUND true) # will be set to false if one of the required modules is not found
set(FIND_PARADISEO_LIB_PATHS
${PARADISEO_ROOT}/${BUILD_DIR}
$ENV{PARADISEO_ROOT}
/usr/local/
/usr/
/sw # Fink
/opt/local/ # DarwinPorts
/opt/csw/ # Blastwave
/opt/
[KEY_CURRENT_USER\\Software\\Inria\\ParadisEO]/local
[HKEY_LOCAL_MACHINE\\Software\\Inria\\ParadisEO]/local
)
#Suffixes
set(PARADISEO_LIB_PATHS_SUFFIXES
eo/lib
mo/lib
moeo/lib
moeo/tutorial/examples/flowshop/lib #For flowshop library
smp/lib
peo/lib
lib
lib32
lib64
)
foreach(FIND_PARADISEO_COMPONENT ${PARADISEO_LIBRARIES_TO_FIND})
string(TOUPPER ${FIND_PARADISEO_COMPONENT} FIND_PARADISEO_COMPONENT_UPPER)
# release library
find_library(PARADISEO_${FIND_PARADISEO_COMPONENT_UPPER}_LIBRARY
NAMES ${FIND_PARADISEO_COMPONENT}
PATH_SUFFIXES ${PARADISEO_LIB_PATHS_SUFFIXES}
PATHS ${FIND_PARADISEO_LIB_PATHS})
if (PARADISEO_${FIND_PARADISEO_COMPONENT_UPPER}_LIBRARY)
# library found
set(PARADISEO_${FIND_PARADISEO_COMPONENT_UPPER}_FOUND true)
else()
# library not found
set(PARADISEO_FOUND false)
set(PARADISEO_${FIND_PARADISEO_COMPONENT_UPPER}_FOUND false)
set(FIND_PARADISEO_MISSING "${FIND_PARADISEO_MISSING} ${FIND_PARADISEO_COMPONENT}")
endif()
set(PARADISEO_LIBRARIES ${PARADISEO_LIBRARIES} "${PARADISEO_${FIND_PARADISEO_COMPONENT_UPPER}_LIBRARY}")
endforeach()
# handle result
if(PARADISEO_FOUND)
message(STATUS "Found ParadisEO includes :")
message(${EO_INCLUDE_DIR})
message(${MO_INCLUDE_DIR})
message(${MOEO_INCLUDE_DIR})
if(SMP_FOUND)
message(${SMP_INCLUDE_DIR})
endif()
if(PEO_FOUND)
message(${PEO_INCLUDE_DIR})
endif()
else()
# include directory or library not found
message(FATAL_ERROR "Could NOT find ParadisEO (missing : ${FIND_PARADISEO_MISSING})")
endif()
......@@ -15,4 +15,5 @@ ADD_LIBRARY(lModel STATIC ${EXERCICE_SOURCES})
add_subdirectory(exception)
add_subdirectory(scale)
add_subdirectory(ea)
\ No newline at end of file
add_subdirectory(ea)
add_subdirectory(constraints)
\ No newline at end of file
......@@ -2,6 +2,7 @@
#include <vector>
#include <utility>
#include <algorithm>
#include <cassert>
#include "profession.h"
#include "competency.h"
......@@ -54,6 +55,13 @@ int Profession::PROFESSION_COUNTER = 0;
return *old;
}
void Profession::setRequiredECTS(int nb)
{
assert(nb >= 0);
this->_requiredECTS = nb;
}
// ADDER
/** Adds a new competency to the prerequisites of a profession. It is protected against duplicata: it can't have twice the same competency.
*
......
......@@ -17,6 +17,8 @@ class Profession
std::string _name;
int _id;
int _requiredECTS;
// === FUNC
/** _duplicataProtection returns true if the value (2nd param) searched into (1st param) is found*/
bool _duplicataProtection(std::vector<Competency> *, Competency);
......@@ -32,6 +34,7 @@ class Profession
// === GETTER
const int id() const{return this->_id;}
const int requiredECTS() const{return this->_requiredECTS;}
const std::string name() const{return this->_name;}
const std::vector<Competency> & prerequisites() const{return this->_prerequisites;}
/// return a modifiable reference to _prerequisite;
......@@ -43,7 +46,7 @@ class Profession
void setName(std::string name);
/// Set the prerequisites of a profession. The old prereq is returned.
std::vector<Competency> & setPrerequisites(std::vector<Competency> & v);
void setRequiredECTS(int ects);
// ADDER
bool addPrerequisite(Competency &);
......
......@@ -4,6 +4,8 @@
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <random>
template<typename T>
/** Searches into vec the element findMe. The class T must have T() defined ( T()=default; is OK) */
......@@ -38,4 +40,27 @@ static bool duplicataFlag(std::vector<T> & toProtect, T & toAdd)
}
///Not working properly yet, just for debug
// static std::queue<int> RNG_QUEUE;
// /**Init a queue of size s from 0 to s, then shuffle it*/
// static void initRandomSuite(const unsigned int s)
// {
// RNG_QUEUE = std::queue<int>();
// std::vector<int> tmp (s);
// for(int i = 0; i < s; i++)
// tmp.push_back(i);
// // std::random_device rng;
// // std::mt19937 urng(rng());
// std::random_shuffle(tmp.begin(), tmp.end());
// for(int i = 0; i < tmp.size(); i++)
// RNG_QUEUE.push(tmp.at(i));
// }
// static int getNextRandom()
// {
// int tmp = RNG_QUEUE.front();
// RNG_QUEUE.pop();
// return tmp;
// }
#endif // SRC_MODEL_TOOLS_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