11.3 Modelling with CLP and ECLiPSe
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
Figure 11.1: A Constraint Network
The main ECLiPSe language constructs used in modelling are
is a natural declarative description of the constraint network
- can serve as a program to set up the constraint network
X #> Y
before(task(Si,Di), task(Sj,Dj)) :- Si+Di #<= Sj.
between(X,Y,Z) :- X #< Y, Y #< Z.
- Disjunction (but see below)
neighbour(X,Y) :- ( X #= Y+1 ; Y #= X+1 ).
not_among(X, L) :- ( foreach(Y,L),param(X) do X #\= Y ).
not_among(X, [Y|Ys]) :- X #\= Y, not_among(X, Ys).