☰

*ON THIS PAGE*# Finite domain solver runtime

**Author(s):** Emilio Jesús Gallego Arias, Rémy Haemmerlé.## Usage and interface

## Documentation on exports

## Documentation on multifiles

## Documentation on imports

This module has the following direct dependencies:

- The Ciao System »

- PART IV - Language extensions »

- Constraint programming over finite domains (new) »

**Finite domain solver runtime**

This module provides Finite Domain (FD) constraints and enumerating predicates for FD variables. See `clpfd_doc` for more details about the Ciao FD solver.

This module provides two kinds of contraints: *basic constraints* (such as `domain/3`, `all_different/1`, ...) that deal with FD variables or lists of FD variables, and *meta-contraints* (such as `#=/2`, `#=</2`, ...) that deal with arithmetic expressions over FD variables, called in the following FD expressions. Meta-constraints of this module behave as described in package `clpfd`, except that their arguments are interpreted at run time.

**Library usage:**`:- use_module(library(clpfd/clpfd_rt)).`**Exports:***Predicates:*`in/2`,`#=/2`,`#\=/2`,`#</2`,`#=</2`,`#>/2`,`#>=/2`,`domain/3`,`in/2`,`all_different/1`,`labeling/2`,`indomain/1`,`label/1`,`labeling/2`,`minimize/2`,`maximize/2`,`wrapper/2`.*Regular Types:*`fdvar/1`,`fd_range_expr/1`,`fd_expr/1`.*Multifiles:*`attr_rt:unify_hook/3`,`attr_rt:attribute_goals/4`.

PREDICATEin/2

Usage:`in(Var,Range)`

Constrains Var to take its value in the domain described by Range.

*The following properties should hold at call time:*

(`clpfd_rt:fdvar/1`)Var is a variable or an integer.

(`clpfd_rt:fd_range_expr/1`)Range is a range expression.

REGTYPEfdvar/1

Usage:`fdvar(X)`

X is a variable or an integer.

REGTYPEfd_range_expr/1

A term denoting a range expression: `in/2` predciate.

fd_range_expr(I) :- integer(I). fd_range_expr(..(Min,Max)) :- integer(Min), integer(Max). fd_range_expr(A\/B) :- fd_range_expr(A), fd_range_expr(B).an integer stands for a singleton range, Min..Max for the closed interval from Min to Max, and A\/B for the union of ranges A and B. Range expressions are used by the

Usage:`fd_range_expr(Expr)`

Expr is a range expression.

REGTYPEfd_expr/1

A term denoting an arithmetic expression over FD variables:

fd_expr(Var) :- var(Var). fd_expr(I*Exp) :- int(I), fd_expr(Exp). fd_expr(Exp*I) :- int(I), fd_expr(Exp). fd_expr(Exp1+Exp2) :- fd_expr(Exp1), fd_expr(Exp2). fd_expr(Exp1-Exp2) :- fd_expr(Exp1), fd_expr(Exp2). fd_expr(-Exp) :- fd_expr(Exp).FD expressions are used by meta-constraints.

Usage:`fd_expr(Expr)`

Expr is an FD expression.

PREDICATE#=/2

Meta-constraint "equal".

Usage:`#=(A,B)`

Constrains the interpretation of A to be equal to the interpretation of B.

*The following properties should hold at call time:*

(`clpfd_rt:fd_expr/1`)A is an FD expression.

(`clpfd_rt:fd_expr/1`)B is an FD expression.

PREDICATE#\=/2

Meta-constraint "not equal".

Usage:`#\=(A,B)`

Constrains the interpretation of A to be different from the interpretation of B

*The following properties should hold at call time:*

(`clpfd_rt:fd_expr/1`)A is an FD expression.

(`clpfd_rt:fd_expr/1`)B is an FD expression.

PREDICATE#</2

Meta-constraint "smaller than".

Usage:`#<(A,B)`

Constrains the interpretation of A to be smaller than the interpretation of B.

*The following properties should hold at call time:*

(`clpfd_rt:fd_expr/1`)A is an FD expression.

(`clpfd_rt:fd_expr/1`)B is an FD expression.

PREDICATE#=</2

Meta-constraint "smaller or equal".

Usage:`#=<(A,B)`

Constrains A to be smaller or equal to B.

