2.Constraint Satisfaction Problems(CSPs)

约束补偿问题(CSPs)是种数学的问题,其定义为一组物件(object),而这些物件需要满足一些限制或条件。 CSPs将其问题中的单元(entities)表示成在变数上有限条件的一组同质(homogeneous)的集合, 这类问题透过"约束补偿方法"来解决。

  1. Situation can be described by a set of variables
  2. Constraint is a condition the variables must meet
  3. Problem: find assignments of values satisfying all constraints
  4. The constraint satisfaction problem (CSP) consists in finding a solution for a constraint network

Example: Eight queens puzzle

Binary constraint network

A constraint network is a triple⟨V,D,C⟩.
V: a finite set of variables
D: a set of finite or infinite sets considered to be the domains of every variable.
C:a set of binary relations
E.g. V = {a,b}. Suppose Da = {1,...,10} and Db = {8,...,20}. If we require a > b then Ca,b is the set {(9, 8), (10, 8), (10, 9)}.

1.Extension to non-binary constraints is simple.
2.SAT is the special case where all domains have just 2 values

Consistency of a partial assignment

if a is a partial assignment, then there are variables u, v in V and a constraint Cu,v in C such that a(u) and a(v) are defined, and (a(v), a(u)) ∈/ Cu,v
In that case, a violates the constraint Cu,v
So, the a is inconsistent.

1.A partial assignment a can be extended to a solution(A consistent total assignment is a solution) if there is a solution which agrees with a wherever a is defined.
2.Not every consistent partial assignment can be extended to a solution.

Pure Backtracking(try to find a solution)

Definition:Recursively instantiate variables one by one, backing up out of a search branch if the partial assignment is inconsistent.

Search: Systematic enumeration of partial assignments
— If a complete assignment is found, that’s a solution
— If the search space is exhausted, there are no [more] solutions

Backtracking: Pruning of inconsistent partial assignments (and all their extensions).

Inference: Reasoning about a partial assignment, to tighten constraints and reduce domains for its extensions.

There is a tradeoff: reduction in number of search nodes vs runtime needed for inference

Time complexity: O(n^k) n is the number of value choice and k is the number of variables.
Space complexity: O(k)

Advantages:

1.Very simple to implement
2.Very fast (per node of the search tree)
3.Complete (always gives a decision)

Disadvantages:

1.Does no reasoning except detecting actual inconsistency
2.Cannot look further ahead than the current state

Improvement

To avoid enumerating many inconsistent (partial) assignments by detecting them early

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 我避开无事时过分热络的友谊,这使我少些负担和承诺。我不多说无谓的闲言,这使我觉得清畅。------ 我尽可能不去缅...
    云水婷心_1016阅读 412评论 0 1
  • 透过一尘不染的玻璃墙,我看到了三个世界。而在三个世界间不停地切换,让我好生的疲惫。 第一个世界,是玻璃窗呈现出来的...
    龙兰达阅读 366评论 0 0
  • 2017年春节回老家,这个春节过的有意义也是非常的忙碌,回家才知道时间太短,与父母还没好好的谈心而又要分开! 初一...
    暮雪飘阅读 268评论 0 0
  • 又是下雨,手机还突然断电,有大约一公里没有记录下来。 但还是很不错。
    AndySong_1ee8阅读 152评论 0 0
  • 这个世界上有很多很多无奈的事,想念而不能碰触,喜欢而不能拥有,相思而不能相守。 【1】他用一个笑容,驻扎进我的心脏...
    南风来阅读 641评论 0 7