Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
APACHES.Prolog_CSDVP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
APACHES.Prolog_CSDVP
Commits
8bcceab3
Commit
8bcceab3
authored
Dec 12, 2019
by
Alexis Lebis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved comments
parent
783ebad3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
prologCSDVP.pl
prologCSDVP.pl
+19
-19
No files found.
prologCSDVP.pl
View file @
8bcceab3
...
...
@@ -44,49 +44,49 @@ finalSkills([
]).
courses
([
[
-
1
,
/*
course 0
*/
[
-
1
,
/*
EMPTY COURSE
*/
[
[]
],
/*
skills given
*/
[
[]
],
/*
prerequisite
*/
[
0
,
1
,
2
,
3
,
4
],
/*
time frame
*/
[
2
]
/*
ects
*/
],
[
0
,
/*
course 0
*/
[
0
,
/*
course 0
*/
[
[
1
,
75
],
[
4
,
50
]
],
/*
skills given
*/
[
[]
],
/*
prerequisite
*/
[
0
],
/*
time frame
*/
[
2
]
/*
ects
*/
],
[
1
,
/*
course
0
*/
[
1
,
/*
course
1
*/
[
[
3
,
50
],
[
1
,
25
]
],
/*
skills given
*/
[
[
1
,
3
]
],
/*
prerequisite
*/
[
1
,
2
],
/*
time frame
*/
[
2
]
/*
ects
*/
],
[
2
,
/*
course
0
*/
[
2
,
/*
course
2
*/
[
[
0
,
50
],
[
2
,
50
],
[
5
,
25
]
],
/*
skills given
*/
[
[
5
,
3
]
],
/*
prerequisite
*/
[
2
,
3
],
/*
time frame
*/
[
2
]
/*
ects
*/
],
[
3
,
/*
course
0
*/
[
3
,
/*
course
3
*/
[
[
5
,
50
]
],
/*
skills given
*/
[
[
1
,
4
],
[
4
,
2
]
],
/*
prerequisite
*/
[
1
,
2
],
/*
time frame
*/
[
2
]
/*
ects
*/
],
[
4
,
/*
course
0
*/
[
4
,
/*
course
4
*/
[
[
1
,
35
],
[
2
,
25
],
[
5
,
5
]
],
/*
skills given
*/
[
[
2
,
2
],
[
4
,
4
]
],
/*
prerequisite
*/
[
2
,
3
,
4
],
/*
time frame
*/
[
2
]
/*
ects
*/
],
[
5
,
/*
course
0
*/
[
5
,
/*
course
5
*/
[
[
6
,
40
],
[
3
,
45
],
[
1
,
10
]
],
/*
skills given
*/
[
[
2
,
2
],
[
4
,
4
]
],
/*
prerequisite
*/
[
2
,
5
,
6
],
/*
time frame
*/
[
2
]
/*
ects
*/
],
[
6
,
/*
course
0
*/
[
6
,
/*
course
6
*/
[
[
0
,
25
],
[
2
,
40
]
],
/*
skills given
*/
[
[
3
,
4
]
],
/*
prerequisite
*/
[
3
,
5
,
6
],
/*
time frame
*/
...
...
@@ -94,20 +94,20 @@ courses([
]
]).
/*
=== GLOBAL CONFIGURATION
*/
minECTS
(
8
).
nbSemester
(
4
).
nbCourses
(
5
).
nbCourseBySemester
(
1
).
% === GETTER AND UTILITY ===
/*
=== GETTER AND UTILITY ===
*/
getIDCourse
([
I
|
_
],
I
).
isNbCoursesIsEQ
(
S
):-
length
(
S
,
L
),
nbCourseBySemester
(
A
),
nbSemester
(
B
),
L
=:=
A
*
B
.
%correct size of S.
isNbCoursesIsLT
(
S
):-
length
(
S
,
L
),
nbCourseBySemester
(
A
),
nbSemester
(
B
),
L
<
A
*
B
.
isNbCoursesIsGT
(
S
):-
length
(
S
,
L
),
nbCourseBySemester
(
A
),
nbSemester
(
B
),
L
>
A
*
B
.
%correct size of S.
% === ECTS CONSTRAINTS ===
/*
=== ECTS CONSTRAINTS ===
*/
ectsConstraintsSolver
([
X
],
V
):-
minECTS
(
M
),
(
X
+
V
)
>=
M
.
ectsConstraintsSolver
([
X
|
Y
],
V
):-
ectsConstraintsSolver
(
Y
,
V
+
X
).
...
...
@@ -117,34 +117,34 @@ ectsListBuilder([X|Y],K):-nth0(4,X,A),ectsListBuilder(Y,L), append(A,L,K).
ectsConstraintsCaller
(
X
):-
ectsListBuilder
(
X
,
L
),
write
(
X
),
ectsConstraintsSolver
(
L
,
0
).
% === ALL DIFFERENTS ===
/*
=== ALL DIFFERENTS ===
*/
isDiffTwo
(
X
,
Y
):-
getIDCourse
(
X
,
XID
),
getIDCourse
(
Y
,
YID
),
XID
\
=
YID
.
allDiff
([
_
]):-!.
allDiff
([
X
,
Y
]):-
!,
isDiffTwo
(
X
,
Y
).
allDiff
([
X
,
Y
|
Z
]):-
isDiffTwo
(
X
,
Y
),
allDiff
([
X
|
Z
]),
allDiff
([
Y
|
Z
]).
% === TIME CONSTRAINTS
/*
=== TIME CONSTRAINTS
*/
timeConstraintsSolver
(
Course
,
PositionInSol
):-
nbCourseBySemester
(
C
),
X
is
PositionInSol
/
C
,
nth0
(
3
,
Course
,
TimeFrame
),
member
(
X
,
TimeFrame
).
timeConstraintsCaller
(
Course
,
PositionInSol
):-
timeConstraintsSolver
(
Course
,
PositionInSol
).
% === PREREQUISITE CONSTRAINTS
/*
=== PREREQUISITE CONSTRAINTS
*/
prerequisiteConstraintsSolver
(
S
,
C
):-
getOnlySkills
(
S
,
Skills
),
getOnlyPrereq
([
C
],
Prereq
),
subset
(
Prereq
,
Skills
),!.
prerequisiteConstraintsCaller
(
CurrentSol
,
CtoCheck
):-
prerequisiteConstraintsSolver
(
CurrentSol
,
CtoCheck
).
% === FINAL SKILLS CONSTRAINTS
/*
=== FINAL SKILLS CONSTRAINTS
*/
finalSkillsConstraintsSolver
(
CurrentSol
,
FinalSkills
):-
getOnlySkills
(
CurrentSol
,
S
),
flattenSkill
(
FinalSkills
,
F
),
subset
(
F
,
S
),!.
finalSkillsConstraintsCaller
(
CurrentSol
):-
finalSkills
(
F
),
finalSkillsConstraintsSolver
(
CurrentSol
,
F
).
% === SKILLS ACQUIRED
% === SKILLS + MASTERY
/*
=== SKILLS ACQUIRED
*/
/*
=== SKILLS + MASTERY
*/
getSkillsValueAcquired
([],[]).
getSkillsValueAcquired
([[
_
,
Skill
|
_
]|
Y
],
L
):-
getSkillsValueAcquired
(
Y
,
Z
),
append
(
Skill
,
Z
,
L
).
% === ONLY SKILLS
/*
=== ONLY SKILLS
*/
flattenSkill
([],[]).
flattenSkill
([[]],[]).
flattenSkill
([[
X
|
_
]],[
X
]).
%Used to remove the sublist, and create a nice depth-1 list with only skill id
...
...
@@ -156,7 +156,7 @@ finalSkillsConstraintsCaller(CurrentSol):- finalSkills(F), finalSkillsConstraint
getOnlyPrereq
([],[]).
getOnlyPrereq
([[
_
,
_
,
Prereq
|
_
]|
Y
],
L
):-
getOnlyPrereq
(
Y
,
Z
),
flattenSkill
(
Prereq
,
FlatSkill
),
append
(
FlatSkill
,
Z
,
L
).
% === SOLVER ===
/*
=== SOLVER ===
*/
solve
(
S
):-
courses
(
C
),
searchSolutions
(
C
,[],
S
,[]).
...
...
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