Backmarking
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, [math]\displaystyle{ x_1,\ldots,x_n }[/math]. It improves over backtracking by maintaining information about the last time a variable [math]\displaystyle{ x_i }[/math] was instantiated to a value and information about what changed since then. In particular:
- for each variable [math]\displaystyle{ x_i }[/math] and value [math]\displaystyle{ a }[/math], the algorithm records information about the last time [math]\displaystyle{ x_i }[/math] has been set to [math]\displaystyle{ a }[/math]; in particular, it stores the minimal index [math]\displaystyle{ j\lt i }[/math] such that the assignment to [math]\displaystyle{ x_1,\ldots,x_j,x_i }[/math] was then inconsistent;
- for each variable [math]\displaystyle{ x_i }[/math], the algorithm stores some information relative to what changed since the last time it has evaluated [math]\displaystyle{ x_i }[/math]; in particular, it stores the minimal index [math]\displaystyle{ k\lt i }[/math] of a variable that was changed since then.
The first information is collected and stored every time the algorithm evaluates a variable [math]\displaystyle{ x_i }[/math] to [math]\displaystyle{ a }[/math], and is done by simply checking consistency of the current assignments for [math]\displaystyle{ x_1,x_i }[/math], for [math]\displaystyle{ x_1,x_2,x_i }[/math], for [math]\displaystyle{ x_1,x_2,x_3,x_i }[/math], etc.
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 [math]\displaystyle{ x_i }[/math]" is possibly changed every time another variable [math]\displaystyle{ x_j }[/math] changes value. Every time an arbitrary variable [math]\displaystyle{ x_j }[/math] changes, all variables [math]\displaystyle{ x_i }[/math] with [math]\displaystyle{ i\gt j }[/math] are considered in turn. If [math]\displaystyle{ k }[/math] was their previous associated index, this value is changed to [math]\displaystyle{ min(k,j) }[/math].
The data collected this way is used to avoid some consistency checks. In particular, whenever backtracking would set [math]\displaystyle{ x_i=a }[/math], backmarking compares the two indexes relative to [math]\displaystyle{ x_i }[/math] and the pair [math]\displaystyle{ x_i=a }[/math]. Two conditions allow to determine partial consistency or inconsistency without checking with the constraints. If [math]\displaystyle{ k }[/math] is the minimal index of a variable that changed since the last time [math]\displaystyle{ x_i }[/math] was evaluated and [math]\displaystyle{ j }[/math] is the minimal index such that the evaluation of [math]\displaystyle{ x_1,\ldots,x_j,x_i }[/math] was consistent the last time [math]\displaystyle{ x_i }[/math] has been evaluated to [math]\displaystyle{ a }[/math], then:
- if [math]\displaystyle{ j\lt k }[/math], the evaluation of [math]\displaystyle{ x_1,\ldots,x_j,x_i }[/math] is still inconsistent as it was before, as none of these variables changed so far; as a result, no further consistency check is necessary;
- if [math]\displaystyle{ j \geq k }[/math], the evaluation [math]\displaystyle{ x_1,\ldots,x_k,x_i }[/math] is still consistent as it was before; this allows for skipping some consistency checks, but the assignment [math]\displaystyle{ x_1,\ldots,x_i }[/math] may still be inconsistent.
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.
References
- Dechter, Rina (2003). Constraint Processing. Morgan Kaufmann. ISBN 1-55860-890-7. https://archive.org/details/constraintproces00rina.
Original source: https://en.wikipedia.org/wiki/Backmarking.
Read more |