Slide Trí Tuệ Nhân Tạo - Lecture04 - CSP - Phạm Bảo Sơn - UET
Slide Trí Tuệ Nhân Tạo - Lecture04 - CSP - Phạm Bảo Sơn - UET
Slide Trí Tuệ Nhân Tạo - Lecture04 - CSP - Phạm Bảo Sơn - UET
Problems!
Các bài toán thỏa mãn ràng buộc #
Outline!
• Constraint Satisfaction Problems (CSP)#
• Backtracking search for CSPs#
• Local search for CSPs#
• Variables: F T U W R O X1 X2 X3!
• Domains: {0,1,2,3,4,5,6,7,8,9}#
• Constraints: Alldiff (F,T,U,W,R,O)#
– O + O = R + 10 · X1!
– X1 + W + W = U + 10 · X2!
– X2 + T + T = O + 10 · X3!
– X3 = F, T ≠ 0, F ≠ 0#
#
Phạm Bảo Sơn 11
Standard search formulation (incremental)!
Let's start with the straightforward approach, then fix it#
States are defined by the values assigned so far#
• Initial state: the empty assignment { }#
• Successor function: assign a value to an unassigned variable
that does not conflict with current assignment#
à fail if no legal assignments#
• Goal test: the current assignment is complete#
1. This is the same for all CSPs#
2. Every solution appears at depth n with n variables
à use depth-first search#
3. Path is irrelevant, so can also use complete-state formulation#
4. b = (n - l )d at depth l, hence n! · dn leaves (d: number of
variable values)#
#
• Combining these heuristics makes 1000
queens feasible#
# Phạm Bảo Sơn 22
Forward checking
Kiểm tra trước!
• Idea: #
– Keep track of remaining legal values for unassigned
variables#
– Terminate search when any variable has no legal values#
#