Previous Up Next

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.



Figure 11.1: A Constraint Network



It can be seen that the Constraint Logic Programming (CLP) formulation The main ECLiPSe language constructs used in modelling are
Built-in constraints

X #> Y
Abstraction

before(task(Si,Di), task(Sj,Dj)) :- Si+Di #<= Sj.
Conjunction

between(X,Y,Z) :- X #< Y, Y #< Z.
Disjunction (but see below)

neighbour(X,Y) :- ( X #= Y+1 ; Y #= X+1 ).
Iteration

not_among(X, L) :- ( foreach(Y,L),param(X) do X #\= Y ).
Recursion

not_among(X, []).
not_among(X, [Y|Ys]) :- X #\= Y, not_among(X, Ys).

Previous Up Next