When modelling problems with constraints, the basic idea is to set up a network of variables and constraints. Figure 11.1 shows such a constraint network.
It can be seen that the Constraint Logic Programming (CLP) formulation
The main ECLiPSe language constructs used in modelling are
X #> Y
before(task(Si,Di), task(Sj,Dj)) :- Si+Di #<= Sj.
between(X,Y,Z) :- X #< Y, Y #< Z.
neighbour(X,Y) :- ( X #= Y+1 ; Y #= X+1 ).
not_among(X, L) :- ( foreach(Y,L),param(X) do X #\= Y ).
not_among(X, []).
not_among(X, [Y|Ys]) :- X #\= Y, not_among(X, Ys).