Presentation is loading. Please wait.

Presentation is loading. Please wait.

Constraint Networks Overview. Suggested reading Russell and Norvig. Artificial Intelligence: Modern Approach. Chapter 5.

Similar presentations


Presentation on theme: "Constraint Networks Overview. Suggested reading Russell and Norvig. Artificial Intelligence: Modern Approach. Chapter 5."— Presentation transcript:

1 Constraint Networks Overview

2 Suggested reading Russell and Norvig. Artificial Intelligence: Modern Approach. Chapter 5.

3 3 Good source of advanced information Rina Dechter, Constraint Processing, Morgan Kaufmann

4 4 Outline CSP: Definition, and simple modeling examples Representing constraints Basic search strategy Improving search: –Consistency algorithms –Look-ahead methods –Look-back methods

5 5 Outline CSP: Definition, and simple modeling examples Representing constraints Basic search strategy Improving search: –Consistency algorithms –Look-ahead methods –Look-back methods

6 AB redgreen redblack greenred greenblack blackgreen black red Constraint Satisfaction Example: map coloring Variables - countries (A,B,C,etc.) Values - colors (e.g., red, green, black) Constraints: C A B D E F G

7 7 Constraint Network; Definition A constraint network is: R= (X,D,C) X variables D domain C constraints R expresses allowed tuples over scopes A solution is an assignment to all variables that satisfies all constraints (join of all relations). Tasks: consistency?, one or all solutions, counting, optimization

8 Spring 20098 Example: The N-queens problem The network has four variables, all with domains Di = {1, 2, 3, 4}. (a) The labeled chess board. (b) The constraints between variables.

9 Example The 4-queen problem Q Q Q Q Q Q Q Q Place 4 Queens on a chess board of 4x4 such that no two queens reside in the same row, column or diagonal. Standard CSP formulation of the problem: Variables: each row is a variable. Q Q Q Q 1 2 3 4 Domains: Constraints: There are = 6 constraints involved: 4 2 ( ) Constraint Graph :

10 A solution and a partial consistent tuple Spring 200910 Not all consistent instantiations are part of a solution: (a)A consistent instantiation that is not part of a solution. (b) The placement of the queens corresponding to the solution (2, 4, 1,3). c) The placement of the queens corresponding to the solution (3, 1, 4, 2).

11

12

13

14 Spring 200914 Example: configuration and design

15 Spring 200915 Configuration and design Want to build: recreation area, apartments, houses, cemetery, dump Recreation area near lake Steep slopes avoided except for recreation area Poor soil avoided for developments Highway far from apartments, houses and recreation Dump not visible from apartments, houses and lake Lots 3 and 4 have poor soil Lots 3, 4, 7, 8 are on steep slopes Lots 2, 3, 4 are near lake Lots 1, 2 are near highway

16 16 Outline CSP: Definition, and simple modeling examples Representing constraints Basic search strategy Improving search: –Consistency algorithms –Look-ahead methods –Look-back methods

17 Spring 200917 Constraint’s representations Relation: allowed tuples Algebraic expression: Propositional formula: Constraint graph

18 18 Operations with relations Intersection Union Difference Selection Projection Join Composition

19 Spring 200919 Figure 1.8: Example of set operations intersection, union, and difference applied to relations.

20 Spring 200920 selection, projection, and join operations on relations.

21 Spring 200921 Constraint Graphs: Primal, Dual and Hypergraphs A (primal) constraint graph: a node per variable arcs connect constrained variables. A dual constraint graph: a node per constraint’s scope, an arc connect nodes sharing variables =hypergraph

22

23

24

25

26 26 Outline CSP: Definition, and simple modeling examples Representing constraints Basic search strategy Improving search: –Consistency algorithms –Look-ahead methods –Look-back methods

27

28 28 Backtracking search

29 Search space

30 Backtracking

31

32

33

34

35 The search space A tree of all partial solutions A partial solution: (a1,…,aj) satisfying all relevant constraints The size of the underlying search space depends on:  Variable ordering  Level of consistency possessed by the problem

36 Search space and the effect of ordering

37 The effect of variable ordering

38 Dependency on consistency level After arc-consistency z=5 and l=5 are removed After path-consistency  R’_zx  R’_zy  R’_zl  R’_xy  R’_xl  R’_yl

39 Backtrack-free network

40 Backtracking Complexity of extending a partial solution:  Complexity of consistent O(e log t), t bounds tuples, e constraints  Complexity of selectvalue O(e k log t)

41 A coloring problem example

42 Backtracking Search for a Solution

43 Backtracking search for a solution

44 Backtracking Search for a Solution

45 Backtracking Search for All Solutions

46 46 Outline CSP: Definition, and simple modeling examples Representing constraints Basic search strategy Improving search: –Consistency algorithms –Look-ahead methods –Look-back methods

47 Before search: (reducing the search space) –Arc-consistency, path-consistency, i-consistency –Variable ordering (fixed) During search : –Look-ahead schemes: Value ordering/pruning (choose a least restricting value), Variable ordering (Choose the most constraining variable) –Look-back schemes: Backjumping Constraint recording Dependency-directed backtracking Improving Backtracking O(exp(n))

48 48 Consistency methods Constraint propagation – inferring new constraints Can get such an explicit network that the search will find the solution without dead-ends. Approximation of inference:  Arc, path and i-consistency Methods that transform the original network into a tighter and tighter representations

