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
Hide 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[]){
...
@@ -466,6 +466,8 @@ int main(int argc, char* argv[]){
std
::
cout
<<
"==============="
<<
std
::
endl
;
std
::
cout
<<
"==============="
<<
std
::
endl
;
ctrPrq
.
_displayDecayedArrays
(
pop
.
best_element
());
ctrPrq
.
_displayDecayedArrays
(
pop
.
best_element
());
std
::
cout
<<
job
;
}
}
// ================================= END RUN ZONE ===============================
// ================================= END RUN ZONE ===============================
...
...
src/model/competencyDistribution.cpp
View file @
3b5f6555
...
@@ -79,8 +79,9 @@ void CompetencyDistribution::linearDistribution(CSDVP &pb)
...
@@ -79,8 +79,9 @@ void CompetencyDistribution::linearDistribution(CSDVP &pb)
// === STATIC
// === STATIC
int
CompetencyDistribution
::
HLevelRange
(
CSDVP
&
pb
)
int
CompetencyDistribution
::
HLevelRange
(
CSDVP
&
pb
)
{
{
int
interval
=
pb
.
cfg_competencyByCourseMax
()
-
pb
.
cfg_competencyByCourseMin
();
assert
(
CompetencyDistribution
::
sanitizeHLEVEL
);
return
interval
;
// int interval = pb.cfg_competencyByCourseMax() - pb.cfg_competencyByCourseMin();
return
CompetencyDistribution
::
HLEVEL
.
size
();
}
}
std
::
vector
<
Competency
>
CompetencyDistribution
::
getHLevel
(
CSDVP
&
pb
,
int
level
)
std
::
vector
<
Competency
>
CompetencyDistribution
::
getHLevel
(
CSDVP
&
pb
,
int
level
)
...
@@ -116,6 +117,38 @@ void CompetencyDistribution::linearDistribution(CSDVP &pb)
...
@@ -116,6 +117,38 @@ void CompetencyDistribution::linearDistribution(CSDVP &pb)
return
res
;
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
()
void
CompetencyDistribution
::
sanitizeHLEVEL
()
{
{
int
sum
=
0
;
int
sum
=
0
;
...
...
src/model/competencyDistribution.h
View file @
3b5f6555
...
@@ -34,6 +34,8 @@ class CompetencyDistribution
...
@@ -34,6 +34,8 @@ class CompetencyDistribution
static
int
HLevelRange
(
CSDVP
&
);
//return the range max (starting from 0) of the HL
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
>
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
>
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:
* sanitizeHLEVEL performs two task:
* * it verifies that the sum of all HLEVEL is equal to 100
* * 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;
...
@@ -398,10 +398,13 @@ int CSDVP::CSDVP_COUNTER = 0;
x
=
_randomizeIn
(
pb
.
cfg_competencyByCourseMin
(),
pb
.
cfg_competencyByCourseMax
());
x
=
_randomizeIn
(
pb
.
cfg_competencyByCourseMin
(),
pb
.
cfg_competencyByCourseMax
());
lastTF
=
pb
.
coursesCatalogue
().
at
(
i
).
lastTimeFrame
();
lastTF
=
pb
.
coursesCatalogue
().
at
(
i
).
lastTimeFrame
();
maxLevel
=
lastTF
*
hLevelR
/
nbTF
;
maxLevel
=
lastTF
*
hLevelR
/
nbTF
;
HLComp
=
CompetencyDistribution
::
upToHLevel
(
pb
,
maxLevel
);
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
::
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
++
)
for
(
int
j
=
0
;
j
<
x
&&
HLComp
.
size
()
>
0
&&
j
<
HLComp
.
size
();
j
++
)
{
{
...
@@ -442,25 +445,24 @@ int CSDVP::CSDVP_COUNTER = 0;
...
@@ -442,25 +445,24 @@ int CSDVP::CSDVP_COUNTER = 0;
x
=
_randomizeIn
(
pb
.
cfg_prerequisiteByCourseMin
(),
pb
.
cfg_prerequisiteByCourseMax
());
x
=
_randomizeIn
(
pb
.
cfg_prerequisiteByCourseMin
(),
pb
.
cfg_prerequisiteByCourseMax
());
lastTF
=
pb
.
coursesCatalogue
().
at
(
i
).
lastTimeFrame
();
lastTF
=
pb
.
coursesCatalogue
().
at
(
i
).
lastTimeFrame
();
maxLevel
=
lastTF
*
hLevelR
/
nbTF
;
maxLevel
=
lastTF
*
hLevelR
/
nbTF
;
HLComp
=
CompetencyDistribution
::
upToHLevel
(
pb
,
maxLevel
-
1
);
maxLevel
--
;
// Logically, prerequisite can only be according to comp of lower HL
std
::
random_shuffle
(
HLComp
.
begin
(),
HLComp
.
end
());
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
::
random_shuffle
(
HLComp
.
begin
(),
HLComp
.
end
());
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
;
for
(
int
j
=
0
;
j
<
x
&&
HLComp
.
size
()
>
0
&&
j
<
HLComp
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
x
&&
HLComp
.
size
()
>
0
&&
j
<
HLComp
.
size
();
j
++
)
{
{
tmpComp
=
HLComp
.
at
(
j
);
tmpComp
=
HLComp
.
at
(
j
);
//we change mag value for prereq
//we change mag value for prereq
magVal
=
pb
.
cfg_magnitudeMin
().
value
()
+
(
(
double
)
rand
()
/
RAND_MAX
)
*
(
pb
.
cfg_magnitudeMax
().
value
()
-
pb
.
cfg_magnitudeMin
().
value
())
;
magVal
=
pb
.
cfg_magnitudeMin
().
value
()
+
(
(
double
)
rand
()
/
RAND_MAX
)
*
(
pb
.
cfg_magnitudeMax
().
value
()
-
pb
.
cfg_magnitudeMin
().
value
())
;
Competency
cpt
=
Competency
::
build
(
magVal
,
tmpComp
.
c_name
());
Competency
cpt
=
Competency
::
build
(
magVal
,
tmpComp
.
c_name
());
pb
.
unlocked_coursesCatalogue
().
at
(
i
).
addPrerequisite
(
cpt
);
pb
.
unlocked_coursesCatalogue
().
at
(
i
).
addPrerequisite
(
cpt
);
queue
.
push
(
tmpComp
);
queue
.
push
(
tmpComp
);
}
}
}
}
}
}
}
void
CSDVP
::
_sourceCourseTeachedComp
(
CSDVP
&
pb
,
unsigned
int
idx
,
Competency
&
c
)
void
CSDVP
::
_sourceCourseTeachedComp
(
CSDVP
&
pb
,
unsigned
int
idx
,
Competency
&
c
)
...
@@ -488,6 +490,7 @@ int CSDVP::CSDVP_COUNTER = 0;
...
@@ -488,6 +490,7 @@ int CSDVP::CSDVP_COUNTER = 0;
}
}
// --------- END GENERATION RELATED FUNCTIONS ---------
// --------- END GENERATION RELATED FUNCTIONS ---------
// === END STATIC
// === END STATIC
void
const
CSDVP
::
displayDistribution
(){
void
const
CSDVP
::
displayDistribution
(){
...
...
src/model/problem.h
View file @
3b5f6555
...
@@ -139,7 +139,8 @@ class CSDVP
...
@@ -139,7 +139,8 @@ class CSDVP
std
::
vector
<
int
>
&
unlocked_timeFrames
(){
return
this
->
_timeFrames
;}
std
::
vector
<
int
>
&
unlocked_timeFrames
(){
return
this
->
_timeFrames
;}
std
::
vector
<
Course
>
&
unlocked_coursesCatalogue
(){
return
this
->
_availableCourses
;}
std
::
vector
<
Course
>
&
unlocked_coursesCatalogue
(){
return
this
->
_availableCourses
;}
std
::
vector
<
Competency
>
&
unlocked_competenciesCatalogue
(){
return
this
->
_availableCompentecies
;}
std
::
vector
<
Competency
>
&
unlocked_competenciesCatalogue
(){
return
this
->
_availableCompentecies
;}
std
::
vector
<
double
>
&
unlocked_distributedCompetencies
(){
return
this
->
_distributedCompetencies
;}
int
getQuantityCoursesToPick
()
const
{
int
getQuantityCoursesToPick
()
const
{
if
(
this
->
_isConfig
)
if
(
this
->
_isConfig
)
return
this
->
_timeFrames
.
size
()
*
this
->
_pickedCoursesByTimeFrame
;
return
this
->
_timeFrames
.
size
()
*
this
->
_pickedCoursesByTimeFrame
;
...
...
src/model/profession.cpp
View file @
3b5f6555
...
@@ -173,12 +173,12 @@ void Profession::_randomlyGenerate(Profession & job, CSDVP & pb)
...
@@ -173,12 +173,12 @@ void Profession::_randomlyGenerate(Profession & job, CSDVP & pb)
int
i
;
int
i
;
std
::
vector
<
Competency
>
compHigherHL
;
std
::
vector
<
Competency
>
compHigherHL
;
switch
(
Profession
::
JOB_SELECTION_TYPE
)
switch
(
Profession
::
JOB_SELECTION_TYPE
)
{
{
case
1
:
//at least one comp in the higher HL
case
1
:
//at least one comp in the higher HL
compHigherHL
=
CompetencyDistribution
::
getHLevel
(
pb
,
CompetencyDistribution
::
HLevelRange
(
pb
));
compHigherHL
=
CompetencyDistribution
::
getHLevel
(
pb
,
CompetencyDistribution
::
HLevelRange
(
pb
)
-
1
);
std
::
cout
<<
"compHigherHL size :"
<<
compHigherHL
.
size
()
<<
std
::
endl
;
//
std::cout << "compHigherHL size :" << compHigherHL.size() << std::endl;
std
::
random_shuffle
(
compHigherHL
.
begin
(),
compHigherHL
.
end
());
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 !
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
...
@@ -254,9 +254,11 @@ void Profession::_pickWithHLWeighting(int nbToPick, Profession & job, CSDVP & pb
const
int
hLRange
=
CompetencyDistribution
::
HLevelRange
(
pb
);
const
int
hLRange
=
CompetencyDistribution
::
HLevelRange
(
pb
);
std
::
vector
<
Competency
>
hlComp
;
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
);
range
.
push_back
(
sumInterval
);
}
}
...
@@ -267,13 +269,13 @@ void Profession::_pickWithHLWeighting(int nbToPick, Profession & job, CSDVP & pb
...
@@ -267,13 +269,13 @@ void Profession::_pickWithHLWeighting(int nbToPick, Profession & job, CSDVP & pb
currentHL
=
0
;
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
())
while
(
x
>
range
[
currentHL
]
&&
currentHL
<
range
.
size
())
{
{
currentHL
++
;
currentHL
++
;
}
}
std
::
cout
<<
"I pick the prereq in the HL: "
<<
currentHL
<<
std
::
endl
;
hlComp
=
CompetencyDistribution
::
getHLevel
(
pb
,
currentHL
);
//we get the correspond hl level
hlComp
=
CompetencyDistribution
::
getHLevel
(
pb
,
currentHL
);
//we get the correspond hl level
assert
(
hlComp
.
size
()
>
0
);
assert
(
hlComp
.
size
()
>
0
);
std
::
random_shuffle
(
hlComp
.
begin
(),
hlComp
.
end
());
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