lecture 6
play

Lecture 6: Constraint satisfaction problems: Given: a set of n - PowerPoint PPT Presentation

CS440/ECE448: Intro to Artificial Intelligence Tuesday s key concepts Lecture 6: Constraint satisfaction problems: Given: a set of n variables X 1 ..X n , with More on constraint domains (sets of possible values) D 1 D n ,


  1. CS440/ECE448: Intro to Artificial Intelligence � Tuesday ʼ s key concepts � Lecture 6: 
 Constraint satisfaction problems: � Given: a set of n variables X 1 ..X n , with More on constraint domains (sets of possible values) D 1 …D n , satisfaction problems � and a set of m constraints C 1 … C m � � Task: assign a value from D i for each X i Prof. Julia Hockenmaier � subjects to the constraints. � juliahmr@illinois.edu � � � http://cs.illinois.edu/fa11/cs440 � � � � Map coloring: 
 a solution for N=3 � CSP 1: 
 Map coloring 
 (Binary constraints) � CS440/ECE448: Intro AI � 4 �

  2. 
 Constraint satisfaction problems States and solutions � are defined by… � - a set of variables X : � Each state is a complete or partial assignment of values to variables: 
 {WA, NT, QLD, NSW, VA, SA, TA} � - a set of domains D i 
 state35 = {WA=red, NT=blue, QLD= green, NSW= red, 
 (possible values for variable x i ): � � � � VA= green, SA= blue, TA= red}; 
 D WA = {red, blue, green} � state23 = {WA = red} � - a set of constraints C : � � Legal assignments don ʼ t violate any constraints. � { 〈 (WA,NT), WA ≠ NT 〉 , 〈 (WA,QLD), WA ≠ QLD 〉 ,…} 
 Solutions are complete legal assignments � scope relation � � CS440/ECE448: Intro AI � 5 � CS440/ECE448: Intro AI � 6 � Binary constraints: 
 Consistency � constraint graph � Node consistency: X is node-consistent iff 
 QLD � NT � each element in D X satisfies unary constraints on X � � Arc consistency: X is arc-consistent iff 
 WA � NSW � for each C(X, Y) and for each x ∈ D X there is a y ∈ D Y such that the assignment {X=x, Y=y} satisfies C(X,Y). � � Path consistency: {X,Y} are path consistent wrt. Z iff 
 SA � VA � for every x ∈ D X and y ∈ D X there is a z ∈ D Z such that the assignment {X=x,Y=y,Z=z} satisfies C(X,Z) and C(Y,Z) � � TA � � CS440/ECE448: Intro AI � 7 � CS440/ECE448: Intro AI � 8 � �

  3. Tree-structured 
 AC-3 � constraint graphs � - // Is the CSP c arc-consistent? � Any two nodes connected by a single path � function AC3(CSP c) � - � input: CSP c = (X,D,C) �� With n vertices, there are n − 1 edges � � local: queue q ← all arcs C(X,Y) in c � - Can be solved in linear time ( O(nd 2 ) ) � � while q ≠ () do: � � � // Can C(X,Y) be satisfied? � � � (X,Y) = pop(q); � E � � // if domain(X) needs to be shrunk: � E B � � if revise(c,X,Y): � A B F � � � // Exit if CSP can’t be solved: � D � � � if domain(X) == () return false; � F C � � � // Are X’s neighbors still okay? � A C D � � � foreach Z in X.NEIGHBORS\{Y}: � � q ← push(q,(Z, X)); � � � � � return true; � CS440/ECE448: Intro AI � 9 � CS440/ECE448: Intro AI � 10 � The 8-queens puzzle � ♕ ! ! ! ! ♕ ! ! !" ! ! CSP 2: 
 ♕ ! ! ! ! ♕ ! ! ! ! ! ! ! 8 queens puzzle 
 ! ! ! ! ! ! ! ! ! ! ! ! ♕ ! ! (Combining search 
 ♕ ! ! ! ! and CSP inference) � The 8-queens puzzle has multiple solutions � Cannot be solved by constraint propagation alone � [ underdetermined CSP] � � � CS440/ECE448: Intro AI � 12 �

  4. Search tree for 8-queens � Branching factor of 8-queens � ! ! ! ! ! ! !" ! ! The branching factor is at most 8: � ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! � ! ! ! ! ! ! ! ! ! ! - We can order the variables: 
 ! ! ! ! (CSPs are commutative ) � ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !" ! ! ! ! !" ! ! ! ! !" ! ! ! ! !" ! ! ! ! !" ! ! ! ! !" ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! 1. place queen in column A, � ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! 2. place queen in column B, � ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! 3. ... � � - The constraints restrict the domains of the ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !" ! ! !" ! ! ! ! !" ! ! ! ! !" ! ! ! ! !" ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! remaining variables � ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! � CS440/ECE448: Intro AI � 13 � CS440/ECE448: Intro AI � 14 � Ordering the variables � Caveat: implied constraints � D X = {R,G,B} C(X,Y): X ≠ Y � D X = D Y = D Z = {0,1,2,3,4,5,6,7,8,9} � D Y = {R} � C(X,Z): X ≠ Z � � D Z = {G,B} � C(X, Y): Y = X 2 � � X � Y � Z � C(Y, Z): Z = Y 2 � Which variable should we consider first? � � Minimum remaining values heuristic: � � The variable with the smallest domain � If we choose X as the root of the tree, we Degree heuristic: � need to run DAC down the tree and up The variable that has the most constraints � again. � CS440/ECE448: Intro AI � 15 � CS440/ECE448: Intro AI � 16 �

  5. 
 Interleaving search 
 Ordering the values � and inference � ! ! ! ! ! ! ! ! ! ! ! ! ! ! !" ! ! !" ! ! !" ! ! ! ! !" ! ! Search: assign (guess) value x for variable X � ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! Forward checking algorithm: � Check that X is arc-consistent with all Which values of X should we consider first? � remaining variables Y 
 � � Least-constraining value heuristic: � Maintaining-Arc-Consistency algorithm: � Pick the most likely value first 
 Run AC3 on all C(Y,X) constraints to check (= the one which rules out the fewest choices for other overall arc-consistency � variables) � CS440/ECE448: Intro AI � 17 � CS440/ECE448: Intro AI � 18 � Cryptarithmetic as CSP � TWO � + TWO � CSP 3: 
 = FOUR � Cryptarithmetic 
 Task: assign a digit to each letter � � (Global constraints) � Constraints : � Each letter has a unique digit 
 (= AllDiff constraint) � The result has to be a valid sum � CS440/ECE448: Intro AI �

  6. Global (n-ary) constraints: 
 Hypergraphs � Constraint Hypergraph � In a hypergraph, hyperedges connect TWO � multiple vertices: � + TWO � = FOUR � F � T � U � W R � O � C 1000 � C 100 � C 10 � CS440/ECE448: Intro AI � 21 � CS440/ECE448: Intro AI � 22 � Global (n-ary) constraints: 
 Global (n-ary) constraints: 
 Constraint Hypergraph � Constraint Hypergraph � TWO � TWO � + TWO � + TWO � = FOUR � = FOUR � F � T � U � W R � O � F � T � U � W R � O � Variables: � Variables: � letters � Carry digits � C 1000 � C 100 � C 10 � C 1000 � C 100 � C 10 � CS440/ECE448: Intro AI � 23 � CS440/ECE448: Intro AI � 24 �

  7. Global (n-ary) constraints: 
 Global (n-ary) constraints: 
 Constraint Hypergraph � Constraint Hypergraph � Alldiff TWO � TWO � constraint � + TWO � + TWO � = FOUR � = FOUR � F � T � U � W R � O � F � T � U � W R � O � 1 column � addition � constraint � C 1000 � C 100 � C 10 � C 1000 � C 100 � C 10 � CS440/ECE448: Intro AI � 25 � CS440/ECE448: Intro AI � 26 � Global (n-ary) constraints: 
 Global (n-ary) constraints: 
 Constraint Hypergraph � Constraint Hypergraph � TWO � TWO � + TWO � + TWO � = FOUR � = FOUR � F � T � U � W R � O � F � T � U � W R � O � 10 column � 100 column � addition � addition � constraint � constraint � C 1000 � C 100 � C 10 � C 1000 � C 100 � C 10 � CS440/ECE448: Intro AI � 27 � CS440/ECE448: Intro AI � 28 �

  8. Global (n-ary) constraints: 
 Constraint propagation: 
 Constraint Hypergraph � Global constraints � Some n-ary constraints can be directly TWO � translated into a set of binary constraints: � + TWO � � = FOUR � Global constraint: � AllDiff(X,Y,Z) � New binary constraints: � 
 F � T � U � W R � O � � � � � � � � C(X,Y): � X ≠ Y 
 1000 column � � � � � C(X,Z): � X ≠ Z 
 addition � � � C(Y,Z): � Y ≠ Z 
 constraint � � NB: Special purpose algorithms are often faster. � C 1000 � C 100 � C 10 � CS440/ECE448: Intro AI � 29 � CS440/ECE448: Intro AI � 30 � Global constraints � With additional auxiliary variables, any n-ary constraint can be translated into a set of binary CSP 3: 
 constraints: � � Scheduling 
 Ternary constraint: � C(X,Y,Z): X+Y = Z � � d D = { 〈 a 1 ,a 2 〉 | a 1 ∈ d X , a 2 ∈ d Y } � Aux. variable A: � (Continuous domains) � New constraints: � � C(A,Z): a 1 + a 2 = Z 
 � � � C(A,X): a 1 = X 
 � � � C(A,Y): a 2 = Y � � NB: Special purpose algorithms are often faster � CS440/ECE448: Intro AI � 31 �

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend