SlideShare a Scribd company logo
1 of 60
Download to read offline
Constraint Satisfaction Problems
Dr. Hnin Lai Nyo
Faculty of Computer Science
1
Content
 Constraint Satisfaction Problems
 Backtracking Search for CSP
2
Constraint Satisfaction Problems
 Standard search problem
 State is a "black box“ – any data structure that supports successor function, heuristic
function, and goal test.
 Constraint Satisfaction Problem
 State is defined by variables Xi with values from domain Di.
 Goal test is a set of constraints specifying allowable combinations of values for subsets
of variables.
 A CSP is defined by
 a set of variables
 a domain of values for each variable
 a set of constraints between variables.
 A solution is an assignment of a value to each variable that satisfies the constraints.
3
Constraint Satisfaction Problems
4
 Variables : WA, NT, Q, NSW, V, SA, T
 Domains : Di = {red,green,blue}
 Constraints : adjacent regions must have different colors
e.g., WA ≠ NT
Example: Map Coloring
Constraint Satisfaction Problems
5
Example: Map Coloring
 Solutions are complete and consistent
assignments.
e.g., WA = red, NT = green, Q = red,
NSW = green, V = red, SA = blue, T = green
 A state may be incomplete.
e.g., just WA=red
Constraint Satisfaction Problems
6
 Binary CSP : each constraint relates two variables
 Constraint graph : nodes are variables, arcs are
constraints.
Constraint Satisfaction Problems
7
Varieties of CSPs
Discrete variables
 Finite Domains :
 n variables, domain size d  O(dn) complete assignments
 e.g., Boolean CSPs, incl. Boolean satisfiability (NP-complete)
 Infinite Domains :
 integers, strings, etc.
 e.g., job scheduling, variables are start/end days for each job
 need a constraint language, e.g., StartJob1 + 5 ≤ StartJob3
Continuous variables
 e.g., start/end times for Hubble Space Telescope observations
 linear constraints solvable in polynomial time by linear programming
Constraint Satisfaction Problems
8
Varieties of constraints
 Unary constraints involve a single variable,
e.g., SA ≠ green
 Binary constraints involve pairs of variables,
e.g., SA ≠ WA
 Higher-order constraints involve 3 or more variables,
e.g., cryptarithmetic column constraints
Backtracking Search For CSPs
9
Standard Search Formulation
 Initial state : none of the variables has a value.
 Successor State : one of the variables without a value will get some value.
 Goal : all variables have a value and none of the constraints is violated.
Backtracking Search For CSPs
10
Backtracking Search
 Every solution appears at depth n with n variables  use depth-first search.
 Depth-first search for CSPs with single-variable assignments is called backtracking search.
 Backtracking search is the basic uninformed algorithm for CSPs.
 It can solve n-queens for n ≈ 25.
Backtracking (Depth-First ) Search
 Special property of CSPs (commutative): the order in which we assign variables does not
matter. (NT=green, WA=blue) = (WA=blue, NT=green)
 Better search tree: First order variables, then assign them values one by one.
Backtracking Search For CSPs
11
A simple Backtracking Algorithm for Constraint Satisfaction Problems.
function BACKTRACKING-SEARCH (csp) returns a solution, or failure
return RECURSIVE-BACKTRACKING ({}, csp)
function RECURSIVE-BACKTRACKING (assignment, csp) return a solution or failure
if assignment is complete then return assignment
var  SELECT-UNASSIGNED-VARIABLE(VARIABLES[csp], assignment, csp)
for each value in ORDER-DOMAIN-VALUES (var, assignment, csp) do
if value is consistent with assignment according to CONSTRAINTS[csp] then
add {var = value} to assignment
result  RECURSIVE-BACKTRACING (assignment, csp)
if result failure then return result
remove {var = value} from assignment
return failure
Backtracking Search For CSPs
12
Backtracking Example
Backtracking Search For CSPs
13
Depth First Search (DFS)
 Given the following state space (tree search), give the sequence of visited nodes when using DFS (assume that the
node 0 is the goal state).
A
B C D E
F G H I J
K L M N
O
Backtracking Search For CSPs
14
Depth First Search (DFS)
 A,
A
B C D E
 A,B,
A
B C D E
F G
Backtracking Search For CSPs
15
Depth First Search (DFS)
 A, B, F,
A
B C D E
F G
 A, B, F,
 G,
A
B C D E
F G
K L
Backtracking Search For CSPs
16
Depth First Search (DFS)
 A, B, F
 G, K,
A
B C D E
F G
K L
 A, B, F
 G, K,
 L, O: Goal State
A
B C D E
F G
K L
O
Backtracking Search For CSPs
17
Depth First Search (DFS)
 The returned solution is the sequence of operators in the path:
