[ library(tentative) | Reference Manual | Alphabetic Index ]

CS :~ ConstrSpec

Add a constraint to a constraint set
Constraint set or free variable
A constraint specification


Add a constraint to a constraint set. After adding, the constraint will be part of the constraint set, and add to its total violatedness. The amount of violatedness contributed by the constraint depends on the constraint's implementation, but can be scaled.

Three forms of constraint specification are recognised here:

A constraint goal. The constraint must have a 'tentative implementation', i.e. a predicate must be defined that takes one additional argument and implements the violation monitoring for the constraint (see constraint implementation interface).
Weight * Constraint
where Weight is an integer. This means that the constraints violatedness is scaled with the factor Weight before being added to the total violatedness of the constraint set.
Constraint alias Term
Term is the term that can be retrieved from the constraint set, in place of the constraint goal itself (see cs_all/2 etc).
Weight * Constraint alias Term
Conbination of both modifiers above.

If CS is a free variable, a new constraint set will be implicitly created (as if created with cs_create(CS, [])).

Modes and Determinism


    ?- lib(tentative_constraints).	% for alldifferent/1
    Yes (0.00s cpu)

    ?- length(Xs, 5), tent_set_all(Xs, 99), CS :~ alldifferent(Xs).
    Xs = [Xi{99 -> 4}, Xi{99 -> 4}, Xi{99 -> 4}, Xi{99 -> 4}, Xi{99 -> 4}]
    CS = constraint_set(TotalVio{10 -> 0}, ...)
    There is 1 delayed goal.
    Yes (0.00s cpu)

See Also

cs_create / 2, cs_clear_all / 1, cs_clear_satisfied / 1, cs_violations / 2, cs_current_violations / 2, cs_random_worst / 2, cs_all_worst / 2, cs_all_violated / 2, cs_random_violated / 2, cs_all / 2, tent_implements / 2