3.2 Constraint Programming
3.2.2 Search schemes
Although both systematic search and some consistency techniques can be used alone to solve a CSP completely, this is rarely done. A combination of both
approaches is a more common way of solving a CSP. There are mainly two schemes to solve a CSP using constraint propagation: the look back and the look ahead schemes.
A look back schema uses consistency checks among already instantiated variables. BT is a simple example of this schema. To avoid some problems of BT, like thrashing and redundant work, other look back schemes were pro-posed.
Backjumping (BJ) is a method to avoid thrashing in BT. The control of BJ is exactly the same as BT, except when backtracking takes place. Both algorithms pick one variable at a time and look for a value for this variable making sure that this new assignment is compatible with values committed to so far. However, if BJ finds an inconsistency, it analyses the situation in order to identify the source of inconsistency. It uses the violated constraints as a guidance to find out the con icting variable. If all the values in the domain are explored, then the BJ algorithm backtracks to the most recent con icting variable. This is the main difference from the BT algorithm, which backtracks to the immediate past variables.
Another look back schemes, called Backchecking (BC) and Backmarking (BM), avoid redundant work of BT. Both BC and its descendent BM are useful algorithms for reducing the number of compatibility checks. If the algorithm finds that some label < Y, b > is incompatible with any recent label < X, a >
then it remembers this incompatibility. As long as < X, a > is still committed to, the < Y, b > will not be considered again.
BM is an improvement over BC that avoids some redundant constraint checking as well as some redundant discoveries of inconsistencies. It reduces the number of compatibility checks by remembering for every label the incom-patible recent labels. Furthermore, it avoids repeating compatibility checks which have already been performed and which have succeeded.
To cope with COPs, one should take into account the cost function. The appropriate modification of the BT search schema is called Branch-and-Bound (BB). During the search, BB maintains the current best value of the cost function (bound ) and, each time a solution with a smaller cost is found, its value is updated. There are many variations on the BB algorithm. One consideration is what to do after a solution with a new best cost is found. The simplest approach is to restart the computation with the bound variable initialized to this new best cost. A less naive approach is to continue the search for better solutions without restarting. In this case, the cost function upper bound is
constrained to the bound variable value. Each time a solution with a new best cost is found, this cost is dynamically imposed through this constraint. The constraint propagation triggered by this constraint leads to a pruning of the search tree by identifying the nodes under which no solution with a smaller cost can be present.
All look back schemes share the disadvantage of late detection of the con-ict. As a matter of fact, they solve the inconsistency when it occurs but do not prevent the inconsistency to occur. Therefore, look ahead schemes were proposed to prevent future con icts.
Forward Checking (FC) is the easiest example of look ahead strategy. It performs arc-consistency between pairs of not yet instantiated variable and instantiated variable, i.e. when a value is assigned to the current variable, any value in the domain of the "future" variable which con icts with this as-signment is (temporally) removed from the domain. Therefore, FC maintains the invariance that for every unlabeled variable there exists at least one value in its domain that is compatible with the values of instantiated/labeled vari-ables. FC does more work than BT when each assignment is added to the current partial solution. Nevertheless, it is almost always a better choice than chronological backtracking.
Even more future inconsistencies are removed by the Partial Look Ahead (PLA) method. While FC performs only the checks of constraints between the current variable and the future variables, the PLA extends this consistency checking even to variables which does not have direct connection with labeled variables.
The approach that uses full arc-consistency after each labeling step is called (Full) Look Ahead (LA) or Maintaining Arc Consistency (MAC). It can use arbitrary arc-consistency algorithms to achieve arc-consistency. However, it should be noted that LA does even more work than FC and PLA when each assignment is added to the current partial solution. Actually, in some cases LA may be more expensive than BT and, therefore, FC and BT are still used in applications.
Stochastic and Heuristic Algorithms
As mentioned, one of the main contributions of CP is to allow the end user to control the search, so problem-specific and generic techniques can be combined to obtained more e cient algorithms. Thus, depending on the problem to be
solved, it is possible to apply specific CP techniques. However, it is important to notice that, although a search improved by these techniques can be useful to find a faster solution for a problem, it can significantly slow the solution of a different problem.
An important technique is to select the order of labeling for the variables and the order in which the values in the domains of these variables are selected.
This point represents one of the most important differences with Linear Pro-gramming (LP): when using LP, once the problem is modeled, the rest of the work is done by the solver. In the CP methodology, the order of variable label-ing and value selection is essential to drive the search. It could be unnecessary to find the optimal values for a set of variables if they do not affect the cost function variables. In this case, they can be labeled only once or leave them represented by their bounded feasible domains. Some of these techniques come usually implemented in CP platforms such as ECLiPSe [9].
Generic techniques for local search such as Genetic Algorithms, Simulated Annealing (SA), or Tabu Search (TS) can also be used to aid CP to find quasi-optimal solutions when it is not feasible to generate the whole search tree (due to memory or CPU time problems). Some examples have been introduced in section 2.1.2. These methods are used when the size of the problem is huge and it is not possible to find the optimal solution. Then, CP is used to find fast poor solutions which will be used as initial values for these techniques. A good solution is sought from these input values. If the best solution found by these techniques is not good enough then new initial values are generated by CP. To avoid the same values than in previous searches, either new constraints are added or some of the existing constraints are removed.
For further descriptions on CP modeling techniques, algorithms, tools, and applications, the reader is referred to [154].