*The following properties should hold at call time:*

(`clpfd_rt:fd_expr/1`)A is an FD expression.

(`clpfd_rt:fd_expr/1`)B is an FD expression.

PREDICATE#>/2

Meta-constraint "greater than".

Usage:`#>(A,B)`

Constrains the interpretation of A to be greater than the interpretation of B.

*The following properties should hold at call time:*

(`clpfd_rt:fd_expr/1`)A is an FD expression.

(`clpfd_rt:fd_expr/1`)B is an FD expression.

PREDICATE#>=/2

Meta-constraint "greater or equal".

Usage:`#>=(A,B)`

Constrains the interpretation of A to be greater or equal than the interpretation of B.

*The following properties should hold at call time:*

(`clpfd_rt:fd_expr/1`)A is an FD expression.

(`clpfd_rt:fd_expr/1`)B is an FD expression.

PREDICATEdomain/3

Usage:`domain(Vars,Min,Max)`

Constrains each element of Vars to take its value between Min and Max (included). This predicate is generally used to set the initial domain of an interval

*The following properties should hold at call time:*

(`basic_props:list/2`)Vars is a list of fdvars.

(`basic_props:int/1`)Min is an integer.

(`basic_props:int/1`)Max is an integer.

PREDICATEin/2

Usage:`in(Var,Range)`

Constrains Var to take its value in the domain described by Range.

*The following properties should hold at call time:*

(`clpfd_rt:fdvar/1`)Var is a variable or an integer.

(`clpfd_rt:fd_range_expr/1`)Range is a range expression.

PREDICATEall_different/1

Usage:`all_different(Vars)`

Constrains all elements in Vars to take distinct values. This is equivalent to posting an inequality constraint for each pair of variables. This constraint is triggered when a variable becomes ground, removing its value from the domain of the other variables.

*The following properties should hold at call time:*

(`basic_props:list/2`)Vars is a list of fdvars.

PREDICATElabeling/2

Usage:`labeling(Options,Vars)`

Assigns a value to each variable in Vars according to the labeling options given by Options. This predicate is re-executable on backtracking.

The different options are :

- []: the leftmost variables is selected first. Its values are enumerating from the smallest to the greatest.
- [ff]: the variable with the smallest number of elements in its domain is selected first. Its values are then enumerated from the smallest to the greatest.
- [step]: the variable with the smallest number of elements in its domain is selected first. The minimal value of the domainis assigned, on bactracking the value is pruned form the domain and a new variable is selected.

*The following properties should hold at call time:*

(`basic_props:list/2`)Vars is a list of fdvars.

PREDICATEindomain/1

No further documentation available for this predicate.

PREDICATElabel/1

No further documentation available for this predicate.

PREDICATElabeling/2

Usage:`labeling(Options,Vars)`

Assigns a value to each variable in Vars according to the labeling options given by Options. This predicate is re-executable on backtracking.

The different options are :

- []: the leftmost variables is selected first. Its values are enumerating from the smallest to the greatest.
- [ff]: the variable with the smallest number of elements in its domain is selected first. Its values are then enumerated from the smallest to the greatest.
- [step]: the variable with the smallest number of elements in its domain is selected first. The minimal value of the domainis assigned, on bactracking the value is pruned form the domain and a new variable is selected.

*The following properties should hold at call time:*

(`basic_props:list/2`)Vars is a list of fdvars.

PREDICATEminimize/2

No further documentation available for this predicate.
*Meta-predicate* with arguments: `minimize(goal,?)`.

PREDICATEmaximize/2

No further documentation available for this predicate.
*Meta-predicate* with arguments: `maximize(goal,?)`.

PREDICATEwrapper/2

No further documentation available for this predicate.

PREDICATEattr_rt:unify_hook/3

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEattr_rt:attribute_goals/4

No further documentation available for this predicate.
The predicate is *multifile*.

*System library modules:*`clpfd_debug_rt`,`fd_term`,`fd_constraints`,`fd_labeling`,`fd_optim`,`attr_rt`.*Packages:*`prelude`,`initial`,`condcomp`,`assertions`,`assertions/assertions_basic`,`regtypes`,`fsyntax`,`dcg`,`clpfd/clpfd_debug`,`clpfd/clpfd_options`,`attr`.

Generated with LPdoc using Ciao