Initial value constraints
Author: Daniel Diaz
Keywords: GNU Prolog, manual, Prolog, compiler, constraints, finite domains

### 9.3 Initial value constraints

- fd_domain/3, fd_domain_bool/1
- fd_domain/2

#### 9.3.1 fd_domain/3, fd_domain_bool/1

Templates

  fd_domain(+fd_variable_list_or_fd_variable, +integer, +integer)
  fd_domain(?fd_variable, +integer, +integer)
  fd_domain_bool(+fd_variable_list)
  fd_domain_bool(?fd_variable)

Description

fd_domain(Vars, Lower, Upper) constraints each element X of Vars to take a value in Lower..Upper. This predicate is generally used to set the initial domain of variables to an interval. Vars can be also a single FD variable (or a single Prolog variable).

fd_domain_bool(Vars) is equivalent to fd_domain(Vars, 0, 1) and is used to declare boolean FD variables.

Errors

Vars is not a variable but is a partial list |  | instantiation_error
Vars is neither a variable nor an FD variable nor an integer nor a list |  | type_error(list, Vars)
an element E of the Vars list is neither a variable nor an FD variable nor an integer |  | type_error(fd_variable, E)
Lower is a variable |  | instantiation_error
Lower is neither a variable nor an integer |  | type_error(integer, Lower)
Upper is a variable |  | instantiation_error
Upper is neither a variable nor an integer |  | type_error(integer, Upper)

Portability

GNU Prolog predicate.

#### 9.3.2 fd_domain/2

Templates

  fd_domain(+fd_variable_list, +integer_list)
  fd_domain(?fd_variable, +integer_list)

Description

fd_domain(Vars, Values) constraints each element X of the list Vars to take a value in the list Values. This predicate is generally used to set the initial domain of variables to a set of values. The domain of each variable of Vars uses a sparse representation. Vars can be also a single FD variable (or a single Prolog variable).

Errors

Vars is not a variable but is a partial list |  | instantiation_error
Vars is neither a variable nor an FD variable nor an integer nor a list |  | type_error(list, Vars)
an element E of the Vars list is neither a variable nor an FD variable nor an integer |  | type_error(fd_variable, E)
Values is a partial list or a list with an element E which is a variable |  | instantiation_error
Values is neither a partial list nor a list |  | type_error(list, Values)
an element E of the Values list is neither a variable nor an integer |  | type_error(integer, E)

Portability

GNU Prolog predicate.

Copyright (C) 1999-2018 Daniel Diaz Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. More about the copyright