Previous Up Next

14.5  Basic Suspension Facility

For the more complex constraint behaviours (beyond those waiting for instantiations), we need to employ lower-level primitives of the ECLiPSe kernel (suspensions and priorities). If we want to add a new constraint to an existing solver, we also need to use the lower-level interface that the particular solver provides.

Apart from the delay clauses used above, ECLiPSe also provides a more powerful (though less declarative) way of causing a goal to delay. The following is another implementation of the constraint checking behaviour, this time using the suspend/3 built-in predicate to create a delayed goal for capacity/2:

capacity(T,N) :- (var(T);var(N)), !,
        suspend(capacity(T,N), 0, [T,N]->inst).
capacity(1, N) :- N>=0.0, N=<350.0.
capacity(2, N) :- N>=0.0, N=<180.0.
capacity(3, N) :- N>=0.0, N=<50.0.


suspend(Goal, Priority, Triggers)
Creates Goal as a delayed goal with a given waking priority and triggering conditions. Triggers is a list of Variables->Conditions terms, specifying under which conditions the goal will be woken up. The priority specifies with which priority the goal will be scheduled after it has been triggered. A priority of 0 selects the default for the predicate. Otherwise, valid priorities range are from 1 (most urgent, reserved for debugging purposes) to 12 (least urgent).
Some valid triggers:
X->inst
wake when the variable becomes instantiated (most specific)
X->constrained
wake when the variable becomes constrained somehow (most general)
X->ic:min
wake when the lower bound of an ic-variable changes
X->ic:max
wake when the upper bound of an ic-variable changes
X->ic:hole
wake an internal domain value gets removed
Figure 14.3: The Basic Suspension Facilities


Previous Up Next