E 约束满足

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

i,j[1,5], ij, Ni Nj
ij, Ci Cj
Street Puzzle
1 2 3 4 5
Ni = {English, Spaniard, Japanese, Italian, Norwegian} Ci = {Red, Green, White, Yellow, Blue} Di = {Tea, Coffee, Milk, Fruit-juice, Water} Ji = {Painter, Sculptor, Diplomat, Violinist, Doctor} Ai = {Dog, Snails, Fox, Horse, Zebra}
owns the Zebra? drinks Water?
Street Puzzle
1 2 3 4 5
Ni = {English, Spaniard, Japanese, Italian, Norwegian} Ci = {Red, Green, White, Yellow, Blue} Di = {Tea, Coffee, Milk, Fruit-juice, Water} Ji = {Painter, Sculptor, Diplomat, Violinist, Doctor} Ai = {Dog, Snails, Fox, Horse, Zebra}
The The The The The The The The The The The The The The
Englishman lives in the Red house i,j[1,5], Spaniard has a Dog Japanese is a Painter ... Italian drinks Tea Norwegian lives in the first house on the left owner of the Green house drinks Coffee Green house is on the right of the White house Sculptor breeds Snails Diplomat lives in the Yellow house owner of the middle house drinks Milk Norwegian lives next door to the Blue house Violinist drinks Fruit juice Fox is in the house next to the Doctor’s Horse is next to the Diplomat’s
The The The The The The The The The The The The The The
(Ni = English) (Ci = Red) Englishman lives in the Red house Spaniard has a Dog (Ni = Japanese) (Ji = Painter) Japanese is a Painter Italian drinks Tea (N1 = Norwegian) Norwegian lives in the first house on the left owner of the Green house drinks Coffee Green house is on the right of the White house Sculptor breeds Snails (Ci = White) (Ci+1 = Green) Diplomat lives in the Yellow house owner of the middle house drinks Milk (C5 White) Norwegian lives next door to the Blue house (C1 Green) Violinist drinks Fruit juice Fox is in the house next to the Doctor’s 其余的类似,留给同学们思考 Horse is next to the Diplomat’s
The The The The The The The The The The The The The The
(Ni = English) (Ci = Red) Englishman lives in the Red house Spaniard has a Dog (Ni = Japanese) (Ji = Painter) Japanese is a Painter Italian drinks Tea (N1 = Norwegian) Norwegian lives in the first house on the left owner of the Green house drinks Coffee Green house is on the right of the White house Sculptor breeds Snails (Ci = White) (Ci+1 = Green) Diplomat lives in the Yellow house owner of the middle house drinks Milk (C5 White) Norwegian lives next door to the Blue house (C1 Green) Violinist drinks Fruit juice Fox is in the house next to the Doctor’s 一元(unary)约束 Horse is next to the Diplomat’s
(对于困难的决策,我们将推迟到它变得容易 的时候再做决定) R&N: Chap. 5
Constraint Satisfaction Problems (CSP)
约束满足问题 (CSP)
我们想做些什么?
搜索技术通常按照一个任意的次序对可能进行选 择,一般很少有效的信息能够帮助如何进行选择
在许多问题中,状态的到达与进行选择的次序无 关(“可交换”) ,即采取不同的次序进行选择 也一样可以到达同一个状态 那能否通过选定某种适合的选择次序能够更有效 的解决这些问题呢?甚至可以避免进行选择?
Street Puzzle
1 2 3 4 5
Ni = {English, Spaniard, Japanese, Italian, Norwegian} Ci = {Red, Green, White, Yellow, Blue} Di = {Tea, Coffee, Milk, Fruit-juice, Water} Ji = {Painter, Sculptor, Diplomat, Violinist, Doctor} Ai = {Dog, Snails, Fox, Horse, Zebra}
1 2 3 4 5
Ni = {English, Spaniard, Japanese, Italian, Norwegian} Ci = {Red, Green, White, Yellow, Blue} Di = {Tea, Coffee, Milk, Fruit-juice, Water} Ji = {Painter, Sculptor, Diplomat, Violinist, Doctor} Ai = {Dog, Snails, Fox, Horse, Zebra}
Street Puzzle
1 2 3 4 5
Ni = {English, Spaniard, Japanese, Italian, Norwegian} Ci = {Red, Green, White, Yellow, Blue} Di = {Tea, Coffee, Milk, Fruit-juice, Water} Ji = {Painter, Sculptor, Diplomat, Violinist, Doctor} Ai = {Dog, Snails, Fox, Horse, Zebra}
8-皇后问题
8 个变量 Xi, i = 1 to 8 每个变量的值域均为: {1,2,…,8} 约束表示为如下形式: • Xi = k Xj k for all j = 1 to 8, ji • 对角线也是相同的约束
所有的约束都是二进制表示
Street Puzzle(课本习题5.13)
约束传播 Constraint Propagation
将一个皇后放入到一个方格里 移去所有可能攻击到的方格
Constraint Propagation
6 6 5 5 5 5 6 5 5 5 5 5 6 7
计算每一行、每一列不会受到攻击的方格数 将一个皇后放置在有着最小数目的行或列上 再次移去可能受到攻击的所有方格
Constraint Propagation
3 4 4 3 3 3 4 5
4
3 3 5
重复前述过程
Constraint Propagation
3 3 4 3 4 3
3
2 3ຫໍສະໝຸດ Baidu4
Constraint Propagation
3 3 4 3 1
2
2 1 3
Constraint Propagation
约束的清晰表示 约束传播算法
约束满足问题 (CSP) Constraint Satisfaction Problem (CSP)
变量的集合 variables {X1, X2, …, Xn} 每一个变量Xi所有可能的取值,构成该变量 的值域Di;通常Di是有限的 约束的集合 constraints {C1, C2, …, Cp} 每个约束描述了一个变量子集与特定的某些 值合法的结合对应关系 目标: 每一个变量都得到了一个赋值,且所有 的约束得到满足
The The The The The The The The The The The The The The
Englishman lives in the Red house Who Spaniard has a Dog Who Japanese is a Painter Italian drinks Tea Norwegian lives in the first house on the left owner of the Green house drinks Coffee Green house is on the right of the White house Sculptor breeds Snails Diplomat lives in the Yellow house owner of the middle house drinks Milk Norwegian lives next door to the Blue house Violinist drinks Fruit juice Fox is in the house next to the Doctor’s Horse is next to the Diplomat’s
地图着色问题
NT
WA SA Q NSW T
V
7 个变量 {WA,NT,SA,Q,NSW,V,T} 每个变量的值域是一样的: {red, green, blue} 两个相邻的变量不能取相同的值:
WANT, WASA, NTSA, NTQ, SAQ, SANSW, SAV,QNSW, NSWV
2 2 2 1
2
1
Constraint Propagation
1 2
2
1
Constraint Propagation
1
1
Constraint Propagation
我们需要些什么?
后继函数与目标测试
还需要:
• 通过约束传播( propagate the constraints ) 信息,比如通过对一个皇后位置的约束来影响 其他皇后的位置 • 提前的失败测试(failure test)
相关文档
最新文档