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

# indomain(?Var, ++Method)

a flexible way to assign values to finite domain variables
Var
a domain variable or an integer
Method
one of the atoms min, max, middle, median, split, interval, random or an integer

## Description

This predicate provides a flexible way to assign values to finite domain variables.

The available methods are:

• enum Identical to indomain/1. Start enumeration from the smallest value upwards, without first removing previously tried values.
• min Start the enumeration from the smallest value upwards. This behaves like the built-in indomain/1, except that it removes previously tested values on backtracking.
• max Start the enumeration from the largest value downwards.
• reverse_min Like min, but tries the alternatives in opposite order, i.e. values are excluded first, then assigned.
• reverse_max Like max, but tries the alternatives in opposite order, i.e. values are excluded first, then assigned.
• middle Try the enumeration starting from the middle of the domain. On backtracking, this chooses alternatively values above and below the middle value, until all alternatives have been tested.
• median Try the enumeration starting from the median value of the domain. On backtracking, this chooses alternatively values above and below the median value, until all alternatives have been tested.
• split Try the enumeration by splitting the domain successively into halves until a ground value is reached. This sometimes can detect failure earlier than the normal enumeration methods, but enumerates the values in the same order as min.
• reverse_split Like split, but tries the upper half of the domain first.
• interval If the domain consists of several intervals, then we branch first on the choice of the interval. For one interval, we use domain splitting.
• random Try the enumeration in a random order. On backtracking, the previously tested value is removed. This method uses random/1 to create random numbers, use seed/1 before to make results reproducible.
• sbds_min Like min, but use sbds_try/2 to make choices (for use in conjunction with the SBDS symmetry breaking library).
• sbds_max Like max, but use sbds_try/2 to make choices (for use in conjunction with the SBDS symmetry breaking library).
• sbds_middle Like middle, but use sbds_try/2 to make choices (for use in conjunction with the SBDS symmetry breaking library).
• sbds_median Like median, but use sbds_try/2 to make choices (for use in conjunction with the SBDS symmetry breaking library).
• sbds_random Like random, but use sbds_try/2 to make choices (for use in conjunction with the SBDS symmetry breaking library).
• sbds(Value:integer) Like Value:integer, but use sbds_try/2 to make choices (for use in conjunction with the SBDS symmetry breaking library).
• gap_sbds_min Like min, but use sbds_try/2 to make choices (for use in conjunction with the GAP-based SBDS symmetry breaking library, lib(ic_gap_sbds)).
• gap_sbds_max Like max, but use sbds_try/2 to make choices (for use in conjunction with the GAP-based SBDS symmetry breaking library, lib(ic_gap_sbds)).
• gap_sbds_middle Like middle, but use sbds_try/2 to make choices (for use in conjunction with the GAP-based SBDS symmetry breaking library, lib(ic_gap_sbds)).
• gap_sbds_median Like median, but use sbds_try/2 to make choices (for use in conjunction with the GAP-based SBDS symmetry breaking library, lib(ic_gap_sbds)).
• gap_sbds_random Like random, but use sbds_try/2 to make choices (for use in conjunction with the GAP-based SBDS symmetry breaking library, lib(ic_gap_sbds)).
• gap_sbds(Value:integer) Like Value:integer, but use sbds_try/2 to make choices (for use in conjunction with the GAP-based SBDS symmetry breaking library, lib(ic_gap_sbds)).
• gap_sbdd_min Like min, but use sbdd_try/2 to make choices (for use in conjunction with the GAP-based SBDD symmetry breaking library, lib(ic_gap_sbdd)).
• gap_sbdd_max Like max, but use sbdd_try/2 to make choices (for use in conjunction with the GAP-based SBDD symmetry breaking library, lib(ic_gap_sbdd)).
• gap_sbdd_middle Like middle, but use sbdd_try/2 to make choices (for use in conjunction with the GAP-based SBDD symmetry breaking library, lib(ic_gap_sbdd)).
• gap_sbdd_median Like median, but use sbdd_try/2 to make choices (for use in conjunction with the GAP-based SBDD symmetry breaking library, lib(ic_gap_sbdd)).
• gap_sbdd_random Like random, but use sbdd_try/2 to make choices (for use in conjunction with the GAP-based SBDD symmetry breaking library, lib(ic_gap_sbdd)).
• gap_sbdd(Value:integer) Like Value:integer, but use sbdd_try/2 to make choices (for use in conjunction with the GAP-based SBDD symmetry breaking library, lib(ic_gap_sbdd)).
On backtracking, all methods except enum first remove the previously tested value before choosing a new one. This sometimes can have a huge impact on the constraint propagation, and normally does not cause much overhead, even if no additional propagation occurs.

No

yes

## Examples

```top:-
X :: 1..10,
indomain(X,min),
write(X),put(32),
fail.
top.

% writes 1 2 3 4 5 6 7 8 9 10

top:-
X :: 1..10,
indomain(X,max),
write(X),put(32),
fail.
top.

% writes 10 9 8 7 6 5 4 3 2 1

top:-
X :: 1..10,
indomain(X,middle),
write(X),put(32),
fail.
top.

% writes 5 6 4 7 3 8 2 9 1 10

top:-
X :: 1..10,
indomain(X,median),
write(X),put(32),
fail.
top.

% writes 5 6 4 7 3 8 2 9 1 10

top:-
X :: 1..10,
indomain(X,3),
write(X),put(32),
fail.
top.

% writes 3 4 2 5 1 6 7 8 9 10

top:-
X :: 1..10,
indomain(X,split),
write(X),put(32),
fail.
top.

% writes 1 2 3 4 5 6 7 8 9 10

top:-
X :: 1..10,
indomain(X,random),
write(X),put(32),
fail.
top.

% writes for example 5 3 7 6 8 1 2 10 9 4

```