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
82f1bf8d
Commit
82f1bf8d
authored
May 12, 2020
by
Alexis Lebis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a bug on generating course catalogue
parent
c992d126
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
13 deletions
+59
-13
.gitignore
.gitignore
+3
-1
problem.cpp
src/model/problem.cpp
+56
-12
No files found.
.gitignore
View file @
82f1bf8d
...
@@ -2,3 +2,5 @@ correction/
...
@@ -2,3 +2,5 @@ correction/
build/
build/
howto.pdf
howto.pdf
.vscode/
.vscode/
.cmake/
src/model/problem.cpp
View file @
82f1bf8d
...
@@ -186,6 +186,7 @@ int CSDVP::CSDVP_COUNTER = 0;
...
@@ -186,6 +186,7 @@ int CSDVP::CSDVP_COUNTER = 0;
}
}
}
}
/// [x;y[ ?
int
CSDVP
::
_randomizeIn
(
const
int
min
,
const
int
max
)
int
CSDVP
::
_randomizeIn
(
const
int
min
,
const
int
max
)
{
{
return
min
+
(
rand
()
%
(
max
-
min
+
1
)
);
return
min
+
(
rand
()
%
(
max
-
min
+
1
)
);
...
@@ -230,32 +231,75 @@ int CSDVP::CSDVP_COUNTER = 0;
...
@@ -230,32 +231,75 @@ int CSDVP::CSDVP_COUNTER = 0;
std
::
vector
<
Course
>
tmpCourses
;
std
::
vector
<
Course
>
tmpCourses
;
for
(
int
i
=
0
;
i
<
pb
.
_quantityAvailableCourses
;
i
++
)
for
(
int
i
=
0
;
i
<
pb
.
_quantityAvailableCourses
;
i
++
)
{
{
tmpCourses
.
push_back
(
Course
::
build
(
CSDVP
::
_randomizeIn
(
pb
.
cfg_
minimalTimeFrame
(),
pb
.
cfg_maximalTimeFrame
()
)));
tmpCourses
.
push_back
(
Course
::
build
(
CSDVP
::
_randomizeIn
(
pb
.
cfg_
ectsMin
(),
pb
.
cfg_ectsMax
()
+
1
)));
}
}
/* We obtain how many courses n by semester s
* then we create an idxCourses vector of size n * s
* then we shuffle it
* then we distribute the course accordingly. If a course already exists, we repick one randomly until it's ok
*/
std
::
vector
<
int
>
idxCourses
;
std
::
vector
<
int
>
nbCoursesByTF
;
for
(
int
i
=
0
;
i
<
pb
.
timeFrames
().
size
();
i
++
)
nbCoursesByTF
.
push_back
(
CSDVP
::
_randomizeIn
(
pb
.
_minimalCoursesByTimeFrame
,
pb
.
_maximalCoursesByTimeFrame
));
int
idxCoursesCounter
=
0
;
for
(
int
i
=
0
;
i
<
nbCoursesByTF
.
size
();
i
++
)
{
for
(
int
j
=
0
;
j
<
nbCoursesByTF
.
at
(
i
);
j
++
)
{
idxCourses
.
push_back
(
idxCoursesCounter
%
pb
.
_quantityAvailableCourses
);
idxCoursesCounter
++
;
}
}
std
::
random_shuffle
(
idxCourses
.
begin
(),
idxCourses
.
end
());
bool
insertRez
;
bool
insertRez
;
int
rndIdx
;
idxCoursesCounter
=
0
;
for
(
int
i
=
0
;
i
<
pb
.
timeFrames
().
size
();
i
++
)
for
(
int
i
=
0
;
i
<
pb
.
timeFrames
().
size
();
i
++
)
{
{
int
nbCoursesInThisTF
=
CSDVP
::
_randomizeIn
(
pb
.
_minimalCoursesByTimeFrame
,
pb
.
_maximalCoursesByTimeFrame
);
for
(
int
j
=
0
;
j
<
nbCoursesByTF
.
at
(
i
);
j
++
)
int
courseIdx
;
std
::
cout
<<
"In the TF "
+
std
::
to_string
(
i
)
+
" I plan "
<<
std
::
to_string
(
nbCoursesInThisTF
)
<<
" courses."
<<
std
::
endl
;
for
(
int
j
=
0
;
j
<
nbCoursesInThisTF
;
j
++
)
{
{
insertRez
=
true
;
insertRez
=
true
;
courseIdx
=
CSDVP
::
_randomizeIn
(
0
,
tmpCourses
.
size
()
-
1
);
int
cc
=
idxCourses
.
at
(
idxCoursesCounter
);
insertRez
=
tmpCourses
.
at
(
courseIdx
).
addTemporalFrame
(
pb
.
timeFrames
().
at
(
i
));
insertRez
=
tmpCourses
.
at
(
idxCourses
.
at
(
idxCoursesCounter
)
).
addTemporalFrame
(
pb
.
timeFrames
().
at
(
i
));
if
(
!
insertRez
)
//If a duplicata has been prevented, we do not count the attempt
while
(
!
insertRez
)
//if duplicataProtection (i.e. course already in this semester)
j
--
;
{
rndIdx
=
CSDVP
::
_randomizeIn
(
0
,
pb
.
_quantityAvailableCourses
);
insertRez
=
tmpCourses
.
at
(
rndIdx
).
addTemporalFrame
(
pb
.
timeFrames
().
at
(
i
));
}
idxCoursesCounter
++
;
}
}
}
}
// // OLD WAY
// bool insertRez;
// for(int i = 0; i < pb.timeFrames().size(); i++)
// {
// int nbCoursesInThisTF = CSDVP::_randomizeIn(pb._minimalCoursesByTimeFrame, pb._maximalCoursesByTimeFrame);
// int courseIdx;
// std::cout << "In the TF "+std::to_string(i)+" I plan " << std::to_string(nbCoursesInThisTF) << " courses." << std::endl;
// for(int j = 0; j < nbCoursesInThisTF; j++)
// {
// insertRez = true;
// courseIdx = CSDVP::_randomizeIn(0,tmpCourses.size()-1);
// insertRez = tmpCourses.at(courseIdx).addTemporalFrame(pb.timeFrames().at(i));
// if(!insertRez) //If a duplicata has been prevented, we do not count the attempt
// j--;
// }
// }
for
(
int
i
=
0
;
i
<
tmpCourses
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
tmpCourses
.
size
();
i
++
)
if
(
tmpCourses
.
at
(
i
).
timeFrame
().
size
()
>
0
)
if
(
tmpCourses
.
at
(
i
).
timeFrame
().
size
()
>
0
)
pb
.
addCourseToCatalogue
(
tmpCourses
.
at
(
i
));
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 )
/* COMPETENCY CREATION
/* COMPETENCY CREATION
* We create _quantityAvailableCompetency competencies. For each comp, we randomly define it's magnitude.
* We create _quantityAvailableCompetency competencies. For each comp, we randomly define it's magnitude.
*/
*/
...
...
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