Constraint Satisfaction Problems (CSP) 2 3 4 5 General search versus CSP General search Blackbox State External Child-generator State-space can be infinite External goal test Goals can occur at any depth Goals can have different costs All the search algorithms we discussed until now are appropriate. Heuristics are aimed at estimating the cost to goal node CSP State is made-up of state variables Children generation involves assigning values to more variables State space is finite A state is a goal state if all variables are assigned and no constraints are violated All goals occur at the same depth In the basic formulation, all goals have the same cost Only the Depth-first search makes sense! Heuristics are aimed at picking the right variable to assign next, and deciding the right value to assign to it 6 7 Also called most constrained variable Usually lead to speedup by a factor of 1,000 or more 8 Unassigned variables 9 Try to leave the maximum flexibility for subsequent variable assignments Does the ordering of values matter if we want to find ALL (instead of A) solutions? 10 Fail-first versus fail-last Variable: fail-first Minimize the number of nodes in the search tree, i.e., minimize the number of possible assignments to check Value: fail-last We only need ONE solution, why not look at the most likely values first? 11 NT WA SA Q NSW V T 12 NT Q WA SA NSW V T 13 NT Q WA SA NSW V T 14 NT WA SA Q NSW V T 15 NT Q WA SA NSW V T 16 NT Q WA SA NSW V T 17 Constraint propagation Node consistency: all values in the variable’s domain satisfy the variable’s unary constraint Arc consistency: Xi is arc-consistent with Xj if for every value in the current domain Di, there is some value in the domain Dj that satisfy the binary constraint on the arc (Xi, Xj) Path consistency: involve three variables K-consistency: involve K variables × Xi is arc-consistent with Xj = Xj is arc-consistent with Xi ?? 18 19 20 21 22 Constraint propagation in Sudoku 1 4 7 23 24 Summary Formulation of CSP Backtracking for CSP Most constrained variable Least constrained value Degree heuristic for tie-breaking Forward checking Constraint propagation 25
© Copyright 2026 Paperzz