![]() | ||
In constraint satisfaction, backmarking is a variant of the backtracking algorithm.
Backmarking works like backtracking by iteratively evaluating variables in a given order, for example,
- for each variable
and valuex i a , the algorithm records information about the last time has been set tox i a ; in particular, it stores the minimal indexj < i such that the assignment tox 1 , … , x j , was then inconsistent;x i - for each variable
, the algorithm stores some information relative to what changed since the last time it has evaluatedx i ; in particular, it stores the minimal indexx i k < i of a variable that was changed since then.
The first information is collected and stored every time the algorithm evaluates a variable
The second information is changed every time another variable is evaluated. In particular, the index of the "maximal unchanged variable since the last evaluation of
The data collected this way is used to avoid some consistency checks. In particular, whenever backtracking would set
- if
j < k , the evaluation ofx 1 , … , x j , is still inconsistent as it was before, as none of these variables changed so far; as a result, no further consistency check is necessary;x i - if
j ≥ k , the evaluationx 1 , … , x k , is still consistent as it was before; this allows for skipping some consistency checks, but the assignmentx i x 1 , … , may still be inconsistent.x i
Contrary to other variants to backtracking, backmarking does not reduce the search space but only possibly reduce the number of constraints that are satisfied by a partial solution.

