Most constrained variable. 即选择"被约束得最厉害的"那个变量,
或者说合法(指不违反约束)取值数目最小的变量. 比如下图在涂过绿色之后, 城市
SA 只剩蓝色这一种选择, 那么优先给 SA 涂上蓝色.
Most constraining variable. 选择变量之后,
剩下的变量"被约束得最厉害", 即使剩下的变量的合法取值变得最少.
这样做的是因为所有的变量都必须被赋值, 可以更早地搜索到不成立的情形.
比如在初始状态, 城市 SA 是最好的选择, 因为 SA 的颜色确定之后, WA, NT, Q,
NSW, V 的合法取值均减一, 是减少的最多的.
对于变量的取值:
Least constraining value.
选择的值对剩余变量的合法取值的减少应该最小.
这样做可以减少对变量取值的尝试, 减少不必要的分支. 比如下面的情况,
应优先给 Q 涂红色而不是蓝色, 否则会导致 SA 没有合法的颜色可选.
对于一个 CSP, 可以随机给一种赋值方案, 这大概率会有违反约束的情况,
local search 指的是通过不断调整不同变量的值来消除违反约束的部分,
最后得到一个可行解.
习题
6.4 Give precise formulations for each of the
following as constraint satisfaction problems:
Rectilinear floor-planning: find non-overlapping places in a
large rectangle for a number of smaller rectangles.
Class scheduling: There is a fixed number of professors and
classrooms, a list of classes to be offered, and a list of possible time
slots for classes. Each professor has a set of classes that he or she
can teach.
Hamiltonian tour: given a network of cities connected by roads,
choose an order to visit all cities in a country without repeating
any.
Find a permutation of such that .
6.6 Show how a single ternary constraint such as
“” can be turned into
three binary constraints by using an auxiliary variable. You may assume
finite domains. (Hint: Consider a new variable that takes on values that
are pairs of other values, and consider constraints such as “X is the
first element of the pair Y .”) Next, show how constraints with more
than three variables can be treated similarly. Finally, show how unary
constraints can be eliminated by altering the domains of variables. This
completes the demonstration that any CSP can be transformed into a CSP
with only binary constraints.
6.13 AC-3 puts back on the queue every arc whenever any value is deleted
from the domain of , even if
each value of is consistent
with several remaining values of . Suppose that, for every arc , we keep track of the number
of remaining values of that are
consistent with each value of .
Explain how to update these numbers efficiently and hence show that arc
consistency can be enforced in total time .
6.14 The TREE-CSP-SOLVER (Figure 6.10) makes arcs
consistent starting at the leaves and working backwards towards the
root. Why does it do that? What would happen if it went in the opposite
direction?