- library
- clp
- clpfd.pl -- CLP(FD): Constraint Logic Programming over Finite Domains
- in/2
- ins/2
- indomain/1
- label/1
- labeling/2
- all_different/1
- all_distinct/1
- sum/3
- scalar_product/4
- #>=/2
- #=</2
- #=/2
- #\=/2
- #>/2
- #</2
- #\/1
- #<==>/2
- #==>/2
- #<==/2
- #/\/2
- #\//2
- #\/2
- lex_chain/1
- tuples_in/2
- serialized/2
- element/3
- global_cardinality/2
- global_cardinality/3
- circuit/1
- cumulative/1
- cumulative/2
- disjoint2/1
- automaton/3
- automaton/8
- transpose/2
- zcompare/3
- chain/2
- fd_var/1
- fd_inf/2
- fd_sup/2
- fd_size/2
- fd_dom/2
- clpb.pl -- CLP(B): Constraint Logic Programming over Boolean Variables
- clpfd.pl -- CLP(FD): Constraint Logic Programming over Finite Domains
- clp
- labeling(+Options, +Vars)
- Assign a value to each variable in Vars. Labeling means systematically
trying out values for the finite domain variables Vars until all of
them are ground. The domain of each variable in Vars must be finite.
Options is a list of options that let you exhibit some control over
the search process. Several categories of options exist:
The variable selection strategy lets you specify which variable of Vars is labeled next and is one of:
- leftmost
- Label the variables in the order they occur in Vars. This is the default.
- ff
- First fail. Label the leftmost variable with smallest domain next, in order to detect infeasibility early. This is often a good strategy.
- ffc
- Of the variables with smallest domains, the leftmost one participating in most constraints is labeled next.
- min
- Label the leftmost variable whose lower bound is the lowest next.
- max
- Label the leftmost variable whose upper bound is the highest next.
The value order is one of:
- up
- Try the elements of the chosen variable's domain in ascending order. This is the default.
- down
- Try the domain elements in descending order.
The branching strategy is one of:
- step
- For each variable X, a choice is made between X = V and X #\= V, where V is determined by the value ordering options. This is the default.
- enum
- For each variable X, a choice is made between X = V_1, X = V_2 etc., for all values V_i of the domain of X. The order is determined by the value ordering options.
- bisect
- For each variable X, a choice is made between X #=< M and X #> M, where M is the midpoint of the domain of X.
At most one option of each category can be specified, and an option must not occur repeatedly.
The order of solutions can be influenced with:
min(Expr)
max(Expr)
This generates solutions in ascending/descending order with respect to the evaluation of the arithmetic expression Expr. Labeling Vars must make Expr ground. If several such options are specified, they are interpreted from left to right, e.g.:
?- [X,Y] ins 10..20, labeling([max(X),min(Y)],[X,Y]).
This generates solutions in descending order of X, and for each binding of X, solutions are generated in ascending order of Y. To obtain the incomplete behaviour that other systems exhibit with "
maximize(Expr)
" and "minimize(Expr)
", use once/1, e.g.:once(labeling([max(Expr)], Vars))
Labeling is always complete, always terminates, and yields no redundant solutions. See core relations and search for usage advice.