Defining Constraint Satisfaction Problems
A constraint satisfaction problem (CSP) consists of three components, X, D, and C:
• X is a set of variables, {X1, . . . , Xn}.
• D is a set of domains, {D1, . . . , Dn}, one for each variable
• C is a set of constraints that specify allowable combination of values CSPs deal with assignments of values to variables.
• A complete assignment is one in which every variable is assigned a value
— A solution to a CSP is a consistent, complete assignment.
• A partial assignment is one that leaves some variables unassigned.
• Partial solution is a partial assignment that is consistent
约束满足问题是一个由三个主要组成部分组成的问题类型:
变量集(X):
X
包含一组变量,通常表示为 {X1, . . . , Xn}
。每个变量代表问题中的一个决策点或决策元素。域集(D):
D
包含一组域,每个域对应一个变量,表示为 {D1, . . . , Dn}
。域 Di
包含所有可能的值,每个值可以被分配给变量 Xi
。约束集(C):
C
包含一组约束,这些约束定义了变量值之间的允许组合。这些约束限制了变量可以取的值,以保证问题的解是有效的。CSPs 涉及的任务是分配值给变量,以满足所有约束。
完整分配(Complete assignment):
部分分配(Partial assignment):
• Standard search problem:
— state is a “black box” — any old data structure that supports goal test, eval, successor
• CSP:
— 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
• Simple example of a formal representation language
• Allows useful general-purpose algorithms with more power than standard search algorithms
状态(State):
目标测试(Goal test):
评估(Evaluation):
成功继任者(Successor):
Map-Colouring
Constraint graph
• Binary CSP: each constraint relates at most two variables
• Constraint graph: nodes are variables, arcs show constraints
General-purpose CSP algorithms use the graph structure
Varieties of CSPs
• Discrete variables
— finite domains; 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
— linear constraints solvable, nonlinear undecidable
• Continuous variables
e.g., start/end times for Hubble Telescope observations
— linear constraints solvable in poly time by LP methods
• Unary constraints involve a single variable,
e.g., S A̸ = green
• Binary constraints involve pairs of variables,
e.g., S A̸ = W A
• Higher-order constraints involve 3 or more variables,
e.g., cryptarithmetic column constraints
• Preferences (soft constraints),
e.g., red is better than green
• often representable by a cost for each variable assignment
→ constrained optimization problems
离散变量的CSPs涉及具有有限域的变量,例如布尔变量、整数、字符串等。
无限域的CSPs涉及具有无限域的变量,例如整数、字符串等。
连续变量的CSPs涉及具有连续域的变量,例如天文观测的开始和结束时间。
单变量约束(Unary constraints):
S ≠ green
。二变量约束(Binary constraints):
S ≠ W
。高阶约束(Higher-order constraints):
偏好约束是软约束,它们为每个变量分配了一个成本,表示对某个变量的偏好。
eg Cryptarithmetic