Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LogIA
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aalbert
LogIA
Merge requests
!11
Resolve "complete mini project 2"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "complete mini project 2"
7-complete-mini-project-2
into
main
Overview
0
Commits
23
Pipelines
0
Changes
9
Merged
aalbert
requested to merge
7-complete-mini-project-2
into
main
2 years ago
Overview
0
Commits
23
Pipelines
0
Changes
1
Expand
Closes
#7 (closed)
👍
0
👎
0
Merge request reports
Viewing commit
c6daa144
Prev
Next
Show latest version
1 file
+
54
−
0
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
c6daa144
another incomplete version
· c6daa144
aalbert
authored
2 years ago
project2/jobshop2.pl
0 → 100644
+
54
−
0
Options
% Student exercise profile
:-
set_prolog_flag
(
occurs_check
,
error
).
% disallow cyclic terms
:-
use_module
(
library
(
clpq
)).
jobshop3
(
Jobs
,
Schedule
,
Time
)
:-
jobshop
(
3
,
3
,
Jobs
,
Schedule
,
Time
).
jobshop
(
N
,
M
,
Jobs
,
Schedule
,
Time
)
:-
% assert the given jobs have the expected size
length
(
Jobs
,
N
),
Len
is
N
*
M
,
length
(
Schedule
,
Len
),
maplist
(
inv_length
(
M
),
Jobs
),
% assert that the tasks are done in the right order
Len1
is
N
-
1
,
numlist
(
0
,
Len1
,
L
),
maplist
(
order_tasks
(
N
,
M
,
Jobs
,
Schedule
,
Time
),
L
),
% TODO assert that jobs on machines do not overlap
minimize
(
Time
).
inv_length
(
N
,
L
)
:-
length
(
L
,
N
).
order_tasks
(
N
,
M
,
Jobs
,
Schedule
,
Time
,
J
)
:-
% First task is done after 0 unit of time.
Pos
is
J
*
N
,
nth0
(
Pos
,
Schedule
,
T0
),
{
0
=<
T0
},
% Every task begin after the previous one is done.
nth0
(
J
,
Jobs
,
Tasks
),
Len
is
M
-
2
,
numlist
(
0
,
Len
,
L
),
maplist
(
order_tasks_
(
N
,
Tasks
,
Schedule
,
J
),
L
),
% Last task finish before the total needed time.
Pos2
is
J
*
N
+
M
-
1
,
nth0
(
Pos2
,
Schedule
,
TM
),
Pos3
is
M
-
1
,
nth0
(
Pos3
,
Tasks
,
(
_
,
DM
)),
{
TM
+
DM
=<
Time
}.
order_tasks_
(
N
,
Tasks
,
Schedule
,
J
,
T
)
:-
Pos
is
J
*
N
+
T
,
nth0
(
Pos
,
Schedule
,
T0
),
Pos1
is
J
*
N
+
T
+
1
,
nth0
(
Pos1
,
Schedule
,
T1
),
nth0
(
T
,
Tasks
,
(
_
,
D0
)),
{
T0
+
D0
=<
T1
}.
%?- jobshop3([[(0,3), (1,2), (2,2)],
% [(0,2), (2,1), (1,4)],
% [(0,4), (1,4), (2,3)]],
% Shedule,
% Time).
Loading