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

search(+L, ++Arg, ++Select, +Choice, ++Method, +Option)

Interface to gecode search-engines to perform search in gecode.
L
is a collection (a la collection_to_list/2) of domain variables (Arg = 0) or a collection of terms (Arg > 0)
Arg
is an integer, which is 0 if L is a collection of domain variables or greater than 0 if L consists of terms of arity greater than Arg, the value Arg indicates the selected argument of the term
Select
is a predefined variable selection method. Predefined methods are input_order, first_fail, anti_first_fail, smallest, largest, occurrence, anti_occurrence, most_constrained, most_constrained_per_value, least_constrained_per_value, max_regret, max_regret_lwb, min_regret_lwb, max_regret_upb, min_regret_upb, random, max_weighted_degree, min_weighted_degree, max_weighted_degree_per_value, min_weighted_degree_per_value
Choice
is the name of a predefine value choice method for choosing the value to try for a variable; Predefined choice methods are: indomain, indomain_reverse_enum, indomain_min, indomain_max, indomain_middle, indomain_median, indomain_split, indomain_reverse_split, indomain_random, indomain_interval, indomain_interval_min, indomain_interval_max
Method
is one of the following: complete, bb_min(Cost:domain variable), restart_min(Cost:domain variable)
Option
is a list of option terms. Currently recognized are: tiebreak(+Select), stats(+Stats), limits(+Stop), timeout(+Seconds), control(+Control), backtrack(-N), node(+Call), nodes(+N)

Description

Search/6 provides an interface to gecode's search-engine, to allow search to be performed by gecode. It is designed to have the same arguments as the generic search/6 routine available for integer domain solvers. so that for common cases, the call will work for both search/6. The generic search/6 is available in the gfd_search module. The difference is that here the search is performed by gecode, and is an atomic step when viewed from ECLiPSe. For the non-optimising search method, backtracking into this predicate will produce the next solution if it exists. By changing the Method argument, different gecode search-engines (implementation of different complete, partial and optimising search algorithms (and their parameters)) can be selected and controlled. The availability of optimising search-engines means that this predicate also provide some of the functionality of lib(branch_and_bound). The predicate also provides a number of pre-defined variable selection methods (to choose which variable will be assigned next) and some pre-defined value assignment methods (to try out the possible values for the selected variable in some heuristic order).

In order to allow more structure in the application program, it is possible to pass a collection of terms rather than only a collection of domain variables. In this way all information about some entity can be easily grouped together.

The variable selection and value choice methods are defined by gecode. They are mapped to the closest matching methods in the generic search/6 (or with a name following the same convention if the method have no correspondence). For variable selection, if several entries have the same heuristic value, then a tiebreak selection method, specified by the tiebreak method, can be used to chose from these entries. Note that there are some differences from ECLiPSe search in how the methods are applied: variable selection is always performed before each value selection: in ECLiPSe, once a variable is selected, all the possible values for that variable are tried on backtracking without re-selecting the variable.

The pre-defined selection methods (with the gecode name in brackets) use the following criteria:

The pre-defined choice methods (with gecode name in brackets) have the following meaning:

The different search methods are

The option list is used to pass additional parameters to and from the procedure. The currently recognized options are:

Modes and Determinism

Fail Conditions

Fails if the search engine does not find any solution. For partial search methods, this does not mean that the problem does not have a solution.

Resatisfiable

yes (non-optimising searches)

Examples

top:-
	length(L,8),
	L :: 1..8,
	search(L,0,input_order,indomain,complete,[]).

top:-
        length(L,8),
        L::1..8,
        L = [Cost|L],
        search(L,0,input_order,indomain_max,bb_min(Cost),[]).

See Also

indomain / 1, gfd_search : indomain / 2, labeling / 1, gfd_search : delete / 5, gfd_search : search / 6