约束满足问题学习笔记
2023.6.27 完成作业时记录的笔记
上传留档
Click to open
CS50’s Introduction to Artificial Intelligence with Python Ep.5 Note
Constraints Satisfaction Problem: 约束满足问题
Constraints
hard / soft constraints: must be satisfied in the solution / preferred in the solution
unary constraint: just involves one single variable
binary constraint: two variables
node consistency: all the elements in the domain satisfies the variable’s unary constraints
- when dealing with problems, conSsider unary constraints first to reach node consistency, through (for example) removing elements from the domain
arc consistency: satisfy the binary constraints
To max $X$ arc consistent with respect to $Y$, remove elements from $X$’s domain until every choice for $X$ has a possible chice for $Y$
max: some times we can’t reach it from one side
When choosing A.Wed, there’s no remaining choices for B in B’s domain, so remove Wed from A
Algorithm to enforce arc consistency
1 | def REVISE(csp, X, Y): |
Search Problems
csp and search problems
- initial state: empty assignment
- actions: add a variable-value pair to assignment
- transition model: hwo adding an assignment changes the assignment
- goal test: constraints all satisfied or not
- path cost function: cost = constant(in this problem)
Backtracking search
1 | def BACKTRACK(assignment, csp): |