Lecture06 - CS440/ECE448: Intro to Artificial...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS440/ECE448: Intro to Artificial Intelligence! Lecture 6:
 More on constraint satisfaction problems" Prof. Julia Hockenmaier! juliahmr@illinois.edu! ! http://cs.illinois.edu/fa11/cs440! ! ! Tuesdayʼs key concepts" Constraint satisfaction problems:" Given: a set of n variables X1..Xn, with domains (sets of possible values) D1…Dn, and a set of m constraints C1… Cm ! ! Task: assign a value from Di for each Xi subjects to the constraints.! ! ! CSP 1:
 Map coloring
 (Binary constraints)" Map coloring:
 a solution for N=3" CS440/ECE448: Intro AI! 4! Constraint satisfaction problems are defined by…" -  a set of variables X: ! {WA, NT, QLD, NSW, VA, SA, TA}! -  a set of domains Di 
 (possible values for variable xi):! DWA = {red, blue, green}! -  a set of constraints C:! {〈(WA,NT), WA ≠ NT〉,〈(WA,QLD), WA≠ QLD〉,…}
 scope relation! CS440/ECE448: Intro AI! 5! States and solutions" Each state is a complete or partial assignment of values to variables: 
 
 state35 = {WA=red, NT=blue, QLD= green, NSW= red, 
 ! ! ! VA= green, SA= blue, TA= red};
 state23 = {WA = red}! ! Legal assignments donʼt violate any constraints.! Solutions are complete legal assignments! ! CS440/ECE448: Intro AI! 6! Binary constraints:
 constraint graph" QLD! NT! WA! NSW! SA! VA! TA! CS440/ECE448: Intro AI! 7! Consistency" Node consistency: X is node-consistent iff
 each element in DX satisfies unary constraints on X! ! Arc consistency: X is arc-consistent iff 
 for each C(X, Y) and for each x ∈ DX there is a y ∈ DY such that the assignment {X=x, Y=y} satisfies C(X,Y).! ! Path consistency: {X,Y} are path consistent wrt. Z iff 
 for every x∈DX and y∈DX there is a z∈DZ such that the assignment {X=x,Y=y,Z=z} satisfies C(X,Z) and C(Y,Z)! ! ! CS440/ECE448: Intro AI! 8! ! AC-3 " // Is the CSP c arc-consistent?! function AC3(CSP c)! !input: CSP c = (X,D,C) !! !local: queue q ← all arcs C(X,Y) in c! !while q ≠ () do:! ! !// Can C(X,Y) be satisfied?! ! !(X,Y) = pop(q);! ! !// if domain(X) needs to be shrunk:! ! !if revise(c,X,Y): ! ! ! !// Exit if CSP can’t be solved:! ! ! !if domain(X) == () return false;! ! ! !// Are X’s neighbors still okay?! ! ! !foreach Z in X.NEIGHBORS\{Y}:! ! ! ! !q ← push(q,(Z, X));! !return true; ! CS440/ECE448: Intro AI! 9! Tree-structured 
 constraint graphs" - Any two nodes connected by a single path! -With n vertices, there are n−1 edges!   -Can be solved in linear time (O(nd2))!   A B D C E E B F CS440/ECE448: Intro AI! A C F D 10! CSP 2: 
 8 queens puzzle
 (Combining search 
 and CSP inference)" The 8-queens puzzle" X ♕ X X ♕ X X X ♕ X ♕ X X X X X X X X X ♕ X ♕ X X The 8-queens puzzle has multiple solutions! Cannot be solved by constraint propagation alone! [underdetermined CSP]! ! ! CS440/ECE448: Intro AI! 12! Search tree for 8-queens" X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X CS440/ECE448: Intro AI! X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X … X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X 13! 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! 14! Ordering the variables" DX = {R,G,B} C(X,Y): X ≠ Y ! DY = {R} !C(X,Z): X ≠ Z! DZ = {G,B}! ! Which variable should we consider first?" Minimum remaining values heuristic: " The variable with the smallest domain! Degree heuristic:" The variable that has the most constraints! CS440/ECE448: Intro AI! 15! Caveat: implied constraints" DX = DY = DZ = {0,1,2,3,4,5,6,7,8,9}! ! C(X, Y): Y = X2 ! X! Y! Z! 2! C(Y, Z): Z = Y " ! If we choose X as the root of the tree, we need to run DAC down the tree and up again.! CS440/ECE448: Intro AI! 16! Ordering the values" X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Which values of X should we consider first?! ! Least-constraining value heuristic:" Pick the most likely value first 
 (= the one which rules out the fewest choices for other variables)! CS440/ECE448: Intro AI! 17! Interleaving search 
 and inference" Search: assign (guess) value x for variable X! 
 Forward checking algorithm:" Check that X is arc-consistent with all remaining variables Y
 ! Maintaining-Arc-Consistency algorithm:" Run AC3 on all C(Y,X) constraints to check overall arc-consistency! CS440/ECE448: Intro AI! 18! CSP 3:
 Cryptarithmetic
 (Global constraints)" Cryptarithmetic as CSP" TWO! + TWO! = FOUR! Task: assign a digit to each letter! " Constraints:! Each letter has a unique digit 
 (= AllDiff constraint)! The result has to be a valid sum! CS440/ECE448: Intro AI! Hypergraphs" In a hypergraph, hyperedges connect multiple vertices:! CS440/ECE448: Intro AI! 21! Global (n-ary) constraints:
 Constraint Hypergraph" TWO! + TWO! = FOUR! F! T! C1000! CS440/ECE448: Intro AI! U! C100! W R! O! C10! 22! Global (n-ary) constraints:
 Constraint Hypergraph" TWO! + TWO! = FOUR! F! T! U! W R! O! Variables:! letters! C1000! CS440/ECE448: Intro AI! C100! C10! 23! Global (n-ary) constraints:
 Constraint Hypergraph" TWO! + TWO! = FOUR! F! T! C1000! CS440/ECE448: Intro AI! U! C100! W R! C10! O! Variables:! Carry digits! 24! Global (n-ary) constraints:
 Constraint Hypergraph" Alldiff constraint! F! T! C1000! CS440/ECE448: Intro AI! U! C100! TWO! + TWO! = FOUR! W R! O! C10! 25! Global (n-ary) constraints:
 Constraint Hypergraph" TWO! + TWO! = FOUR! F! T! U! W R! O! 1 column! addition ! constraint! C1000! CS440/ECE448: Intro AI! C100! C10! 26! Global (n-ary) constraints:
 Constraint Hypergraph" TWO! + TWO! = FOUR! F! T! U! W R! O! 10 column! addition ! constraint! C1000! CS440/ECE448: Intro AI! C100! C10! 27! Global (n-ary) constraints:
 Constraint Hypergraph" TWO! + TWO! = FOUR! F! T! U! W R! O! 100 column! addition ! constraint! C1000! CS440/ECE448: Intro AI! C100! C10! 28! Global (n-ary) constraints:
 Constraint Hypergraph" TWO! + TWO! = FOUR! F! T! U! W R! O! 1000 column! addition ! constraint! C1000! CS440/ECE448: Intro AI! C100! C10! 29! Constraint propagation:
 Global constraints" Some n-ary constraints can be directly translated into a set of binary constraints:! ! Global constraint: !AllDiff(X,Y,Z)! New binary constraints: !
 " " " " " " "C(X,Y): !X ≠ Y
 !!!! C(X,Z): !X ≠ Z
 !! C(Y,Z): !Y ≠ Z
 ! NB: Special purpose algorithms are often faster.! CS440/ECE448: Intro AI! 30! Global constraints" With additional auxiliary variables, any n-ary constraint can be translated into a set of binary constraints:! ! Ternary constraint: "C(X,Y,Z): X+Y = Z! Aux. variable A: " "dD = {〈a1,a2〉 | a1∈dX, a2∈dY}! New constraints: ! !C(A,Z): a1+ a2 = Z 
 !! !C(A,X): a1 = X 
 !! !C(A,Y): a2 = Y! ! NB: Special purpose algorithms are often faster! CS440/ECE448: Intro AI! 31! CSP 3:
 Scheduling
 (Continuous domains)" Job-shop scheduling" Task: schedule the steps required 
 to assemble a car.
 ! Constraints:" -  Each step takes a certain amount of time! -  Some steps need to happen before others! -  Some steps require the same tools
 (canʼt happen at the same time)! -  The car needs to be assembled by 5pm! ! CS440/ECE448: Intro AI! 33! Scheduling as CSP" Variables: {WheelLF, WheelRF, … Engine,…}" Domain: 8:00am…5:00pm" Constraints:
 " •  Front axle assembly takes 10 minutes, 
 and has to happen before the front wheels:! AxleF + 10 ≤ WheelLF
 AxleF + 10 ≤ WheelRF! •  Front and rear axle require the same tool:! (AxleF + 10 ≤ AxleR or AxleR + 10 ≤ AxleF) ! CS440/ECE448: Intro AI! 34! Bounds consistency:
 large (or continuous) domains" Continuous or large finite domains are represented by lower and upper bounds: !! ![lower… upper]
 ! You want to invest $2000 in companies A and B.! Aʼs shares cost $2, Bʼs cost $1:! ! !A: [0…1000] B: [0…2000]! You need to buy at least 100 shares of each:! Bounds propagation: 
 !A: [100…950] B: [100..1800]! CS440/ECE448: Intro AI! 35! To conclude…" Todayʼs key concepts" Combining CSP search and inference:" Ordering variables (minimum remaining value, degree heuristics)! Ordering values (forward checking, MAC)! ! Global constraints:" Constraint hypergraph; auxiliary variables! Continuous domains: 
 bounds consistency! " CS440/ECE448: Intro AI! " 37! Your tasks" Reading
 Ch. 6.3, 6.5! ! Compass quiz:! up at 2pm! ! CS440/ECE448: Intro AI! 38! ...
View Full Document

This note was uploaded on 10/13/2011 for the course CS 440 taught by Professor Levinson,s during the Spring '08 term at University of Illinois, Urbana Champaign.

Ask a homework question - tutors are online