49 49 Arc-consistency 32,1, 32,1,32,1, 1  X, Y, Z, T  3 X  Y Y = Z T  Z X  T XY TZ 32,1,  =   - infer constraints based on pairs of variables Insures that every legal value in the domain of a single variable has a legal match In the domain of any other selected variable

50 50 1  X, Y, Z, T  3 X  Y Y = Z T  Z X  T XY TZ  =   13 23 Arc-consistency

51 Arc-consistency algorithm domain of x domain of y Arc is arc-consistent if for any value of there exist a matching value of Algorithm Revise makes an arc consistent Begin 1. For each a in D i if there is no value b in D j that matches a then delete a from the D j. End. Revise is, k is the number of value in each domain.

52 Algorithm AC-3 Begin –1. Q <--- put all arcs in the queue in both directions –2. While Q is not empty do, –3. Select and delete an arc from the queue Q 4. Revise 5. If Revise cause a change then add to the queue all arcs that touch X i (namely ( X i,X m ) and ( X l,X i )). –6. end-while End Complexity: –Processing an arc requires O(k^2) steps –The number of times each arc can be processed is 2·k –Total complexity is

53 53 Sudoku – Constraint Satisfaction Each row, column and major block must be alldifferent “Well posed” if it has unique solution: 27 constraints 2 3 4 6 2 Variables: empty slots Domains = {1,2,3,4,5,6,7,8,9} Constraints: 27 all-different Constraint Propagation Inference

54 54 Path-consistency

55 55 Path-consistency

56 56 Example: before and after path- consistency PC-1 requires 2 processings of each arc while PC-2 may not Can we do path-consistency distributedly?

57 57 I-consistency

58 The Effect of Consistency Level After arc-consistency z=5 and l=5 are removed After path-consistency –R’_zx –R’_zy –R’_zl –R’_xy –R’_xl –R’_yl Tighter networks yield smaller search spaces

59 59 Outline CSP: Definition, and simple modeling examples Representing constraints Basic search strategy Improving search: –Consistency algorithms –Look-ahead methods –Look-back methods

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74 Forward-checking on Graph-coloring FW overhead: MAC overhead:

75 Propositional Satisfiability If Alex goes, then Becky goes: If Chris goes, then Alex goes: Query: Is it possible that Chris goes to the party but Becky does not? Example: party problem

76 Unit Propagation Arc-consistency for cnfs. Involve a single clause and a single literal Example: (A, not B, C) ^ (B) (A,C)

77 Look-ahead for SAT (Davis-Putnam, Logeman and Laveland, 1962)

78 Look-ahead for SAT: DPLL example: (~AVB)(~CVA)(AVBVD)(C) Only enclosed area will be explored with unit-propagation Backtracking look-ahead with Unit propagation= Generalized arc-consistency (Davis-Putnam, Logeman and Laveland, 1962)

79 79 Outline CSP: Definition, and simple modeling examples Representing constraints Basic search strategy Improving search: –Consistency algorithms –Look-ahead methods –Look-back methods

80 Look-back: Backjumping / Learning Backjumping: – In deadends, go back to the most recent culprit. Learning: – constraint-recording, no-good recording. – good-recording

81 Backjumping (X1=r,x2=b,x3=b,x4=b,x5=g,x6=r,x7={r,b}) (r,b,b,b,g,r) conflict set of x7 (r,-,b,b,g,-) c.s. of x7 (r,-,b,-,-,-,-) minimal conflict-set Leaf deadend: (r,b,b,b,g,r) Every conflict-set is a no-good

82 A coloring problem

83 Example of Gaschnig’s backjump

84

85

86

87

88

89 The cycle-cutset method An instantiation can be viewed as blocking cycles in the graph Given an instantiation to a set of variables that cut all cycles (a cycle-cutset) the rest of the problem can be solved in linear time by a tree algorithm. Complexity (n number of variables, k the domain size and C the cycle-cutset size):

90 Tree Decomposition

91

92

93

94 GSAT – local search for SAT (Selman, Levesque and Mitchell, 1992) 1.For i=1 to MaxTries 2. Select a random assignment A 3. For j=1 to MaxFlips 4. if A satisfies all constraint, return A 5. else flip a variable to maximize the score 6. (number of satisfied constraints; if no variable 7. assignment increases the score, flip at random) 8. end 9.end Greatly improves hill-climbing by adding restarts and sideway moves

95 WalkSAT (Selman, Kautz and Cohen, 1994) With probability p random walk – flip a variable in some unsatisfied constraint With probability 1-p perform a hill-climbing step Adds random walk to GSAT: Randomized hill-climbing often solves large and hard satisfiable problems

96 More Stochastic Search: Simulated Annealing, reweighting Simulated annealing: – A method for overcoming local minimas – Allows bad moves with some probability: With some probability related to a temperature parameter T the next move is picked randomly. – Theoretically, with a slow enough cooling schedule, this algorithm will find the optimal solution. But so will searching randomly. Breakout method (Morris, 1990): adjust the weights of the violated constraints

97


Download ppt "Constraint Networks Overview. Suggested reading Russell and Norvig. Artificial Intelligence: Modern Approach. Chapter 5."

Similar presentations


Ads by Google