Finish CSPs




CS156

Chris Pollett

Oct 9, 2017

Outline

Introduction

Sudoku

Formulating Sudoku as a CSP

Effects of consistency checks on Sudoku

Example Sudoku Board

Quiz

Which of the following is true?

  1. In a constraint satisfaction problem states are atomic.
  2. Precedence constraints are used to model in a CSP that something must occur before something else.
  3. The AC-3 algorithm is used to check the consistency of ternary constraints.

Backtracking Search for CSPs

Backtracking-Search

Here is some pseudo-code for backtracking search:

function Backtracking-Search(csp) returns a solution, or failure
    return Backtrack({},csp)

function Backtrack(assignment, csp) returns a solution, failure
   if(assignment is complete) then return assignment
   var := Select-Unassigned-Variable(csp)
   for each value in Order-Domain-Values(var, assignment, csp) do
        if value is consistent with assignment then
            add {var= value} to assignment
            inferences := INFERENCE(csp, var, value) 
                //this might do AC-3 or the like
            if inferences != failure then
                add inferences to assignment
                result := Backtrack(assignment, csp)
                if result != failure then
                    return result
        remove {var = value} and inferences from assignment
   return failure

Making Backtracking Search More Sophisticated

Performance of backtracking can be improved by focusing on:

Variable and Value Ordering

Interleaving search and Inference

Intelligent Backtracking