[ 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:

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.

Fail Conditions

No

Resatisfiable

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

See Also

search / 6, ic : indomain / 1, ic_symbolic : indomain / 1, gfd : indomain / 1, sd : indomain / 1, fd : indomain / 1, random / 1, seed / 1, ic_sbds : sbds_try / 2, gfd_sbds : sbds_try / 2, fd_sbds : sbds_try / 2, ic_gap_sbds : sbds_try / 2, ic_gap_sbdd : sbdd_try / 2