This example concerns the planning of a simple project. Tasks are only dependent on the completion of other tasks. Further analysis reveals the ``critical path'' - those tasks in which a delay would be critical to the completion of the project on time.
The tasks A through G comprise the planned project. Each task requires a certain amount of time to complete and is dependent on the completion of other tasks according to the following diagram:
:- import(const_domain).program :- Jobs = [A,B,C,D,E,F,G], Durations = [Da,Db,Dc,Dd,De,Df,Dg], Durations = [ 4, 2, 4, 3, 4, 4, 3],
A ?>= 0 + Da, D ?>= B + Dd, F ?>= D + Df, B ?>= A + Db, D ?>= C + Dd, G ?>= F + Dg, C ?>= A + Dc, E ?>= C + De, G ?>= E + Dg,
label(Jobs), print(Jobs).
[user] ?- program. [4,6,8,11,12,15,18] yes
In the IF/Prolog program, inter-dependencies between the jobs (A...G) are represented as arithmetic constraints, for example D ?>= B + Dd can be read as Job D is completed after the start and duration of Job B.
The constraints themselves (?>=/2) do not activate to determine a solution to the variables they contain, until they are passed to one of the solver predicates which then solves the complete problem. The label/1 predicate finds values for all variables in the list Jobs.
In the above, label/1 is quickly able to determine that a value for variable A exists as its start time and duration are fixed. Then, through ``constraint propagation'', values are calculated for the remaining variables.