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
3b5f6555
Commit
3b5f6555
authored
Dec 02, 2020
by
Alexis Lebis
2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pb distrib for comp + prereq + job
parent
bcc70b52
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
27 deletions
+70
-27
main.cpp
application/main.cpp
+2
-0
competencyDistribution.cpp
src/model/competencyDistribution.cpp
+35
-2
competencyDistribution.h
src/model/competencyDistribution.h
+2
-0
problem.cpp
src/model/problem.cpp
+20
-17
problem.h
src/model/problem.h
+2
-1
profession.cpp
src/model/profession.cpp
+9
-7
No files found.
application/main.cpp
View file @
3b5f6555
...
...
@@ -466,6 +466,8 @@ int main(int argc, char* argv[]){
std
::
cout
<<
"==============="
<<
std
::
endl
;
ctrPrq
.
_displayDecayedArrays
(
pop
.
best_element
());
std
::
cout
<<
job
;
}
// ================================= END RUN ZONE ===============================
...
...
src/model/competencyDistribution.cpp
View file @
3b5f6555
...
...
@@ -79,8 +79,9 @@ void CompetencyDistribution::linearDistribution(CSDVP &pb)
// === STATIC
int
CompetencyDistribution
::
HLevelRange
(
CSDVP
&
pb
)
{
int
interval
=
pb
.
cfg_competencyByCourseMax
()
-
pb
.
cfg_competencyByCourseMin
();
return
interval
;
assert
(
CompetencyDistribution
::
sanitizeHLEVEL
);
// int interval = pb.cfg_competencyByCourseMax() - pb.cfg_competencyByCourseMin();
return
CompetencyDistribution
::
HLEVEL
.
size
();
}
std
::
vector
<
Competency
>
CompetencyDistribution
::
getHLevel
(
CSDVP
&
pb
,
int
level
)
...
...
@@ -116,6 +117,38 @@ void CompetencyDistribution::linearDistribution(CSDVP &pb)
return
res
;
}
std
::
vector
<
Competency
>
CompetencyDistribution
::
unassignedUpToHLevel
(
CSDVP
&
pb
,
int
level
)
{
std
::
vector
<
Competency
>
res
;
std
::
vector
<
Competency
>
tmp
;
//assert(level < HLEVEL.size());
for
(
int
i
=
0
;
i
<=
level
;
i
++
)
{
tmp
=
CompetencyDistribution
::
unassignedAtHLevel
(
pb
,
i
);
for
(
int
j
=
0
;
j
<
tmp
.
size
();
j
++
)
res
.
push_back
(
tmp
[
j
]);
}
return
res
;
}
std
::
vector
<
Competency
>
CompetencyDistribution
::
unassignedAtHLevel
(
CSDVP
&
pb
,
int
hlevel
)
{
assert
(
hlevel
>=
0
);
std
::
vector
<
Competency
>
res
;
for
(
int
i
=
0
;
i
<
pb
.
competencyCatalogue
().
size
();
i
++
)
{
if
(
pb
.
competencyCatalogue
().
at
(
i
).
hLevel
()
==
hlevel
&&
pb
.
unlocked_distributedCompetencies
().
at
(
i
)
==
-
1
)
res
.
push_back
(
pb
.
competencyCatalogue
().
at
(
i
));
}
return
res
;
}
void
CompetencyDistribution
::
sanitizeHLEVEL
()
{
int
sum
=
0
;
...
...
src/model/competencyDistribution.h
View file @
3b5f6555
...
...
@@ -34,6 +34,8 @@ class CompetencyDistribution
static
int
HLevelRange
(
CSDVP
&
);
//return the range max (starting from 0) of the HL
static
std
::
vector
<
Competency
>
getHLevel
(
CSDVP
&
,
int
);
// returns all the competency of a given HL
static
std
::
vector
<
Competency
>
upToHLevel
(
CSDVP
&
,
int
);
// retrieves all the comp comprised between [0;int] (and NOT [0;int[)
static
std
::
vector
<
Competency
>
unassignedAtHLevel
(
CSDVP
&
,
int
hlevel
);
static
std
::
vector
<
Competency
>
unassignedUpToHLevel
(
CSDVP
&
,
int
);
/*
* sanitizeHLEVEL performs two task:
* * it verifies that the sum of all HLEVEL is equal to 100
...
...
src/model/problem.cpp
View file @
3b5f6555
...
...
@@ -398,10 +398,13 @@ int CSDVP::CSDVP_COUNTER = 0;
x
=
_randomizeIn
(
pb
.
cfg_competencyByCourseMin
(),
pb
.
cfg_competencyByCourseMax
());
lastTF
=
pb
.
coursesCatalogue
().
at
(
i
).
lastTimeFrame
();
maxLevel
=
lastTF
*
hLevelR
/
nbTF
;
HLComp
=
CompetencyDistribution
::
unassignedUpToHLevel
(
pb
,
maxLevel
);
if
(
HLComp
.
size
()
==
0
)
//if there is no more HL unassigned, it doesnot matter which one we take
HLComp
=
CompetencyDistribution
::
upToHLevel
(
pb
,
maxLevel
);
std
::
random_shuffle
(
HLComp
.
begin
(),
HLComp
.
end
());
std
::
cout
<<
"SIZE OF HLCOMP : "
<<
HLComp
.
size
()
<<
std
::
endl
;
//
std::cout << "SIZE OF HLCOMP : " << HLComp.size() << std::endl;
for
(
int
j
=
0
;
j
<
x
&&
HLComp
.
size
()
>
0
&&
j
<
HLComp
.
size
();
j
++
)
{
...
...
@@ -442,13 +445,12 @@ int CSDVP::CSDVP_COUNTER = 0;
x
=
_randomizeIn
(
pb
.
cfg_prerequisiteByCourseMin
(),
pb
.
cfg_prerequisiteByCourseMax
());
lastTF
=
pb
.
coursesCatalogue
().
at
(
i
).
lastTimeFrame
();
maxLevel
=
lastTF
*
hLevelR
/
nbTF
;
HLComp
=
CompetencyDistribution
::
upToHLevel
(
pb
,
maxLevel
-
1
);
std
::
random_shuffle
(
HLComp
.
begin
(),
HLComp
.
end
());
maxLevel
--
;
// Logically, prerequisite can only be according to comp of lower HL
if
(
maxLevel
>
0
)
// then this means we are dealing with at least a HL 1, so only HL below can serve as prereq
{
HLComp
=
CompetencyDistribution
::
upToHLevel
(
pb
,
maxLevel
);
if
(
x
==
0
)
std
::
cout
<<
"X is 0! for "
<<
pb
.
coursesCatalogue
().
at
(
i
).
name
()
<<
std
::
endl
;
if
(
HLComp
.
size
()
==
0
)
std
::
cout
<<
"HLComp size is 0! for "
<<
pb
.
coursesCatalogue
().
at
(
i
).
name
()
<<
std
::
endl
;
std
::
random_shuffle
(
HLComp
.
begin
(),
HLComp
.
end
());
for
(
int
j
=
0
;
j
<
x
&&
HLComp
.
size
()
>
0
&&
j
<
HLComp
.
size
();
j
++
)
{
...
...
@@ -460,7 +462,7 @@ int CSDVP::CSDVP_COUNTER = 0;
queue
.
push
(
tmpComp
);
}
}
}
}
void
CSDVP
::
_sourceCourseTeachedComp
(
CSDVP
&
pb
,
unsigned
int
idx
,
Competency
&
c
)
...
...
@@ -488,6 +490,7 @@ int CSDVP::CSDVP_COUNTER = 0;
}
// --------- END GENERATION RELATED FUNCTIONS ---------
// === END STATIC
void
const
CSDVP
::
displayDistribution
(){
...
...
src/model/problem.h
View file @
3b5f6555
...
...
@@ -139,6 +139,7 @@ class CSDVP
std
::
vector
<
int
>
&
unlocked_timeFrames
(){
return
this
->
_timeFrames
;}
std
::
vector
<
Course
>
&
unlocked_coursesCatalogue
(){
return
this
->
_availableCourses
;}
std
::
vector
<
Competency
>
&
unlocked_competenciesCatalogue
(){
return
this
->
_availableCompentecies
;}
std
::
vector
<
double
>
&
unlocked_distributedCompetencies
(){
return
this
->
_distributedCompetencies
;}
int
getQuantityCoursesToPick
()
const
{
if
(
this
->
_isConfig
)
...
...
src/model/profession.cpp
View file @
3b5f6555
...
...
@@ -177,8 +177,8 @@ void Profession::_randomlyGenerate(Profession & job, CSDVP & pb)
switch
(
Profession
::
JOB_SELECTION_TYPE
)
{
case
1
:
//at least one comp in the higher HL
compHigherHL
=
CompetencyDistribution
::
getHLevel
(
pb
,
CompetencyDistribution
::
HLevelRange
(
pb
));
std
::
cout
<<
"compHigherHL size :"
<<
compHigherHL
.
size
()
<<
std
::
endl
;
compHigherHL
=
CompetencyDistribution
::
getHLevel
(
pb
,
CompetencyDistribution
::
HLevelRange
(
pb
)
-
1
);
//
std::cout << "compHigherHL size :" << compHigherHL.size() << std::endl;
std
::
random_shuffle
(
compHigherHL
.
begin
(),
compHigherHL
.
end
());
assert
(
compHigherHL
.
size
()
>
0
);
//if no comp retrieved in the higher hlevel (hhl), there is a pb here !
...
...
@@ -254,9 +254,11 @@ void Profession::_pickWithHLWeighting(int nbToPick, Profession & job, CSDVP & pb
const
int
hLRange
=
CompetencyDistribution
::
HLevelRange
(
pb
);
std
::
vector
<
Competency
>
hlComp
;
for
(
int
i
=
0
;
i
<
=
hLRange
;
i
++
)
for
(
int
i
=
0
;
i
<
hLRange
;
i
++
)
{
sumInterval
+=
i
;
// sumInterval+=i;
// sumInterval = i * 2;
sumInterval
=
i
*
i
;
range
.
push_back
(
sumInterval
);
}
...
...
@@ -267,13 +269,13 @@ void Profession::_pickWithHLWeighting(int nbToPick, Profession & job, CSDVP & pb
currentHL
=
0
;
std
::
cout
<<
"sumInterval: "
<<
sumInterval
<<
" & x: "
<<
x
<<
std
::
endl
;
//
std::cout << "sumInterval: " << sumInterval << " & x: " << x << std::endl;
while
(
x
>
range
[
currentHL
]
&&
currentHL
<
range
.
size
())
{
currentHL
++
;
}
std
::
cout
<<
"I pick the prereq in the HL: "
<<
currentHL
<<
std
::
endl
;
hlComp
=
CompetencyDistribution
::
getHLevel
(
pb
,
currentHL
);
//we get the correspond hl level
assert
(
hlComp
.
size
()
>
0
);
std
::
random_shuffle
(
hlComp
.
begin
(),
hlComp
.
end
());
...
...
Alexis Lebis
@alexis.lebis
mentioned in issue
#17 (closed)
·
Dec 02, 2020
mentioned in issue
#17 (closed)
mentioned in issue #17
Toggle commit list
Alexis Lebis
@alexis.lebis
mentioned in issue
#18 (closed)
·
Dec 02, 2020
mentioned in issue
#18 (closed)
mentioned in issue #18
Toggle commit list
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