Selectors and evaluators

A search phase can specify not only a group of variables to fix but also in what order they should be fixed. Additionally, a search phase can specify what values should be tried first for those variables. The fixing order can be specified using selectors and evaluators.

Variable selectors and evaluators

The following picture illustrates the process of choosing the next variable to fix using three variable selectors:

On the input (left) there is a set of all variables specified in the search phase that still remain unfixed. The first selector (gray funnel) is:


selectSmallest(domainSize(), 5)

It evaluates input variables using the domainSize() evaluator and keeps for further consideration only variables whose current domain size is in the range min..min+5 where min is the minimum current domain size among all the input variables.

Note that the ordering of variables by domainSize() evaluator is not static. Domains of variables change during the search, so the selector always uses the current domain size.

The subset of variables selected by the first selector is the input for the second selector which is:


selectLargest(3, varImpact())

This time the selector evaluates the input variables by using varImpact() evaluator and selects at least 3 variables with the biggest evaluation. More than 3 variables can be selected only if there is a tie for third place. In this instance, all variables which come equal third according to the largest variable impact are selected (as well as those coming first and second). If there are less than 3 variables on the input then the selector selects all of them.

Finally the selected variables are passed to the third selector which selects one of the preselected variables randomly:


selectRandomVar()

In the case above, the last selector always selects only one variable. However if there is still more than one variable to choose from after the last selector, then the variable which is mentioned first in the search phase is chosen.

Value selectors and evaluators

Once a variable is chosen for fixing, it is necessary to chose a value from its domain. This is also done using selectors and evaluators. For example, the following selector selects from the current domain 3 values with the largest impact.


selectLargest(3, valueImpact())

Again the selectors can be chained until a single value is chosen. If there is more than one possible value after the last selector then the minimum value is chosen.

Search phase with selectors and evaluators

To finish the example, here is how the selectors and evaluators can be used in a search phase:


search {
  searchPhase([selectSmallest(domainSize(), 5), selectLargest(3, varImpact()), selectRandomVar()],
               selectSmallest(3, value()));
}

The search phase above does not specify a set of variables. When no variable set is specified, it is assumed that the phase takes as input all integer variables in the model.