Previous: , Up: CLPFD Example Programs   [Contents][Index]


10.9.12.3 Cumulative Scheduling

This example is a very small scheduling problem. We consider seven tasks where each task has a fixed duration and a fixed amount of used resource:

TaskDurationResource
t1162
t269
t3133
t477
t5510
t6181
t7411

The goal is to find a schedule that minimizes the completion time for the schedule while not exceeding the capacity 13 of the resource. The resource constraint is succinctly captured by a cumulative/2 constraint. Branch-and-bound search is used to find the minimal completion time.

This example was adapted from [Beldiceanu & Contejean 94].

:- use_module(library(clpfd)).

schedule(Ss, End) :-
        Ss = [S1,S2,S3,S4,S5,S6,S7],
        Es = [E1,E2,E3,E4,E5,E6,E7],
        Tasks = [task(S1,16,E1, 2,0),
                 task(S2, 6,E2, 9,0),
                 task(S3,13,E3, 3,0),
                 task(S4, 7,E4, 7,0),
                 task(S5, 5,E5,10,0),
                 task(S6,18,E6, 1,0),
                 task(S7, 4,E7,11,0)],
        domain(Ss, 1, 30),
        domain(Es, 1, 50),
        domain([End], 1, 50),
        maximum(End, Es),
        cumulative(Tasks, [limit(13)]),
        append(Ss, [End], Vars),
        labeling([minimize(End)], Vars). % label End last

%% End of file

| ?- schedule(Ss, End).
Ss = [1,17,10,10,5,5,1],
End = 23

Send feedback on this subject.