Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
FIC_DK_P GA Solving
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
6
Issues
6
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
M3TAL
FIC_DK_P GA Solving
Commits
74d3cc48
Commit
74d3cc48
authored
May 15, 2020
by
jeremie.humeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ajout contrainte dans l'eval
parent
aac66378
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
27 deletions
+49
-27
main.cpp
application/main.cpp
+23
-13
prerequisitesConstraints.cpp
src/model/constraints/prerequisitesConstraints.cpp
+6
-4
evaluator.cpp
src/model/ea/evaluator.cpp
+14
-5
evaluator.h
src/model/ea/evaluator.h
+2
-1
initConstraint.h
src/model/ea/initConstraint.h
+4
-4
No files found.
application/main.cpp
View file @
74d3cc48
...
...
@@ -9,6 +9,7 @@
#include <model/profession.h>
#include <model/magnitude.h>
#include <model/tools.h>
#include <model/competency.h>
#include <model/ea/cursus.h>
#include <model/ea/initializer.h>
...
...
@@ -68,35 +69,42 @@ int main(int argc, char* argv[]){
CSDVP
pb
;
Profession
job
;
// ===== PB CONFIG ZONE =====
pb
.
set_cfg_quantityCourses
(
10
);
pb
.
set_cfg_quantityCompetencies
(
5
);
pb
.
set_cfg_quantityCourses
(
25
);
pb
.
set_cfg_quantityCompetencies
(
40
);
pb
.
set_cfg_minimalTimeFrames
(
1
);
pb
.
set_cfg_maximalTimeFrames
(
6
);
//Just "Licence"
pb
.
set_cfg_ectsMin
(
1
);
pb
.
set_cfg_ectsMax
(
5
);
pb
.
set_cfg_courseByTFMin
(
3
);
pb
.
set_cfg_courseByTFMax
(
5
);
pb
.
set_cfg_courseByTFMax
(
8
);
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_maximalCompetencyByCourse
(
5
);
pb
.
set_cfg_minimalPrerequisiteByCourse
(
0
);
pb
.
set_cfg_maximalPrerequisiteByCourse
(
1
);
pb
.
set_cfg_maximalPrerequisiteByCourse
(
3
);
pb
.
set_cfg_pickedCoursesByTimeFrame
(
2
);
CSDVP
::
generateProblem
(
pb
,
CSDVP
::
GenerationType
::
RANDOM
,
7777
);
assert
(
pb
.
checkConfig
());
job
.
setRequiredECTS
(
4
*
6
);
Competency
tmpC
=
pb
.
competencyCatalogue
().
at
(
0
);
tmpC
=
Competency
::
buildTMP
(
0.8
,
tmpC
.
c_name
());
job
.
addPrerequisite
(
tmpC
);
tmpC
=
pb
.
competencyCatalogue
().
at
(
10
);
tmpC
=
Competency
::
buildTMP
(
0.8
,
tmpC
.
c_name
());
job
.
addPrerequisite
(
tmpC
);
tmpC
=
pb
.
competencyCatalogue
().
at
(
1
);
tmpC
=
pb
.
competencyCatalogue
().
at
(
20
);
tmpC
=
Competency
::
buildTMP
(
0.8
,
tmpC
.
c_name
());
job
.
addPrerequisite
(
tmpC
);
//tmpC = Competency::build(0.5,"Wesh");
//job.addPrerequisite(tmpC);
tmpC
=
pb
.
competencyCatalogue
().
at
(
8
);
job
.
addPrerequisite
(
tmpC
);
//
tmpC = pb.competencyCatalogue().at(8);
//
job.addPrerequisite(tmpC);
// ===== END PB CONFIG =====
Cursus
c1
;
...
...
@@ -117,15 +125,15 @@ int main(int argc, char* argv[]){
//CursusInit init(pb.getQuantityCoursesToPick(),pb.coursesCatalogue().size(),pb.seed());
CursusInitConstraint
init
(
pb
);
//pb.cfg_quantityCourses());//pb.getQuantityCoursesToPick(),pb.cfg_quantityCourses(), pb.seed());
CursusEval
eval
(
ctrRep
,
ctrJob
,
ctrECTS
);
CursusEval
eval
(
ctr
Prq
,
ctr
Rep
,
ctrJob
,
ctrECTS
);
CursusCrossover
cross
(
pb
,
ctrRep
,
init
);
CursusMutation
mut
(
pb
,
ctrRep
);
eoGenContinue
<
Cursus
>
cont
(
1000
0
);
// runs for 100 gen
eoGenContinue
<
Cursus
>
cont
(
1000
);
// runs for 100 gen
//xOver, xOver rate, mutation, mutation rate
eoSGATransform
<
Cursus
>
transform
(
cross
,
0.
1
,
mut
,
0.7
);
eoSGATransform
<
Cursus
>
transform
(
cross
,
0.
5
,
mut
,
0.8
);
eoDetTournamentSelect
<
Cursus
>
selectOne
(
5
);
//selection method by tournament, here against 2
eoSelectPerc
<
Cursus
>
select
(
selectOne
);
eoGenerationalReplacement
<
Cursus
>
replace
;
...
...
@@ -137,6 +145,7 @@ int main(int argc, char* argv[]){
{
init
(
c1
);
eval
(
c1
);
/*
res = ctrECTS.integrityCheck(c1);
std::cout << "ECTS Metric" << std::to_string(res.second) << std::endl;
//res = ctrRep.integrityCheck(c1);
...
...
@@ -155,9 +164,10 @@ int main(int argc, char* argv[]){
{
std::cout << pb.coursesCatalogue().at(c1.at(i)) << std::endl;
}
*/
pop
.
push_back
(
c1
);
}
//MUTATION TEST
/*
pop[0].printOn(std::cout);
...
...
@@ -191,7 +201,7 @@ int main(int argc, char* argv[]){
std
::
cout
<<
"===== CURRENT POP ====="
<<
std
::
endl
;
pop
.
printOn
(
std
::
cout
);
pop
.
best_element
().
printOn
(
std
::
cout
);
std
::
cout
<<
"===== ====="
<<
std
::
endl
;
eoEasyEA
<
QUEEN
>
algo
(
cont
,
eval
,
select
,
transform
,
replace
);
...
...
src/model/constraints/prerequisitesConstraints.cpp
View file @
74d3cc48
...
...
@@ -112,10 +112,12 @@ std::pair<bool, double> ConstraintsPrerequisites::integrityCheck(Cursus indiv)
}
bool
isOK
=
((
notFound
==
0
)
&&
(
notRespected
==
0
));
std
::
cout
<<
"========== PREREQ CSTR RES =========="
<<
std
::
endl
;
/*
std::cout << "========== PREREQ CSTR RES ==========" << std::endl;
std::cout << "Not Found: " << std::to_string(notFound) << std::endl;
std::cout << "Not Respected: " << std::to_string(notRespected) << std::endl;
std::cout << "Nb Prereq: " << std::to_string(nbPrereq) << std::endl;
*/
double
metric
=
0
;
if
(
nbPrereq
>
0
)
{
...
...
@@ -128,8 +130,8 @@ std::pair<bool, double> ConstraintsPrerequisites::integrityCheck(Cursus indiv)
else
metric
=
0
;
}
std
::
cout
<<
"Metric: "
<<
std
::
to_string
(
metric
)
<<
std
::
endl
;
std
::
cout
<<
"===================="
<<
std
::
endl
;
//
std::cout << "Metric: " << std::to_string(metric) << std::endl;
//
std::cout << "====================" << std::endl;
return
std
::
pair
<
bool
,
double
>
(
isOK
,
metric
);
}
...
...
@@ -164,4 +166,4 @@ std::pair<int, int> ConstraintsPrerequisites::_prereqsInPreviousTF(std::vector<C
}
//std::cout << "NF: " << std::to_string(notFound) << " | NR: " << std::to_string(notRespected) << std::endl;
return
std
::
pair
<
int
,
int
>
(
notFound
,
notRespected
);
}
\ No newline at end of file
}
src/model/ea/evaluator.cpp
View file @
74d3cc48
...
...
@@ -3,22 +3,31 @@
void
CursusEval
::
operator
()(
Cursus
&
_cursus
){
double
fit
=
0.0
;
int
pCE
,
pCP
,
pCR
;
int
pCE
,
pCP
,
pCR
,
pCPR
;
pCE
=
1
;
pCR
=
1
;
pCP
=
1
;
pCPR
=
1
;
std
::
pair
<
bool
,
double
>
resCE
;
std
::
pair
<
bool
,
double
>
resCP
;
std
::
pair
<
bool
,
double
>
resCR
;
std
::
pair
<
bool
,
double
>
resCPR
;
resCE
=
ce
.
integrityCheck
(
_cursus
);
resCP
=
cp
.
integrityCheck
(
_cursus
);
resCR
=
cr
.
integrityCheck
(
_cursus
);
//std::cout << resCP.first << " " << resCP.second << std::endl;
double
sum
=
pCE
*
resCE
.
second
+
pCR
*
resCR
.
second
+
pCP
*
resCP
.
second
;
resCPR
=
cpr
.
integrityCheck
(
_cursus
);
/*
std::cout << "EVAL: ";
std::cout << resCE.first << " " << resCE.second << std::endl;
std::cout << resCP.first << " " << resCP.second << std::endl;
std::cout << resCR.first << " " << resCR.second << std::endl;
std::cout << resCPR.first << " " << resCPR.second << std::endl;
std::cout << std::endl << std::endl;
*/
double
sum
=
pCE
*
resCE
.
second
+
pCR
*
resCR
.
second
+
pCP
*
resCP
.
second
+
pCPR
*
resCPR
.
second
;
fit
=
1.0
/
(
1
+
sum
)
*
100
;
_cursus
.
fitness
(
fit
);
...
...
src/model/ea/evaluator.h
View file @
74d3cc48
...
...
@@ -13,12 +13,13 @@ class CursusEval : public eoEvalFunc<Cursus>
{
public
:
CursusEval
(
Constraints
Repetition
&
_cr
,
ConstraintsProfession
&
_cp
,
ConstraintsECTS
&
_ce
)
:
cr
(
_cr
),
cp
(
_cp
),
ce
(
_ce
){}
CursusEval
(
Constraints
Prerequisites
&
_cpr
,
ConstraintsRepetition
&
_cr
,
ConstraintsProfession
&
_cp
,
ConstraintsECTS
&
_ce
)
:
cpr
(
_cpr
),
cr
(
_cr
),
cp
(
_cp
),
ce
(
_ce
){}
void
operator
()(
Cursus
&
_cursus
);
private
:
ConstraintsPrerequisites
cpr
;
ConstraintsRepetition
cr
;
ConstraintsProfession
cp
;
ConstraintsECTS
ce
;
...
...
src/model/ea/initConstraint.h
View file @
74d3cc48
...
...
@@ -47,11 +47,11 @@ class eoInitConstraintCSDVP: public eoInit<EOT>
virtual
void
operator
()(
EOT
&
chrom
){
int
cpt
=
0
;
//
std::cout << "Enter init" << std::endl;
std
::
cout
<<
"Enter init"
<<
std
::
endl
;
unsigned
int
r
=
eo
::
rng
.
random
(
possibleIDbyTF
[
0
].
size
());
chrom
.
resize
(
0
);
chrom
.
push_back
(
possibleIDbyTF
[
0
][
r
]);
//
std::cout << "push " << possibleIDbyTF[0][r] << std::endl;
std
::
cout
<<
"push "
<<
possibleIDbyTF
[
0
][
r
]
<<
std
::
endl
;
for
(
int
i
=
1
;
i
<
chromSize
;
i
++
){
cpt
=
0
;
r
=
eo
::
rng
.
random
(
possibleIDbyTF
[
i
/
sizeTF
].
size
());
...
...
@@ -62,14 +62,14 @@ class eoInitConstraintCSDVP: public eoInit<EOT>
if
(
cpt
<
maxVal
){
std
::
cout
<<
i
<<
" "
<<
r
<<
" "
;
chrom
.
push_back
(
possibleIDbyTF
[
i
/
sizeTF
][
r
]);
//
std::cout << "push " << possibleIDbyTF[i/sizeTF][r] << std::endl;
std
::
cout
<<
"push "
<<
possibleIDbyTF
[
i
/
sizeTF
][
r
]
<<
std
::
endl
;
}
else
{
r
=
eo
::
rng
.
random
(
maxVal
);
while
(
!
notin
(
chrom
,
r
,
i
))
r
=
eo
::
rng
.
random
(
maxVal
);
chrom
.
push_back
(
r
);
//
std::cout << "push with error " << r << std::endl;
std
::
cout
<<
"push with error "
<<
r
<<
std
::
endl
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment