Since you marked this as prolog, I recommend embedding it in logical constraint programming (CLP) and using the algorithms built into your CLP implementation. A partial example:
:- use_module(library(clpfd)).
on_time([]).
on_time([Task|Tasks]) :-
Task = task(TSuggested,TActual,L,Rs),
TActual
TActual
on_time(Tasks).
Another predicate will verify that two tasks do not use the same resource at the same time:
nonoverlap(R,Task1,Task2) :-
Task1 = task(_,T1,L1,Rs2),
Task2 = task(_,T2,L2,Rs2),
((member(R,Rs1), member(R,Rs2)) ->
T2
T1
;
true % non-conflicting, do nothing
).
Finally, call labelingfor all restricted variables to give them consistent values. This uses CLP (fd) , which works for whole units of time. CLP (R) does the same for real time, but a little more complicated. Links for SWI-Prolog, but SICStus and ECLiPSe have similar libraries.
source
share