A, B, G, L, O : assignments when using CSP.
A
B C D E
F G
K L
O
Backtracking Search For CSPs
18
Example 1 of a CSP
A
B
C
D
E
F
G
H
{red, green, blue}
{red, green, blue}
{red, green, blue}
{red, green, blue}
{red, green, blue}
{red, green, blue}
{red, green, blue}
{red, green, blue}
1 = red
2 = blue
3 = green
Backtracking Search For CSPs
19
Example 1 of a CSP
A B
C
D
E
F
G
H
1 = red
2 = blue
3 = green
A B
C
D
E
F
G
H
A B
C
D
E
F
G
H
Backtracking Search For CSPs
20
Example 1 of a CSP
A
B
C
D
E
F
G
H
1 = red
2 = blue
3 = green
A
B
C
D
E
F
G
H
Backtracking Search For CSPs
21
Example 1 of a CSP
1 = red
2 = blue
3 = green
A
B
C
D
E
F
G
H
A
B
C
D
E
F
G
H
Solution!
Backtracking Search For CSPs
22
Example 2 of a CSP
1 = red
2 = blue
3 = green
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
Backtracking Search For CSPs
23
Example 2 of a CSP
1 = red
2 = blue
3 = green
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
Backtracking Search For CSPs
24
Example 2 of a CSP
1 = red
2 = blue
3 = green
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
Dead End  Backtrack
Backtracking Search For CSPs
25
Example 2 of a CSP
1 = red
2 = blue
3 = green
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
Backtracking Search For CSPs
26
Example 2 of a CSP
1 = red
2 = blue
3 = green
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
Solution!
Backtracking Search For CSPs
27
Imporving Backtracing Efficiency
 General-purpose methods can give huge gains in speed:
 Which variable should be assigned next?
 In what order should its values be tried?
 Can we detect inevitable failure early?
Minimum Remaining Values (MRV)
 Most constrained variable
 Choose the variable with the fewest legal values.
 Called minimum remaining values (MRV) heuristic
 Picks a variable which will cause failure as soon as possible, allowing the tree to be pruned.
Backtracking Search For CSPs
28
Backpropagation-MRV (Mininum Remaining Value)
 Choose the variable with the fewest legal values.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
Backtracking Search For CSPs
29
Backpropagation-MRV (Mininum Remaining Value)
 Choose the variable with the fewest legal values.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
Backtracking Search For CSPs
30
Backpropagation-MRV (Mininum Remaining Value)
 Choose the variable with the fewest legal values.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
Solution!
Backtracking Search For CSPs
31
Most Constraining Variable (MCV)
 Tie-breaker among most constrained variables.
 Most constraining variable:
 Choose the variable with the most constraints on remaining variables (most edges in graph).
