Backtracking Search with Propagation
Solving a CSP by combining depth-first backtracking with constraint propagation (typically arc consistency) at every node, including variable selection via the fail-first / MRV heuristic and failure detection via domain wipeout.
Tutorial
Backtracking Search with Propagation
Solving a CSP means assigning a value to every variable so that all constraints are satisfied. Backtracking search does this by assigning variables one at a time and recursing, undoing the assignment when a constraint is violated. Plain backtracking is slow because it discovers conflicts only after committing to an assignment that propagation could have ruled out in advance.
Backtracking search with propagation interleaves the two. After every assignment we enforce arc consistency on the remaining domains. If propagation empties any domain, the current branch is a dead end and we backtrack immediately. The classic variant that re-establishes AC after each branch is called MAC (Maintaining Arc Consistency).
The algorithm is:
- Enforce arc consistency on the current domains.
- If some domain is empty, return failure.
- If every variable's domain is a singleton, return the assignment.
- Choose an unfixed variable .
- For each value :
- Save the current domains.
- Set and recurse.
- If the recursion returns a solution, return it.
- Otherwise restore the saved domains and try the next .
- If every value has failed, return failure.
Tiny illustration. Variables with . Initial AC reduces the domains to and . Branch ; propagation leaves . Branch ; both domains are singletons. Solution .