Constraint Satisfaction Problems

Constraint Satisfaction problems

identification problem(只关心结果,不关心path)

planning v.s. identification

  1. planning problems: search problem
    following path will result a goal
    path has various cost
    heuristics give problems a guide
    state is a black-box,and goal test is performed on state
  2. identification problems: CSP
    all paths have the same cost
    goal is important , path doesn’t matter
    state id a feature vector, goal test is constraint on the feature vector

CSP factors(构成)

  1. variable: { X 1 , ⋯   , X N } \{X_1,\cdots,X_N\} {X1,,XN}
    discrete or continuous
  2. domain
  3. constraints:变量的值约束
    unary constraints: not graph, prune the domain
    binary constraints:
    higher-order constraints: 3 or more variables
    global constraints
    preference: often reperesent by cost of each assignment
    补充一些概念
    feature vector
    一个state 被一个完全赋值的vector明确
    partitial assignment/ complete assignment

property

  1. NP hard problem:没办法在多项式时间内求解
    o ( d n ) o(d^n) o(dn)种可能赋值
  2. partial states: partial assignments有的变量没有被赋值
  3. complete state:完全赋值
  4. successor function: total states with a new variable assigned
  5. solution: assignments satisfies all the constraints
  6. goal test:完全赋值并满足约束

Constraint Graphs

  1. node: variables
    edges: constraints between them
  2. constraints
    unary constraints: not graph, prune the domain
    binary constraints:
    higher-order constraints: 3 or more variables(也可以在约束图中被表示,但有一些不寻常)eg global constraints all dif
  3. transform N-nary CSPS to binary CSPS
    step:
    将3元约束,转化为2元约束
    1. z with domain 3 tuples ( A , B , C ) ∈ { ( a 1 , b 1 , c 1 ) , ⋯   , ( a n , b n , c n ) } (A,B,C)\in\{(a_1,b_1,c_1),\cdots,(a_n,b_n,c_n)\} (A,B,C){(a1,b1,c1),,(an,bn,cn)}
    2. (Z,A),(Z,B)

约束图:
binary constraint graph(最常见)
多元也可以写出来

solving CSP

csp问题有有限domain或无限domain,也有可能variable是连续variable(enumerate就不可以用了)

problem

initial state: empty assignments{}
successor function: assign a value to an anssigned value
goal test: an assignment satisfies all the constraints 并且complete

backtracking search

uninformed search
优化DFS用于CSP

2 principles

  1. fix an ordering for variables, and select values in this order(赋值顺序没有影响)
  2. 只赋不会冲突的值,当没有合适的值的时候,回溯,取改变前一个变量的值在这里插入图片描述

improvement of backtracking search

filtering

(直接去掉会导致回溯的没有assign的variable的值域)

  1. forward checking: whenever a value is assigned to X i X_i Xi, cross off the value of unassigned variable X j X_j Xj which will vilotile the constraints
  2. arc consistency:
    把约束图上的一条无方向的edge,变成两条有方向的arc
    an arc x → y x\rightarrow y xy is consistency, if for every x in the tail there is some y in the head could be assigned without violating some constraints,否则的话就移出x
    forward checking: 所有的指向new assignment的arc consistent(只能保证局部arc consistent)
    在这里插入图片描述
    在这里插入图片描述
    in our class, we did not mention there is no need to insert if it has already existed, it does not matter (AC-3)也是重复插入了

time complexity: o ( e d 3 ) o(ed^3) o(ed3)
查一条arc的时间 d 2 d^2 d2,一个变量对应d
一条arc被放入的次数 d d d,一个变量最多被放d次
4. 1-consistecy
2-consistency
k-consistency:任取k个node的组合,对k-1个node赋值,能够保证第k个node有至少一个可以赋值
strong k-consistency: 能够保证更低的个数的一致

forward checking 仅仅保证了指向新赋值的arc相容性,没有弧相容发现错误早

ordering

1.MRV: minimum remaining variable/most constrained variable,就是可以选择的值最少
2.LCV: least constraining value:may need arc consistency or forward checking,影响其他变量的值最少

structure

  1. independent sub-problems: extreme case
  2. connected-subgraph
  3. tree-structure CSPS(no loop in the constraint graph )
    O ( d n ) → O ( n d 2 ) O(d^n)\rightarrow O(nd^2) O(dn)O(nd2)
  4. step
    1. prick an arbitrary node as the root
    2. let the undtrected edges point from parents to childs
    3. check arc consistency from children to parents
    4. forward assignment:对每一个选取和parents consisitent 的值
      在这里插入图片描述
  5. instantiate a variable, and then the subgraph is a tree
  6. cycle cutest conditioning:
    找到最小的一个set(cutset)移走他们,剩下的集合是一个树
    o ( d c ) ( n − c ) d 2 o(d^c)(n-c)d^2 o(dc)(nc)d2
  7. tree-decomposition: create a tree-structured graph of mega-variables,each mega-variable encodes part of the original CSP,sub-problems overlap to ensure consistent solutions

local search

  1. work with a complete states, then reassign variable values
  2. randomly select any conflicted variable,reassign
  3. choose a value that violates the fewest constraints
    在这里插入图片描述
    可以在常数时间内,解决问题,但是不能保证完备性,而且是次优的
    R = c o n s t r a i n t s v a r i a b l e s R=\frac{constraints}{variables} R=variablesconstraints: 在某个值的时候,求解问题很困难

local search

local search v.s. systematic search

systematic search:
keep paths in memory. and remember alternatives so search can backtrack
search covered before
keep history of some visited nodes
always complete for finite search spaces, some complete for infinite search spaces
good for building up solutions incrementally : state _partitial solution,action_extend partial solution

local search:
path may be irrelevant, if only the final configuration is needed
garden descent, greedy local search ,simulated annealing(退火算法), genetic algorithm(遗传算法)
not keep the history of visited nodes
not complete
Good for fixing up candidate silutions: not satisfy all constraints ,action, make a small change in the candidate solution

hill-climbing search
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

题目问题

np难问题,我们无法最小化解决时间,通过范式解
如果我们保证arc consistency 那么当剩余部分是树形结构时,就不会导致backtracking search

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值