Presentation is loading. Please wait.

Presentation is loading. Please wait.

Constraint Satisfaction Problems Rich and Knight: 3.5 Russell and Norvig: Chapter 3, Section 3.7 Chapter 4, Pages 104-105 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm.

Similar presentations


Presentation on theme: "Constraint Satisfaction Problems Rich and Knight: 3.5 Russell and Norvig: Chapter 3, Section 3.7 Chapter 4, Pages 104-105 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm."— Presentation transcript:

1 Constraint Satisfaction Problems Rich and Knight: 3.5 Russell and Norvig: Chapter 3, Section 3.7 Chapter 4, Pages 104-105 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm

2 Intro Example: 8-Queens Generate-and-test, with no redundancies  “only” 8 8 combinations

3 Intro Example: 8-Queens

4 What is Needed? Not just a successor function and goal test But also a means to propagate the constraints imposed by one queen on the others and an early failure test  Explicit representation of constraints and constraint manipulation algorithms

5 Constraint Satisfaction Problem Set of variables {X 1, X 2, …, X n } Each variable X i has a domain D i of possible values Usually D i is discrete and finite Set of constraints {C 1, C 2, …, C p } Each constraint C k involves a subset of variables and specifies the allowable combinations of values of these variables Assign a value to every variable such that all constraints are satisfied

6 Example: 8-Queens Problem 8 variables X i, i = 1 to 8 Domain for each variable {1,2,…,8} Constraints are of the forms: X i = k  X j  k for all j = 1 to 8, j  i X i = k i, X j = k j  |i-j|  | k i - k j |  for all j = 1 to 8, j  i

7 Example: Map Coloring 7 variables {WA,NT,SA,Q,NSW,V,T} Each variable has the same domain {red, green, blue} No two adjacent variables have the same value: WA  NT, WA  SA, NT  SA, NT  Q, SA  Q, SA  NSW, SA  V,Q  NSW, NSW  V WA NT SA Q NSW V T WA NT SA Q NSW V T

8 Example: Task Scheduling T1 must be done during T3 T2 must be achieved before T1 starts T2 must overlap with T3 T4 must start after T1 is complete T1 T2 T3 T4

9 Constraint Graph Binary constraints T WA NT SA Q NSW V Two variables are adjacent or neighbors if they are connected by an edge or an arc T1 T2 T3 T4

10 Example: Map Coloring s 0 = ??????? successors(s 0 ) = {R??????, G??????, B??????} What search algorithms could we use? BFS? DFS?

11 Remark Finite CSP include 3SAT as a special case 3SAT is known to be NP-complete So, in the worst-case, we cannot expect to solve a finite CSP in less than exponential time

12 Map Coloring {} WA=redWA=greenWA=blue WA=red NT=green WA=red NT=blue WA=red NT=green Q=red WA=red NT=green Q=blue WA NT SA Q NSW V T

13 Backtracking Algorithm CSP-BACKTRACKING(PartialAssignment a) If a is complete then return a X  select an unassigned variable D  select an ordering for the domain of X For each value v in D do  If v is consistent with a then Add (X= v) to a result  CSP-BACKTRACKING(a) If result  failure then return result Return failure CSP-BACKTRACKING({})

14 Questions 1. Which variable X should be assigned a value next? 2. In which order should its domain D be sorted? 3. What are the implications of a partial assignment for yet unassigned variables?

15 Choice of Variable Map coloring WA NT SA Q NSW V T WA NTSA

16 Choice of Variable 8-queen

17 Choice of Variable Most-constrained-variable heuristic: Select a variable with the fewest remaining values = Fail First Principle

18 Choice of Variable Most-constraining-variable heuristic: Select the variable that is involved in the largest number of constraints on other unassigned variables = Fail First Principle again WA NT SA Q NSW V T SA

19 {} Choice of Value WA NT SA Q NSW V T WA NT

20 Choice of Value Least-constraining-value heuristic: Prefer the value that leaves the largest subset of legal values for other unassigned variables {blue} WA NT SA Q NSW V T WA NT

21 Choice of Constraint to Test Most-constraining-Constraint: Prefer testing constraints that are more difficult to satisfy = Fail First Principle

22 Constraint Propagation … … is the process of determining how the possible values of one variable affect the possible values of other variables

23 Forward Checking After a variable X is assigned a value v, look at each unassigned variable Y that is connected to X by a constraint and deletes from Y’s domain any value that is inconsistent with v

24 Map Coloring WANTQNSWVSAT RGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGB T WA NT SA Q NSW V

25 Map Coloring WANTQNSWVSAT RGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGB RGBGBRGBRGBRGBRGBRGBRGBGBGBRGBRGB T WA NT SA Q NSW V

26 WANTQNSWVSAT RGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGB RGBGBRGBRGBRGBRGBRGBRGBGBGBRGBRGB RBGRBRBRGBRGBBRGBRGB Map Coloring T WA NT SA Q NSW V

27 Map Coloring WANTQNSWVSAT RGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGB RGBGBRGBRGBRGBRGBRGBRGBGBGBRGBRGB RBGRBRBRGBRGBBRGBRGB RBGRBRGBRGB Impossible assignments that forward checking do not detect T WA NT SA Q NSW V

28 Edge Labeling in Computer Vision Rich and Knight: Chapter 14, Pages 367-375 Russell and Norvig: Chapter 24, pages 745-749

29 Edge Labeling

30 Trihedral Objects Objects in which exactly three plane surfaces come together at each vertex. Goal: label a 2-D object to produce a 3-D object

31 Edge Labeling

32 Labels of Edges Convex edge: two surfaces intersecting at an angle greater than 180° Concave edge two surfaces intersecting at an angle less than 180° + convex edge, both surfaces visible − concave edge, both surfaces visible  convex edge, only one surface is visible and it is on the right side of 

33 Edge Labeling

34 + + + + + + + + + + - -

35 Junction Label Sets ++ - - - -- ++ ++ + + + - - - - - + (Waltz, 1975; Mackworth, 1977)

36 Edge Labeling as a CSP A variable is associated with each junction The domain of a variable is the label set of the corresponding junction Each constraint imposes that the values given to two adjacent junctions give the same label to the joining edge

37 Edge Labeling + - + - + - - + +

38 + + + + - - - - - - +

39 + + + + + + - -- ++ ++

40 + + + -- ++ ++ - -

41 Removal of Arc Inconsistencies REMOVE-ARC-INCONSISTENCIES(J,K) removed  false X  label set of J Y  label set of K For every label y in Y do If there exists no label x in X such that the constraint (x,y) is satisfied then  Remove y from Y  If Y is empty then contradiction  true  removed  true Label set of K  Y Return removed

42 CP Algorithm for Edge Labeling Associate with every junction its label set Q  stack of all junctions while Q is not empty do J  UNSTACK(Q) For every junction K adjacent to J do  If REMOVE-ARC-INCONSISTENCIES(J,K) then If K’s domain is non-empty then STACK(K,Q) Else return false (Waltz, 1975; Mackworth, 1977)


Download ppt "Constraint Satisfaction Problems Rich and Knight: 3.5 Russell and Norvig: Chapter 3, Section 3.7 Chapter 4, Pages 104-105 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm."

Similar presentations


Ads by Google