Backtracking Search For CSPs
32
Backpropagation-MCV (Most Constrainted Variable)
 Choose the variable with the most constraints on remaining variables.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs {R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
Backtracking Search For CSPs
33
Backpropagation-MCV (Most Constrainted Variable)
 Choose the variable with the most constraints on remaining variables.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
Backtracking Search For CSPs
34
Backpropagation-MCV (Most Constrainted Variable)
 Choose the variable with the most constraints on remaining variables.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
Dead End
Backtracking Search For CSPs
35
Backpropagation-MCV (Most Constrainted Variable)
 Choose the variable with the most constraints on remaining variables.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
Backtracking Search For CSPs
36
Backpropagation-MCV (Most Constrainted Variable)
 Choose the variable with the most constraints on remaining variables.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
Dead End
Backtracking Search For CSPs
37
Backpropagation-MCV (Most Constrainted Variable)
 Choose the variable with the most constraints on remaining variables.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
Backtracking Search For CSPs
38
Backpropagation-MCV (Most Constrainted Variable)
 Choose the variable with the most constraints on remaining variables.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
Solution!
Backtracking Search For CSPs
39
Least Constraining Value (LCV)
 Given a variable, choose the least constraining value:
 The one that rules out (eliminate) the values
 Combining these heuristics makes 1000 queens feasible.
Backtracking Search For CSPs
40
Backpropagation LCV
 Choose the value which eliminates the fewest number of values in the remaining variables.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
Backtracking Search For CSPs
41
Backpropagation LCV
 Choose the value which eliminates the fewest number of values in the remaining variables.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
Backtracking Search For CSPs
42
Backpropagation LCV
 Choose the value which eliminates the fewest number of values in the remaining variables.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
Dead End
Backtracking Search For CSPs
43
Backpropagation LCV
 Choose the value which eliminates the fewest number of values in the remaining variables.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
Backtracking Search For CSPs
44
Backpropagation LCV
 Choose the value which eliminates the fewest number of values in the remaining variables.
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
2 arcs
4 arcs
3 arcs
3 arcs
2 arcs
Solution!
Backtracking Search For CSPs
45
Forward Checking
 Assigns variable X, say
 Looks at each unassigned variable, Y say, connected to X and delete from Y’s domain any value
inconsistent with X’s assignment.
 Eliminates branching on certain variables by propagating information.
 If forward checking detects a dead end, algorithm will backtrack immediately.
 Idea :
 Keep track of remaining legal values for unassigned variables.
 Terminate search when any variable has no legal values.
Backtracking Search For CSPs
46
Forward Checking
Backtracking Search For CSPs
47
Forward Checking
Dead End
Backtracking Search For CSPs
48
Forward Checking : Example – 4-Queens Problem
X1
{1,2,3,4}
X3
{1,2,3,4}
X2
{1,2,3,4}
X4
{1,2,3,4}
X1
{1,2,3,4}
X3
{1,2,3,4}
X2
{1,2,3,4}
X4
{1,2,3,4}
Backtracking Search For CSPs
49
Forward Checking : Example – 4-Queens Problem
X1
{1,2,3,4}
X3
{ ,2, ,4}
X2
{ , ,3,4}
X4
{ ,2,3, }
X1
{1,2,3,4}
X3
{ ,2, ,4}
X2
{ , ,3,4}
X4
{ ,2,3, }
Backtracking Search For CSPs
50
Forward Checking : Example – 4-Queens Problem
X1
{1,2,3,4}
X3
{ , , , }
X2
{ , ,3,4}
X4
{ ,2, , }
X1
{1,2,3,4}
X3
{ ,2, , }
X2
{ , , ,4 }
X4
{ , ,3, }
Dead End  Backtrack
Backtracking Search For CSPs
51
Forward Checking : Example – 4-Queens Problem
X1
{1,2,3,4}
X3
{ , 2 , , }
X2
{ , , ,4 }
X4
{ , , , }
X1
{ , 2, 3, 4}
X3
{1, 2, 3, 4}
X2
{ 1,2 ,3 ,4 }
X4
{ 1, 2, 3, 4}
Backtracking Search For CSPs
52
Forward Checking : Example – 4-Queens Problem
X1
{ , 2, 3, 4}
X3
{1, , 3, }
X2
{ , , ,4 }
X4
{ 1, , 3, 4}
X1
{ , 2, 3, 4}
X3
{1, , 3, }
X2
{ , , ,4 }
X4
{ 1, , 3, 4}
Backtracking Search For CSPs
53
Forward Checking : Example – 4-Queens Problem
X1
{ , 2, 3, 4}
X3
{1, , , }
X2
{ , , ,4 }
X4
{ 1, , 3, }
X1
{ , 2, 3, 4}
X3
{1, , , }
X2
{ , , ,4 }
X4
{ 1, , 3, }
Backtracking Search For CSPs
54
Forward Checking : Example – 4-Queens Problem
X1
{ , 2, 3, 4}
X3
{1, , , }
X2
{ , , ,4 }
X4
{ , , 3, }
X1
{ , 2, 3, 4}
X3
{1, , , }
X2
{ , , ,4 }
X4
{ , , 3, }
Solution!
Backtracking Search For CSPs
55
Forward Checking : Example
{R,B,G}
{R,B,G}
{R,B,G} {R,B,G}
{R}
{R,B,G}
{ ,B,G}
{ ,B,G} {R,B,G}
{R}
Backtracking Search For CSPs
56
Forward Checking : Example
{R,B,G}
{ ,B,G}
{ ,B,G} {R,B,G}
{R}
{R, ,G}
{ ,B,G}
{ , ,G} {R, ,G}
{R}
Backtracking Search For CSPs
57
Forward Checking : Example
{R, ,G}
{ ,B,G}
{ , ,G} {R, ,G}
{R}
{R, ,G}
{ ,B,G}
{ , ,G} { , ,G}
{R}
Backtracking Search For CSPs
58
Forward Checking : Example
{R, ,G}
{ ,B,G}
{ , ,G} { , ,G}
{R}
{R, ,G}
{ ,B,G}
{ , , } { , ,G}
{R}
Backtracking Search For CSPs
59
Forward Checking : Example
{R, ,G}
{ ,B,G}
{ , , } { , ,G}
{R}
Dead End
{R, ,G}
{ ,B,G}
{ , , G} {R, ,G}
{R}
Backtracking Search For CSPs
60
Forward Checking : Example
{R, ,G}
{ ,B,G}
{ , , G} {R, , }
{R}
{R, ,G}
{ ,B,G}
{ , ,G } {R, , }
{R}
{R, ,G}
{ ,B,G}
{ , ,G } {R, , }
{R}
Solution!!

More Related Content

Similar to Ch5_Constraint Satisfaction Problems_Lecture 1.pdf

Kernel for Chordal Vertex Deletion
Kernel for Chordal Vertex DeletionKernel for Chordal Vertex Deletion
Kernel for Chordal Vertex DeletionAkankshaAgrawal55
 
Second Order Heuristics in ACGP
Second Order Heuristics in ACGPSecond Order Heuristics in ACGP
Second Order Heuristics in ACGPhauschildm
 
A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...
A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...
A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...Federico Cerutti
 
First Place Memocode'14 Design Contest Entry
First Place Memocode'14 Design Contest EntryFirst Place Memocode'14 Design Contest Entry
First Place Memocode'14 Design Contest EntryKevin Townsend
 
Sensors and Samples: A Homological Approach
Sensors and Samples:  A Homological ApproachSensors and Samples:  A Homological Approach
Sensors and Samples: A Homological ApproachDon Sheehy
 
Frequency Based Analysis of Voting Rules
Frequency Based Analysis of Voting RulesFrequency Based Analysis of Voting Rules
Frequency Based Analysis of Voting Rulesswarnendu chatterjee
 
Baibao siopt-2017
Baibao siopt-2017Baibao siopt-2017
Baibao siopt-2017Cam huynh
 
Bioinformatics t5-databasesearching v2014
Bioinformatics t5-databasesearching v2014Bioinformatics t5-databasesearching v2014
Bioinformatics t5-databasesearching v2014Prof. Wim Van Criekinge
 
Ai lecture 11(unit02)
Ai lecture  11(unit02)Ai lecture  11(unit02)
Ai lecture 11(unit02)vikas dhakane
 
FinalPresentation_200630888 (1)
FinalPresentation_200630888 (1)FinalPresentation_200630888 (1)
FinalPresentation_200630888 (1)woods6795
 
Nondeterministic Finite Automata AFN.pdf
Nondeterministic Finite Automata AFN.pdfNondeterministic Finite Automata AFN.pdf
Nondeterministic Finite Automata AFN.pdfSergioUlisesRojasAla
 
Cost versus distance_in_the_traveling_sa_79149
Cost versus distance_in_the_traveling_sa_79149Cost versus distance_in_the_traveling_sa_79149
Cost versus distance_in_the_traveling_sa_79149olimpica
 
Delayed acceptance for Metropolis-Hastings algorithms
Delayed acceptance for Metropolis-Hastings algorithmsDelayed acceptance for Metropolis-Hastings algorithms
Delayed acceptance for Metropolis-Hastings algorithmsChristian Robert
 
Finding Top-k Similar Graphs in Graph Database @ ReadingCircle
Finding Top-k Similar Graphs in Graph Database @ ReadingCircleFinding Top-k Similar Graphs in Graph Database @ ReadingCircle
Finding Top-k Similar Graphs in Graph Database @ ReadingCirclecharlingual
 
Electromagnetic theory EMT lecture 1
Electromagnetic theory EMT lecture 1Electromagnetic theory EMT lecture 1
Electromagnetic theory EMT lecture 1Ali Farooq
 

Similar to Ch5_Constraint Satisfaction Problems_Lecture 1.pdf (20)

Kernel for Chordal Vertex Deletion
Kernel for Chordal Vertex DeletionKernel for Chordal Vertex Deletion
Kernel for Chordal Vertex Deletion
 
Second Order Heuristics in ACGP
Second Order Heuristics in ACGPSecond Order Heuristics in ACGP
Second Order Heuristics in ACGP
 
A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...
A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...
A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...
 
First Place Memocode'14 Design Contest Entry
First Place Memocode'14 Design Contest EntryFirst Place Memocode'14 Design Contest Entry
First Place Memocode'14 Design Contest Entry
 
Data analysis of weather forecasting
Data analysis of weather forecastingData analysis of weather forecasting
Data analysis of weather forecasting
 
Dp
DpDp
Dp
 
Sensors and Samples: A Homological Approach
Sensors and Samples:  A Homological ApproachSensors and Samples:  A Homological Approach
Sensors and Samples: A Homological Approach
 
Frequency Based Analysis of Voting Rules
Frequency Based Analysis of Voting RulesFrequency Based Analysis of Voting Rules
Frequency Based Analysis of Voting Rules
 
constraintSat.ppt
constraintSat.pptconstraintSat.ppt
constraintSat.ppt
 
Baibao siopt-2017
Baibao siopt-2017Baibao siopt-2017
Baibao siopt-2017
 
Determinants
DeterminantsDeterminants
Determinants
 
AIw10_Backtracking.pptx
AIw10_Backtracking.pptxAIw10_Backtracking.pptx
AIw10_Backtracking.pptx
 
Bioinformatics t5-databasesearching v2014
Bioinformatics t5-databasesearching v2014Bioinformatics t5-databasesearching v2014
Bioinformatics t5-databasesearching v2014
 
Ai lecture 11(unit02)
Ai lecture  11(unit02)Ai lecture  11(unit02)
Ai lecture 11(unit02)
 
FinalPresentation_200630888 (1)
FinalPresentation_200630888 (1)FinalPresentation_200630888 (1)
FinalPresentation_200630888 (1)
 
Nondeterministic Finite Automata AFN.pdf
Nondeterministic Finite Automata AFN.pdfNondeterministic Finite Automata AFN.pdf
Nondeterministic Finite Automata AFN.pdf
 
Cost versus distance_in_the_traveling_sa_79149
Cost versus distance_in_the_traveling_sa_79149Cost versus distance_in_the_traveling_sa_79149
Cost versus distance_in_the_traveling_sa_79149
 
Delayed acceptance for Metropolis-Hastings algorithms
Delayed acceptance for Metropolis-Hastings algorithmsDelayed acceptance for Metropolis-Hastings algorithms
Delayed acceptance for Metropolis-Hastings algorithms
 
Finding Top-k Similar Graphs in Graph Database @ ReadingCircle
Finding Top-k Similar Graphs in Graph Database @ ReadingCircleFinding Top-k Similar Graphs in Graph Database @ ReadingCircle
Finding Top-k Similar Graphs in Graph Database @ ReadingCircle
 
Electromagnetic theory EMT lecture 1
Electromagnetic theory EMT lecture 1Electromagnetic theory EMT lecture 1
Electromagnetic theory EMT lecture 1
 

Recently uploaded

Audience Researchndfhcvnfgvgbhujhgfv.pptx
Audience Researchndfhcvnfgvgbhujhgfv.pptxAudience Researchndfhcvnfgvgbhujhgfv.pptx
Audience Researchndfhcvnfgvgbhujhgfv.pptxStephen266013
 
Displacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second DerivativesDisplacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second Derivatives23050636
 
Seven tools of quality control.slideshare
Seven tools of quality control.slideshareSeven tools of quality control.slideshare
Seven tools of quality control.slideshareraiaryan448
 
How to Transform Clinical Trial Management with Advanced Data Analytics
How to Transform Clinical Trial Management with Advanced Data AnalyticsHow to Transform Clinical Trial Management with Advanced Data Analytics
How to Transform Clinical Trial Management with Advanced Data AnalyticsBrainSell Technologies
 
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证acoha1
 
原件一样伦敦国王学院毕业证成绩单留信学历认证
原件一样伦敦国王学院毕业证成绩单留信学历认证原件一样伦敦国王学院毕业证成绩单留信学历认证
原件一样伦敦国王学院毕业证成绩单留信学历认证pwgnohujw
 
如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证
如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证
如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证a8om7o51
 
如何办理英国卡迪夫大学毕业证(Cardiff毕业证书)成绩单留信学历认证
如何办理英国卡迪夫大学毕业证(Cardiff毕业证书)成绩单留信学历认证如何办理英国卡迪夫大学毕业证(Cardiff毕业证书)成绩单留信学历认证
如何办理英国卡迪夫大学毕业证(Cardiff毕业证书)成绩单留信学历认证ju0dztxtn
 
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证pwgnohujw
 
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...ThinkInnovation
 
如何办理哥伦比亚大学毕业证(Columbia毕业证)成绩单原版一比一
如何办理哥伦比亚大学毕业证(Columbia毕业证)成绩单原版一比一如何办理哥伦比亚大学毕业证(Columbia毕业证)成绩单原版一比一
如何办理哥伦比亚大学毕业证(Columbia毕业证)成绩单原版一比一fztigerwe
 
NOAM AAUG Adobe Summit 2024: Summit Slam Dunks
NOAM AAUG Adobe Summit 2024: Summit Slam DunksNOAM AAUG Adobe Summit 2024: Summit Slam Dunks
NOAM AAUG Adobe Summit 2024: Summit Slam Dunksgmuir1066
 
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证dq9vz1isj
 
社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token PredictionNABLAS株式会社
 
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证ppy8zfkfm
 
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证zifhagzkk
 
The Significance of Transliteration Enhancing
The Significance of Transliteration EnhancingThe Significance of Transliteration Enhancing
The Significance of Transliteration Enhancingmohamed Elzalabany
 
Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024patrickdtherriault
 
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarjSCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarjadimosmejiaslendon
 

Recently uploaded (20)

Audience Researchndfhcvnfgvgbhujhgfv.pptx
Audience Researchndfhcvnfgvgbhujhgfv.pptxAudience Researchndfhcvnfgvgbhujhgfv.pptx
Audience Researchndfhcvnfgvgbhujhgfv.pptx
 
Displacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second DerivativesDisplacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second Derivatives
 
Seven tools of quality control.slideshare
Seven tools of quality control.slideshareSeven tools of quality control.slideshare
Seven tools of quality control.slideshare
 
How to Transform Clinical Trial Management with Advanced Data Analytics
How to Transform Clinical Trial Management with Advanced Data AnalyticsHow to Transform Clinical Trial Management with Advanced Data Analytics
How to Transform Clinical Trial Management with Advanced Data Analytics
 
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
 
原件一样伦敦国王学院毕业证成绩单留信学历认证
原件一样伦敦国王学院毕业证成绩单留信学历认证原件一样伦敦国王学院毕业证成绩单留信学历认证
原件一样伦敦国王学院毕业证成绩单留信学历认证
 
如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证
如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证
如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证
 
如何办理英国卡迪夫大学毕业证(Cardiff毕业证书)成绩单留信学历认证
如何办理英国卡迪夫大学毕业证(Cardiff毕业证书)成绩单留信学历认证如何办理英国卡迪夫大学毕业证(Cardiff毕业证书)成绩单留信学历认证
如何办理英国卡迪夫大学毕业证(Cardiff毕业证书)成绩单留信学历认证
 
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
 
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
 
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotecAbortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
 
如何办理哥伦比亚大学毕业证(Columbia毕业证)成绩单原版一比一
如何办理哥伦比亚大学毕业证(Columbia毕业证)成绩单原版一比一如何办理哥伦比亚大学毕业证(Columbia毕业证)成绩单原版一比一
如何办理哥伦比亚大学毕业证(Columbia毕业证)成绩单原版一比一
 
NOAM AAUG Adobe Summit 2024: Summit Slam Dunks
NOAM AAUG Adobe Summit 2024: Summit Slam DunksNOAM AAUG Adobe Summit 2024: Summit Slam Dunks
NOAM AAUG Adobe Summit 2024: Summit Slam Dunks
 
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
 
社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction
 
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
 
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
 
The Significance of Transliteration Enhancing
The Significance of Transliteration EnhancingThe Significance of Transliteration Enhancing
The Significance of Transliteration Enhancing
 
Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024
 
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarjSCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
 

Ch5_Constraint Satisfaction Problems_Lecture 1.pdf

  • 1. Constraint Satisfaction Problems Dr. Hnin Lai Nyo Faculty of Computer Science 1
  • 2. Content  Constraint Satisfaction Problems  Backtracking Search for CSP 2
  • 3. Constraint Satisfaction Problems  Standard search problem  State is a "black box“ – any data structure that supports successor function, heuristic function, and goal test.  Constraint Satisfaction Problem  State is defined by variables Xi with values from domain Di.  Goal test is a set of constraints specifying allowable combinations of values for subsets of variables.  A CSP is defined by  a set of variables  a domain of values for each variable  a set of constraints between variables.  A solution is an assignment of a value to each variable that satisfies the constraints. 3
  • 4. Constraint Satisfaction Problems 4  Variables : WA, NT, Q, NSW, V, SA, T  Domains : Di = {red,green,blue}  Constraints : adjacent regions must have different colors e.g., WA ≠ NT Example: Map Coloring
  • 5. Constraint Satisfaction Problems 5 Example: Map Coloring  Solutions are complete and consistent assignments. e.g., WA = red, NT = green, Q = red, NSW = green, V = red, SA = blue, T = green  A state may be incomplete. e.g., just WA=red
  • 6. Constraint Satisfaction Problems 6  Binary CSP : each constraint relates two variables  Constraint graph : nodes are variables, arcs are constraints.
  • 7. Constraint Satisfaction Problems 7 Varieties of CSPs Discrete variables  Finite Domains :  n variables, domain size d  O(dn) complete assignments  e.g., Boolean CSPs, incl. Boolean satisfiability (NP-complete)  Infinite Domains :  integers, strings, etc.  e.g., job scheduling, variables are start/end days for each job  need a constraint language, e.g., StartJob1 + 5 ≤ StartJob3 Continuous variables  e.g., start/end times for Hubble Space Telescope observations  linear constraints solvable in polynomial time by linear programming
  • 8. Constraint Satisfaction Problems 8 Varieties of constraints  Unary constraints involve a single variable, e.g., SA ≠ green  Binary constraints involve pairs of variables, e.g., SA ≠ WA  Higher-order constraints involve 3 or more variables, e.g., cryptarithmetic column constraints
  • 9. Backtracking Search For CSPs 9 Standard Search Formulation  Initial state : none of the variables has a value.  Successor State : one of the variables without a value will get some value.  Goal : all variables have a value and none of the constraints is violated.
  • 10. Backtracking Search For CSPs 10 Backtracking Search  Every solution appears at depth n with n variables  use depth-first search.  Depth-first search for CSPs with single-variable assignments is called backtracking search.  Backtracking search is the basic uninformed algorithm for CSPs.  It can solve n-queens for n ≈ 25. Backtracking (Depth-First ) Search  Special property of CSPs (commutative): the order in which we assign variables does not matter. (NT=green, WA=blue) = (WA=blue, NT=green)  Better search tree: First order variables, then assign them values one by one.
  • 11. Backtracking Search For CSPs 11 A simple Backtracking Algorithm for Constraint Satisfaction Problems. function BACKTRACKING-SEARCH (csp) returns a solution, or failure return RECURSIVE-BACKTRACKING ({}, csp) function RECURSIVE-BACKTRACKING (assignment, csp) return a solution or failure if assignment is complete then return assignment var  SELECT-UNASSIGNED-VARIABLE(VARIABLES[csp], assignment, csp) for each value in ORDER-DOMAIN-VALUES (var, assignment, csp) do if value is consistent with assignment according to CONSTRAINTS[csp] then add {var = value} to assignment result  RECURSIVE-BACKTRACING (assignment, csp) if result failure then return result remove {var = value} from assignment return failure
  • 12. Backtracking Search For CSPs 12 Backtracking Example
  • 13. Backtracking Search For CSPs 13 Depth First Search (DFS)  Given the following state space (tree search), give the sequence of visited nodes when using DFS (assume that the node 0 is the goal state). A B C D E F G H I J K L M N O
  • 14. Backtracking Search For CSPs 14 Depth First Search (DFS)  A, A B C D E  A,B, A B C D E F G
  • 15. Backtracking Search For CSPs 15 Depth First Search (DFS)  A, B, F, A B C D E F G  A, B, F,  G, A B C D E F G K L
  • 16. Backtracking Search For CSPs 16 Depth First Search (DFS)  A, B, F  G, K, A B C D E F G K L  A, B, F  G, K,  L, O: Goal State A B C D E F G K L O
  • 17. Backtracking Search For CSPs 17 Depth First Search (DFS)  The returned solution is the sequence of operators in the path: A, B, G, L, O : assignments when using CSP. A B C D E F G K L O
  • 18. Backtracking Search For CSPs 18 Example 1 of a CSP A B C D E F G H {red, green, blue} {red, green, blue} {red, green, blue} {red, green, blue} {red, green, blue} {red, green, blue} {red, green, blue} {red, green, blue} 1 = red 2 = blue 3 = green
  • 19. Backtracking Search For CSPs 19 Example 1 of a CSP A B C D E F G H 1 = red 2 = blue 3 = green A B C D E F G H A B C D E F G H
  • 20. Backtracking Search For CSPs 20 Example 1 of a CSP A B C D E F G H 1 = red 2 = blue 3 = green A B C D E F G H
  • 21. Backtracking Search For CSPs 21 Example 1 of a CSP 1 = red 2 = blue 3 = green A B C D E F G H A B C D E F G H Solution!
  • 22. Backtracking Search For CSPs 22 Example 2 of a CSP 1 = red 2 = blue 3 = green {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R}
  • 23. Backtracking Search For CSPs 23 Example 2 of a CSP 1 = red 2 = blue 3 = green {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R}
  • 24. Backtracking Search For CSPs 24 Example 2 of a CSP 1 = red 2 = blue 3 = green {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} Dead End  Backtrack
  • 25. Backtracking Search For CSPs 25 Example 2 of a CSP 1 = red 2 = blue 3 = green {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R}
  • 26. Backtracking Search For CSPs 26 Example 2 of a CSP 1 = red 2 = blue 3 = green {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} Solution!
  • 27. Backtracking Search For CSPs 27 Imporving Backtracing Efficiency  General-purpose methods can give huge gains in speed:  Which variable should be assigned next?  In what order should its values be tried?  Can we detect inevitable failure early? Minimum Remaining Values (MRV)  Most constrained variable  Choose the variable with the fewest legal values.  Called minimum remaining values (MRV) heuristic  Picks a variable which will cause failure as soon as possible, allowing the tree to be pruned.
  • 28. Backtracking Search For CSPs 28 Backpropagation-MRV (Mininum Remaining Value)  Choose the variable with the fewest legal values. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R}
  • 29. Backtracking Search For CSPs 29 Backpropagation-MRV (Mininum Remaining Value)  Choose the variable with the fewest legal values. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R}
  • 30. Backtracking Search For CSPs 30 Backpropagation-MRV (Mininum Remaining Value)  Choose the variable with the fewest legal values. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} Solution!
  • 31. Backtracking Search For CSPs 31 Most Constraining Variable (MCV)  Tie-breaker among most constrained variables.  Most constraining variable:  Choose the variable with the most constraints on remaining variables (most edges in graph).
  • 32. Backtracking Search For CSPs 32 Backpropagation-MCV (Most Constrainted Variable)  Choose the variable with the most constraints on remaining variables. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs
  • 33. Backtracking Search For CSPs 33 Backpropagation-MCV (Most Constrainted Variable)  Choose the variable with the most constraints on remaining variables. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs
  • 34. Backtracking Search For CSPs 34 Backpropagation-MCV (Most Constrainted Variable)  Choose the variable with the most constraints on remaining variables. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs Dead End
  • 35. Backtracking Search For CSPs 35 Backpropagation-MCV (Most Constrainted Variable)  Choose the variable with the most constraints on remaining variables. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs
  • 36. Backtracking Search For CSPs 36 Backpropagation-MCV (Most Constrainted Variable)  Choose the variable with the most constraints on remaining variables. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs Dead End
  • 37. Backtracking Search For CSPs 37 Backpropagation-MCV (Most Constrainted Variable)  Choose the variable with the most constraints on remaining variables. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs
  • 38. Backtracking Search For CSPs 38 Backpropagation-MCV (Most Constrainted Variable)  Choose the variable with the most constraints on remaining variables. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs Solution!
  • 39. Backtracking Search For CSPs 39 Least Constraining Value (LCV)  Given a variable, choose the least constraining value:  The one that rules out (eliminate) the values  Combining these heuristics makes 1000 queens feasible.
  • 40. Backtracking Search For CSPs 40 Backpropagation LCV  Choose the value which eliminates the fewest number of values in the remaining variables. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs
  • 41. Backtracking Search For CSPs 41 Backpropagation LCV  Choose the value which eliminates the fewest number of values in the remaining variables. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs
  • 42. Backtracking Search For CSPs 42 Backpropagation LCV  Choose the value which eliminates the fewest number of values in the remaining variables. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs Dead End
  • 43. Backtracking Search For CSPs 43 Backpropagation LCV  Choose the value which eliminates the fewest number of values in the remaining variables. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs
  • 44. Backtracking Search For CSPs 44 Backpropagation LCV  Choose the value which eliminates the fewest number of values in the remaining variables. {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} 2 arcs 4 arcs 3 arcs 3 arcs 2 arcs Solution!
  • 45. Backtracking Search For CSPs 45 Forward Checking  Assigns variable X, say  Looks at each unassigned variable, Y say, connected to X and delete from Y’s domain any value inconsistent with X’s assignment.  Eliminates branching on certain variables by propagating information.  If forward checking detects a dead end, algorithm will backtrack immediately.  Idea :  Keep track of remaining legal values for unassigned variables.  Terminate search when any variable has no legal values.
  • 46. Backtracking Search For CSPs 46 Forward Checking
  • 47. Backtracking Search For CSPs 47 Forward Checking Dead End
  • 48. Backtracking Search For CSPs 48 Forward Checking : Example – 4-Queens Problem X1 {1,2,3,4} X3 {1,2,3,4} X2 {1,2,3,4} X4 {1,2,3,4} X1 {1,2,3,4} X3 {1,2,3,4} X2 {1,2,3,4} X4 {1,2,3,4}
  • 49. Backtracking Search For CSPs 49 Forward Checking : Example – 4-Queens Problem X1 {1,2,3,4} X3 { ,2, ,4} X2 { , ,3,4} X4 { ,2,3, } X1 {1,2,3,4} X3 { ,2, ,4} X2 { , ,3,4} X4 { ,2,3, }
  • 50. Backtracking Search For CSPs 50 Forward Checking : Example – 4-Queens Problem X1 {1,2,3,4} X3 { , , , } X2 { , ,3,4} X4 { ,2, , } X1 {1,2,3,4} X3 { ,2, , } X2 { , , ,4 } X4 { , ,3, } Dead End  Backtrack
  • 51. Backtracking Search For CSPs 51 Forward Checking : Example – 4-Queens Problem X1 {1,2,3,4} X3 { , 2 , , } X2 { , , ,4 } X4 { , , , } X1 { , 2, 3, 4} X3 {1, 2, 3, 4} X2 { 1,2 ,3 ,4 } X4 { 1, 2, 3, 4}
  • 52. Backtracking Search For CSPs 52 Forward Checking : Example – 4-Queens Problem X1 { , 2, 3, 4} X3 {1, , 3, } X2 { , , ,4 } X4 { 1, , 3, 4} X1 { , 2, 3, 4} X3 {1, , 3, } X2 { , , ,4 } X4 { 1, , 3, 4}
  • 53. Backtracking Search For CSPs 53 Forward Checking : Example – 4-Queens Problem X1 { , 2, 3, 4} X3 {1, , , } X2 { , , ,4 } X4 { 1, , 3, } X1 { , 2, 3, 4} X3 {1, , , } X2 { , , ,4 } X4 { 1, , 3, }
  • 54. Backtracking Search For CSPs 54 Forward Checking : Example – 4-Queens Problem X1 { , 2, 3, 4} X3 {1, , , } X2 { , , ,4 } X4 { , , 3, } X1 { , 2, 3, 4} X3 {1, , , } X2 { , , ,4 } X4 { , , 3, } Solution!
  • 55. Backtracking Search For CSPs 55 Forward Checking : Example {R,B,G} {R,B,G} {R,B,G} {R,B,G} {R} {R,B,G} { ,B,G} { ,B,G} {R,B,G} {R}
  • 56. Backtracking Search For CSPs 56 Forward Checking : Example {R,B,G} { ,B,G} { ,B,G} {R,B,G} {R} {R, ,G} { ,B,G} { , ,G} {R, ,G} {R}
  • 57. Backtracking Search For CSPs 57 Forward Checking : Example {R, ,G} { ,B,G} { , ,G} {R, ,G} {R} {R, ,G} { ,B,G} { , ,G} { , ,G} {R}
  • 58. Backtracking Search For CSPs 58 Forward Checking : Example {R, ,G} { ,B,G} { , ,G} { , ,G} {R} {R, ,G} { ,B,G} { , , } { , ,G} {R}
  • 59. Backtracking Search For CSPs 59 Forward Checking : Example {R, ,G} { ,B,G} { , , } { , ,G} {R} Dead End {R, ,G} { ,B,G} { , , G} {R, ,G} {R}
  • 60. Backtracking Search For CSPs 60 Forward Checking : Example {R, ,G} { ,B,G} { , , G} {R, , } {R} {R, ,G} { ,B,G} { , ,G } {R, , } {R} {R, ,G} { ,B,G} { , ,G } {R, , } {R} Solution!!