Finish CSPs




CS156

Chris Pollett

Mar 2, 2015

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. The AC3 algorithm from class is a polynomial time algorithm in the size of the variable domains and in the number of constraints.
  2. A solution to a CSP is always unique.
  3. A game tree will always have an alpha-cut.

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