Since you've tagged this as prolog
, I recommend implementing it in constraint logic programming (CLP) and using the algorithms built into your CLP implementation. Partial example:
:- use_module(library(clpfd)).
on_time([]).
on_time([Task|Tasks]) :-
Task = task(TSuggested,TActual,L,Rs),
TActual #>= TSuggested - 10,
TActual #=< TSuggested + 10,
on_time(Tasks).
Another predicate would check that no two tasks use the same resource concurrently:
nonoverlap(R,Task1,Task2) :-
Task1 = task(_,T1,L1,Rs2),
Task2 = task(_,T2,L2,Rs2),
((member(R,Rs1), member(R,Rs2)) ->
T2 #> T1+L1 % start Task2 after Task1 has finished
#\/ % OR
T1 #> T2+L2 % start Task1 after Task2 has finished
;
true % non-conflicting, do nothing
).
Finally, call labeling
on all the constrained variables to give them consistent values. This uses CLP(fd), which works for integer time units. CLP(R) does the same for real-valued time but it slightly more complicated. Links are for SWI-Prolog but SICStus and ECLiPSe have similar libraries.