Commit 91b9b23b authored by Alexis Lebis's avatar Alexis Lebis

Merge branch 'bugFixBranch' into 'master'

Bug fix branch (nbCourseFix)

See merge request !8
parents 6dfc228f f5cd7216
......@@ -3,4 +3,4 @@ build/
howto.pdf
.vscode/
.cmake/
results/
......@@ -49,6 +49,13 @@ include_directories(${PARADISEO_INCLUDE_DIR})
# the user should choose the build type on windows environments,excepted under cygwin (default=none)
set(CMAKE_DEFAULT_BUILD_TYPE "Release" CACHE STRING "Variable that stores the default CMake build type" FORCE)
add_definitions(-DDEPRECATED_MESSAGES)
set(CMAKE_CXX_FLAGS_DEBUG "-Wunknown-pragmas -O0 -g -fPIC -Wall -Wextra -ansi -pedantic -std=c++11" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-Wunknown-pragmas -O2 -fPIC -std=c++11" CACHE STRING "" FORCE)
find_program(MEMORYCHECK_COMMAND
NAMES purify valgrind
PATHS
......
......@@ -5,6 +5,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
# 2) Define targets: executable and dependencies
ADD_EXECUTABLE(ceao main.cpp)
ADD_EXECUTABLE(ceao2 main2.cpp)
ADD_EXECUTABLE(ceao_competency ceao_competency.cpp)
ADD_EXECUTABLE(ceao_course ceao_course.cpp)
ADD_EXECUTABLE(ceao_profession ceao_profession.cpp)
......@@ -16,6 +17,7 @@ ADD_EXECUTABLE(tryCrossover tryCrossover.cpp)
ADD_EXECUTABLE(tryEval tryEval.cpp)
ADD_DEPENDENCIES(ceao lQueen lModel lEA lCstr)
ADD_DEPENDENCIES(ceao2 lQueen lModel lEA lCstr)
ADD_DEPENDENCIES(ceao_competency lQueen lModel)
ADD_DEPENDENCIES(ceao_course lQueen lModel)
ADD_DEPENDENCIES(ceao_profession lQueen lModel)
......@@ -29,6 +31,7 @@ ADD_DEPENDENCIES(tryEval lQueen)
# 3) Link the librairies for your executable
TARGET_LINK_LIBRARIES(ceao ${PARADISEO_LIBRARIES} lQueen lModel lEA lCstr)
TARGET_LINK_LIBRARIES(ceao2 ${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)
......
......@@ -10,6 +10,7 @@
#include <model/magnitude.h>
#include <model/tools.h>
#include <model/competency.h>
#include <model/decay.h>
#include <model/ea/cursus.h>
#include <model/ea/initializer.h>
......@@ -43,6 +44,7 @@ int main(int argc, char* argv[]){
unsigned int _seedParam = parser.createParam((unsigned int)(0), "seed", "Random number seed", 'S').value();
std::string _outputFile = parser.createParam(std::string("/scratch"), "outputfile", "", '\0', "Representation", true).value();
eo::rng.reseed(_seedParam);
unsigned int localDisplay = parser.createParam((unsigned int)(0), "localDisplay", "whether or not display on local output", 'd', "Param").value();
//PROBLEM PARAMETERS
unsigned int SEED = parser.createParam((unsigned int)(7777), "csdvpSeed", "Seed used for the CSDVP",'s',"Param").value();
......@@ -58,9 +60,14 @@ int main(int argc, char* argv[]){
double MAXMAGN = parser.createParam((double)(0.75), "maxMagn", "maximal magnitude", 'M', "Param").value();
unsigned int MINCBYC = parser.createParam((unsigned int)(1), "minCbyC", "minimal competency by course",'r',"Param").value();
unsigned int MAXCBYC = parser.createParam((unsigned int)(5), "maxCbyC", "maximal competency by course",'R',"Param").value();
unsigned int MINPRE = parser.createParam((unsigned int)(0), "minPre", "minimal competency by course",'p',"Param").value();
unsigned int MAXPRE = parser.createParam((unsigned int)(3), "maxPre", "maximal competency by course",'P',"Param").value();
unsigned int MINPRE = parser.createParam((unsigned int)(0), "minPre", "minimal competency by course",'q',"Param").value();
unsigned int MAXPRE = parser.createParam((unsigned int)(3), "maxPre", "maximal competency by course",'Q',"Param").value();
unsigned int CBYTF = parser.createParam((unsigned int)(2), "cbyTF", "course by time frame to pick",'A',"Param").value();
CursusEval::WEIGHT_ECTS = parser.createParam((double)(1.0), "wECTS", "Weight of ECTS in the fitness value", 'V', "Param").value();
CursusEval::WEIGHT_REPETION = parser.createParam((double)(1.0), "wREP", "Weight of Repetition in the fitness value", 'v', "Param").value();
CursusEval::WEIGHT_JOB = parser.createParam((double)(1.0), "wJob", "Weight of profession in the fitness value", 'w', "Param").value();
CursusEval::WEIGHT_PREREQ = parser.createParam((double)(1.0), "wPrereq", "Weight of prerequisites in the fitness value", 'W', "Param").value();
DecayEngine::IS_DECAY_DEACTIVATED = parser.createParam((int)(0), "decayDeactivated", "Wether or not the decay is deactivated", 'D', "Param").value();
//PROFESSION PARAMETERS
unsigned int JOB_SEED = parser.createParam((unsigned int)(7777), "jobSeed", "Seed used for the Profession", 'g', "Param").value();
......@@ -75,10 +82,12 @@ int main(int argc, char* argv[]){
double PCROSS = parser.createParam((double)(0.5), "pCross", "crossover rate", 'X', "Evolution Engine").value();
unsigned int NBGEN = parser.createParam((unsigned int)(100), "nbGen", "Number of generation",'G',"Param").value();
unsigned int SIZET = parser.createParam((unsigned int)(7), "sizeT", "Tournament Size",'F',"Param").value();
RATIO_RANDOM_VS_BEST = parser.createParam((unsigned int)(75), "ratioBest", "Ratio between full random and best while prereq check fails in mutation",'B',"Param").value();
// ===== PB CONFIG ZONE =====
CSDVP pb;
Profession job;
std::cout << "nb cours: ---> " << NBCOURSES << std::endl;
pb.set_cfg_quantityCourses(NBCOURSES);
pb.set_cfg_quantityCompetencies(NBCOMP);
pb.set_cfg_minimalTimeFrames(MINTF);
......@@ -152,7 +161,8 @@ int main(int argc, char* argv[]){
eoSGATransform<Cursus> transform(cross, PCROSS, mut, PMUT);
eoDetTournamentSelect<Cursus> selectOne(SIZET);
eoSelectPerc<Cursus> select(selectOne);
eoGenerationalReplacement<Cursus> replace;
eoGenerationalReplacement<Cursus> genReplace;
eoWeakElitistReplacement<Cursus> replace(genReplace);
//POPULATION INITIALISATION
eoPop<Cursus> pop;
......@@ -269,14 +279,45 @@ int main(int argc, char* argv[]){
// ================================= RUN ZONE ===============================
std::string filename=_outputFile + "/bestsol.";
std::ostringstream oss;
oss << _seedParam;
filename+=oss.str();
std::ofstream outputfile(filename.c_str(), std::ios::app);
oss.str("");
filename=_outputFile + "/pop.";
oss << _seedParam;
filename+=oss.str();
std::ofstream outputfile2(filename.c_str(), std::ios::app);
oss.str("");
filename=_outputFile + "/req.";
oss << _seedParam;
filename+=oss.str();
std::ofstream outputfile3(filename.c_str(), std::ios::app);
oss.str("");
filename=_outputFile + "/solsstats.";
oss << _seedParam;
filename+=oss.str();
std::ofstream outputfile4(filename.c_str(), std::ios::app);
std::pair<bool, double> resECTS;
std::pair<bool, double> resRep ;
std::pair<bool, double> resJob ;
std::pair<bool, double> resPrq ;
if(localDisplay)
{
std::cout << "===== CURRENT POP =====" << std::endl;
pop.best_element().printOn(std::cout);
std::cout << " fitness:" << pop.best_element().fitness() << std::endl;
std::cout << "Stats & metrics: \n" << std::endl;
std::pair<bool, double> resECTS = ctrECTS.integrityCheck(pop.best_element());
std::pair<bool, double> resRep = ctrRep.integrityCheck(pop.best_element());
std::pair<bool, double> resJob = ctrJob.integrityCheck(pop.best_element());
std::pair<bool, double> resPrq = ctrPrq.integrityCheck(pop.best_element());
resECTS = ctrECTS.integrityCheck(pop.best_element());
resRep = ctrRep.integrityCheck(pop.best_element());
resJob = ctrJob.integrityCheck(pop.best_element());
resPrq = ctrPrq.integrityCheck(pop.best_element());
std::cout << "ECTS: ";
if(resECTS.first)
......@@ -306,13 +347,59 @@ int main(int argc, char* argv[]){
std::cout << "failed";
std::cout << " | value: " << resPrq.second << std::endl;
std::cout << "\n==========" << std::endl;
}
// ---------- ALGO HERE
eoEasyEA<QUEEN> algo(cont,eval,select,transform,replace);
eoEasyEA<Cursus> algo(cont,eval,select,transform,replace);
//WRITE CURRENT POP
pop.best_element().printOn(outputfile4);
outputfile4 << " " << ctrECTS.integrityCheck(pop.best_element()).second << " " << ctrRep.integrityCheck(pop.best_element()).second << " " << ctrJob.integrityCheck(pop.best_element()).second << " " << ctrPrq.integrityCheck(pop.best_element()).second << std::endl;
outputfile2 << pop.size() << std::endl;
outputfile3 << pop.size() << std::endl;
for(int i=0; i<pop.size();i++){
//Write pop + prerequires values
pop[i].printOn(outputfile2);
outputfile2 << " " << ctrECTS.integrityCheck(pop[i]).second << " " << ctrRep.integrityCheck(pop[i]).second << " " << ctrJob.integrityCheck(pop[i]).second << " " << ctrPrq.integrityCheck(pop[i]).second << std::endl;
//Write prerequires values
outputfile3 << ctrECTS.integrityCheck(pop[i]).second << " " << ctrRep.integrityCheck(pop[i]).second << " " << ctrJob.integrityCheck(pop[i]).second << " " << ctrPrq.integrityCheck(pop[i]).second << std::endl;
}
//RUN ALGO
algo(pop);
//WRITE FINAL POP
pop.best_element().printOn(outputfile);
outputfile << std::endl;
pop.best_element().printOn(outputfile4);
outputfile4 << " " << ctrECTS.integrityCheck(pop.best_element()).second << " " << ctrRep.integrityCheck(pop.best_element()).second << " " << ctrJob.integrityCheck(pop.best_element()).second << " " << ctrPrq.integrityCheck(pop.best_element()).second << std::endl;
outputfile2 << pop.size() << std::endl;
outputfile3 << pop.size() << std::endl;
for(int i=0; i<pop.size();i++){
//Write pop + prerequires values
pop[i].printOn(outputfile2);
outputfile2 << " " << ctrECTS.integrityCheck(pop[i]).second << " " << ctrRep.integrityCheck(pop[i]).second << " " << ctrJob.integrityCheck(pop[i]).second << " " << ctrPrq.integrityCheck(pop[i]).second << std::endl;
//Write prerequires values
outputfile3 << ctrECTS.integrityCheck(pop[i]).second << " " << ctrRep.integrityCheck(pop[i]).second << " " << ctrJob.integrityCheck(pop[i]).second << " " << ctrPrq.integrityCheck(pop[i]).second << std::endl;
}
outputfile.close();
outputfile2.close();
outputfile3.close();
outputfile4.close();
// -------------------
if(localDisplay)
{
std::cout << "\n===== BEST INDIVIDU =====" << std::endl;
pop.best_element().printOn(std::cout);
std::cout << " fitness:" << pop.best_element().fitness() << std::endl;
......@@ -346,13 +433,13 @@ int main(int argc, char* argv[]){
std::cout << "Prereq: ";
if(resPrq.first)
std::cout << "succeed";
else
std::cout << "failed";
std::cout << " | value: " << resPrq.second << std::endl;
std::cout << "===============" << std::endl;
std::cout << "cpt: " << cross.cpt << std::endl;
}
// ================================= END RUN ZONE ===============================
......
This diff is collapsed.
This diff is collapsed.
......@@ -48,6 +48,7 @@ set(BUILD_DIR build)
# Path
set(PARADISEO_SRC_PATHS
/home/jeremie.humeau/private/ParadisEO-2.0/
/home/jerem/Softs/ParadisEO-2.0/
${PARADISEO_ROOT}
$ENV{PARADISEO_ROOT}
......@@ -102,6 +103,7 @@ endif()
set(PARADISEO_FOUND true) # will be set to false if one of the required modules is not found
set(FIND_PARADISEO_LIB_PATHS
/home/jeremie.humeau/private/ParadisEO-2.0/build
/home/jerem/Softs/ParadisEO-2.0/build/
${PARADISEO_ROOT}/${BUILD_DIR}
$ENV{PARADISEO_ROOT}
......@@ -163,3 +165,4 @@ else()
# include directory or library not found
message(FATAL_ERROR "Could NOT find ParadisEO (missing : ${FIND_PARADISEO_MISSING})")
endif()
File added
${cbyTF}_${minCbyTF}_${maxCbyTF}_${nbGen}"
sbatch --array=1-${run} --job-name=${RESDIR} --output=${RESDIR}.out --export=C=$nbCours,c=$nbComps,R=$maxCbyC,Q=$maxPre,A=$cbyTF,n=$minCbyTF,N=$maxCbyTF,r=1,q=0,O=$RESDIR,B=20,x=0.75,X=0.75,F=3,G=$nbGen job.sh
echo "-C=${nbCours} -c=${nbComps} -R=${maxCbyC} -Q=${maxPre} -A=${cbyTF} -n=${minCbyTF} -N=${maxCbyTF} -r=1 -q=0" >> case
done
done
done
done
done
done
done
done
22.3794 70 4 23 62 95 39 81 0 16 66 57 103 47 61 63 26 3 82 93 44 97 14 37 65 83 41 60 87 72 69 80 36 40 74 32 2 11 38 52 46 30 53 77 64 75 31 5 21 50 25 51 43 86 28 34 67 98 49 102 101 54 94 76 33 73 48 18 91 13 70 59
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
100
0.969849 1 0.333333 0.554974
1 1 0 0.488506
1 1 0.333333 0.513369
1 1 0 0.511299
1 1 0 0.48
0.969849 1 0.333333 0.49711
0.994975 1 0 0.5
1 1 0 0.474138
1 1 0 0.486264
1 1 0.666667 0.521622
0.994975 1 0 0.513812
0.979899 1 0.333333 0.521739
1 1 0.333333 0.455621
1 1 0 0.49435
0.994975 1 0 0.474227
0.98995 1 0 0.486188
1 1 0.333333 0.486486
0.954774 1 0.333333 0.561798
0.904523 1 0.333333 0.5
1 1 0 0.515707
1 1 0 0.520231
0.974874 1 0.333333 0.544693
1 1 0 0.497326
1 1 0.333333 0.489247
1 1 0 0.491935
0.944724 1 0.666667 0.48324
1 1 0 0.486486
1 1 0 0.457627
1 1 0 0.541436
0.994975 1 0 0.434524
0.969849 1 0 0.519663
1 1 0 0.448276
0.979899 1 0.333333 0.516393
1 1 0.333333 0.494444
0.954774 1 0 0.478378
1 1 0 0.469444
0.934673 1 0.333333 0.527933
0.974874 1 0 0.52907
1 1 0 0.466102
0.969849 1 0 0.442308
0.974874 1 0 0.483333
1 1 0.333333 0.468208
1 1 0 0.519774
1 1 0.333333 0.519663
0.979899 1 0.333333 0.502825
1 1 0.333333 0.547486
0.98995 1 0 0.546154
1 1 0.333333 0.463483
0.974874 1 0 0.502778
0.939698 1 0.333333 0.478378
1 1 0.666667 0.513889
1 1 0.333333 0.529586
1 1 0 0.488827
1 1 0 0.481183
1 1 0.666667 0.53352
1 1 0.666667 0.528571
1 1 0 0.464674
1 1 0.333333 0.565341
1 1 0.333333 0.474093
1 1 0 0.497207
1 1 0.333333 0.519663
1 1 0 0.532258
0.994975 1 0 0.480978
1 1 0.666667 0.472892
0.98995 1 0 0.480226
1 1 0 0.509036
1 1 0 0.497326
0.979899 1 0.333333 0.459239
1 1 0.333333 0.463277
1 1 0 0.513089
0.984925 1 0 0.542614
0.984925 1 0 0.453804
1 1 0.333333 0.444149
1 1 0.333333 0.434211
0.984925 1 0 0.518717
0.979899 1 0 0.5
1 1 0 0.558333
1 1 0 0.488889
0.984925 1 0 0.555263
1 1 0.333333 0.502907
1 1 0.333333 0.522222
1 1 0.333333 0.472678
1 1 0.333333 0.472222
1 1 0.666667 0.483051
1 1 0.333333 0.494565
0.979899 1 0 0.505618
1 1 0 0.48895
1 1 0 0.46648
0.979899 1 0 0.463277
1 1 0 0.494505
0.98995 1 0 0.508876
0.994975 1 0 0.475676
1 1 0 0.535326
0.969849 1 0.333333 0.47619
1 1 0.666667 0.485207
0.984925 1 0 0.467568
0.984925 1 0 0.462567
0.924623 1 0.666667 0.491892
1 1 0 0.532787
0.994975 1 0.333333 0.566298
100
1 1 0.666667 0.794944
1 1 0.666667 0.784483
1 1 0.666667 0.786127
1 1 0.666667 0.796089
1 1 0.666667 0.79661
1 1 0.666667 0.79661
1 1 0.666667 0.768786
1 1 0.666667 0.79023
1 1 0.666667 0.797753
1 1 0.666667 0.79661
1 1 0.666667 0.780702
1 1 0.666667 0.791176
1 1 0.666667 0.795977
1 1 0.666667 0.793785
1 1 0.666667 0.784091
1 1 0.666667 0.796089
1 1 0.666667 0.779412
1 1 0.666667 0.801724
1 1 0.666667 0.779412
1 1 0.666667 0.792135
1 1 0.666667 0.791429
1 1 0.666667 0.782486
1 1 0.666667 0.768786
1 1 0.666667 0.792614
1 1 0.666667 0.788235
1 1 0.666667 0.782353
1 1 0.666667 0.784884
1 1 0.666667 0.764706
1 1 0.666667 0.789017
1 1 0.666667 0.801724
1 1 0.666667 0.789017
1 1 0.666667 0.77907
1 1 0.666667 0.785294
1 1 0.666667 0.78012
1 1 0.666667 0.787709
1 1 0.666667 0.777778
1 1 0.666667 0.79096
1 1 0.666667 0.764535
1 1 0.666667 0.795977
1 1 0.666667 0.801676
1 1 0.666667 0.784091
1 1 0.666667 0.772472
1 1 0.666667 0.784024
1 1 0.666667 0.771429
1 1 0.666667 0.783237
1 1 0.666667 0.792398
1 1 0.666667 0.762857
1 1 0.666667 0.770115
1 1 0.666667 0.783333
1 1 0.666667 0.793605
1 1 0.666667 0.795455
1 1 0.666667 0.789326
1 1 0.666667 0.788571
1 1 0.666667 0.793605
1 1 0.666667 0.801676
1 1 0.666667 0.795455
1 1 0.666667 0.778736
1 1 0.666667 0.776163
1 1 0.666667 0.786145
1 1 0.666667 0.790698
1 1 0.666667 0.792614
1 1 0.666667 0.793605
1 1 0.666667 0.78125
1 1 0.666667 0.789941
1 1 0.666667 0.801676
1 1 0.666667 0.801676
1 1 0.666667 0.79023
1 1 0.666667 0.800562
1 1 0.666667 0.755952
1 1 0.666667 0.790698
1 1 0.666667 0.801676
1 1 0.666667 0.801676
1 1 0.666667 0.774566
1 1 0.666667 0.774854
1 1 0.666667 0.768362
1 1 0.666667 0.801724
1 1 0.666667 0.778409
1 1 0.666667 0.786127
1 1 0.666667 0.801724
1 1 0.666667 0.767857
1 1 0.666667 0.796512
1 1 0.666667 0.801724
1 1 0.666667 0.79661
1 1 0.666667 0.789773
1 1 0.666667 0.794444
1 1 0.666667 0.793785
1 1 0.666667 0.787356
1 1 0.666667 0.79661
1 1 0.666667 0.794444
1 1 0.666667 0.786932
1 1 0.666667 0.797753
1 1 0.666667 0.789773
1 1 0.666667 0.79661
1 1 0.666667 0.793785
1 1 0.666667 0.787425
1 1 0.666667 0.780556
1 1 0.666667 0.794118
1 1 0.666667 0.788571
1 1 0.666667 0.79096
1 1 0.666667 0.784091
23.8085 70 28 22 7 39 79 85 81 63 103 57 90 34 66 12 93 36 30 59 0 82 8 64 23 15 83 68 72 65 17 74 69 5 2 61 32 38 52 55 9 42 62 43 58 25 31 75 49 101 21 40 46 35 26 41 3 20 84 6 4 27 104 94 10 37 24 98 73 102 13 54 1 1 0.666667 0.53352
22.3794 70 4 23 62 95 39 81 0 16 66 57 103 47 61 63 26 3 82 93 44 97 14 37 65 83 41 60 87 72 69 80 36 40 74 32 2 11 38 52 46 30 53 77 64 75 31 5 21 50 25 51 43 86 28 34 67 98 49 102 101 54 94 76 33 73 48 18 91 13 70 59 1 1 0.666667 0.801724
#bash
for d in */ ;
do
echo $d" " | tr -d "\n" >> 'allallbestsols.txt'
cd $d
rm -f 'allbestsols.txt'
for f in bestsol.* ;
do
cat $f >> 'allbestsols.txt'
echo >> 'allbestsols.txt'
cat $f | cut -d " " -f 1 | tr -d "\n" >> ../'allallbestsols.txt'
echo " " | tr -d "\n" >> ../'allallbestsols.txt'
done
cd ..
echo >> 'allallbestsols.txt'
done
\ No newline at end of file
-C=105 -c=52 -R=7 -Q=5 -A=5 -n=10 -N=35 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=5 -A=5 -n=10 -N=35 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=5 -n=10 -N=35 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=6 -n=10 -N=35 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=7 -n=10 -N=35 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=8 -n=10 -N=35 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=9 -n=10 -N=35 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=10 -n=10 -N=35 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=5 -n=10 -N=26 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=6 -n=10 -N=26 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=7 -n=10 -N=26 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=8 -n=10 -N=26 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=9 -n=10 -N=26 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=10 -n=10 -N=26 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=5 -n=10 -N=21 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=6 -n=10 -N=21 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=7 -n=10 -N=21 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=8 -n=10 -N=21 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=9 -n=10 -N=21 -r=1 -q=0
-C=105 -c=52 -R=7 -Q=2 -A=10 -n=10 -N=21 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=5 -n=10 -N=35 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=6 -n=10 -N=35 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=7 -n=10 -N=35 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=8 -n=10 -N=35 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=9 -n=10 -N=35 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=10 -n=10 -N=35 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=5 -n=10 -N=26 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=6 -n=10 -N=26 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=7 -n=10 -N=26 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=8 -n=10 -N=26 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=9 -n=10 -N=26 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=10 -n=10 -N=26 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=5 -n=10 -N=21 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=6 -n=10 -N=21 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=7 -n=10 -N=21 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=8 -n=10 -N=21 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=9 -n=10 -N=21 -r=1 -q=0
-C=105 -c=104 -R=7 -Q=2 -A=10 -n=10 -N=21 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=5 -n=10 -N=35 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=6 -n=10 -N=35 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=7 -n=10 -N=35 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=8 -n=10 -N=35 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=9 -n=10 -N=35 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=10 -n=10 -N=35 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=5 -n=10 -N=26 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=6 -n=10 -N=26 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=7 -n=10 -N=26 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=8 -n=10 -N=26 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=9 -n=10 -N=26 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=10 -n=10 -N=26 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=5 -n=10 -N=21 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=6 -n=10 -N=21 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=7 -n=10 -N=21 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=8 -n=10 -N=21 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=9 -n=10 -N=21 -r=1 -q=0
-C=105 -c=156 -R=7 -Q=2 -A=10 -n=10 -N=21 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=5 -n=10 -N=35 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=6 -n=10 -N=35 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=7 -n=10 -N=35 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=8 -n=10 -N=35 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=9 -n=10 -N=35 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=10 -n=10 -N=35 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=5 -n=10 -N=26 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=6 -n=10 -N=26 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=7 -n=10 -N=26 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=8 -n=10 -N=26 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=9 -n=10 -N=26 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=10 -n=10 -N=26 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=5 -n=10 -N=21 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=6 -n=10 -N=21 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=7 -n=10 -N=21 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=8 -n=10 -N=21 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=9 -n=10 -N=21 -r=1 -q=0
-C=105 -c=208 -R=7 -Q=2 -A=10 -n=10 -N=21 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
-C=400 -c=400 -R=3 -Q=3 -A=15 -n=16 -N=40 -r=1 -q=0
for nbCours in 15
do
for nbComps in 10 20
do
for cbyTF in 2
do
for rEngine in 50
do
for pMut in 0.25 0.5 0.75
do
for pCross in 0.25 0.5 0.75
do
for tSize in 3 7
do
RESDIR="../results/${nbCours}_${nbComps}_${cbyTF}_${rEngine}_${pMut}_${pCross}_${tSize}"
mkdir $RESDIR
for run in 30
do
RESDIR="../results/${nbCours}_${nbComps}_${cbyTF}_${rEngine}_${pMut}_${pCross}_${tSize}"
sbatch --array=1-${run} --job-name=${RESDIR} --output=${RESDIR}.out --export=C=$nbCours,c=$nbComps,A=$cbyTF,O=$RESDIR,B=$rEngine,x=$pMut,X=$pCross,F=$tSize job.sh
done
done
done
done
done
done
done
done
for nbCours in 25
do
for nbComps in 10
do
for cbyTF in 3
do
for rEngine in 50
do
for pMut in 0.25 0.5 0.75
do
for pCross in 0.25 0.5 0.75
do
for tSize in 3 7
do
RESDIR="../results/${nbCours}_${nbComps}_${cbyTF}_${rEngine}_${pMut}_${pCross}_${tSize}"
mkdir $RESDIR
for run in 30
do
RESDIR="../results/${nbCours}_${nbComps}_${cbyTF}_${rEngine}_${pMut}_${pCross}_${tSize}"
sbatch --array=1-${run} --job-name=${RESDIR} --output=${RESDIR}.out --export=C=$nbCours,c=$nbComps,A=$cbyTF,O=$RESDIR,B=$rEngine,x=$pMut,X=$pCross,F=$tSize job.sh
done
done
done
done
done
done
done
done
for nbCours in 20
do
for nbComps in 20
do
for cbyTF in 3
do
for rEngine in 50
do
for pMut in 0.25 0.5 0.75
do
for pCross in 0.25 0.5 0.75
do
for tSize in 3 7
do
RESDIR="../results/${nbCours}_${nbComps}_${cbyTF}_${rEngine}_${pMut}_${pCross}_${tSize}"
mkdir $RESDIR
for run in 30
do
RESDIR="../results/${nbCours}_${nbComps}_${cbyTF}_${rEngine}_${pMut}_${pCross}_${tSize}"
sbatch --array=1-${run} --job-name=${RESDIR} --output=${RESDIR}.out --export=C=$nbCours,c=$nbComps,A=$cbyTF,O=$RESDIR,B=$rEngine,x=$pMut,X=$pCross,F=$tSize job.sh
done
done
done
done
done
done
done
done
for nbCours in 30
do
for nbComps in 40
do
for cbyTF in 4
do
for rEngine in 50
do
for pMut in 0.25 0.5 0.75
do
for pCross in 0.25 0.5 0.75
do
for tSize in 3 7
do
RESDIR="../results/${nbCours}_${nbComps}_${cbyTF}_${rEngine}_${pMut}_${pCross}_${tSize}"
mkdir $RESDIR
for run in 30
do
RESDIR="../results/${nbCours}_${nbComps}_${cbyTF}_${rEngine}_${pMut}_${pCross}_${tSize}"
sbatch --array=1-${run} --job-name=${RESDIR} --output=${RESDIR}.out --export=C=$nbCours,c=$nbComps,A=$cbyTF,O=$RESDIR,B=$rEngine,x=$pMut,X=$pCross,F=$tSize job.sh
done
done
done
done
done
done
done
done
for idx in 1 2 3 4
do
for nbCours in 105 #LATER 95 85 75 65 55 45 35
do
for i in 3 4 5
do
for cbyTF in 5 6 7 8 9 10
do
for maxCbyC in 7 #LATER 3 4 5 6
do
for maxPre in 2 #LATER 3 4 DONE 5
do
for nbGen in 10000
do
let "nbComps=$idx * ($nbCours/2)"
let "maxCbyTF=$nbCours/$i"
let "minCbyTF=$nbCours/10"
if [ $minCbyTF -lt $cbyTF ]
then
let "minCbyTF=$cbyTF"
fi
RESDIR="../results/${nbCours}_${nbComps}_${maxCbyC}_${maxPre}_${cbyTF}_${minCbyTF}_${maxCbyTF}_${nbGen}"
mkdir $RESDIR
for run in 30
do
let "nbComps=$idx * ($nbCours/2)"
let "maxCbyTF=$nbCours/$i"
let "minCbyTF=$nbCours/10"
if [ $minCbyTF -lt $cbyTF ]
then
let "minCbyTF=$cbyTF"
fi
RESDIR="../results/${nbCours}_${nbComps}_${maxCbyC}_${maxPre}_${cbyTF}_${minCbyTF}_${maxCbyTF}_${nbGen}"
sbatch --array=1-${run} --job-name=${RESDIR} --output=${RESDIR}.out --export=C=$nbCours,c=$nbComps,R=$maxCbyC,Q=$maxPre,A=$cbyTF,n=$minCbyTF,N=$maxCbyTF,r=1,q=0,O=$RESDIR,B=20,x=0.75,X=0.75,F=3,G=$nbGen job.sh
echo "-C=${nbCours} -c=${nbComps} -R=${maxCbyC} -Q=${maxPre} -A=${cbyTF} -n=${minCbyTF} -N=${maxCbyTF} -r=1 -q=0" >> case
done
done
done
done
done
done
done
done
#
for nbCours in 55 #LATER 95 85 75 65 55 45 35
do
for i in 3 #4 5
do
for cbyTF in 6 #6 7 8 9 10
do
for maxCbyC in 5 #LATER 3 4 5 6
do
for maxPre in 3 #LATER 2 3 4
do
for nbGen in 10000
do
nbComps=75
RESDIR="../results/${nbCours}_${nbComps}_${maxCbyC}_${maxPre}_${cbyTF}_${nbGen}"
mkdir $RESDIR
for run in 30
do
nbComps=75
minCbyTF=7
maxCbyTF=15
RESDIR="../results/${nbCours}_${nbComps}_${maxCbyC}_${maxPre}_${cbyTF}_${nbGen}"
sbatch --array=1-${run} --job-name=${RESDIR} --output=${RESDIR}.out --export=C=$nbCours,c=$nbComps,R=$maxCbyC,Q=$maxPre,A=$cbyTF,n=$minCbyTF,N=$maxCbyTF,r=1,q=0,O=$RESDIR,B=50,x=0.75,X=0.75,F=3,G=$nbGen job.sh
echo "-C=${nbCours} -c=${nbComps} -R=${maxCbyC} -Q=${maxPre} -A=${cbyTF} -n=${minCbyTF} -N=${maxCbyTF} -r=1 -q=0" >> case
done
done
done
done
done
done
done
#
for nbCours in 105 #LATER 95 85 75 65 55 45 35
do
for cbyTF in 9 #6 7 8 9 10
do
for maxCbyC in 5 #LATER 3 4 5 6
do
for maxPre in 3 #LATER 2 3 4
do
for nbGen in 100000
do
nbComps=210
RESDIR="../results/${nbCours}_${nbComps}_${maxCbyC}_${maxPre}_${cbyTF}_${nbGen}"
mkdir $RESDIR
for run in 30
do
nbComps=210
minCbyTF=10
maxCbyTF=21
RESDIR="../results/${nbCours}_${nbComps}_${maxCbyC}_${maxPre}_${cbyTF}_${nbGen}"
sbatch --array=1-${run} --job-name=${RESDIR} --output=${RESDIR}.out --export=C=$nbCours,c=$nbComps,R=$maxCbyC,Q=$maxPre,A=$cbyTF,n=$minCbyTF,N=$maxCbyTF,r=1,q=0,O=$RESDIR,B=50,x=0.75,X=0.75,F=3,G=$nbGen job.sh
echo "-C=${nbCours} -c=${nbComps} -R=${maxCbyC} -Q=${maxPre} -A=${cbyTF} -n=${minCbyTF} -N=${maxCbyTF} -r=1 -q=0" >> case
done
done
done
done
done
done
#
for nbCours in 400 #LATER 300 310 320 330 340 350 360 370 380 390 410 420 430 440 450 460 470 480 490 500
do
for cbyTF in 15
do
for maxCbyC in 3
do
for maxPre in 3
do
for nbGen in 10000
do
nbComps=400
RESDIR="../results/${nbCours}_${nbComps}_${maxCbyC}_${maxPre}_${cbyTF}_${nbGen}"
mkdir $RESDIR
for run in 1
do
nbComps=400
minCbyTF=16
maxCbyTF=40
RESDIR="../results/${nbCours}_${nbComps}_${maxCbyC}_${maxPre}_${cbyTF}_${nbGen}"
sbatch --array=1-${run} --job-name=${RESDIR} --output=${RESDIR}.out --export=C=$nbCours,c=$nbComps,R=$maxCbyC,Q=$maxPre,A=$cbyTF,n=$minCbyTF,N=$maxCbyTF,r=1,q=0,O=$RESDIR,B=50,x=0.75,X=0.75,F=3,G=$nbGen job.sh
echo "-C=${nbCours} -c=${nbComps} -R=${maxCbyC} -Q=${maxPre} -A=${cbyTF} -n=${minCbyTF} -N=${maxCbyTF} -r=1 -q=0" >> case
done
done
done
done
done
done
#
for nbCours in 400 #LATER 300 310 320 330 340 350 360 370 380 390 410 420 430 440 450 460 470 480 490 500
do
for cbyTF in 15
do
for maxCbyC in 3
do
for maxPre in 3
do
for nbGen in 100000
do
nbComps=400
RESDIR="../results/${nbCours}_${nbComps}_${maxCbyC}_${maxPre}_${cbyTF}_${nbGen}"
mkdir $RESDIR
for run in 1
do
nbComps=400
minCbyTF=16
maxCbyTF=40
RESDIR="../results/${nbCours}_${nbComps}_${maxCbyC}_${maxPre}_${cbyTF}_${nbGen}"
sbatch --array=1-${run} --job-name=${RESDIR} --output=${RESDIR}.out --export=C=$nbCours,c=$nbComps,R=$maxCbyC,Q=$maxPre,A=$cbyTF,n=$minCbyTF,N=$maxCbyTF,r=1,q=0,O=$RESDIR,B=50,x=0.75,X=0.75,F=3,G=$nbGen job.sh
echo "-C=${nbCours} -c=${nbComps} -R=${maxCbyC} -Q=${maxPre} -A=${cbyTF} -n=${minCbyTF} -N=${maxCbyTF} -r=1 -q=0" >> case
done
done
done
done
done
done
#!/bin/bash
#SBATCH -o main.out
#SBATCH -N 1
#SBATCH -n 1
#SBATCH --mem=4G
#SBATCH -p defq
/home/jeremie.humeau/private/gitProject/csdvp-evolutionary-algorithm-optimization/build/application/ceao -G=$G -P=100 -S=$SLURM_ARRAY_TASK_ID -C=$C -c=$c -R=$R -Q=$Q -A=$A --outputfile=$O -n=$n -N=$N -r=$r -q=$q -B=$B -x=$x -X=$X -F=$F -T=10
exit 0
#!/bin/bash
#SBATCH -o main.out
#SBATCH -N 1
#SBATCH -n 1
#SBATCH --mem=4G
#SBATCH -p defq
/home/jeremie.humeau/private/gitProject/csdvp-evolutionary-algorithm-optimization/build/application/ceao2 -G=10000 -P=100 -S=1 -C=105 -c=104 -R=7 -Q=5 -A=7 --outputfile=./TFtest -n=10 -N=25 -r=1 -q=0 -B=20 -x=0.75 -X=0.75 -F=3 -T=10
exit 0
push with error 98
push with error 58
push with error 72
push with error 67
push with error 42
push with error 70
push with error 60
push with error 1
push with error 21
push with error 97
push with error 73
push with error 101
push with error 66
push with error 75
push with error 1
push with error 7
push with error 28
push with error 66
push with error 1
push with error 31
push with error 21
push with error 1
push with error 54
push with error 72
push with error 101
push with error 80
push with error 94
push with error 83
push with error 54
push with error 84
push with error 16
push with error 1
push with error 89
push with error 27
push with error 84
push with error 24
push with error 87
push with error 21
push with error 54
push with error 72
push with error 51
push with error 98
......@@ -9,6 +9,7 @@ SET (EXERCICE_SOURCES
course.cpp
profession.cpp
problem.cpp
decay.cpp
)
ADD_LIBRARY(lModel STATIC ${EXERCICE_SOURCES})
......
......@@ -61,7 +61,7 @@ Competency Competency::buildTMP(double d, std::string name)
// === CONSTRUCTOR
Competency::Competency(int id, Magnitude m, std::string s)
: _id(id), _m(m), _name(s)
: _id(id), _m(m), _undecayedMag(m), _name(s), _howLongDecaying(0), _isDecaying(false)
{
}
......@@ -115,11 +115,33 @@ void Competency::evolveTowards(double d)
}
}
const double Competency::competencyValue() const
double Competency::competencyValue() const
{
return this->_m.value();
}
double Competency::decay()
{
if(!this->_isDecaying)
return this->_m.value();
double val = this->_m.value();
val -= DecayEngine::defaultDecay(this->_howLongDecaying);
//std::cout << "before:" << this->_m.value() << " vs. after: " << val << std::endl;
return val < 0 ? 0 : val > 1 ? 1 : val;
}
void Competency::saveDecay()
{
double val = this->decay();
//std::cout << "inS&D:" << val << std::endl;
this->_howLongDecaying = 0;
this->_isDecaying = false;
this->_m.set(val);
}
// === OPERATOR
std::ostream& operator<<(std::ostream& Stream, const Competency & c)
{
......
......@@ -4,6 +4,8 @@
#include <string>
#include "magnitude.h"
#include "decay.h"
/**
* Represents the notion of a competency (a.k.a. "non operationalisable" skill).
......@@ -15,9 +17,13 @@
class Competency
{
private:
int _id;
Magnitude _m;
Magnitude _undecayedMag; //Decay related
std::string _name;
int _id;
int _howLongDecaying; //Decay related
bool _isDecaying; //Decay related
//Constructor
Competency(int, Magnitude, std::string);
......@@ -51,7 +57,7 @@ class Competency
// === GETTER
///Retrieves the magnitude/mastery value of the competency
const double competencyValue() const;
double competencyValue() const;
///Retrieves the magnitude of the compentecy
const Magnitude c_magnitude() const {return this->_m;}
Magnitude & magnitude(){return this->_m;}
......@@ -59,12 +65,27 @@ class Competency
const std::string c_name() const {return this->_name;}
std::string & name() {return this->_name;}
const int id() const {return this->_id;}
int id() const {return this->_id;}
// === SETTER
void setMagnitude(Magnitude & m){this->_m = m;}
void setName(std::string s){this->_name = s;}
// === DECAY
bool isDecaying() const {return this->_isDecaying;}
void decayState(bool state) {this->_isDecaying = state;}
int increaseDecay(){this->_isDecaying = true; this->_howLongDecaying++; return this->_howLongDecaying;}
void resetDecay(){this->_isDecaying = false; this->_howLongDecaying = 0;}
void setTimeDecay(unsigned int time){this->_howLongDecaying = time;}
Magnitude getUndecayedMagnitude(){return this->_undecayedMag;}
/**Returns the new magnitude of this affected by the current competency's decay.
* Note that the decay **IS NOT** saved in the magnitude. Use saveDecay instead.
*/
double decay();
/** Save the new magnitude value according to the decay of this. The function reset the decay of this by setting it to FALSE. Therefore, the decay restart to 0.
*/
void saveDecay();
// === OPERATOR
/// A competency is equal to another iff their id are the same, or their name
bool operator==(const Competency & c) const;
......
......@@ -46,6 +46,7 @@ std::pair<bool, double> ConstraintsPrerequisites::integrityCheck(Cursus indiv)
{
// HERE, VARIABLE DECAY CAN BE APPLIED!!!!!!!!
compByTF.at(currentTF).push_back(compByTF.at(currentTF-1).at(j));
compByTF.at(currentTF).at(compByTF.at(currentTF).size()-1).increaseDecay();
}
// Then, we explore the current TF for new Comp
......@@ -83,6 +84,7 @@ std::pair<bool, double> ConstraintsPrerequisites::integrityCheck(Cursus indiv)
//std::cout << currentCompetency.c_name() << " already exists" <<std::endl;
try
{
compByTF.at(currentTF).at(alreadyExists.first).saveDecay();
compByTF.at(currentTF).at(alreadyExists.first).evolveTowards(currentCompetency.magnitude());
}
catch(CompetencyEvolvingException & e) //if CEE is thrown, then magnitude has been auto rebased
......@@ -101,15 +103,15 @@ std::pair<bool, double> ConstraintsPrerequisites::integrityCheck(Cursus indiv)
}
}
//std::cout << "==EXPLORING COMP BY TF" << std::endl;
for(int i = 0; i < compByTF.size(); i++)
{
//std::cout << "TF#" << std::to_string(i) << std::endl;
for(int j = 0; j < compByTF.at(i).size() ; j++)
{
//std::cout << compByTF.at(i).at(j) << std::endl;
}
}
// //std::cout << "==EXPLORING COMP BY TF" << std::endl;
// for(int i = 0; i < compByTF.size(); i++)
// {
// //std::cout << "TF#" << std::to_string(i) << std::endl;
// for(int j = 0; j < compByTF.at(i).size() ; j++)
// {
// //std::cout << compByTF.at(i).at(j) << std::endl;
// }
// }
bool isOK = ((notFound == 0) && (notRespected == 0));
/*
......@@ -156,7 +158,7 @@ std::pair<int, int> ConstraintsPrerequisites::_prereqsInPreviousTF(std::vector<C
if(prereqs.at(i)==cInTF.at(j))
{
found = true;
if(prereqs.at(i).c_magnitude().value() > cInTF.at(j).c_magnitude().value())
if(prereqs.at(i).c_magnitude().value() > cInTF.at(j).decay())
notRespected++;
}
}
......
......@@ -23,10 +23,24 @@ std::pair<bool, double> ConstraintsProfession::integrityCheck(Cursus indiv)
Competency currentComp;
std::pair<int, Competency> posFound;
bool changedTF = false;
int currentTF = 0;
for(int i = 0 ; i < indiv.size(); i++)
{
current = this->_pb.coursesCatalogue().at(indiv.at(i));
if(currentTF != i / this->_pb.cfg_pickedCoursesByTimeFrame())
changedTF = true;
else
changedTF = false;
currentTF = i / this->_pb.cfg_pickedCoursesByTimeFrame();
for(int j = 0; j < compToAnswer.size(); j++)
{
compToAnswer.at(j).increaseDecay();
}
for(int j = 0 ; j < current.teachedCompetenciesWeighted().size() ; j++)
{
currentComp = current.teachedCompetenciesWeighted().at(j).first;
......@@ -36,6 +50,7 @@ std::pair<bool, double> ConstraintsProfession::integrityCheck(Cursus indiv)
{
try
{
compToAnswer.at(posFound.first).saveDecay();
compToAnswer.at(posFound.first).evolveTowards(currentComp.magnitude());
}
catch(CompetencyEvolvingException & e) //if CEE is thrown, then magnitude has been auto rebased
......@@ -48,6 +63,12 @@ std::pair<bool, double> ConstraintsProfession::integrityCheck(Cursus indiv)
}
}
for(int i = 0; i < compToAnswer.size(); i++)
{
compToAnswer.at(i).saveDecay();
//std::cout << compToAnswer.at(i) << std::endl;
}
//Now that we have evolve all the tmp competency, we compate their mag to the requirement. We count how many is not met to define the metric
int score = 0;
......
......@@ -239,10 +239,10 @@ bool Course::_lazyEquality(const Course & c) const
}
///@todo
bool Course::_fullEquality(const Course & c) const
{
throw NotImplementedException("Course::_fullEquality");
}
// bool Course::_fullEquality(const Course & c) const
// {
// throw NotImplementedException("Course::_fullEquality");
// }
// === OPERATOR
std::ostream& operator<<(std::ostream& Stream, const Course & c)
......@@ -251,20 +251,20 @@ std::ostream& operator<<(std::ostream& Stream, const Course & c)
std::string tf;
if(c.timeFrame().size() > 0)
{
for(int i = 0; i < c.timeFrame().size()-1; i++)
for(unsigned int i = 0; i < c.timeFrame().size()-1; i++)
tf+=std::to_string(c.timeFrame().at(i))+" ; ";
tf+=std::to_string(c.timeFrame().at(c.timeFrame().size()-1));
s+="\n\tTimeFrames: ["+tf+"]";
}
s+="\n\tRequirement: [";
for(int i = 0; i < c.prerequisites().size(); i++)
for(unsigned int i = 0; i < c.prerequisites().size(); i++)
{
s+="" + c.prerequisites().at(i).c_name()+ "("+ std::to_string(c.prerequisites().at(i).c_magnitude().value()) + ") ; ";
}
s+="]";
s+="\n\tTeaches: [";
for(int i = 0 ; i < c.teachedCompetenciesWeighted().size(); i++)
for(unsigned int i = 0 ; i < c.teachedCompetenciesWeighted().size(); i++)
{
s+= "" + c.teachedCompetenciesWeighted().at(i).first.c_name() + "("+ std::to_string(c.teachedCompetenciesWeighted().at(i).first.c_magnitude().value())+") ; ";
}
......@@ -308,9 +308,9 @@ std::vector<std::vector<Course>> Course::organiseByTF(std::vector<Course> course
std::vector<std::vector<Course>> coursesByTF(timeFrames.size());
int tmpIdx;
for(int i = 0; i < courses.size(); i++)
for(unsigned int i = 0; i < courses.size(); i++)
{
for(int j = 0; j < courses.at(i).timeFrame().size(); j++)
for(unsigned int j = 0; j < courses.at(i).timeFrame().size(); j++)
{
tmpIdx = courses.at(i).timeFrame().at(j) - timeFrames.at(0);
coursesByTF.at(tmpIdx).push_back(courses.at(i));
......
......@@ -30,6 +30,7 @@ class Course
// std::vector<double> diffusionWeight;
// === OTHER
int _id;
/// European Credit Transfer and Accumulation System
int _ects;
/** Timeframe availablity of a course.
......@@ -38,7 +39,7 @@ class Course
*/
std::vector<int> _temporalAvailability;
std::string _name;
int _id;
// === FUNC
/// _duplicataProtection returns true if the value (2nd param) searched into (1st param) is found
......@@ -73,9 +74,9 @@ class Course
Course() = default;
// === GETTER
const int id() const{return this->_id;};
int id() const{return this->_id;};
const std::string name() const{return this->_name;};
const int ects() const{return this->_ects;}
int ects() const{return this->_ects;}
const std::vector<Competency> prerequisites() const {return this->_prerequisites;}
std::vector<Competency>& unlocked_prerequisites() {return this->_prerequisites;}
const std::vector<int> timeFrame() const {return this->_temporalAvailability;}
......
#include "decay.h"
int DecayEngine::IS_DECAY_DEACTIVATED = 0;
\ No newline at end of file
#ifndef SRC_MODEL_DECAY_H_
#define SRC_MODEL_DECAY_H_
#include <cmath>
#include <iostream>
class DecayEngine
{
private:
public:
static int IS_DECAY_DEACTIVATED;
/** Expresses the decay over the time x.
*/
static double defaultDecay(int t)
{
if(IS_DECAY_DEACTIVATED)
return 0;
if(t == 0)
return 0;
return (exp(t / 1.25) + 5)/100;
}
};
#endif //SRC_MODEL_DECAY_H_
\ No newline at end of file
#ifndef SRC_MODEL_EA_BESTFITSTAT_H_
#define SRC_MODEL_EA_BESTFITSTAT_H_
#include <eo>
#include <fstream>
#include <iostream>
#include "cursus.h"
template <class EOT>
class bestFitStat: public eoStat<EOT, typename EOT::Fitness>
{
public:
typedef typename EOT::Fitness Fitness;
bestFitStat(int _interval, std::string _filename, std::string _description="best "):eoStat<EOT, Fitness>(Fitness(), _description), interval(_interval),filename(_filename){
cpt=0;
}
void operator()(const eoPop<EOT>& _pop){
if((cpt%interval)==0){
std::ofstream outputfile(filename.c_str(), std::ios::app);
outputfile << cpt << ":\t" << std::endl;
_pop.best_element().printOn(outputfile);
outputfile << std::endl;
outputfile.close();
}
cpt++;
}
virtual void lastCall(eoPop<EOT>& _pop){
std::ofstream outputfile(filename.c_str(), std::ios::app);
outputfile << cpt << ":\t" << std::endl;
_pop.best_element().printOn(outputfile);
outputfile << std::endl;
outputfile.close();
}
int interval;
std::string filename;
int cpt;
};
#endif // SRC_MODEL_EA_BESTFITSTAT_H_
......@@ -9,11 +9,10 @@ class crossCSDVP: public eoQuadOp<EOT>
public:
crossCSDVP(CSDVP& _pb, ConstraintsRepetition& _ctr, CursusInitConstraint& _init):pb(_pb),ctr(_ctr), init(_init), cpt(0){}
crossCSDVP(CSDVP& _pb, ConstraintsRepetition& _ctr, CursusInitConstraint& _init):pb(_pb),ctr(_ctr), init(_init){}
virtual bool operator()(EOT& _chrom1, EOT& _chrom2){
cpt++;
//Integrity Check BEFORE CROSS
std::pair<bool, double> ctrRes1= ctr.integrityCheck(_chrom1);
std::pair<bool, double> ctrRes2= ctr.integrityCheck(_chrom2);
......@@ -137,7 +136,6 @@ class crossCSDVP: public eoQuadOp<EOT>
}
}
int cpt;
private:
CSDVP pb;
......
#include "evaluator.h"
#include "../tools.h"
double CursusEval::WEIGHT_ECTS = 1;
double CursusEval::WEIGHT_REPETION = 1;
double CursusEval::WEIGHT_JOB = 1;
double CursusEval::WEIGHT_PREREQ = 1;
void CursusEval::operator()(Cursus & _cursus){
double fit=0.0;
int pCE, pCP, pCR, pCPR;
double pCE, pCP, pCR, pCPR;
pCE=1;
pCR=1;
pCP=1;
pCPR=1;
pCE = WEIGHT_ECTS;
pCR = WEIGHT_REPETION;
pCP = WEIGHT_JOB;
pCPR= WEIGHT_PREREQ;
std::pair<bool, double> resCE;
std::pair<bool, double> resCP;
......
......@@ -17,6 +17,10 @@ public:
void operator()(Cursus & _cursus);
static double WEIGHT_ECTS;
static double WEIGHT_REPETION;
static double WEIGHT_JOB;
static double WEIGHT_PREREQ;
private:
ConstraintsPrerequisites cpr;
......
......@@ -23,10 +23,14 @@ class eoInitConstraintCSDVP: public eoInit<EOT>
eoInitConstraintCSDVP(CSDVP& _pb): pb(_pb){
std::vector<int> tmp;
chromSize=pb.getQuantityCoursesToPick();
std::cout << "nombre de cours à prendre: " << chromSize << std::endl;
maxVal=pb.coursesCatalogue().size();
std::cout << "nb Cours total dans le catalogue: " << maxVal << std::endl;
seed=pb.seed();
TF = pb.timeFrames();
nbTF=TF.size();
std::cout << "nb de Semestres" << nbTF << std::endl;
sizeTF=chromSize/nbTF;
catalogue = pb.coursesCatalogue();
possibleIDbyTF.resize(nbTF);
......@@ -36,13 +40,13 @@ class eoInitConstraintCSDVP: public eoInit<EOT>
possibleIDbyTF[tmp[j]-pb.cfg_minimalTimeFrame()].push_back(i);
}
}
// for(int i=0; i<possibleIDbyTF.size(); i++){
// std::cout << "Possible course in TF " << i+pb.cfg_minimalTimeFrame() << ": ";
// for(int j=0; j<possibleIDbyTF[i].size(); j++){
// std::cout << possibleIDbyTF[i][j] << " ";
// }
// std::cout << std::endl;
// }
/*for(int i=0; i<possibleIDbyTF.size(); i++){
std::cout << "Possible course in TF " << i+pb.cfg_minimalTimeFrame() << ": ";
for(int j=0; j<possibleIDbyTF[i].size(); j++){
std::cout << possibleIDbyTF[i][j] << " ";
}
std::cout << std::endl;
}*/
}
virtual void operator()(EOT& chrom){
......
#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"
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), seed(_seed)
{}
virtual void operator()(EOT& chrom)
{
chrom.resize(0);
for(int i = 0; i < maxVal; i++)
chrom.push_back(i);
std::random_shuffle(chrom.begin(), chrom.end());
chrom.resize(chromSize);
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_
......@@ -20,7 +20,6 @@ template <class EOT>
class mutCSDVP: public eoMonOp<EOT>
{
public:
mutCSDVP(CSDVP& _pb, ConstraintsRepetition& _ctr):pb(_pb),ctr(_ctr){}
//_CourseID subastraction from _chrom
......@@ -178,9 +177,9 @@ class mutCSDVP: public eoMonOp<EOT>
std::random_shuffle(gfiCourse.begin(), gfiCourse.end());
_chrom[rngCourseToSwap] = pb.mapCourseToPosition(gfiCourse.at(0));
}
else //least constraint courses in 60% of the cases, otherwise full rand
else //least constraint courses in 25% of the cases, otherwise full rand
{
if(eo::rng.random(100) > 60)
if(eo::rng.random(100) > RATIO_RANDOM_VS_BEST)
{
fbBestCourse = coursesOfTF.at(0);
for(i = 1; i < coursesOfTF.size(); i++)
......@@ -228,10 +227,27 @@ class mutCSDVP: public eoMonOp<EOT>
bool addStatus = false;
int pos=0;
bool changedTF = false;
int currentTF = 0;
for(int i = 0; i < _chrom.size() && (i / nbCbyTF < TF); i++)
{
currentCourse = catalogue.at(_chrom.at(i));
if(currentTF != i / nbCbyTF)
changedTF = true;
else
changedTF = false;
currentTF = i / nbCbyTF;
if(changedTF) //if we have changed of tf, lets improve decay for all comp
{
for(int j = 0; j < tmpCourse.prerequisites().size(); j++)
{
tmpCourse.unlocked_prerequisites().at(j).increaseDecay();
}
}
for(int j = 0; j < currentCourse.teachedCompetenciesWeighted().size(); j++)
{
tmpComp = currentCourse.teachedCompetenciesWeighted().at(j).first;
......@@ -246,7 +262,7 @@ class mutCSDVP: public eoMonOp<EOT>
try
{
Magnitude mag = currentCourse.teachedCompetenciesWeighted().at(j).first.c_magnitude();
//tmpCourse.unlocked_prerequisites().at(pos).saveDecay();
tmpCourse.unlocked_prerequisites().at(pos).evolveTowards(mag);
}
catch(CompetencyEvolvingException & e)
......@@ -259,6 +275,9 @@ class mutCSDVP: public eoMonOp<EOT>
}
compStatus = tmpCourse.prerequisites();
for(int i = 0; i < compStatus.size(); i++)
compStatus.at(i).saveDecay();
return compStatus;
}
......@@ -287,7 +306,7 @@ class mutCSDVP: public eoMonOp<EOT>
{
if(checkCmp == state.at(itState))
{
if(checkCmp.c_magnitude().value() > state.at(itState).c_magnitude().value())
if(checkCmp.c_magnitude().value() > state.at(itState).decay())
{ stop = true; found = false; }
else
{ stop = true; found = true; }
......
......@@ -30,7 +30,7 @@ class CourseTemporalFrameException : public std::exception
}
Course & getCourse() const{return *(this->_course);}
const int getTime() const{return this->_time;}
int getTime() const{return this->_time;}
};
#endif // SRC_MODEL_EXCEPTION_COURSE_TEMPORAL_FRAME_EXCEPTION_H_
\ No newline at end of file
......@@ -80,9 +80,9 @@ int CSDVP::CSDVP_COUNTER = 0;
void CSDVP::setTimeFrames(std::vector<int> & v)
{this->_timeFrames = v;}
void CSDVP::setCoursesCatalogue(std::vector<Course> & c)
{this->_availableCourses;}
{this->_availableCourses = c;}
void CSDVP::setCompetenciesCatalogue(std::vector<Competency> & c)
{this->_availableCompentecies;}
{this->_availableCompentecies = c;}
// ADDER
bool CSDVP::addTimeFrame(int tF)
{
......@@ -167,13 +167,13 @@ int CSDVP::CSDVP_COUNTER = 0;
void CSDVP::_makeCoursesSortedByTF()
{
//Init the vector of the size of the time frames
for(int i = 0; i < this->_timeFrames.size(); i++)
for(unsigned 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(unsigned int i = 0; i < this->_availableCourses.size(); i++)
{
for(int j = 0; j < this->_availableCourses.at(i).timeFrame().size(); j++)
for(unsigned 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));
......@@ -182,7 +182,7 @@ int CSDVP::CSDVP_COUNTER = 0;
}
int CSDVP::mapCourseToPosition(const Course & c)
{
for(int i = 0; i < this->coursesCatalogue().size(); i++)
for(unsigned int i = 0; i < this->coursesCatalogue().size(); i++)
if(c == this->coursesCatalogue().at(i))
return i;
return -1;
......@@ -217,10 +217,10 @@ int CSDVP::CSDVP_COUNTER = 0;
return min + ( rand() % (max - min + 1) );
}
double CSDVP::_randomizeIn(const double min, const double max)
{
throw NotImplementedException("CSDVP::_randomizeIn");
}
// double CSDVP::_randomizeIn(const double min, const double max)
// {
// throw NotImplementedException("CSDVP::_randomizeIn");
// }
void CSDVP::randomizeProblem(CSDVP & pb, int seed)
{
......@@ -258,7 +258,6 @@ int CSDVP::CSDVP_COUNTER = 0;
{
tmpCourses.push_back(Course::build(CSDVP::_randomizeIn(pb.cfg_ectsMin(), pb.cfg_ectsMax())));
}
/* We obtain how many courses n by semester s
* then we create an idxCourses vector of size n * s
* then we shuffle it
......@@ -266,10 +265,19 @@ int CSDVP::CSDVP_COUNTER = 0;
*/
std::vector<int> idxCourses;
std::vector<int> nbCoursesByTF;
for(int i = 0 ; i < pb.timeFrames().size(); i++)
int somme=0;
for(unsigned int i = 0 ; i < pb.timeFrames().size(); i++){
nbCoursesByTF.push_back(CSDVP::_randomizeIn(pb._minimalCoursesByTimeFrame, pb._maximalCoursesByTimeFrame));
somme+=nbCoursesByTF[i];
}
while(somme<tmpCourses.size()){
int r=CSDVP::_randomizeIn(0, pb.timeFrames().size()-1);
nbCoursesByTF[r]++;
somme++;
}
int idxCoursesCounter = 0;
for(int i = 0; i < nbCoursesByTF.size(); i++)
for(unsigned int i = 0; i < nbCoursesByTF.size(); i++)
{
for(int j = 0; j < nbCoursesByTF.at(i); j++)
{
......@@ -282,17 +290,16 @@ int CSDVP::CSDVP_COUNTER = 0;
bool insertRez;
int rndIdx;
idxCoursesCounter = 0;
for(int i = 0; i < pb.timeFrames().size(); i++)
for(unsigned int i = 0; i < pb.timeFrames().size(); i++)
{
for(int j = 0; j < nbCoursesByTF.at(i); j++)
{
insertRez = true;
int cc = idxCourses.at(idxCoursesCounter);
insertRez = tmpCourses.at(idxCourses.at(idxCoursesCounter)).addTemporalFrame(pb.timeFrames().at(i));
while(!insertRez)//if duplicataProtection (i.e. course already in this semester)
{
rndIdx = CSDVP::_randomizeIn(0, pb._quantityAvailableCourses);
rndIdx = CSDVP::_randomizeIn(0, pb._quantityAvailableCourses - 1 );
insertRez = tmpCourses.at(rndIdx).addTemporalFrame(pb.timeFrames().at(i));
}
idxCoursesCounter++;
......@@ -319,9 +326,10 @@ int CSDVP::CSDVP_COUNTER = 0;
// }
// }
for(int i = 0; i < tmpCourses.size(); i++)
for(unsigned int i = 0; i < tmpCourses.size(); i++){
if(tmpCourses.at(i).timeFrame().size() > 0)
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 )
pb._makeCoursesSortedByTF();
......@@ -349,14 +357,14 @@ int CSDVP::CSDVP_COUNTER = 0;
std::vector<Competency> randomVec(pb.competencyCatalogue());
std::random_shuffle(randomVec.begin(), randomVec.end());
std::queue<Competency> queue;
for(int i = 0 ; i < randomVec.size(); i++)
for(unsigned int i = 0 ; i < randomVec.size(); i++)
queue.push(randomVec.at(i));
int x;
Competency tmpComp;
std::pair<Competency, double> teachedComp;
for(int i = 0; i < pb.coursesCatalogue().size(); i++)
for(unsigned int i = 0; i < pb.coursesCatalogue().size(); i++)
{
x = _randomizeIn(pb.cfg_competencyByCourseMin(), pb.cfg_competencyByCourseMax());
for(int j = 0; j < x; j++)
......@@ -375,10 +383,10 @@ int CSDVP::CSDVP_COUNTER = 0;
*/
std::random_shuffle(randomVec.begin(), randomVec.end());
queue = std::queue<Competency>();
for(int i = 0 ; i < randomVec.size(); i++)
for(unsigned int i = 0 ; i < randomVec.size(); i++)
queue.push(randomVec.at(i));
for(int i = 0; i < pb.coursesCatalogue().size(); i++)
for(unsigned int i = 0; i < pb.coursesCatalogue().size(); i++)
{
x = _randomizeIn(pb.cfg_prerequisiteByCourseMin(), pb.cfg_prerequisiteByCourseMax());
for(int j = 0; j < x; j++)
......
......@@ -102,21 +102,21 @@ class CSDVP
static void generateProblem(CSDVP & csdvp, CSDVP::GenerationType type, int seed= -1 );
// === GETTER
const int id() const{return this->_id;}
const int seed() const{return this->_seed;}
const int cfg_quantityCompetencies() const{return this->_quantityAvailableCompetencies;}
const int cfg_quantityCourses() const{return this->_quantityAvailableCourses;}
const int cfg_minimalTimeFrame() const{return this->_minimalTimeFrame;}
const int cfg_maximalTimeFrame() const{return this->_maximalTimeFrame;}
const int cfg_ectsMax() const{return this->_maximalECTSValue;}
const int cfg_ectsMin() const{return this->_minimalECTSValue;}
const int cfg_courseByTFMax() const{return this->_maximalCoursesByTimeFrame;}
const int cfg_courseByTFMin() const{return this->_minimalCoursesByTimeFrame;}
const int cfg_competencyByCourseMin() const {return this->_minimalCompetencyByCourse;}
const int cfg_competencyByCourseMax() const {return this->_maximalCompetencyByCourse;}
const int cfg_prerequisiteByCourseMin() const {return this->_minimalPrerequisiteByCourse;}
const int cfg_prerequisiteByCourseMax() const {return this->_maximalPrerequisiteByCourse;}
const int cfg_pickedCoursesByTimeFrame() const {return this->_pickedCoursesByTimeFrame;}
int id() const{return this->_id;}
int seed() const{return this->_seed;}
int cfg_quantityCompetencies() const{return this->_quantityAvailableCompetencies;}
int cfg_quantityCourses() const{return this->_quantityAvailableCourses;}
int cfg_minimalTimeFrame() const{return this->_minimalTimeFrame;}
int cfg_maximalTimeFrame() const{return this->_maximalTimeFrame;}
int cfg_ectsMax() const{return this->_maximalECTSValue;}
int cfg_ectsMin() const{return this->_minimalECTSValue;}
int cfg_courseByTFMax() const{return this->_maximalCoursesByTimeFrame;}
int cfg_courseByTFMin() const{return this->_minimalCoursesByTimeFrame;}
int cfg_competencyByCourseMin() const {return this->_minimalCompetencyByCourse;}
int cfg_competencyByCourseMax() const {return this->_maximalCompetencyByCourse;}
int cfg_prerequisiteByCourseMin() const {return this->_minimalPrerequisiteByCourse;}
int cfg_prerequisiteByCourseMax() const {return this->_maximalPrerequisiteByCourse;}
int cfg_pickedCoursesByTimeFrame() const {return this->_pickedCoursesByTimeFrame;}
const Magnitude & cfg_magnitudeMin() const{return this->_minimalMagnitude;}
const Magnitude & cfg_magnitudeMax() const{return this->_maximalMagnitude;}
......@@ -131,7 +131,7 @@ class CSDVP
std::vector<Course> & unlocked_coursesCatalogue(){return this->_availableCourses;}
std::vector<Competency> & unlocked_competenciesCatalogue(){return this->_availableCompentecies;}
const int getQuantityCoursesToPick() const{
int getQuantityCoursesToPick() const{
if(this->_isConfig)
return this->_timeFrames.size() * this->_pickedCoursesByTimeFrame;
return -1;//if not config
......
......@@ -112,7 +112,7 @@ std::ostream & operator<<(std::ostream & Stream, const Profession & p)
{
std::string s = "Profession\n\tid:"+std::to_string(p.id())+"\n\tName:"+p.name()+"\n\tECTS: " + std::to_string(p.requiredECTS()) +"\n\t#Prereq:"+std::to_string(p.prerequisites().size())+"\n\t===Details:===\n\t";
Stream << s ;
for(int i = 0; i < p.prerequisites().size(); i++)
for(unsigned int i = 0; i < p.prerequisites().size(); i++)
Stream << "("<< i<< "th) " << p.prerequisites().at(i) << "\n\t";
Stream << "==========" << std::endl;
return Stream;
......@@ -170,7 +170,7 @@ void Profession::_randomlyGenerate(Profession & job, CSDVP & pb)
std::random_shuffle(tmpComp.begin(), tmpComp.end());
int i;
for(i = 0; i < tmpComp.size() && i < howManyPrereq; i++)
for(i = 0; i < (int)tmpComp.size() && i < howManyPrereq; i++)
{
magVal = job.cfg_minimalMagnitude().value() + ( (double)rand()/RAND_MAX) * ( job.cfg_maximalMagnitude().value() - job.cfg_minimalMagnitude().value()) ;
ctmp = Competency::buildTMP(magVal,tmpComp.at(i).name());
......@@ -196,7 +196,7 @@ void Profession::_randomlyGenerate(Profession & job, CSDVP & pb)
// ects = pb.timeFrames().size() * 30; //30 is the default european value
for(i = 0; i < pb.timeFrames().size(); i++)
for(i = 0; i < (int)pb.timeFrames().size(); i++)
{
for(int j = 0; j < pb.cfg_pickedCoursesByTimeFrame(); j++)
{
......
......@@ -65,16 +65,16 @@ class Profession
bool checkConfig();
// === GETTER
const int id() const{return this->_id;}
const int seed() const{return this->_seed;}
const int requiredECTS() const{return this->_requiredECTS;}
int id() const{return this->_id;}
int seed() const{return this->_seed;}
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;
std::vector<Competency> & unlocked_prerequisites(){return this->_prerequisites;}
const int cfg_minimalPrerequisites() const{return this->_minimalPrerequisites;}
const int cfg_maximalPrerequisites() const{return this->_maximalPrerequisites;}
int cfg_minimalPrerequisites() const{return this->_minimalPrerequisites;}
int cfg_maximalPrerequisites() const{return this->_maximalPrerequisites;}
const Magnitude cfg_minimalMagnitude() const{return this->_minimalMagnitude;}
const Magnitude cfg_maximalMagnitude() const{return this->_maximalMagnitude;}
......
......@@ -10,6 +10,7 @@
static const int ID_RANGE_FOR_OBJECT = 10000;
static const int ID_RANGE_FOR_TEMPORARY_OBJECT = std::numeric_limits<int>::max();
static unsigned int RATIO_RANDOM_VS_BEST;
template<typename T>
/** Searches into vec the element findMe. The class T must have T() defined ( T()=default; is OK) */
......@@ -21,7 +22,7 @@ static std::pair<int, T> findInVector(std::vector<T> & vec, T & findMe)
if(it == vec.end())
{
res.first = -1;
res.second; //NTD, -1 SHOULD BE USED TO DETECT THAT NOTHING HAS BEEN FOUND
//res.second; //NTD, -1 SHOULD BE USED TO DETECT THAT NOTHING HAS BEEN FOUND
}
else
{
......
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