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
272fdc0d
Commit
272fdc0d
authored
Dec 12, 2019
by
Alexis Lebis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add prerequisite test and final obj
parent
8391e6d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
4 deletions
+31
-4
prologTest.pl
prologTest.pl
+31
-4
No files found.
prologTest.pl
View file @
272fdc0d
...
...
@@ -95,7 +95,7 @@ courses([
]).
minECTS
(
9
).
minECTS
(
8
).
nbSemester
(
4
).
nbCourses
(
5
).
nbCourseBySemester
(
1
).
...
...
@@ -121,7 +121,7 @@ ectsConstraintsCaller(X):- ectsListBuilder(X,L), write(X), ectsConstraintsSolver
isDiffTwo
(
X
,
Y
):-
getIDCourse
(
X
,
XID
),
getIDCourse
(
Y
,
YID
),
XID
\
=
YID
.
allDiff
([
_
]):-!.
allDiff
([
X
,
Y
]):-
isDiffTwo
(
X
,
Y
),
!
.
allDiff
([
X
,
Y
]):-
!,
isDiffTwo
(
X
,
Y
)
.
allDiff
([
X
,
Y
|
Z
]):-
isDiffTwo
(
X
,
Y
),
allDiff
([
X
|
Z
]),
allDiff
([
Y
|
Z
]).
% === TIME CONSTRAINTS
...
...
@@ -130,6 +130,32 @@ timeConstraintsSolver(Course,PositionInSol):- nbCourseBySemester(C), X is Positi
timeConstraintsCaller
(
Course
,
PositionInSol
):-
timeConstraintsSolver
(
Course
,
PositionInSol
).
% === PREREQUISITE CONSTRAINTS
prerequisiteConstraintsSolver
(
S
,
C
):-
getOnlySkills
(
S
,
Skills
),
getOnlyPrereq
([
C
],
Prereq
),
subset
(
Prereq
,
Skills
),!.
prerequisiteConstraintsCaller
(
CurrentSol
,
CtoCheck
):-
prerequisiteConstraintsSolver
(
CurrentSol
,
CtoCheck
).
% === 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
getSkillsValueAcquired
([],[]).
getSkillsValueAcquired
([[
_
,
Skill
|
_
]|
Y
],
L
):-
getSkillsValueAcquired
(
Y
,
Z
),
append
(
Skill
,
Z
,
L
).
% === ONLY SKILLS
flattenSkill
([],[]).
flattenSkill
([[]],[]).
flattenSkill
([[
X
|
_
]],[
X
]).
%Used to remove the sublist, and create a nice depth-1 list with only skill id
flattenSkill
([[
X
|
_
]|
Y
],
L
):-
flattenSkill
(
Y
,
Z
),
append
([
X
],
Z
,
L
).
getOnlySkills
([],[]).
getOnlySkills
([[
_
,
Skill
|
_
]|
Y
],
L
):-
getOnlySkills
(
Y
,
Z
),
flattenSkill
(
Skill
,
FlatSkill
),
append
(
FlatSkill
,
Z
,
L
).
getOnlyPrereq
([],[]).
getOnlyPrereq
([[
_
,
_
,
Prereq
|
_
]|
Y
],
L
):-
getOnlyPrereq
(
Y
,
Z
),
flattenSkill
(
Prereq
,
FlatSkill
),
append
(
FlatSkill
,
Z
,
L
).
% === SOLVER ===
solve
(
S
):-
courses
(
C
),
...
...
@@ -137,12 +163,13 @@ solve(S):-
chooseNewCourse
(
C
,
OneC
,
Tabou
):-
member
(
OneC
,
C
).
searchSolutions
(
_
,
S
,
S
,
_
):-
isNbCoursesIsEQ
(
S
),!,
ectsConstraintsCaller
(
S
),
displaySolution
(
S
).
searchSolutions
(
_
,
S
,
S
,
_
):-
isNbCoursesIsEQ
(
S
),!,
ectsConstraintsCaller
(
S
),
finalSkillsConstraintsCaller
(
S
),
displaySolution
(
S
).
searchSolutions
(
C
,
S
,
Sol
,
Tabou
):-
isNbCoursesIsLT
(
S
),
length
(
S
,
SizeOfS
),
chooseNewCourse
(
C
,
OneC
,
Tabou
),
%Backtracker
timeConstraintsCaller
(
OneC
,
SizeOfS
),
%check if the course picked is ok
prerequisiteConstraintsCaller
(
S
,
OneC
),
append
(
S
,[
OneC
],
N
),
allDiff
(
N
),
searchSolutions
(
C
,
N
,
Sol
,
Tabou
).
displaySolution
([]).
displaySolution
([
[
ID
|
_
]|
Y
]):-
write
(
"Course"
),
write
(
ID
),
write
(
"\n"
),
displaySolution
(
Y
).
displaySolution
([
[
ID
|
_
]|
Y
]):-
write
(
"\n"
),
write
(
"Course"
),
write
(
ID
),
displaySolution
(
Y
).
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