constraint satisfaction problemspinar/courses/bbm405/...4 constraint satisfaction problems (csps)...
TRANSCRIPT
![Page 1: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/1.jpg)
1
Constraint Satisfaction
Problems
Fundamentals of Artificial Intelligence
Slides are mostly adapted from AIMA, MIT Open Courseware
Svetlana Lazebnik (UIUC) and Manuela Veloso (CMU)
![Page 2: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/2.jpg)
2
![Page 3: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/3.jpg)
3
What is search for?
• Assumptions: single agent,
deterministic, fully observable,
discrete environment
• Search for planning
– The path to the goal is the important
thing
– Paths have various costs, depths
• Search for assignment
– Assign values to variables while
respecting certain constraints
– The goal (complete, consistent
assignment) is the important thing
![Page 4: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/4.jpg)
4
Constraint satisfaction problems (CSPs)
• Definition:
– 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
– Solution is a complete, consistent assignment
• How does this compare to the “generic” tree search
formulation?
– A more structured representation for states, expressed in a
formal representation language
– Allows useful general-purpose algorithms with more power
than standard search algorithms
![Page 5: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/5.jpg)
5
![Page 6: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/6.jpg)
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
![Page 7: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/7.jpg)
8
CSP definition
CSP = {V, D, C}
• Variables: V = {V1,..,VN}
– Example: The values of the nodes in the graph
• Domain: The set of d values that each variable can take
– Example: D = {R, G, B}
• Constraints: C = {C1,..,CK}
• Each constraint consists of a tuple of variables and a list of values
that the tuple is allowed to take for this problem
– Example: [(V2,V3),{(R,B),(R,G),(B,R),(B,G),(G,R),(G,B)}]
• Constraints are usually defined implicitly a A function is defined to
test if a tuple of variables satisfies the constraint
– Example: Vi ≠ Vj for every edge (i,j)
Unary constraints involve a single variable,
– e.g., SA ≠ green
Binary constraints involve pairs of variables,
– e.g., SA ≠ WA
![Page 8: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/8.jpg)
9
![Page 9: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/9.jpg)
10
Graph Coloring
![Page 10: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/10.jpg)
11
Graph Coloring
![Page 11: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/11.jpg)
12
Example: Map Coloring
• Variables: WA, NT, Q, NSW, V, SA, T
• Domains: {red, green, blue}
• Constraints: adjacent regions must have different colors
e.g., WA ≠ NT, or (WA, NT) in {(red, green), (red, blue),
(green, red), (green, blue), (blue, red), (blue, green)}
![Page 12: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/12.jpg)
13
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
![Page 13: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/13.jpg)
14
Example: n-queens problem
• Put n queens on an n × n board with no two queens on the
same row, column, or diagonal
![Page 14: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/14.jpg)
15
N-Queens:
• Variables: Qi
• Domains: {1, … , N}
• Constraints:
i, j non-threatening (Qi , Qj)Q2
Q1
Q3
Q4
![Page 15: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/15.jpg)
16
N- Queens
![Page 16: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/16.jpg)
17
Alternative formulation
![Page 17: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/17.jpg)
18
Example: N-Queens
• Variables: Xij
• Domains: {0, 1}
• Constraints:
i,j Xij = N
(Xij, Xik) {(0, 0), (0, 1), (1, 0)}
(Xij, Xkj) {(0, 0), (0, 1), (1, 0)}
(Xij, Xi+k, j+k) {(0, 0), (0, 1), (1, 0)}
(Xij, Xi+k, j–k) {(0, 0), (0, 1), (1, 0)}
Xij
![Page 18: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/18.jpg)
19
Example: Sudoku
• Variables: Xij
• Domains: {1, 2, …, 9}
• Constraints:
Alldiff(Xij in the same unit)
Xij
![Page 19: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/19.jpg)
20
Example: Cryptarithmetic
• Variables: T, W, O, F, U, R
X1, X2
• Domains: {0, 1, 2, …, 9}
• Constraints:
O + O = R + 10 * X1
W + W + X1 = U + 10 * X2
T + T + X2 = O + 10 * F
Alldiff(T, W, O, F, U, R)
T ≠ 0, F ≠ 0
X2 X1
![Page 20: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/20.jpg)
24
Real-world CSPs
• Assignment problems
– e.g., who teaches what class
• Timetable problems
– e.g., which class is offered when and where?
• Transportation scheduling
• Factory scheduling
• More examples of CSPs: http://www.csplib.org/
![Page 21: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/21.jpg)
25
![Page 22: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/22.jpg)
27
![Page 23: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/23.jpg)
28
![Page 24: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/24.jpg)
29
![Page 25: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/25.jpg)
30
![Page 26: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/26.jpg)
31
Standard search formulation (incremental)
• States:
– Variables and values assigned so far
• Initial state:
– The empty assignment
• Action:
– Choose any unassigned variable and assign to it a value
that does not violate any constraints
• Fail if no legal assignments
• Goal test:
– The current assignment is complete and satisfies all
constraints
![Page 27: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/27.jpg)
32
CSP as a Standard search problem
![Page 28: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/28.jpg)
33
CSP as a Standard search problem
![Page 29: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/29.jpg)
34
![Page 30: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/30.jpg)
35
![Page 31: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/31.jpg)
36
Standard search formulation (incremental)
• What is the depth of any solution (assuming n variables)?
n (this is good)
• Given that there are m possible values for any variable,
how many paths are there in the search tree?
n! · mn (this is bad)
• How can we reduce the branching factor?
![Page 32: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/32.jpg)
37
![Page 33: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/33.jpg)
38
Backtracking DFS
For every possible value x in D:
– If assigning x to the next unassigned variable
Vk+1 does not violate any constraint with the k
already assigned variables:
• Set the variable Vk+1 to x
• Evaluate the successors of the current state with this variable
assignment
• If no valid assignment is found:
Backtrack to previous state
• Stop as soon as a solution is found
![Page 34: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/34.jpg)
39
![Page 35: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/35.jpg)
40
Backtracking search algorithm
![Page 36: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/36.jpg)
41
Example
![Page 37: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/37.jpg)
42
Example
![Page 38: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/38.jpg)
43
Example
![Page 39: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/39.jpg)
44
Example
![Page 40: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/40.jpg)
46
Improving Backtracking Efficiency
• Making backtracking search efficient:
– Can we detect inevitable failure early?
– Which variable should be assigned next?
– In what order should its values be tried?
![Page 41: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/41.jpg)
47
Early detection of failure
Apply inference to reduce the space of possible
assignments and detect failure early
![Page 42: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/42.jpg)
48
Early detection of failure: Forward checking
• Keep track of remaining legal values for unassigned variables
• Terminate search when any variable has no legal values
![Page 43: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/43.jpg)
49
Early detection of failure
Apply inference to reduce the space of possible
assignments and detect failure early
![Page 44: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/44.jpg)
50
![Page 45: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/45.jpg)
51
![Page 46: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/46.jpg)
52
![Page 47: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/47.jpg)
53
![Page 48: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/48.jpg)
54
![Page 49: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/49.jpg)
55
![Page 50: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/50.jpg)
56
![Page 51: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/51.jpg)
57
![Page 52: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/52.jpg)
58
![Page 53: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/53.jpg)
59
![Page 54: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/54.jpg)
60
![Page 55: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/55.jpg)
61
![Page 56: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/56.jpg)
62
![Page 57: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/57.jpg)
63
![Page 58: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/58.jpg)
64
![Page 59: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/59.jpg)
65
![Page 60: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/60.jpg)
66
![Page 61: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/61.jpg)
67
![Page 62: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/62.jpg)
68
![Page 63: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/63.jpg)
69
![Page 64: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/64.jpg)
70
![Page 65: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/65.jpg)
71
![Page 66: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/66.jpg)
72
![Page 67: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/67.jpg)
73
![Page 68: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/68.jpg)
74
![Page 69: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/69.jpg)
75
![Page 70: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/70.jpg)
76
![Page 71: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/71.jpg)
77
![Page 72: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/72.jpg)
78
![Page 73: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/73.jpg)
79
![Page 74: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/74.jpg)
80
![Page 75: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/75.jpg)
81
![Page 76: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/76.jpg)
82
![Page 77: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/77.jpg)
83
![Page 78: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/78.jpg)
84
Early detection of failure: Forward checking
• Keep track of remaining legal values for unassigned variables
• Terminate search when any variable has no legal values
![Page 79: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/79.jpg)
85
Early detection of failure: Forward checking
• Keep track of remaining legal values for unassigned variables
• Terminate search when any variable has no legal values
![Page 80: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/80.jpg)
86
Early detection of failure: Forward checking
• Keep track of remaining legal values for unassigned variables
• Terminate search when any variable has no legal values
![Page 81: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/81.jpg)
87
Early detection of failure: Forward checking
• Keep track of remaining legal values for unassigned variables• Terminate search when any variable has no legal values
![Page 82: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/82.jpg)
88
Constraint propagation
• Forward checking propagates information from assigned to
unassigned variables, but doesn't provide early detection for all
failures
• NT and SA cannot both be blue!
• Constraint propagation repeatedly enforces constraints locally
![Page 83: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/83.jpg)
89
• Simplest form of propagation makes each pair of variables
consistent:
– X Y is consistent iff for every value of X there is some allowed value of Y
Arc consistency
Consistent!
![Page 84: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/84.jpg)
91
• Simplest form of propagation makes each pair of variables
consistent:
– X Y is consistent iff for every value of X there is some allowed value of Y
– When checking X Y, throw out any values of X for which there isn’t an
allowed value of Y
• If X loses a value, all pairs Z X need to be rechecked
Arc consistency
![Page 85: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/85.jpg)
92
Arc consistency
• Simplest form of propagation makes each pair of variables
consistent:
– X Y is consistent iff for every value of X there is some allowed value of Y
– When checking X Y, throw out any values of X for which there isn’t an
allowed value of Y
• If X loses a value, all pairs Z X need to be rechecked
![Page 86: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/86.jpg)
93
Arc consistency
• Simplest form of propagation makes each pair of variables
consistent:
– X Y is consistent iff for every value of X there is some allowed value of Y
– When checking X Y, throw out any values of X for which there isn’t an
allowed value of Y
• If X loses a value, all pairs Z X need to be rechecked
![Page 87: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/87.jpg)
94
• Simplest form of propagation makes each pair of variables
consistent:
– X Y is consistent iff for every value of X there is some allowed value of Y
– When checking X Y, throw out any values of X for which there isn’t an
allowed value of Y
Arc consistency
![Page 88: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/88.jpg)
95
• Simplest form of propagation makes each pair of variables
consistent:
– X Y is consistent iff for every value of X there is some allowed value of Y
– When checking X Y, throw out any values of X for which there isn’t an
allowed value of Y
• Arc consistency detects failure earlier than forward checking• Can be run before or after each assignment
Arc consistency
![Page 89: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/89.jpg)
96
Arc consistency algorithm AC-3
![Page 90: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/90.jpg)
97
![Page 91: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/91.jpg)
98
![Page 92: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/92.jpg)
99
![Page 93: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/93.jpg)
100
![Page 94: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/94.jpg)
101
![Page 95: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/95.jpg)
102
![Page 96: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/96.jpg)
103
![Page 97: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/97.jpg)
104
![Page 98: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/98.jpg)
105
Which variable should be assigned next?
• Most constrained variable:
– Choose the variable with the fewest legal values
– A.k.a. minimum remaining values (MRV) heuristic
![Page 99: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/99.jpg)
106
Which variable should be assigned next?
• Most constraining variable:
– Choose the variable that imposes the most constraints
on the remaining variables
– Tie-breaker among most constrained variables
![Page 100: Constraint Satisfaction Problemspinar/courses/BBM405/...4 Constraint satisfaction problems (CSPs) • Definition: –State is defined by variables X i with values from domain D i –Goal](https://reader035.vdocument.in/reader035/viewer/2022062311/5fe1eb8235700845974ceabb/html5/thumbnails/100.jpg)
107
Given a variable, what should be the order of values?
• Choose the least constraining value:
– The value that rules out the fewest values in the remaining
variables
Which
assignment for
Q should we
choose?