Local Search for CSPs
Local search algorithms use a complete-state formulation where:
— each state assigns a value to every variable, and
— the search changes the value of one variable at a time
• Min-conflicts heuristic: value that results in the minimum number of conflicts with
other variables that brings us closer to a solution.
— Usually has a series of plateaus
• Plateau search: allowing sideways moves to another state with the same score.
— can help local search find its way off the plateau.
• Constraint weighting aims to concentrate the search on the important constraints
— Each constraint is given a numeric weight, initially all 1.
— weights adjusted by incrementing when it is violated by the current assignment
• Min-conflicts heuristic: value that results in the minimum number of conflicts with
other variables that brings us closer to a solution.c
通过选择冲突最少的变量值来逐步接近解决方案
— Usually has a series of plateaus
“plateaus” 指的是解空间中的一片区域,在这片区域内,目标函数(例如冲突数量)的变化非常小或者没有变化。可能会导致算法收敛到一个局部最优解而不是全局最优解。
Problem structure
• Tasmania and mainland are independent subproblems
• Identifiable as connected components of constraint graph
• Suppose each subproblem has c variables out of n total
• Worst-case solution cost is n/c · dc, linear in n
E.g. n = 80, d = 2, c = 20
280 = 4 billion years at 10 million nodes/sec
4 · 220 = 0.4 seconds at 10 million nodes/sec
Tree-structured CSPs
• Theorem: if the constraint graph has no loops, the CSP can be solved in O(nd**2) time
即约束图是一个树 CSP O(nd**2)
• Compare to general CSPs, where worst-case time is O(d**n)
• This property also applies to logical and probabilistic reasoning: an important example of the relation between syntactic restrictions and the complexity of reasoning.
- 句法限制:在树状结构的CSP中,句法限制是指约束图没有环。这种结构限制了变量之间约束的方式。
- 推理复杂性:句法限制可以显著降低推理的复杂性。在树状结构中,由于没有环,我们可以从树的叶子节点开始,向上逐层解决约束,而不需要考虑变量之间的循环依赖。
Algorithm for tree-structured CSPs
1 Choose a variable as root, order variables from root to leaves such that every node’s parent precedes it in the ordering 选择一个变量为root 排序时父节点要在子节点之前
2 For j from n down to 2, apply RemoveInconsistent(Parent(Xj ), Xj )
- 从n递减到2:从最后一个变量开始,向上遍历到第二个变量。
- RemoveInconsistent:这个操作会移除变量Xj的域中所有与它的父节点Parent(Xj)不一致的值。也就是说,如果某个值与Parent(Xj)的当前值冲突,那么这个值就不会被考虑为Xj的可能值。
3 For j from 1 to n, assign Xj consistently with Parent(Xj )
- 在修剪完域之后,开始为每个变量分配值。
- 从1到n:从第一个变量开始,向下遍历到最后一个变量。
- 按一致的方式分配:对于每个变量Xj,选择一个值(如果可能的话),这个值与它的父节点Parent(Xj)的值是一致的。这意味着选择的值不会违反与父节点的约束。
Nearly tree-structured CSPs
Conditioning: instantiate a variable, prune its neighbous’ domains
Cutset conditioning: instantiate (in all ways) a set of variables such that the remaining
constraint graph is a tree
Cutset size c ⇒ runtime , very fast for small c
-
条件化(Conditioning)
-
实例化一个变量:
- 在CSP中选择一个变量,并为其分配一个具体的值(实例化)。
-
修剪其邻居的域:
- 一旦一个变量被实例化,就需要更新与该变量有约束关系的其他变量(邻居)的域。具体来说,就是移除那些与已实例化变量值冲突的值。
-
割集条件化(Cutset Conditioning)
-
实例化一组变量:
- 选择CSP中的一组变量,并为这些变量分配所有可能的值组合(即穷举所有可能的实例化方式)。
-
使得剩余的约束图成为一棵树:
- 通过实例化这组变量,目的是移除约束图中的所有环,使得剩余的变量形成一个树状结构。
-
割集大小 c:
- 割集是指为了将图转换为树而被实例化的变量集合的大小。
Iterative algorithms for CSPs
• Hill-climbing, simulated annealing typically work with “complete” states, i.e., all variables assigned
• To apply to CSPs:
— allow states with unsatisfied constraints
— operators reassign variable values
• Variable selection: randomly select any conflicted variable
• Value selection by min-conflicts heuristic:
— choose value that violates the fewest constraints
— i.e., hillclimb with h(n) = total number of violated constraints
CSP Summary
• CSPs are a special kind of problem:
— states defined by values of a fixed set of variables
— goal test defined by constraints on variable values
• Backtracking = depth-first search with one variable assigned per node
• Variable ordering and value selection heuristics help significantly
• Forward checking prevents assignments that guarantee later failure
• Constraint propagation (e.g., arc consistency) does additional work to constrain
values and detect inconsistencies
• Local search using the min-conflicts heuristic has also been applied to constraint
satisfaction problems with great success
• The CSP representation allows analysis of problem structure
• Tree-structured CSPs can be solved in linear time
• CSPs still beat the most advanced ML methods for most optimization tasks